Wrong readings and pins influenced by others
Hi, I've been doing some tests and some of the values seem to be influenced by other pins values. I used a 0.9V source obtained from a simple voltage divider from the 1.8V VDD_ADC and GNDA_ADC. (10 kΩ resistors were used).
-When I connect the 0.9V to AIN3, and leave the rest disconnected, AIN3 reads 1.02 oscilating (Picture 1): -Then if I connect 0.9V to AIN0, both AIN0 and AIN3 get 0.89V -If I connect GNDA_ADC to AIN0: AIN0 reads 0 and AIN3 reads 0.75 -If I connect VDD_ADC to AIN0: AIN0 reads 0 and AIN3 reads 1.05 constant(like in the first case, but more constant)
I tested with more pins always obtaining similar results, EXCEPT for pin AIN0, which when it's the only one connected, it reads the correct value of 0.9V.
I tested all the pins with GNDA_ADC to make sure I was looking at the correct pin.
When I do the same with Adafruit_BBIO for adc, the values are always constant regardless of the other inputs as shown in picture 2.
I really need the high sampling rate of this library compared to the Adafruit_BBIO, where I'm only getting around 250Hz (seems low to me). Can you fix this error, or point me to another library that provides high sampling rates ? I need at least 3000Hz.
I have tested using both the usb connection and the power suply and solely with usb connection.
Code:
######################## pru_adc
import beaglebone_pru_adc as adc import time
constant = 1.8 / 4095.0 capture = adc.Capture() # Clamp voltage capture.start() while(True): v_list = ["{0:.4f}".format(item * constant) for item in capture.values] #just creates a list with the values from the pins del v_list[7] print v_list time.sleep(0.00001) capture.stop() capture.wait() capture.close()
######################## Adafruit_BBIO
!/usr/bin/python
import time import Adafruit_BBIO.ADC as ADC
constant = 1.8 / 4095.0 numsamples = 4000
pins = ["AIN0", "AIN1", "AIN2", "AIN3", "AIN4", "AIN5", "AIN6"] ADC.setup() while(True): valList = ["{0:.4f}".format(ADC.read(pin) * 1.8) for pin in pins] #just creates a list with the values from the pins print valList
Pictures:
1

2

