PDA

View Full Version : PIC based mAh meter/current draw sensor



skimask
- 4th January 2008, 04:58
Got a new one that'll keep track of how much current a small circuit draws and logs totals. I'd guess you'd call it a 'battery gauge' or 'mileage meter' for a batter pack.
Looking for a better idea...if one exist's...
The idea I've got just to measure circuit draw, not battery pack before the regulator draw, now goes like this:
I get a 5v switch-mode regulator (LM2825 type thing) with an external V sense line, run the regulator output thru a low ohm resistor (.001, .01, .1 ohms, how low is low enough? depends on max current draw I suppose), the regulator's external V sense line goes on the circuit side of the resistor.
Measure the voltage on both sides of the resistor with the ADC with respect to Batt- (with a divider if need be and add that current draw to final result), apply a little Kirchoff's and Ohm's law, do the math, and done...I got current draw. I then integrate time into the equation and get mAh (limited by the resolution of time and the ADC and accuracy of the regulator and resistor).
Am I done?
In fact, it would be kinda nice to throw this in-line with most other projects on the bench just to see what they pull...

Ioannis
- 4th January 2008, 08:31
May be I did not got it right, but why make it so complicated?

You need current flow, so from the 0 point input to your regulator put the shunt resistor with an op-amp and then the ADC. Even better, Analog has such current sensors already made with op-amps and the rest in one chip (AD8210).

You don't have to mess with the regulation loop of the regulator and sense lines. Work on the input directly after your rectifier/capacitor.

Ioannis

skimask
- 4th January 2008, 13:32
You need current flow, so from the 0 point input to your regulator put the shunt resistor with an op-amp and then the ADC. Even better, Analog has such current sensors already made with op-amps and the rest in one chip (AD8210).

You don't have to mess with the regulation loop of the regulator and sense lines. Work on the input directly after your rectifier/capacitor.

Ioannis

I don't think it's complicated, but that's just me...and I want to get to experience with this type thing anyways. I know Analog and National and a bunch of other have chips, just plug and go and you're done...again, I want to play a bit.
And I pulling power out of a battery pack, no rectifier :)
Basically, I guess I'm looking for confirmation that I'm on the right track.

Ioannis
- 5th January 2008, 10:23
Ok. No matter what your source is, bat or line power. You need to measure the current flow so, it is easier to do it before your regulator. In this case you do not mess with the output voltage regulation and everything is much simpler.

Of course this has the drawback that measurment would include also the regulators own consumption. But if you know it, then it can be subtracted or do not bother at all if it is << that output current.

I have to state that I tried that way and because of the components needed, a one chip solution is much more accurate, elegant and is working either at + or ground rail. But then, it is just me!

Ioannis

skimask
- 6th January 2008, 06:35
Ok. No matter what your source is, bat or line power. You need to measure the current flow so, it is easier to do it before your regulator. In this case you do not mess with the output voltage regulation and everything is much simpler.
Of course this has the drawback that measurment would include also the regulators own consumption. But if you know it, then it can be subtracted or do not bother at all if it is << that output current.
I have to state that I tried that way and because of the components needed, a one chip solution is much more accurate, elegant and is working either at + or ground rail. But then, it is just me!
Ioannis

I smell what you're cooking (understand what you're getting at, picking up what you're laying down, and so on, I could keep going but I won't :D )...

I'm just looking at getting some comparison readings between running at various clock speeds down to the built-in 37khz (32, 40, whatever) oscillator for a few keyfob type devices. If I take the current readings while running off of 5v and then switch the circuit over to a coin cell, the current draw should drop on a fairly decent curve following the voltage. That way I can keep track of mAh's (uAh maybe?) used in the keyfob and flash and LED in a slightly different pattern during activation to indicate that the battery is probably near EOL and will need changing, and if this works, I can keep the whole thing buried inside the same PIC in the keyfob without adding another chip.

Ioannis
- 7th January 2008, 09:57
Hmm, what you are trying to achieve has already been included in the Keeloq devices of Microchip.

That is what I use now instead of the old coding chips or soft-coded scheme.

But, the current flow is not the key factor in this case. It is the voltage level and the keeloq devices that is exactly what they measure.

More, current is a little more difficult to measure when you don't have linear consumption. Keyfobs are pulsing current out of the battery, so you have somehow to integrate the measurements and find the actual average current flow.

But I insist on that you need to measure the voltage level only and you will be more that good.

How will the result be indicated is another matter. Either locally on the LED as you stated or remotely by another indicator with battery state transmitted by the keyfob.

Ioannis

RYTECH
- 26th February 2008, 02:10
I find the max4172 is a simple way to meter current.