Устарело: низкоуровневая работа с ADC в Wiren Board 2, 3 и 4/en: различия между версиями

Материал из Wiren Board
(Новая страница: «== Acuumulator voltage ==»)
(Новая страница: «For WB 2.8 and WB 3.5:»)
Строка 76: Строка 76:
== Acuumulator voltage ==
== Acuumulator voltage ==


Для WB 2.8 и WB 3.5:
For WB 2.8 and WB 3.5:


<pre>
<pre>

Версия 20:31, 23 мая 2019

Другие языки:

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



Сhangeover 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

Для преобразования в вольты: значение/ 4095.0 * 1.85 * 4 .

Смотрите тему на форуме.


Для Wiren Board 5 аналогичным образом получается напряжение на рейке 4В.