Hi Miguel,
Pretty interesting evidence you present.
It is unlikely to be a software error per se, library just returns captured values verbatim. There is no code that would allow a possibility of such interference.
Possibly Adafruit configures hardware differently. Maybe setting pull-up/pull down resistors on AIN inputs differently.
What is your voltage divider? Can you try the same experiment using 200 Ohm
- 200 Ohm divider?
Mike
On Monday, September 14, 2015, miguel-ribeiro [email protected] wrote:
Hi, I've been doing some tests and some of the values seem to be influenced by other pins values. I used a 0.9V source obtained from a simple voltage divider from the 1.8V VDD_ADC and GNDA_ADC.
-When I connect the 0.9V to AIN3, and leave the rest disconnected, AIN3 reads 1.02 oscilating (Picture 1): -Then if I connect 0.9V to AIN0, both AIN0 and AIN3 get 0.89V -If I connect GNDA_ADC to AIN0: AIN0 reads 0 and AIN3 reads 0.75 -If I connect VDD_ADC to AIN0: AIN0 reads 0 and AIN3 reads 1.05 constant(like in the first case, but more constant)
I tested with more pins always obtaining similar results, EXCEPT for pin AIN0, which when it's the only one connected, it reads the correct value of 0.9V.
I tested all the pins with GNDA_ADC to make sure I was looking at the correct pin.
When I do the same with Adafruit_BBIO for adc, the values are always constant regardless of the other inputs as shown in picture 2.
I really need the high sampling rate of this library compared to the Adafruit_BBIO, where I'm only getting around 250Hz (seems low to me). Can you fix this error, or point me to another library that provides high sampling rates ? I need at least 3000Hz.
I have tested using both the usb connection and the power suply and solely with usb connection.
Code: ############################## pru_adc ############################ import beaglebone_pru_adc as adc import time
constant = 1.8 / 4095.0 capture = adc.Capture() # Clamp voltage capture.start() while(True): v_list = ["{0:.4f}".format(item * constant) for item in capture.values] #just creates a list with the values from the pins del v_list[7] print v_list time.sleep(0.00001) capture.stop() capture.wait() capture.close()
############################## Adafruit_BBIO ############################ #!/usr/bin/python import time import Adafruit_BBIO.ADC as ADC
constant = 1.8 / 4095.0 numsamples = 4000
pins = ["AIN0", "AIN1", "AIN2", "AIN3", "AIN4", "AIN5", "AIN6"] ADC.setup() while(True): valList = ["{0:.4f}".format(ADC.read(pin) * 1.8) for pin in pins] #just creates a list with the values from the pins print valList
Pictures: 1 [image: 1] https://cloud.githubusercontent.com/assets/6084480/9851031/93491de4-5aee-11e5-8d46-04ba29ae2bef.jpg
2 [image: 2] https://cloud.githubusercontent.com/assets/6084480/9851033/9709762c-5aee-11e5-8bab-b84bd3345c12.jpg
— Reply to this email directly or view it on GitHub https://github.com/pgmmpk/beaglebone_pru_adc/issues/8.
What would be the difference between 100 and 200 ? I tried with 100k, and the results are good with 0.9V constant but it's wrong when I apply more voltage to AIN3 -> it changes the value of AIN4 by 0.15V. This doesn't happen when I apply voltage to any other input besides AIN3. Really strange stuff is happening here.
"Maybe setting pull-up/pull down resistors on AIN inputs differently." I don't think so, because the values also float around when the pins are disconected with that library. If it was configured with pull up/down resistors, it would be either 0 or 1.8 ? am I right ?
I would really like to stick with this library due to the sampling rates, but if you just read the values, how come it reads differently from both the multimeter that I'm testing and Adafruit library ?
Internal impedance of AIN input is about 1K (i might be wrong here - its been a while since i checked the bb specs). What I've seen empirically is that 10k is not strong enough to pull it all the way down or up. Hence my request to use stronger voltage divider, like 0.2k+0.2k
Explain multimeter thingy, please. So far the puzzling evidence was the difference in readings between pru_adc and Adafruit.
On Mon, Sep 14, 2015 at 11:53 AM, miguel-ribeiro [email protected] wrote:
What would be the difference between 100 and 200 ? I tried with 100k, and the results are good with 0.9V constant but it's wrong when I apply more voltage to AIN3 -> it changes the value of AIN4 by 0.15V. This doesn't happen when I apply voltage to any other input besides AIN3. Really strange stuff is happening here.
"Maybe setting pull-up/pull down resistors on AIN inputs differently." I don't think so, because the values also float around when the pins are disconected with that library. If it was configured with pull up/down resistors, it would be either 0 or 1.8 ? am I right ?
I would really like to stick with this library due to the sampling rates, but if you just read the values, how come it reads differently from both the multimeter that I'm testing and Adafruit library ?
— Reply to this email directly or view it on GitHub https://github.com/pgmmpk/beaglebone_pru_adc/issues/8#issuecomment-140122944 .
The value read y the multimeter is also 0.9 equal do adafruit one.
I tried with 200 Ohm and the 0.9V value is correct (and so it is with 100K except for AIN4 which is influenced by AIN3).
But at this stage of the project it's no longer possible to change the resistors.
Do you know what could possibly be causing this ? and how does adafruit manages to compensate the final value ?
Thank you for the attention
Thanks for checking 200 Ohm divider.
Does the following correctly summarizes the observations?
- When using 100k+100k divider, AIN3 reading as returned by pru_adc depends on AIN0 and varies between 0.75 and 1.0. While Adafruit library does not show this interference.
- When using 0.2k+0.2k divider, AIN3 reading is stable and pru_adc returns same (or very similar) results as Adafruit.
I will need to analyze (again) what Adafruit is doing differently.
Additionally, I may need to return to my prior experiment that showed that 10k can not pull ADC input all the way down or up - and check if the same effect is seen with Adafruit. Just to have an extra bit of information.
On Mon, Sep 14, 2015 at 12:47 PM, miguel-ribeiro [email protected] wrote:
The value read y the multimeter is also 0.9 equal do adafruit one.
I tried with 200 Ohm and the 0.9V value is correct (and so it is with 100K except for AIN4 which is influenced by AIN3).
But at this stage of the project it's no longer possible to change the resistors.
Do you know what could possibly be causing this ? and how does adafruit manages to compensate the final value ?
Thank you for the attention
— Reply to this email directly or view it on GitHub https://github.com/pgmmpk/beaglebone_pru_adc/issues/8#issuecomment-140141455 .
Yes, it summarizes correctly the situation. And the AIN0 always reads correctly independent of the reistors used or other inputs
Was there any solution for this presented? I'm noticing that all of the readings from AI0 on are influenced by previous pins. For example, if I have a voltage input at AI0, all inputs from 1-7 are effected. If I have a voltage input at AI4, only 5-7 are effected. This is a pretty problematic thing to have!