flex_enable_encoders |
Enable Encoders
Usage
status = flex_enable_encoders(u8 boardID, u16 encoderMap);
Purpose
Enables one or more of the unmapped encoder resources.
Parameters
Name | Type | Description |
---|---|---|
boardID | u8 | assigned by Measurement & Automation Explorer (MAX) |
encoderMap | u16 | bitmap of encoders to enable |
Parameter Discussion
encoderMap is the bitmap of encoder resources to enable:
D15 | ... | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
Enc 15 | ... | Enc 10 | Enc 9 | Enc 8 | Enc 7 | Enc 6 | Enc 5 | Enc 4 | Enc 3 | Enc 2 | Enc 1 | 0 |
D1 through D15:
1 = Encoder enabled
0 = Encoder disabled (default)
Using This Function
This function enables one or more independent encoder channels for use as general-purpose encoder inputs. It has no effect on encoders that are mapped to axes and being used for axis feedback. These feedback encoders are automatically enabled/disabled when their corresponding axis is enabled or disabled with the Enable Axis function. Bit locations corresponding to mapped encoders are ignored, as are encoder resources that do not exist. For example, encoders 5 through 8 are ignored if you are using a controller that supports a maximum of four axes.
Typical uses for independent encoder inputs include velocity monitoring, masters for master-slave gearing, and digital potentiometer applications.
Example
To enable encoders 3 and 4 on an NI motion controller, call the Enable Encoders function with encoderMap = 0x0018, which corresponds to the following bitmap:
D15 | ... | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
Enc 15 | ... | Enc 10 | Enc 9 | Enc 8 | Enc 7 | Enc 6 | Enc 5 | Enc 4 | Enc 3 | Enc 2 | Enc 1 | 0 |
0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
Normally, because encoders 1 and 2 are set to zero (0), they is disabled by this function execution. However, if encoder 2 is already being used as feedback for axis 2 and axis 1 is not being used, the disable (0) for Enc 2 is ignored resulting in the following bitmap of enabled encoders:
D15 | ... | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
Enc 15 | ... | Enc 10 | Enc 9 | Enc 8 | Enc 7 | Enc 6 | Enc 5 | Enc 4 | Enc 3 | Enc 2 | Enc 1 | 0 |
0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
There is a limit on the number of enabled encoders supportable at the faster update rates. Attempting to enable too many encoders generates an error. Refer to the Enable Axis function for more information about update rate limitations.