Low-level work with ADC

Материал из Wiren Board
Это утверждённая версия страницы. Она же — наиболее свежая версия.
Другие языки:

Reference voltage

The reference voltage of LRADC is 1.85 V. Software installation of 2:1 divider inside the channel is possible.


Work

(make sure the wb-homa-adc daemon is not running):

  • Channel selection:
 wb-adc-set-mux <channel number>
или
 wb-adc-set-mux <A1|A2|A3|A4|R1|R2|R3|R4> (for WB Smart Home)
или
 wb-adc-set-mux tb<terminal block number> (for WB2.8)
или
 wb-adc-set-mux vin  (for WB2.8)
  • Reading values:
root@wirenboard:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw 
3838

or

root@wirenboard:~# wb-adc-get-value
3838
  • Reading the values of the pre-installed channel:
 wb-adc-read-channel <A1|A2|A3|A4|R1|R2|R3|R4> (для WB Smart Home, options are similar to the wb-adc-set-mux)


Example

  • Set the ADC to measure the voltage at the terminal A3::
root@wirenboard:~# wb-adc-set-mux A3
  • Read raw ADC value:
root@wirenboard:~# wb-adc-get-value
2523
  • Converting the value
V = 2523 * 4.97 mV = 12539 mV = 12.54 V



The convertation of values

There should be installed a divider by two (not yet installed) on the channel. Formula for translation:

V_measured = N / 4095 * 1.85V * (R1+R2)/R2



Acuumulator voltage

For WB 2.8 and WB 3.5:

 cat /sys/bus/iio/devices/iio:device0/in_voltage7_raw

To convert to volts: value/ 4095.0 * 1.85 * 4 .

See the topic on the forum.


For Wiren Board 5, the voltage on the 4V rail is obtained in the same way.