Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

ADCDAC Accuracy?

3253 Views - Created 30/10/2015

30/10/2015

Posted by:
Adam

Adam Avatar

Just running the ADCDAC through its first test using the suggested Python ADC.py code.
I'm using a test input voltage of 3v30 but the code is returning a reading some 15% lower - the read voltage shows about 2v75. This fluctuates by about 0v01 from reading to reading though the input voltage is rock steady.
When I lower the input to 1v65 the read voltage changes to 1v4 or thereabouts, suggesting a slight non-linearity as well.

Any suggestions?
The 3v3 rail on the board was measured at exactly 3v30.
When I raise the input voltage above 3v3 the reading continues to rise, until at an input of 3v85 the reading tops out at 3v29919433594.

Many thanks

Adam

30/10/2015

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hello Adam

I am sorry you are having trouble with the ADC DAC Pi. I have just tried running the demo-adcread.py script from the https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/tree/master/ADCDACPi library with one of the ADC DAC Pi boards we have here and the library appears to be measuring the correct voltage. If the voltage is 15% low then it sounds like the ADC DAC Pi is faulty. I will send you a replacement one first thing tomorrow.

30/10/2015

Posted by:
Adam

Adam Avatar

Wow! That is great service!
BUT - I have done some further testing, isolating other circuitry that was in place and, lo and behold, I now get the correct readings. - no need to send a replacement.
So it looks like my plan that is flawed, and not the ADCDAC Pi.
Which raises a further question: My project is a battery capacity analyser which uses GPIO 17 to drive a relay (through a transistor). The relay contacts connect a resistive load for the battery and the ADCDAC pi monitors the battery's voltage as it discharges.A voltage divider keeps the voltage within the 3v3 range. There is no electrical connection between the GPIO pin and the ADC's input.
Could my use of GPIO17 in this way be detrimental to the operation of the ADCDAC Pi?

Thanks again for your help.

30/10/2015

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Using GPIO 17 to drive a relay via a transistor shouldn't cause any problems with the ADC DAC Pi, as long as the current being drawn from GPIO 17 isn't too high. I think the current limit on any GPIO pin is about 10mA so you just need a current limiting resistor in between the GPIO pin and the transistor to keep it below 10mA.

Are you powering the relay from the 3.3V rail or from an external supply? The ADC DAC Pi uses the 3.3V rail as the voltage reference so any sudden large changes in the current draw on that rail could cause the voltage to drop which would in turn cause the ADC DAC Pi to give an incorrect reading. With relays, it is always a good idea to use a reverse protection diode across the coil so you don't get any negative voltage spikes on the power lines which could damage the raspberry pi.

The main thing you have to check when you are using the ADC DAC Pi or any other ADC on the Raspberry Pi is you have a common ground between the Raspberry Pi and the battery you are measuring. If the grounds are at a different potential then that could cause problems with the values the ADC DAC Pi is reading.

31/10/2015

Posted by:
Adam

Adam Avatar

My design covers the points you mention, using a 1k for the transistor's base, The circuit resides on one of your Breakout Plus boards and the transistor / relay coil 5v supply comes from the Pi's 5v provided on the Breakout. The ADCDAC is piggy-backed onto the Breakout.
Testing was done using the demo-adcread.py script so no issue with the code attempting to switch on the relay.
All the grounds are all common though I didn't take a separate ground wire to the ADCDAC's input pads as there seemed to be continuity internally (and it made no difference when I tried it later).

I guess I just need to double-check my soldering!

Thanks again for your assistance Andrew..

01/11/2015

Posted by:
Adam

Adam Avatar

Okay, so I'm really confused now!

I have gone back to basics with testing my project by dispensing with all software and circuitry related to the GPIO output, and I just cannot understand the effect I'm seeing:-

If I apply a test voltage of 3v3 directly to the ADCDAC Pi's input the code duly returns the correct reading.
My project requires measurement of a voltage in the range 0-10v, so I use two resistors in series (10k and 20k303) to create a voltage divider. The voltage fed into the ADC is that across the 10K resistor, (ie 3v3 when Vtest = 10v). With the voltage divider in situ the voltage reading reported by the Pi becomes inaccurate as reported before.
Since I can measure the voltage at the input with a multimeter as 3v3 I feel confident to rule out the ADCs input impedance as a factor. These tests are done with just the two resistors and a breadboard.
Am I missing something obvious?
Adam

02/11/2015

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

After a lot of head-scratching, I think I may have figured out what is going wrong. I tried to replicate your circuit using a 10K and 20.3K voltage divider and I got the same problem as you, 3.3V was being recorded by the ADC as around 2.5V. Next, I tried replacing the resistors with 1K and 2.03K and when I tried measuring the voltage it showed up on the ADC as 3.3V.

What I think is happening is with the 10K and 20.3K resistors the current flowing into the ADC is too low for it to get a proper sample. The ADC works by charging a capacitor over a set time and then measuring the voltage across the capacitor, if the current at the input of the ADC is too low then the capacitor will not charge properly within the sample period and the voltage reading will be low. By replacing the resistors with lower values I increased the current flow to a high enough level that the ADC could function properly.

The problem with using lower-value resistors to measure a battery is the voltage divider will be drawing extra current from the battery and cause it to discharge quicker so I think your best option would be to use an op-amp on the ADC input to create a low impedance input for the ADC from a high impedance output from the battery.

If you look at page 16 of the datasheet for the ADC https://www.abelectronics.co.uk/docs/pdf/mcp3202.pdf it gives some details on using an op-amp to buffer the input voltage. Hopefully doing this should solve your problem.

02/11/2015

Posted by:
Adam

Adam Avatar

I can see this makes a lot of sense.
Fortunately for me current drain is not a problem since I am in any case draining the battey's entire charge into a 22R load attempting to measure its real-world capacity and endurance. I can simply factor the extra few mA into my code.
Thanks again for helping save my sanity, and providing great products and such excellent service.
Adam

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.