Analog Input of the Specified Channel
Use function AioSingleAi
or AioSingleAiEx
to analog input to the specified channel.
Function AioSingleAi gets the conversion data by binary value, and function
AioSingleAiEx gets the conversion data by voltage or current value.
Ret = AioSingleAi ( Id , AiChannel , AiData )
Ret = AioSingleAiEx ( Id , AiChannel , AiData )
In AiChannel, specify the channel for analog input. Since channels are counted like 0, 1, 2, ..., for example, if the total number of analog input channels is 4, the channel that can be specified is 0, 1, 2, 3.
In AiData, specify the address of the array that stores the analog input
data.
For AioSingleAi, the analog input data is stored as binary value, and the
range is 0 to 4095 for a 12-bit resolution device and 0 to 65535 for a
16-bit resolution device.
For AioSingleAiEx, analog input data is stored as voltage or current value.
The channel sequence setting does not affect this function.
Analog Input of Multiple Channels
Use function AioMultiAi
or AioMultiAiEx
to analog input to multiple channels.
Function AioMultiAi gets the conversion data by binary value, and function
AioMultiAiEx gets the conversion data by voltage or current value.
Ret = AioMultiAi ( Id , AiChannels , AiData )
Ret = AioMultiAiEx ( Id , AiChannels , AiData )
In AiChannels, specify the number of channels
for analog input.
The order of channels to be converted is based on the setting of channel
conversion sequence.
The number of channels that will be eventually converted is determined
by this function.
The following table shows the relationship between AiChannels and the channel actually converted, with the default channel conversion sequence.
AiChannels |
Channel to be converted |
1 |
0 |
2 |
0, 1 |
3 |
0, 1, 2 |
: |
: |
In AiData, specify the address of the array
that stores the input data.
Please ensure the size of array, that must be the number of channels specified
by AiChannels.
Conversion data stored in the array is also stored in the order of the
set channel conversion sequence.
The following table shows the contents of the conversion data stored in the array with the default channel conversion sequence.
Array (0) |
Input data of Ch0 |
Array (1) |
Input data of Ch1 |
Array (2) |
Input data of Ch2 |
: |
: |
For AioMultiAi, the analog input data is stored as binary value, and
the range is 0 to 4095 for a 12-bit resolution device and 0 to 65535 for
a 16-bit resolution device.
For AioMultiAiEx, analog input data is stored as voltage or current value.
Conversion from Binary Value to Voltage
Analog input functions (AioSingleAi, AioMultiAi) get the input data
by binary value.
The conversion from binary value to voltage value is performed by the following
formula.
Voltage value = Binary value ×
( Maximum range value - Minimum range value ) ÷ Resolution + Minimum
range value
The resolution is 4096 for 12-bit, 65535 for 16-bit.
e.g.) Analog input range : -10 to 10V, Resolution : 12-bit, convert
binary value 3072 to voltage value
Voltage value = 3072 × ( 10 -
(-10) ) ÷ 4096 + (-10) ≒ 5.000