Go Down

Topic: 4 nimh Battery charging through arduino (Read 2 times) previous topic - next topic

ChowMix12

As a little side function of my robot, i wanted to be able to charge
4 AA 1.2volt 2100 mAh nimh batteries in series. I'm using this to power my Arduino, as well as run 2 motors, so they are eaten up quickly. I was wondering if i could use analogRead to measure the battery capacity. I know there are other people who asked about this, but i couldn't find a definitive answer from any of the other posts.

CrossRoads

#1
Dec 22, 2010, 06:30 am Last Edit: Dec 22, 2010, 06:33 am by CrossRoads Reason: 1
Yes, you can read the voltage on the battery pack.
If you want to use 4 analog inputs, you could measure all 4.
Or use 2 digital bits to control an analog multiplexer and take turns reading them with a single analog pin.
Or use an external A/D converter and bring in the voltage information serially.
Lots of options.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

retrolefty

#2
Dec 22, 2010, 06:51 am Last Edit: Dec 22, 2010, 06:51 am by retrolefty Reason: 1
Quote
I'm using this to power my Arduino, as well as run 2 motors, so they are eaten up quickly. I was wondering if i could use analogRead to measure the battery capacity.


Well you can but it will be a meaningless reading in that it will measure they are always fully charged? How could that be? Well if you are powering your Arduino with the 4 AA batteries in series then they becomes the Vcc for the processor chip which by default is also the reference voltage for the analog to digital function on the chip. So by reading the battery via a analog input pin the resulting measurement will always be 1023 counts regardless of the actual voltage of the cells. They will remain true until the battery voltage gets so low that the chip stops functioning. Pretty cool huh?

So what can you do? Well you can read up on the A/D section of the datasheet for the processor. You can consider using internal or external regulated A/D voltage references. There are ways around it but it's best that you try and understand the how and why as there will be various trade-off decision of costs Vs component count, etc.

Lefty

ChowMix12

#3
Dec 22, 2010, 04:55 pm Last Edit: Dec 22, 2010, 04:56 pm by ChowMix12 Reason: 1
Actually, i planned on having a spdt switch, or a latching relay to the circuit to choose between charging, and operation when plugged in to another powersource.

retrolefty

Quote
Actually, i planned on having a spdt switch, or a latching relay to the circuit to choose between charging, and operation when plugged in to another powersource.


What does that have to do with the ability to be able to measure the battery voltage via the Arduino accurately?

Lefty

Cloudy


I have an Arduino Pro Mini 3.3v based LCD remote control which runs off NiMH and includes a small header at the side where I can plug in a power source to charge the battery.  The battery feeds Vraw on the Pro Mini so it uses it's own Vref for ADC that's generated from the onboard regulator.  The charging power source goes through a LM317 to provide constant current and I control charging using a transistor which turns the 317 on and off.  The remote control carries on working while being charged.  To measure voltage I use a resistor divider 100k/100k.  The Pro Mini controls the charging using 3 stages.


ChowMix12

@retrolefty

Basically, i wont be using the batteries that are being charged while reading the battery level.

retrolefty

Quote
Basically, i wont be using the batteries that are being charged while reading the battery level.


Understood. However the more fundemental problem is that how the analogRead() function is setup by default you will not be able to read the true battery voltage if it is also directly being used to power the +5v bus of the Arduino, it will always read out as 1023 counts, never change even though the battery voltage is decreasing over time. You will have to read up on alternate voltage references and using resistor voltage dividers. Lots of info on this forum if you search around.

Lefty

ChowMix12

ok thanks.. BTW, why would the arduino be reading a decrease of battery level when charging? im only going to use the arduino as a charger, i won't be monitoring the battery level when its in use. how do phones and other devices read their battery level?

retrolefty

Quote
how do phones and other devices read their battery level?


By using a A to D reference voltage that does not change with battery voltage.

Lefty

CrossRoads

How could one take advantage of the 1.1V reference internal to the ATMega?
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

retrolefty

Quote
How could one take advantage of the 1.1V reference internal to the ATMega?


Simple by using the internal 1.1v reference then one can use an external 2 resistor voltage divider to cut the battery voltage down such that maximum battery voltage is measured as say 1vdc. Software can be used to scale that to any internal value you wish, or just treat it as 1v = 100%.  The 1.1v reference will not change as the battery (therefore Vcc) slowly drops as the battery discharges.

Make sense?

Go Up