Pages: [1]   Go Down
Author Topic: 4 nimh Battery charging through arduino  (Read 2321 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 546
Posts: 27361
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 22, 2010, 12:33:07 am by CrossRoads » Logged

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.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: December 22, 2010, 12:51:48 am by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 22, 2010, 10:56:03 am by ChowMix12 » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@retrolefty

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 546
Posts: 27361
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1]   Go Up
Jump to: