flex_read_encoder |
Read Encoder Position
Usage
status = flex_read_encoder(u8 boardID, u8 axisOrEncoder, u8 returnVector);
Purpose
Reads the position of an encoder.
Parameters
Name | Type | Description |
---|---|---|
boardID | u8 | assigned by Measurement & Automation Explorer (MAX) |
axisOrEncoder | u8 | axis or encoder to read |
returnVector | u8 | destination for the return data |
Parameter Discussion
axisOrEncoder is the axis or encoder to read. Valid values are NIMC_AXIS1 through NIMC_AXIS30 or NIMC_ENCODER1 through NIMC_ENCODER30. On motion controllers that support fewer than thirty axes, reading non-existent axes or encoders returns error 70006 (NIMC_badResourceIDOrAxisError). Refer to Axes and Encoders for axis and encoder resource IDs.
returnVector indicates the destination for the return data generated by this function. Available return vectors include return data to the host (0xFF), to a variable (0x01 through 0x78), to an indirect variable (0x81 through 0xF8), and return no data (0). Refer to Input and Return Vectors for more detailed information.
Note The suffix _rtn on the function indicates that the data must be returned to the host. When this calling convention is used, no returnVector is required. |
Using This Function
This function returns the quadrature count value of the encoder selected. The encoder must be enabled, either directly through the Enable Encoders function or automatically, by being mapped to an enabled axis.
The Read Encoder Position function is typically used to read the value of an encoder that is not part of an axis. This encoder could be a master encoder used for master-slave gearing or an independent position or velocity sensor.
For reading encoders mapped to axes, you can call this function on the axis or directly on its mapped encoder. For servo axes, both approaches return the same value as the Read Position function. On stepper axes however, this function can return additional useful information.
During axis setup, you can operate the closed-loop stepper axis in open-loop mode and use this function to directly measure the counts per revolution and steps per revolution for the axis. These values must be loaded in advance for subsequent closed-loop operation. Refer to the Load Counts/Steps per Revolution function for more information.
You also can use this function to return a finer reading of position in cases where the encoder resolution greatly exceeds the step resolution of the closed-loop stepper axis.