TS-9370 ADC
From embeddedTS Manuals
The onboard ADC uses a TI ADC121S021 SPI ADC. This ADC supports 50-200ksps sampling at 12-bits on a single channel. This is connected to onboard muxes to support up to 6 analog inputs.
Under Linux this is supported with IIO.
# Read AN_1 Voltage (0-12V):
iio_attr -c an-1-voltage voltage0
# Read AN_2 Voltage (0-12V):
iio_attr -c an-2-voltage voltage0
# Read AN_3 Voltage (0-12V):
iio_attr -c an-3-voltage voltage0
# Read AN_4 Voltage (0-48V):
iio_attr -c an-4-voltage voltage0
# Read MIKRO_AN (0-3.3V)
iio_attr -c adc-mux voltage4
These will output a raw and scale value. Multiply the raw value * the scale value to get the value in millivolts.
AN_1, AN_2, and AN_3 have built in 120ohm current loop shunts that can be enabled. These allow the ADC to sample 0-24mA. The current shunt resistors for AN_1 and AN_2 are enabled together, while AN_3 can be enabled/disabled independently.
## Switch AN_3 to current loop:
# Enable current loop, assert EN_CL_3:
gpioset 5 26=1
# Turn off voltage divider, deassert EN_ADC_3_12V:
gpioset 5 21=0
## Switch AN_1 and AN_2 to current loop:
# Enable current loop, assert EN_CL_1_2
gpioset 5 25=1
# Turn off voltage divider, deassert EN_ADC_3_12V:
gpioset 5 22=0
For the current loops, Linux does not provide the scaling itself. Read the voltage's raw value, but multiply by:
raw * 3300*1000/(4095*120)
to get the scaled value in uA.