Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Setting Axis Attributes with the Motion Control Module

0 ratings | 0.00 out of 5
Print

Overview

The Motion Control Module for Measurement Studio provides access to detailed state information for an axis and generates status notifications through the AxisStateChanged event.

What are Axis Attributes?

Each axis on a National Instruments motion controller contains 16 status bits. Each bit represents the state of a different attribute of the axis, such as execution state (profile complete, blend complete, direction of travel), error conditions (limits reached, following error exceeded), and external triggers (breakpoint and high-speed capture status). You can configure the NIMotion ActiveX control to generate the AxisStateChanged event when any of the attributes changes state. You also can select a set of attributes that are relevant to your application. Use the AttributeMask property on an NIMotionAxis object to select the set of attributes that trigger the AxisStateChanged event. The complete list of available attributes are stored in the NIMotionAxisAttributes enumeration.
Note: You must set AttributeMask to generate the AxisStateChanged event. The AttributeMask property has a default value of 0.

Setting Axis Attributes


To select a single axis attribute, set AttributeMask to the corresponding enumeration value, as shown in the following example:
NIMotion1.Tasks("Task-1").Axes("X-Axis").AttributeMask = nimotionAxisFollowingErrorExceeded

To select multiple axis attributes, set AttributeMask to the sum of the corresponding enumeration values, as shown in the following example:
NIMotion1.Tasks("Task-1").Axes("X-Axis").AttributeMask = nimotionAxisMotorOff + nimotionAxisReverseDirection + nimotionAxisFollowingErrorExceeded

To select all axis attributes, set AttributeMask to -1, as shown in the following example:
NIMotion1.Tasks("Task-1").Axes("X-Axis").AttributeMask = -1

AxisStateChanged Event


The AxisStateChanged event returns the following information:
AxisA reference to an NIMotionAxis object. Use this parameter to determine the axis for a multi-axis motion task.
TaskA reference to an NIMotionTask object. Use this parameter to determine the corresponding task when there are multiple tasks within the same NIMotion control.
StateThe current state of the specified axis. State information is available only for attributes that are specified in AttributeMask.
ChangedAttributeMaskA bitmap that indicates which attributes have changed state since the last time the AxisStateChanged event was generated.

When the Configure method is called on the NIMotion ActiveX control, the current state of each axis is read from the motion controller. The AxisStateChanged event is generated with the initial attribute values for each axis. The corresponding bit in ChangedAttributeMask is set to 1 for each attribute in AttributeMask. Other attributes have a bit value of 0 in ChangedAttributeMask. State contains the current state of each attribute represented in AttributeMask. The attribute is On or True if the corresponding bit has a value of 1. A bit value of 0 indicates that the attribute is Off or False. To test if the state of an attribute is On, perform a logical And operation between the returned State and the attribute enumeration value.

Example:
Configure a single-axis task with AttributeMask set for the motor off, reverse direction, and following error attributes. Call the Configure method. When the first AxisStateChanged event is generated, ChangedAttributeMask is set for these three attributes. The State parameter contains the current state of these three attributes.
  • (ChangedAttributeMask And nimotionAxisMotorOff) evaluates to True because the motor off attribute has changed state (in this case, it is returned for the first time).
  • (State And nimotionAxisMotorOff ) evaluates to False because the axis is energized.
  • (ChangedAttributeMask And nimotionAxisCaptureOccurred) evaluates to False because the capture occurred attribute is not included in AttributeMask.
  • (State and nimotionAxisCaptureOccurred) also evaluates to False because the state of this attribute was not returned.

The NIMotion control periodically polls the motion controller to retrieve the current axis state. The AxisStateChanged event is generated when any of the selected attributes changes state. Only the attributes that have changed value since the last AxisStateChanged event are specified in ChangedAttributeMask. The current state of all selected attributes is returned in State, even if the states have not changed since the last time the AxisStateChanged event was generated.

Example:
Call the Start method on the NIMotion control from the previous example. The first point-to-point move is in the reverse direction. When the move starts, the AxisStateChanged event is generated. The ChangedAttributeMask parameter is set to nimotionAxisReverseDirection. The motor off and following error attributes have not changed state since the last AxisStateChanged event. The State parameter contains the current state of the motor off, reverse direction and following error attributes. The State parameter returns False for the motor off attribute, True for the reverse direction attribute, and False for the following error attribute.
Related Links:
Axis Attributes
0 ratings | 0.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).