Skip to content

Conversation

@dengber
Copy link

@dengber dengber commented Oct 26, 2016

BBB has 12‐bit ADCs (2^12 = 4,096), meaning a value between 0 and 2^12 − 1 (0 to 4,095), read() should return the raw value divided by 4095, not by 1800.

…2 − 1 (0 to 4,095), read() should return the raw value devide by 4095.
@pdp7 pdp7 merged commit 50e8883 into adafruit:master Oct 28, 2016
@pdp7
Copy link
Collaborator

pdp7 commented Oct 28, 2016

4.1.15-bone18

read_raw() value: 2782.0 read() value: 0.713308930397 voltage value: 1.28395607471 

4.1.16-ti-rt-r44

root@beaglebone:~# python ./adc_test.py read_raw() value: 2773.0 read() value: 0.720390737057 voltage value: 1.2967033267 

Test program adc_test.py

import Adafruit_BBIO.ADC as ADC ADC.setup() #read_raw returns non-normalized value value = ADC.read_raw("P9_40") print "read_raw() value:" print value #read returns values 0-1.0 value = ADC.read("P9_40") print "read() value:" print value print "voltage value:" voltage = value * 1.8 #1.8V print voltage 
@pdp7
Copy link
Collaborator

pdp7 commented Oct 28, 2016

Thanks @dengber

I've realized that the older 3.81.13 kernel produces ADC raw value of 0 to 1800, so I'm going to push a commit that chooses the right scaling based on kernel version.

@pdp7
Copy link
Collaborator

pdp7 commented Oct 28, 2016

Test OK for all kernels after 4371949

3.8.13-bone80

root@beaglebone:~# python ./test_adc.py
read_raw() value:
1694.0
read() value:
0.94055557251
voltage value:
1.69300003052

4.1.16-ti-rt-r44

root@beaglebone:~# python ./adc_test.py
read_raw() value:
3849.0
read() value:
0.939682543278
voltage value:
1.6914285779

4.1.15-bone18

root@beaglebone:~# python ./test_adc.py
read_raw() value:
3848.0
read() value:
0.941636145115
voltage value:
1.69494506121

4.4.27-bone14

root@beaglebone:~# python ./test_adc.py
read_raw() value:
3849.0
read() value:
0.938949942589
voltage value:
1.69010989666

Test program adc_test.py

import Adafruit_BBIO.ADC as ADC ADC.setup() #read_raw returns non-normalized value value = ADC.read_raw("P9_40") print "read_raw() value:" print value #read returns values 0-1.0 value = ADC.read("P9_40") print "read() value:" print value print "voltage value:" voltage = value * 1.8 #1.8V print voltage 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants