TS-7180 CPU ADC: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 17: | Line 17: | ||
</source> | </source> | ||
To switch to the 10.9V input range, the appropriate enable must be set high. Each input AN_IN_1 through AN_IN_4 has its own enable, EN_ADC1_10V through EN_ADC4_10V, and these are controlled by | To switch to the 10.9V input range, the appropriate enable must be set high. Each input AN_IN_1 through AN_IN_4 has its own enable, EN_ADC1_10V through EN_ADC4_10V, and these are controlled by GPIO #10 through #13. For example, to switch AN_IN_1 to the 10.9V range, run the following command: | ||
<source lang=bash> | <source lang=bash> | ||
tshwctl -a 10 -w 3 | tshwctl -a 10 -w 3 | ||
Line 24: | Line 24: | ||
Note that the result must now be multiplied by (10.9/2.5). Note also that the input impedance will now be around 2k ohms. | Note that the result must now be multiplied by (10.9/2.5). Note also that the input impedance will now be around 2k ohms. | ||
To switch to the 20mA current-loop mode, the appropriate enable must be set high. These are EN_CL_1 through EN_CL_4, and are controlled by | To switch to the 20mA current-loop mode, the appropriate enable must be set high. These are EN_CL_1 through EN_CL_4, and are controlled by GPIO #6 through #9. First select the 2.5V range as follows: | ||
<source lang=bash> | <source lang=bash> | ||
tshwctl -a 10 -w 1 | tshwctl -a 10 -w 1 |
Revision as of 15:56, 28 February 2017
The TS-7180 has four channels of ADC, and those inputs are available on the P3 connector, as AN_IN_1 through AN_IN_4. Each input may be configured to measure voltage in two ranges (0-2.5V and 0-10.9V), or a 20mA current-loop.
The standard linux kernel offers a simple interface to the ADC that does not require any sort of programming to use. For example, to see the "raw" reading from the AN_IN_1 input, type the following command:
cat /sys/bus/iio/devices/iio\:device0/in_voltage5_raw
To convert this raw value to a voltage, it must be multiplied by the "scaling factor", which can be found by typing the following command:
cat /sys/bus/iio/devices/iio\:device0/in_voltage_scale
The result will be in millivolts. If you have the bc utility installed, you can enter the following command:
echo `cat /sys/bus/iio/devices/iio\:device0/in_voltage5_raw` \* `cat /sys/bus/iio/devices/iio\:device0/in_voltage_scale` | bc
To switch to the 10.9V input range, the appropriate enable must be set high. Each input AN_IN_1 through AN_IN_4 has its own enable, EN_ADC1_10V through EN_ADC4_10V, and these are controlled by GPIO #10 through #13. For example, to switch AN_IN_1 to the 10.9V range, run the following command:
tshwctl -a 10 -w 3
Note that the result must now be multiplied by (10.9/2.5). Note also that the input impedance will now be around 2k ohms.
To switch to the 20mA current-loop mode, the appropriate enable must be set high. These are EN_CL_1 through EN_CL_4, and are controlled by GPIO #6 through #9. First select the 2.5V range as follows:
tshwctl -a 10 -w 1
And then set the EN_CL_1 enable high as follows:
tshwctl -a 6 -w 3