PT_AIScale

typedef struct tagPT_AIScale
{
     INT16U reading;
     FP32 MaxVolt;
     INT16U MaxCount;
     INT16U offset;
     FP32  *voltage;
} PT_AIScale, * LPT_AIScale;

PT_AIScale is used in function DRV_AIScale.

Member Description

Name Direction Range Description
reading input Depends on the hardware The input digital value that comes from DRV_AIBinaryIn or DRV_MAIBinaryIn.
MaxVolt input Depends on the hardware The range of input voltage or analog value. For example, 10.0 for input voltage range from 0.0 to 10.0 volt and 5.0 for -5.0 to +5.0 volt.
MaxCount input Depends on the hardware The range of output digital value. For example, 4095 for 12 bits A/D and 65535 for 16 bits A/D.
offset input Depends on the hardware The offset of zero point. For example, the zero volt offset on input voltage range -5.0 to +5.0 volt is 2048. While the zero volt offset on input voltage range 0 to +5.0 volt is 0.
voltage output Depends on the input range. The pointer to indicate user prepared space that stores the result of analog value.
The return analog value (voltage) comes from the following formula:
voltage = MaxVolt * (reading - offset) / (MaxCount - offset)
The sign (+ or -) of the return analog value (voltage) will be properly assigned after the operation.
For example, for an AI channel of 12-bit A/D resolution with the input voltage range from -5.0 V to +5.0 V, the related parameters should be set as follows:
MaxVolt is +5.0 (volt).
MaxCount is 4095 (the highest resolution that 12-bit A/D can reach).
The offset of zero point is 2048 (the zero volt point on 12-bit A/D).