I'm adding a voltage divider so I can monitor the voltage levels on a 7.4V 2S1P Li-Po battery pack and I have a few questions.
I'm assuming:
The max voltage to be <8.4V
This will be used for an Uno or a Mega
I think I'm save just cutting it in half, <4.2V. Can I use 1M ohm resistors to limit the current draw?
I'm only planning on checking it every 5 seconds, so it's basically off all the time. Will it continue to draw current? and could I put that in check with a signal P-MOS as a gate?
If I use the P-MOS will that affect the reading as I switch it on, like a button bounce?
I've heard of using a capacitor for this circuit. Is that necessary given the large window between readings?
I don't know if anyone has determined the maximum resistor divider value that still works on analog input, but I suspect 1M would be ok. That would give you 2M in total, so not much current would flow. But yes, it would flow all the time.
If you want to switch it, you would need a P-channel to do the switching, plus an N-channel, or bipolar NPN, to control the P-channel's gate. You can't connect an Arduino pin directly to the P-channel's gate.
I was just starting to wonder about that. In another circuit with a BS170N I use a 100Ohm resistor from the pin to the gate and a 10k pull-down on the pin. Same should work here too?
Re: 4 - I've used the techniques described here to measure battery voltage. It's usually been 3x AA non-rechargeable batteries but i've also used it to monitor the voltage on a 3.7v LiPo battery connected to a CN3065 based solar charger.
My setup is Vin to 2M2 to a 560K to Gnd + a 100n cap in parallel with the 560K. The junction of the 2M2 and the 560K gets fed to one of the 328P ADC channels. There's no switching, the resistors stay in circuit all the time. This generates about 1.014V from 5V in so can be used against the internal 1.1V reference.
My 100n is unpolarised - just some axial 100n cap i've had lying around for ages.
The internal voltage reference is just that - a reference voltage that is known. In order to measure something, you have to compare it against a known reference in order to determine its value. Note that the internal reference on a 328P is 1.1V, so you need to calculate the resistor values to deliver no more than 1.1V.
A quick play with the Electronics2000 potential divider calculator shows that if you leave your R1 at 2M2, then make your R3 a 360K, then you should get around 1.041V from a 7.4V input.
Very helpful reply. My mistake was in the third resistor as I'm still learning to draw from text descriptions. I can calculate the value across a divider but thank you for saving me the futzing around This is now a 7.111 divider.
What does the capacitor in this circuit do? Does it block the ground when it reverses? Does that stop the current draw?
Issue with the AREF pin. If I've read correctly, it's available on the Uno but not the Mega. Do I have that right?
INTERNAL: a built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts on the ATmega32U4 and ATmega8 (not available on the Arduino Mega)
INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
Re the capacitor - have a read of the link I gave you in reply #4.
As far as I know, the AREF signal is brought out to a pin on the actual micro package. Whether that signal is routed to an accessible connector is down to the board maker. On an UNO, its available on the header near the USB connector. Same for the MEGA.
I think the confusion may be simply down to the names given: INTERNAL, INTERNAL1V1 and INTERNAL2V56. I've not coded on a MEGA board so i'll hazard a guess that selecting the internal 1.1V reference on a MEGA is:
analogReference(INTERNAL1V1)
But if you're writing code for an UNO, then the same 1.1V reference is selected by:
analogReference(INTERNAL)
The way it all works is that the ADC (Analogue to Digital Converter) compares the voltage you want to measure against a reference - say 1.1V. On the 328P (used on the UNO), the ADC is 10-bit which means that it will give you values between 0x0000 and 0x03FF. In theory when you apply 0V, the ADC gives you 0x0000 and when you apply 1.1V it gives you 0x03FF, with a linear relationship between Vin and the ADC value.
In simple terms, the resolution is the voltage change required to change the value reported by the ADC by 1.
Again, very helpful. Thank you.
I miss the inline links sometimes, glad you pointed it out for me. I read that page and moved onto the next page. I really like his zero-draw circuit.
Ultimately though, I'm going to go with yours, because the Vin to it is switched and will only have that tiny draw when the unit is actually powered on and that's just not enough to worry about.
I have some 0.1uF electrolytic capacitors but the pins are different length so I think those are polarized. I do have some ceramic caps marked 104. I think that the same in non-polarized.
Also, that clears up the Uno -v- Mega, the issue is just syntax.
@alto777 Yup, definitely connecting the grounds. Thanks for the scale I shall set a reminder on my phone when I'm down to a couple years