Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

BBIO python library analog data isn't what's published
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BBIO python library analog data isn't what's published

by pschmidt on Mon Jul 25, 2016 4:39 pm

Using this example code with the ADC module:

print ADC.read(port) / ADC.read_raw(port) * 4096

for all seven values of port does not yield the same value for all ports. I get values ranging from about 1.97 and 2.28. I would expect all the values to be "exactly" the same. Why the discrepancy?

pschmidt
 
Posts: 4
Joined: Mon Jul 25, 2016 4:31 pm

Re: BBIO python library analog data isn't what's published

by drewfustini on Mon Jul 25, 2016 6:09 pm

What do you have wired to the ADC pins? Is it the wiring same for all the ADC pins?

drewfustini
 
Posts: 920
Joined: Sat Dec 26, 2015 1:19 pm

Re: BBIO python library analog data isn't what's published

by pschmidt on Tue Jul 26, 2016 10:11 am

Well, nothing actually. But it should not matter. I expect the code I posted to yield a value of 1.8 for all channels.

And by the way, according to the documentation, the construct ADC.read(port) should return a "normalized" value between 0.0 and 1.0. It does not do this in my case.

pschmidt
 
Posts: 4
Joined: Mon Jul 25, 2016 4:31 pm

Re: BBIO python library analog data isn't what's published

by tomis4cd on Tue Jul 26, 2016 1:10 pm

ADC.read(port) is returning ADC_COUNTS / 4096 where ADC_COUNTS is 0 to 4095
which produces a value between 0 and almost 1.0

ADC.read(port) * 4096 will equal the ADC_COUNTS and should match ADC.read_raw()
Maybe exact match but could be off a few counts because of noise on the input and
values being read at separate times.

ADC.read(port) * VREF where VREF = 1.8 gets you the volts on the pin as a percentage of VREF
If VREF was spot on 1.80 volts the best you can get is (4095/4096) * 1.80

Leaving the analog inputs floating will always produce random values, because of noise pickup.
That is true for any A/D
The doc's also say you need to take each reading twice and average

Tom

tomis4cd
 
Posts: 68
Joined: Wed Mar 14, 2012 1:02 pm

Re: BBIO python library analog data isn't what's published

by drewfustini on Tue Jul 26, 2016 9:03 pm

I'd like to know what system software is running on your Beaglebone. Please paste the output of:

uname -a

cat /etc/dogtag

cat /etc/debian_version


You may also want to install the latest version of Adafruit_BBIO from GtiHub:
https://github.com/adafruit/adafruit-be ... -io-python

The most recent change added ADC for Linux kernel 4.1+:
https://github.com/adafruit/adafruit-be ... n/pull/102

drewfustini
 
Posts: 920
Joined: Sat Dec 26, 2015 1:19 pm

Re: BBIO python library analog data isn't what's published

by pschmidt on Thu Jul 28, 2016 3:02 pm

Hi Drew,

Here's what I have:

xxxx@beaglebone:~$ uname -a
Linux beaglebone 4.1.18-ti-rt-r49 #1 SMP PREEMPT RT Thu Feb 25 21:59:17 UTC 2016 armv7l GNU/Linux
xxxx@beaglebone:~$ cat /etc/dogtag
BeagleBoard.org Debian Image 2016-05-13
xxxx@beaglebone:~$ cat /etc/debian_version
8.4


I have installed the latest BBIO, but not the kernel 4.1+ change. At this point, I'm just reading the raw A/D values anyway, which seems to be working fine.

Thanks,
Phil

pschmidt
 
Posts: 4
Joined: Mon Jul 25, 2016 4:31 pm

Please be positive and constructive with your questions and comments.