unsigned int anaIn(unsigned int channel, int opmode, int gaincode);
Reads the value of an analog input channel using the Direct Mode method of addressing the A/D converter. Note that it takes about 1 second to ensure an internal capacitor on the A/D converter is charged when the function is called the first time.
PARAMETERS
channel is the channel number (0 to 7) corresponding to LN0_IN to LN7_IN opmode is the mode of operation:
channel | SINGLE | DIFF | mAMP |
|
|
|
|
0 | +AIN0 | +AIN0 | +AIN0* |
1 | +AIN1 | +AIN1 | +AIN1* |
|
|
|
|
2 | +AIN2 | +AIN2 | +AIN2* |
|
|
|
|
3 | +AIN3 | +AIN3 | +AIN3 |
|
|
|
|
4 | +AIN4 | +AIN4 | +AIN4 |
|
|
|
|
5 | +AIN5 | +AIN5 | +AIN5 |
|
|
|
|
6 | +AIN6 | +AIN6 | +AIN6 |
|
|
|
|
7 | +AIN7 | +AIN7 | +AIN7* |
|
|
|
|
* Not accessible on Prototyping Board.
gaincode is the gain code of 0 to 7 (applies only to Prototyping Board):
Gain Code | Multiplier | Voltage Range | |
(V) | |||
|
| ||
0 | ×1 | ||
|
|
| |
1 | ×2 | ||
|
|
| |
2 | ×4 | ||
|
|
| |
3 | ×5 | ||
|
|
| |
4 | ×8 | ||
|
|
| |
5 | ×10 | ||
|
|
| |
6 | ×16 | ||
|
|
| |
7 | ×20 | ||
|
|
|
RETURN VALUE
A value corresponding to the voltage on the analog input channel:
ADTIMEOUT (defined macro =
SEE ALSO
anaIn, anaInConfig, anaInDriver
User’s Manual | 51 |