flex_read_adc16_rtn

NI-Motion Functions

flex_read_adc16_rtn

Device Compatibility

Device Compatibility
7330
Y
7340
Y
7344
Y
7350
Y
7390
N
NI SoftMotion Controller for CANopen—Xenus
Y
NI SoftMotion Controller for CANopen—Accelnet
N

Read ADCs Return

Usage

status = flex_read_adc16_rtn(u8 boardID, u8 ADC, i32* ADCValue);

Purpose

Reads the converted value from an ADC input channel.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
ADC u8 ADC channel to read
ADCValue i32* the converted analog value

Parameter Discussion

ADC is the Analog-to-Digital Converter channel to read. Valid ADC resources are NIMC_ADC1 through NIMC_ADC30. On motion controllers that support fewer than thirty axes, reading non-existent ADCs returns error –70006 (NIMC_badResourceIDOrAxisError). Refer to ADC Channels for ADC resource IDs.

ADCValue is the signed 16-bit (7350) or 12-bit (all others) value from the ADC channel. The voltage range is set through the Set ADC Range function.

Range Values Analog Values
7350 7330/40 NI SoftMotion Controller
for CANopen—Xenus
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 –2,048 to +2,047

Using This Function

This function returns the converted voltage from any of the analog input channels. You can only read values from channels that have been either directly enabled by the Enable ADCs function or automatically enabled by being mapped to an enabled axis.

For an ADC channel mapped to an axis, this function returns the actual ADC value. In contrast, the Read Position function executed on the owner axis returns an ADC value that has been offset by a reset value stored when the Reset Position function was executed. ADC channels are never internally reset so their DC values are preserved.