flex_set_adc_range |
Set ADC Range
Usage
status = flex_set_adc_range(u8 boardID, u8 ADC, u16 range);
Purpose
Sets the voltage range for the analog to digital converters, on a per-channel basis.
Parameters
Name | Type | Description |
---|---|---|
boardID | u8 | assigned by Measurement & Automation Explorer (MAX) |
ADC | u8 | ADC channel to configure |
range | u16 | the voltage range for the specified ADC |
Parameter Discussion
ADC is the analog-to-digital converter channel to configure. Valid ADC resources are NIMC_ADC1 through NIMC_ADC30. On motion controllers that support fewer than thirty axes, configuring non-existent ADC channels returns error 70006 (NIMC_badResourceIDOrAxisError). Refer to ADC Channels for ADC resource IDs.
range specifies the input voltage range over which the ADC converts input voltages to digital values. Voltages outside of the range clamps at the extremes, which are –2048 or +2047 (NI 7330/40) and –32,768 to +32,767 (NI 7350) for the –5 to +5 V and –10 to +10 V ranges, and 0 to 4,096 (NI 7330/40) and 0 to +65,535 (NI 7350) for the 0 to +5 V and 0 to +10 V ranges. You can choose from the following values for the range:
Range Values | Binary Values | |
---|---|---|
7350 | 7330/40 | |
0 to 5 | 0 to +65,535 |
0 to +4,095 |
–5 to +5 | –32,768 to +32,767 |
–2,048 to +2,047 |
0 to +10 | 0 to +65,535 |
0 to +4,095 |
–10 to +10 (default) | –32,768 to +32,767 | –2,048 to +2,047 |
The constants listed previously are defined in the NI-Motion header files MotnCnst.h (for C/C++ users) and motncnst.bas (for Visual Basic users).
Using This Function
If you do not call this function, the range defaults to –10 to +10 V. If you know that the input voltage falls within a more restrictive range, you can effectively increase the resolution of the measurements by selecting an appropriate range from the previous list.
Note With the 7350 motion controller, changing the range of an ADC changes all other ADCs to the same range. Other NI motion controllers can set the range independent of other ADCs. |
For example, if you are using a 7340 motion controller, the input signal ranges from –3 to +3 V, and you select the –5 to +5 V range, the 4,096 discrete values for the ADC is 2.44 mV apart instead of the 4.88 mV apart when using the –10 to +10 V range. If you are using a 7350 motion controller, the input signal ranges from –3 to +3 V, and you select the –5 to +5 V range, the 65,536 discrete values for the ADC is 152 µV apart instead of the 305 µV apart when using the –10 to +10 V range.
ADC ranges cannot be changed on any ADC while an axis that is using analog feedback is enabled. You must first disable the axis using analog feedback, then change the range. Refer to the Read ADC and Enable ADCs functions for more information.