From Technologic Systems Manuals

The TS-7120 has two channels of ADC, and those inputs are available on the CN16-A connector, as 6UL_ADC_0 and 6UL_ADC_1.

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_voltage4_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_voltage4_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

ADC Table
# 'raw' 2.5/10.9V Select 20mA Loop Select
AN_IN_1 in_voltage4_raw GPIO 10 GPIO 6
AN_IN_2 in_voltage5_raw GPIO 11 GPIO 7
AN_IN_3 in_voltage8_raw GPIO 12 GPIO 8
AN_IN_4 in_voltage9_raw GPIO 13 GPIO 9
Note: The four ADC inputs use the CPU ADC inputs 4,5,8, and 9, corresponding with the 'raw' entries in the above table.