When using device buffer, it is necessary to acquire conversion data by executing functions.
Use function AioGetAiSamplingData
or AioGetAiSamplingDataEx
to acquire conversion data.
Function AioGetAiSamplingData acquires conversion data in binary value,
and function AioGetAiSamplingDataEx acquires conversion data in voltage
or current value.
Acquire Conversion Data
Ret = AioGetAiSamplingData ( Id , AiSamplingTimes , AiData )
Ret = AioGetAiSamplingDataEx ( Id , AiSamplingTimes , AiData )
In AiSamplingTimes, set the number of sampling times.
The number of sampling times means the number of times conversion is performed,
and it is irrelevant to the number of channels used for conversion.
In AiData, specify a pointer to the array that stores the acquired conversion data.
For AioGetAiSamplingData, the analog input data is stored in binary
value.
The range is 0 to 4095 for a 12-bit resolution device and 0 to 65535 for
a 16-bit resolution device.
For AioGetAiSamplingDataEx, the analog input data is stored in voltage or current value.
The required elements of this array is : AiSamplingTimes × Number of Channels
Number of Channels |
Number of Elements Required for Array AiData |
1 |
AiSamplingTimes × 1 |
2 |
AiSamplingTimes × 2 |
: |
|
8 |
AiSamplingTimes × 8 |
: |
|
16 |
AiSamplingTimes × 16 |
The conversion data to be included in the array of AiData is stored in the following format.
How to acquire the conversion data from memory depends on the type of used memory.
How to Acquire in the FIFO Memory
How to Acquire in the RING Memory
Conversion from Binary Value to Voltage
When using function AioGetAiSamplingData, the input data is stored in
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.
Example) Analog input range : -5 to 5V, Resolution : 12-bit, convert
binary value 3072 to voltage value
Voltage value = 3072 × ( 5 -
(-5) ) ÷ 4096 + (-5) = 2.5V