flex_enable_adcs |
Enable ADCs
Usage
status = flex_enable_adcs(u8 boardID, u8 reserved, u16 ADCMap);
Purpose
Enables one or more of the unmapped ADC channels.
Parameters
Name | Type | Description |
---|---|---|
boardID | u8 | assigned by Measurement & Automation Explorer (MAX) |
reserved | u8 | unused input |
ADCMap | u16 | bitmap of ADCs to enable |
Parameter Discussion
reserved is an unused input. The input value is ignored.
ADCMap is the bitmap of ADC channels to enable:
D15 | ... | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
0 | ... | 0 | 0 | 0 | ADC 8 | ADC 7 | ADC 6 | ADC 5 | ADC 4 | ADC 3 | ADC 2 | ADC 1 |
D0 through D7:
1 = ADC channel enabled (default)
0 = ADC channel disabled
Using This Function
This function enables one or more independent ADC channels for use as general-purpose analog inputs. The motion controller returns an error if you attempt to enable or disable and ADC that is being used as an axis feedback when the axis is enabled. These feedback channels are automatically enabled/disabled when you enable or disable their corresponding axis with the Enable Axis function. You must first disable the axis using analog feedback, then enable or disable ADCs. Bit locations corresponding to mapped ADC channels are ignored.
The NI-Motion Analog-to-Digital Converter (ADC) multiplexes between channels with a scan rate of approximately 40 µs for the 7340 motion controller, and 25 µs for the 7350 motion controller. Therefore, the time between samples for a specific ADC channel is as follows:
7330/40:
ADC sample time = 40 µs/channel x (number of enabled channels)
7350:
ADC sample time = 25 µs/channel x (number of enabled channels)
By default, all channels are enabled at power up. You must disable unused channels to increase the scan rate and decrease the sample time.
The 40 µs/channel scan rate is fast enough to support analog feedback at the fastest PID update rates as long as no additional ADC channels are enabled.
Example
To enable ADC channels 1, 3, 5, and 7 on the 7350 motion controller, call the Enable ADCs function with ADCMap = 0x0055, which corresponds to the following bitmap:
D15 | ... | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
0 | ... | 0 | 0 | 0 | ADC 8 | ADC 7 | ADC 6 | ADC 5 | ADC 4 | ADC 3 | ADC 2 | ADC 1 |
0 | ... | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
Under normal conditions, because ADC channels 2, 4, 6, and 8 are set to zero (0) they are disabled when you execute this function. However, if ADC channel 2 is already being used as feedback for axis 2, the disable (0) for ADC 2 is ignored, resulting in a modal error and the following bitmap of enabled ADCs:
D15 | ... | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
0 | ... | 0 | 0 | 0 | ADC 8 | ADC 7 | ADC 6 | ADC 5 | ADC 4 | ADC 3 | ADC 2 | ADC 1 |
0 | ... | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 1 |
In this example there are five ADCs enabled, so the sample time for each ADC channel is as follows:
ADC sample time = 40 µs/channel x 5 = 200 µs
The ADC sample time puts a limit on the fastest PID update rate practically achievable. You can set a faster PID update rate with the Enable Axis function, but the PID loop does not truly operate at that faster rate because the ADC channels used as feedback are not being sampled fast enough.