ADC issues with simple voltage divider

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all, 

 

    I am trying to measure a battery voltage ( 2 * AAA Batteries ) via a  voltage divider connected with an ADC pin of ATmega169PA. The voltage divider is of 43k ( top - battery ) and 20k ( bottom - gnd ) and a 100nf capacitor connected in parallel with 20k resistor. Without connecting a voltage divider to ADC pin and when I measure the voltage using DMM , I get a voltage reading of .984V which is almost correct.

 

   But the moment I connect the voltage divider to the ADC pin the voltage changes to 1.413V ( read by same DMM ). Any idea of what is happening ? Is it because of 10K of ADC impedance boundary ?

 

   I measure the samples once in every 500ms .  I am using Internal 1.1V Voltage Reference with external capacitor at AREF pin.  ADC input pin is configured correctly and also the DIDR0 for the respective ADC pin.

Last Edited: Wed. Aug 9, 2017 - 06:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

babusujay@iconmedicare.com wrote:
ADC input pin is configured correctly and also the DIDR0 for the respective ADC pin.

Let's see the code.  Preferably, the smallest complete test program that exhibits the symptoms.

 

Is the battery pack directly connected to Vcc of the micro?  And AVcc?

 

If so, many/most would test battery V by using AVcc as reference, and doing conversions on the internal bandgap channel.  Start here...

http://www.avrfreaks.net/forum/a...

 

1)  Be sure to do the battery test under your app load.  An unloaded battery with just the AVR running will show near-fresh levels even when nearly depleted.

2)  Your divider will waste battery juice continually.  Consider putting the "ground" to an AVR pin.  Make it a low output when testing; floating input when not.

3)  You may well need to calibrate your internal bandgap; at least once.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

perhaps your IO has a config with pull up?

Thierry

Thierry Pottier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your suggestions theusch. Implemented the same and by which I avoided the voltage divider network and thus a little current is also saved. Battery monitoring is not that critical in my application and so I can live with Bandgap method for now. 

 

But still I couldn't understand how the voltage divider gives higher voltage when it is being connected to an ADC pin. I am trying to figure out correct my mistake if I ever committed one. I have only one proto PCB made for testing and in couple of days I will get few more boards so that I can cross check for circuit faulty.

 

TPE :  The IO has been configured correctly as follows. ATmega169PA is the MCU and PF5 is used as an ADC pin and all other PortF pins are not used and configured as input and pull up enabled.

 

DDRF = 0x20;  PORTF = 0xDF;  

DIDR0 = 0x20;  ADMUX = 0x65;  ( using AVCC and ADLAR )

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
DDRF = 0x20;  PORTF = 0xDF;

You have made PF5 an output driving low.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for the typing error. It is DDRF = 0x00; 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First, thanks for your puzzling topic (and thanks theush and joemorin  for hinting some solutions/explanations) . But you should not type code -redundent in the best case- , your mouse, unless you use lynx,  should copy and paste it, avoiding exponential (at least) growth of confusion.

Last Edited: Thu. Aug 10, 2017 - 10:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't "type" code, use copy / paste and use the code "<>" tags in the line above.    We are still waiting for the complete code that demos the problem!

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

babusujay@iconmedicare.com wrote:
Sorry for the typing error. It is DDRF = 0x00;
babusujay@iconmedicare.com wrote:
The IO has been configured correctly
theusch wrote:
Let's see the code. Preferably, the smallest complete test program that exhibits the symptoms.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you sure you aren't accidentally using 200k & 430K?   Also, look at the voltage with a scope...in case you are perhaps pulsating the pin & the meter is reading some sort of avg or rms, giving you a misleading number.  Ensure any pullup is off.

 

Also, you could use a cmos opamp, which would allow you to use much higher ohm dividers, yet drive the adc pin very well.  This would be more imperative if the Vbat was higher than allowable by a "floatable" gnd resistor (like a 9V bat).   The cmos opamp itself could draw next to nothing.

Take a look at the very low cost TLV521 ,TLV522 ---400 na supply, 1 pa input current (at room temp)

 

http://www.ti.com/lit/ds/symlink/tlv521.pdf

 

 

When in the dark remember-the future looks brighter than ever.

Last Edited: Sat. Aug 12, 2017 - 01:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will first see if your GND is ok .

if you connected some resistor to a IO and voltage increase , that means you get some leak current from the IO.

1) IO pull up 

2) GND problem

 a) power for CPU has not same GND

 b) voltage for IO / source wrong ( but you write at you use 2 AAA that cant be a problem)

 

3) Test a set a resistor to you IO & GND and measure at you have zero volt!

Thierry Pottier