Monday, January 12, 2009

Battery Monitor - Voltage Divider Circuit

There are many IC's out there that can do what is called "gas gauging" to monitor how much battery is left in your robot, just like in mobile phones.

Since I am somewhat new to electronics, I wanted to learn how to implement a battery monitor sensor by using what is called a voltage divider circuit.



Just like LEDs use a series resistor to ensure they receive no more than 20mA of current, with 5vdc this usually turns out to be a 330ohm resistor.

If you wanted to power this same LED, but all you had was say a 9volt or 12volt power source, then you would have to use a second resistor on the ground side of the LED, which would give you a lower voltage AND lower current.

This voltage divider circuit has many more uses besides just LEDs, it can also be used to create a reference voltage or logical voltage level.

For example, I have a 6vdc NiMH battery, but when fully charged it reads 7.08vdc on the multimeter. For my sensor, I want to say that 5vdc is fully charged. I will do some math to calculate what resistors I need to get a 5vdc Vout. Or in my case, I dread math so I will use a Java applet I found:

The applet will help me get a close approximation to start with. I enter in 7v for Vs, and I find I can get 5.00vdc on the voltmeter with R1 = 20k, and R2 = 50k
Voltage Divider Applet

The only snag apparent right now is that with common 5% resistors, there are only a limited selection to chose from. Unfortunately, there is no such thing as a 5% 20k and 50k resistor.

There is another snag too that i'll tell you about now, is that this circuit is assuming there is nothing connected to Vout, meaning no load. It is basically just a series resistance. The way to deal with that is if you know the current that will be on the load, you can use another series resistor on your 5v. The other way, which is what I will use, is you can add a capacitor between ground, and the voltage you want to stabalize. In my case a 10uF 16V cap is perfect.

According to Ohm's Law, the ratio of voltage across our two resistors will be equal to the ratio of the resistance values themselves. In my case, I want to drop from 7.08 to 5, thats a drop of 2.08. Therefore my ratio is 2.08:5, or more simply 0.416:1. Unfortunately, this ratio will not work using common 5% resistors. I will round down and say my batteries max charge is 7vdc, which is fine as they will lower in voltage as they get older anyway. So lets say 2:5, or 0.4:1 (or for the purpose of the calculator below, 1:0.4)

In this next calculator, the table shows the significant digits (1st digit, and 2nd digit) of standard 5% resistor values. When you type in a ratio, it calculates the corresponding significant digits (1st digit, and 2nd digit) that would be required to complete that ratio.

Resistor Ratio Calculator

Go ahead and type in '0.4' in the desired ratio box.

All you need to do is pick out ratios of valid significant digits (meaning no decimal point, and a number you already see listed on the table, in my case the first 4 in 10:4 is not an existing resistor value).

The table shows that you can use resistance values with the first two digits of (this does not talk about the multiplier) 30:12, or 75:30 to obtain the ratio of 1:0.4.

If instead of doing 2/5 to get 0.4, you had done 5/2, you would have gotten 2.5. If you had specified 1:2.5 (the inverse of 1:0.4), you would have gotten the ratios of 12:30, and 30:75. Which is the same ratios that fit the standard resistor values.

We the voltage out that we want (5vdc) by using any resistors of the ratios that we discovered. We could use (12ohm & 30ohm), (120ohm & 300ohm), (1.2kohm & 3kohm), (12kohm & 30kohm), (120kohm & 300kohm), all the way up to (120Mohm & 300Mohm). The same goes with the 30:75 ratio.

You can check it out by entering some of these values into a calculator:

The sensor:

The way we make this into a sensor, is wire up some sort of battery tap on the MCU board, and the place the 10uF cap across your positive and negative voltages. Place your two resistors in series on each end of the cap. From the two resistor wires that are connected, place a wire coming off of there and crimp it with a molex connector

From there you can plug that into a male header coming off of a pin on your microprocessor. The pin should be one that is using your mcu's 8-bit ADC. This way theoretically, a full battery would return 255, and a drained battery would be closer to zero (although your robot may start malfunction a lot earlier). You have to test to see the lowest voltages your robot can operate at. From there you can either flash some sort of LED, or have it enter into an algorithm that searches out for a charger beacon, or tape on the ground leading to the charger.

From all of that your robot will know when its low and power, and will be able to implement a self-charging routine.

3 comments:

  1. This helped add some depth to what information I had. Thanks

    ReplyDelete
  2. Hi,


    It’s really good to know about the batteries in detail.

    Seriously do we realize how many things in your house that need batteries? However, with that so many kinds of battery, which is generally different between one to another, sometimes we have some difficulties in finding the desired type.

    Find the right batteries supplier is not hard if you check out batterystation.co.uk because this website provides the widest selection of batteries and you can choose the right battery based on the categories. You can get the procell batteries which available in several sizes and voltage. You also can find Duracell batteries that divided into duracell plus batteries and duracell ultra batteries. All of the batteries come with cheaper price because this website provides the discount batteries in bulk, wholesale, and retail quantities.

    Thanks,

    ReplyDelete
  3. I think Jolly has a point we do use batteries a lot nowadays for something or the other of many sizes and brands. The thing is not what type of battery you have like an eveready battery or a procell battery the question really is how we can get the most life from these batteries and our appliances?

    ReplyDelete