Author Topic: Voltage divider for arduino: only small resistors?  (Read 2950 times)

0 Members and 1 Guest are viewing this topic.

Offline anvoiceTopic starter

  • Regular Contributor
  • *
  • Posts: 248
  • Country: us
Voltage divider for arduino: only small resistors?
« on: September 10, 2017, 10:34:17 pm »
I'd like to measure a 3S LiPo battery voltage (12.6V max) using an arduino (5V). I know the max recommended impedance to be connected to the analog measurement pins is about 10K, but I read about a certain trick someone applied to use resistances in the 10M range for the divider: https://jeelabs.org/2013/05/16/measuring-the-battery-without-draining-it/.
By using a 0.1uF resistor connected in parallel with the bottom (closer to ground) resistor, they were able to measure the voltage with good accuracy and stability. I was hoping to replicate this to minimize the battery drain during measurement. However, when I tried the same, I notice that as soon as I attach a capacitor (I only have 0.01uF and 1uF, so I tried both) to the circuit, the measured voltage at the divider drops significantly. In fact the apparent resistances on the resistors change as well, e.g. my 1.2M resistor now measures as 500K. Clearly something is going wrong, and it's a bit beyond my knowledge right now.
So the question is two-fold: could anyone explain what might be going on in this circuit, and is it in fact possible to use the higher value resistances, or should I stick to the 10K range?
Thank you.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Voltage divider for arduino: only small resistors?
« Reply #1 on: September 10, 2017, 11:10:09 pm »
The capacitor makes the impedance look lower, when the internal sample and hold circuitry inside the ADC tries to charge its sampling capacitor. When that happens, the ADC pulls some small amount of current for a short time //microseconds//. If the measured voltage source impedance is high, then you measure inaccurately, because the ADC sampling capacitor could not charge enough, because the source impedance was too high.

Therefore there is a limit of how big the impedance can be, to still be able to measure voltage correctly.

Connecting a cap to the input analog pin (when the voltage source impedance is very high) makes possible for the ADC to pull the current to charge its sampling capacitor quickly.

Adding a capacitor there can NOT affect the impedance of the votlage divider. You're doing something wrong. Draw us a circuit diagram please, how you connected everything together.

Note: If you do not want to drain the battery at all, then disconnect the divider, when not measuring voltage of the battery. For example using a mosfet. (Choose one with especially low leakage current if possible.)
« Last Edit: September 10, 2017, 11:12:20 pm by Yansi »
 

Offline anvoiceTopic starter

  • Regular Contributor
  • *
  • Posts: 248
  • Country: us
Re: Voltage divider for arduino: only small resistors?
« Reply #2 on: September 11, 2017, 01:44:25 am »
Attached is the circuit I'm making. The 2 resistors on top are merely a crude tuning of the resistor to maximize my measured voltage range on the arduino, you can view them as 1 resistor I believe.

The thing is, the circuit is so simple, I don't see what I could be doing wrong. Please correct me if there's an obvious error.

Edit:
Ok, I think I figured it out... I forgot to connect the arduino to common ground with the rest of the circuit. |O Now everything behaves as expected. Not sure how to explain the behavior I saw anyway, but apparently the dissimilar grounds didn't play well with the capacitor.
« Last Edit: September 11, 2017, 02:11:34 am by anvoice »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Voltage divider for arduino: only small resistors?
« Reply #3 on: September 11, 2017, 11:56:08 am »
Note that adding a capacitor only helps with the current transient when the s/h capacitor in the ADC is switched to the required input.  A capacitor will not help with errors introduced by any leakage currents.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11536
  • Country: ch
Re: Voltage divider for arduino: only small resistors?
« Reply #4 on: September 11, 2017, 03:27:23 pm »
FWIW, I would just use a device designed precisely for this purpose, like the INA219 or INA226 power monitor ICs. You can get them mounted on a breakout board for a few bucks on eBay. There are arduino libraries for them, so they're super easy to use. They're also amazingly accurate -- in my tests, staying within a few counts of a 6.5 digit DMM.
 

Offline perieanuo

  • Frequent Contributor
  • **
  • Posts: 838
  • Country: fr
Re: Voltage divider for arduino: only small resistors?
« Reply #5 on: September 11, 2017, 05:23:26 pm »
I'd like to measure a 3S LiPo battery voltage (12.6V max) using an arduino (5V). I know the max recommended impedance to be connected to the analog measurement pins is about 10K, but I read about a certain trick someone applied to use resistances in the 10M range for the divider: https://jeelabs.org/2013/05/16/measuring-the-battery-without-draining-it/.
By using a 0.1uF resistor connected in parallel with the bottom (closer to ground) resistor, they were able to measure the voltage with good accuracy and stability. I was hoping to replicate this to minimize the battery drain during measurement. However, when I tried the same, I notice that as soon as I attach a capacitor (I only have 0.01uF and 1uF, so I tried both) to the circuit, the measured voltage at the divider drops significantly. In fact the apparent resistances on the resistors change as well, e.g. my 1.2M resistor now measures as 500K. Clearly something is going wrong, and it's a bit beyond my knowledge right now.
So the question is two-fold: could anyone explain what might be going on in this circuit, and is it in fact possible to use the higher value resistances, or should I stick to the 10K range?
Thank you.
Toooo big resistor latter.read at mega adc port spec,need lower resistance below 10k.put 4k7 .regards pierre


Envoyé de mon iPad en utilisant Tapatalk
 

Offline anvoiceTopic starter

  • Regular Contributor
  • *
  • Posts: 248
  • Country: us
Re: Voltage divider for arduino: only small resistors?
« Reply #6 on: September 12, 2017, 12:09:03 am »
FWIW, I would just use a device designed precisely for this purpose, like the INA219 or INA226 power monitor ICs. You can get them mounted on a breakout board for a few bucks on eBay. There are arduino libraries for them, so they're super easy to use. They're also amazingly accurate -- in my tests, staying within a few counts of a 6.5 digit DMM.
Thanks, I'm still learning so I don't know about all the IC choices out there! I'll definitely look into that.

Toooo big resistor latter.read at mega adc port spec,need lower resistance below 10k.put 4k7 .regards pierre
Yep I know that, but the capacitor is supposed to be a "trick" to circumvent that restriction, hence my question.
 

Offline perieanuo

  • Frequent Contributor
  • **
  • Posts: 838
  • Country: fr
Re: Voltage divider for arduino: only small resistors?
« Reply #7 on: September 12, 2017, 07:56:56 am »
Quote
Yep I know that, but the capacitor is supposed to be a "trick" to circumvent that restriction, hence my question.
I allready tried that, in fact that's the error source.I'm also ,ot talking theory, I made amp/voltmeter with an arduino pro mini in my variable DC power supply with some 1.3" oled SH1106, works ok.Of course I have capacitors on the source output, both filtering and RF reject and diode :)
So I think the only mistake is resistors value.the rest is discussion, just try and post results.
regards,pierre
« Last Edit: September 12, 2017, 08:02:09 am by perieanuo »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19527
  • Country: gb
  • 0999
Re: Voltage divider for arduino: only small resistors?
« Reply #8 on: September 12, 2017, 09:53:14 pm »
Note: If you do not want to drain the battery at all, then disconnect the divider, when not measuring voltage of the battery. For example using a mosfet. (Choose one with especially low leakage current if possible.)
That's a good idea. Another option is a BJT, which will have a lower leakage current, than a MOSFET, but the on voltage will be slightly higher and current required to turn it on is greater, than a MOSFET.
 

Offline perieanuo

  • Frequent Contributor
  • **
  • Posts: 838
  • Country: fr
Re: Voltage divider for arduino: only small resistors?
« Reply #9 on: September 13, 2017, 05:30:16 am »
Mosfet rules baby!!

Envoyé de mon HUAWEI NXT-L29 en utilisant Tapatalk

 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Voltage divider for arduino: only small resistors?
« Reply #10 on: September 13, 2017, 11:31:41 am »
Voltage divider values tradeoff -

1) Power
2) Noise
3) Offsets
4) Precision
5) Accuracy

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline perieanuo

  • Frequent Contributor
  • **
  • Posts: 838
  • Country: fr
Re: Voltage divider for arduino: only small resistors?
« Reply #11 on: September 13, 2017, 05:54:11 pm »
Voltage divider values tradeoff -

1) Power
2) Noise
3) Offsets
4) Precision
5) Accuracy

Regards, Dana.
For his application it's sooo easy to touch the accuracy by sw means.measure Vcc, integrate,measure I or V, correction,integrate also, use value.it's not 6 digits dmm just 10 mV precision voltage.
Your observations are veery good for professional use not a simple li bat management imho


Envoyé de mon iPad en utilisant Tapatalk
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf