Battery voltage monitor

boriz

Senior Member
I’m thinking of making a battery voltage monitor for a 4-cell NiCd pack. The nominal voltage should be around 4.8v. (1.2v/cell). The pack is considered exhausted when this falls to 0.9v/cell (3.6v). The PICAXE 08 will light some LEDs to indicate battery voltage.

If I use a diode+resistor on the ADC and power the PICAXE from the battery, the reading should go up as the battery voltage drops. BUT. The diode voltage drop will vary according to ambient temperature (about 2mV/DegC) and supplied current. I am trying to find ways to correct for this error.

Could putting an identical diode in the PICAXE +ve power supply path offset this error?
 
Last edited:

moxhamj

New Member
2mV per degree is pretty small compared with the voltage drop of the battery pack, which will go from 1.5V to 0.9V (x4). If you were really obsessive you could add an LM35 temperature sensor, but if you did that you would need to run the picaxe off a regulated 5V supply. Even over a 40C temp range, 2mV/C is only 0.08V which is tiny compared with the battery changes. Also, looking at the nicad discharge curve, they hold 1.2V for most of the discharge. When they are down to 0.9V the volts are dropping very rapidly. A 0.08V error due to temperature would only affect a led coming on by less than a minute either way.
 
Last edited:

hippy

Ex-Staff (retired)
I'd also ignore the temperature effect. The lost precision in your PICAXE maths is quite likely to be far greater than that anyway :)
 

westaust55

Moderator
I agree with Hippy.
Even out in the Great Sandy Desert where i have worked with outdoor temperature variations of 50 deg C, that only equates to 0.1V (or ~2% error).
I guess an automotive applciation in the engine bay might see similar but fairly inconsequently.


If you are powering the PICAXE from the same voltage you are monitoring, you may also need to use the CALIBADC command to help compensate for the fact that the PICAXE ADC is normally calibrated against its supply voltage. So with a falling supply voltage along with a proportionally dropping voltage signal to the ADC input may give greater error than any temperature effects.

If you have not already read the App note, Microchip publication AN1072 available at: http://ww1.microchip.com/downloads/en/AppNotes/01072A.pdf
which gives details on how to measure Vdd (the PICAXE supply voltage) compared to a “nominal” internal 0.6V reference.
The CALIBADC command is doing this for you.

Even this calibration can have around 2% error but from the App Note is seemingly more accurate around the 4V region (0%) with an average of ~0.5% error in the 4 to 4.8V range.
 
Last edited:

boriz

Senior Member
Thanks.

The small error introduced by temperature change is indeed insignificant when compared to the battery voltage range. But this system, is supposed to give a consistent indication of battery condition across all expected temperature ranges, summer or winter. IE: If the ‘4.8v or greater’ LED operates sometimes at 4.8v but sometimes at 4.7v, the reliability of the battery meter is compromised.

@Dr_Acula.
“…looking at the nicad discharge curve, they hold 1.2V for most of the discharge…”

Agreed. Which is why measuring the terminal voltage under no-load conditions will not provide accurate charge-remaining information. But in this application (RC plane), the load can vary from a few mA up to a couple of Amps (when all the servos are operating). The terminal voltage could possibly vary a volt or so, even with a freshly charged battery pack. What this device effectively does is measure the internal battery resistance.

This is the plan:

The display will consist of a few LEDs, not sure how many yet, but let’s say 3. Each lit LED indicates a certain guaranteed minimum terminal voltage. Say 3.6v, 4.2v, 4.8v. (0.6v intervals). So when the battery is fresh and not under load, all three LEDs will be on.

Now the user operates the RC transmitter controls and watches the LEDs. (A pre-flight test). At full load, with a fresh battery, I would expect maybe one of the LEDs to briefly go out or at least flicker. This would be normal. But as the battery becomes more and more discharged and the internal resistance increases, the same test will tend to extinguish more LEDs (briefly). Each flight is preceded by the same test and the user builds up an accurate feel for the battery condition based upon how the LEDs behave during the same repeated load test.

I want to eliminate, if I can, the effect temperature will have on these thresholds so that the battery condition does not artificially vary across the seasons.
 

boriz

Senior Member
P.S.

The PICAXE will operate in this manner for around 60 seconds after power-up then auto-sleep to preserve power. No need for the LEDs to be on when the plane is 50ft up :)
 

moxhamj

New Member
Ah - that makes a lot of sense. I have just done a quick search on google - as I understand it the problem is that the internal resistance of a nicad battery rises as it ages. This manifests itself as an inability to provide high current pulses, though the volts could still measure fine under low loads and even when testing with standard battery testers.

Thinking about this more, I think if you are measuring the volts under high load, you are partially measuring the capacity of the battery at that time (ie how flat it is), and you are partially measuring the internal resistance which will be rising as the batteries age. As to the % mix of these two factors - I am not sure but I think you are right in that you may start to get a feel for it the more you use the device.

I still think the temperature effect will be minimal compared to other effects. However, I see another potential problem. If you are powering the picaxe from 4.8V and you switch on all the servos at once, the powersupply to the picaxe will be collapsing at the same time you are measuring the volts. You are going to need to be measuring this collapsing power supply as well and taking it into account in the maths the picaxe is doing.

I am wondering if this might call for a regulated 5V supply? It will make the math a lot easier. You could use a 9V battery and a 5V reg but that does add extra weight. There are other cunning solutions. You could use the picaxe to create its own higher voltage supply using switched capacitors and diodes. You should be able to get 8V easily and then you can regulate this back to 5V. I have some circuits if you like. The weight would come in much less than a 9V battery, but the circuits can get a little complicated. Once you have a regulated supply, you can easily add a temperature measure like the LM35. Is this a 14M? I think it might be struggling to fit in an 08M.
 
Last edited:

hippy

Ex-Staff (retired)
If you need very accurate voltage measurements and are only looking at discrete levels it may be better to run the battery through an adjustable trimpot, select say $40 as the trip point, and adjust the pot so $40 is the value returned for a particular boundary voltage. Repeat three times for each boundary voltage.

Or you could do the same with external comparators and deal with digital inputs. With a bit of SFR hackery it may be possible to use the inbuilt comparator peripherals on some of the PICAXE's.

While it may have sounded a bit flippant, getting the PICAXE maths right and accurate with enough resolution is going to be another side of the challenge if you go for a READADC and software solution.
 

westaust55

Moderator
From Dr Acula:
However, I see another potential problem. If you are powering the picaxe from 4.8V and you switch on all the servos at once, the powersupply to the picaxe will be collapsing at the same time you are measuring the volts. You are going to need to be measuring this collapsing power supply as well and taking it into account in the maths the picaxe is doing.
That is why I sugegsted in post 4 to use the CALIBADC command.
You do this instruction just prior to doing the READADC command.

That way you are tracking the falling Vdd and referencing all to a nominal 0.6V.
 

212

Senior Member
I think I would add a micro-switch to say...full left rudder...or something...to load the batteries when testing the voltage.
 

westaust55

Moderator
A further option as alluded to by BCJKiwi in his link to his past threads is an external voltage reference and use READADC to check to ext reference voltage and then the Battery/Vdd voltage.

A simple scheme is to use a zener diode and a series resistor as per the attached schematic. The lower the zener diode voltage rating giving more “headroom” to the battery voltage the better but about 2.4V or 2.7V should be acceptable.

With this scheme you will then have to do your own calibration calculation, but can compensate for any tolerance in the zener diode actual breakdown voltage.
 

Attachments

slurp

Senior Member
I've used one of these for monitoring the voltage level on my Li-Poly batteries...

LTC1440
Ultralow Power Single/Dual Comparator with Reference
http://www.farnell.com/datasheets/44712.pdf

The data sheets is straight forward with a good worked example... if you want to take a controller input make sure you use the hysteresis options otherwise you'll have a rapid pulse chain as you start getting close to the trigger point.

best regards,
Colin
 

Dippy

Moderator
The best reference will be a bandgap type.

Zener 'voltages' will vary with current as will be the case of a Z+R simple circuit. A 2V4 may vary from 2.3V to 2.6V if the supply varies from 3.5 to 5V. And will vary another 100mV if you freeze it.
If these tolerances are OK then a Zener is fine. I would have thought the temp effect was minor compared to the temp effects on the rest of the system.
 

boriz

Senior Member
In my first post I said “If I use a diode+resistor on the ADC and power the PICAXE from the battery, the reading should go up as the battery voltage drops.”

Exactly the method described by BCJKiwi with his diagram reproduced here:
Code:
        V+ ----/\/\/\/\----+----|>|---- V0
                 R = 1k    |   BAT85
                           |
                           |
                          ADC
                    Reference Voltage
          ReadADC10 here in place of CalibADC10
Since the reference voltage thus created (~0.6v) will remain about the same as the PICAXE supply voltage drops, the ADC readings will go up. I thought I had made that clear. Sorry.

The trouble with using a diode (or zener) is it’s tendency to change voltage slightly as the temperature and current change. Using a simple single transistor current source will help, but can be avoided by proper calibration at the set-up stage. The only real problem is the temperature coefficient.

My initial question regarding an additional diode in the PICAXE +ve supply is, in theory, supposed to work like this: As the temperature of the reference diode climbs, and it’s voltage drops, the same thing happens to the other diode, causing the supply voltage to the PICAXE to rise by exactly the same amount.

I better illustrate what I mean:



In the above circuit, the ADC readings will raise as the +V falls, but even with a stable fixed +V the readings will fall as the ambient temperature increases due to the slight reduction in the drop across D1.



In this version, any drop in voltage across D1 due to ambient temperature change will be accompanied by an equivalent rise in the voltage at the AXE08 +v pin because D2 will exhibit the same temperature coefficient as D1. Thus, in theory, compensating for any reading variation due only to temperature change.

The original question was, would this work?

I have spotted another possible problem. The V drop across D2 will mean that when the battery voltage reaches 3.6v, the AXE08 will only be getting about 3v. So with a low battery, the AXE08 might keep resetting during the load test. But that situation could probably be improved with a large capacitor between the +v and 0v pins.
 

Dippy

Moderator
I understood what you meant, but I don't think your assumption is correct.

The diode to the PICAXE supply is effectively offsetting the V+ reference to the ADC.
The R+diode to the ADC will be a fraction of the reference and not an offset.

I did a quick calc using a spreadsheet and it confirmed this - assuming I did the calcs correctly though I did do it in a rush (that's my get-out).

I would suggest that it would be quicker if you tried it...??
 
Last edited:

moxhamj

New Member
I'm also concerned about accurate readings with a rapidly collapsing power supply. If you put in D2 presumably you have to have a capacitor across the picaxe supply. And at the very least that ought to be 0.1uF, but if you do it properly it will be 22uF and 0.1uF in parallel. You turn on the servos, the voltage at the battery collapses rapidly, but the volts on the picaxe supply are still 4.8V (minus 0.6V) due to the capacitors. Your readings won't change. And if you leave out the capacitors, you are likely to have resets as you say. I don't think you can put in D2, and I still think this is going to be a lot easier if the picaxe is being powered from a regulated 5V supply.
 
Last edited:

westaust55

Moderator
Dippy.
A 2V4 may vary from 2.3V to 2.6V if the supply varies from 3.5 to 5V.
Are you confusing the tolerance range of a zener diode with with effect of supply variations?


A zener diode can come in various tolerances.
The last letter typically indicates the tolerance.
For example, A = 1% and C (as per my earlier post) = 5%

So:
for a BZX55C 2V4, the actual Vz may be from 2.28 to 2.52V over a range of sample zeners but the voltage Vz is constant provided the current is kept within a certain range.

and for a BZX55A 2V4, the actual Vz may be from 2.37 to 2.42V over a range of sample zeners.

But for a given specimen, Vz is constant over a reasonable current range (case of selecting a resistor to suit). If one measures the Vz for the specimen used, then that value can be used in the PICAXE maths for good calibration resolution.
 

Dippy

Moderator
2 WA:
As you just have a Zener + R there will be a change in current as the battery supply droops. I knew that the Zener V will change with current.

The numbers I gave were the measured Zener voltage vs Supply voltage when the Zener was in a simple Z+R arrangement as you had suggested.

So, I got a 2V4 Zener plus a series resistor of the value range you suggested and actually tried it with a quality bench power supply.

So, no, I'm not confusing anything - I tried it and took measurements. And also gave it a squirt with freezer spray too.

Yes, there will be manufcaturer's tolerances as well, but I'm afraid that Real Life is run by physics not just the writing on the tin.

"But for a given specimen, Vz is constant over a reasonable current range (case of selecting a resistor to suit)."
- sadly not true, though this depends on your definition of 'reasonable' and 'constant'.
It certainly is NOT constant enough for a semi-accurate voltage reference over the life of a battery with the componnt vals you gave.
All I can say is try it. Forget the school theory.


Honestly, for the sake of a few pennies, like I said yesterday get your self a proper reference
.. oh you have.
 
Last edited:

westaust55

Moderator
'As you just have a Zener + R there will be a change in current as the battery supply droops. I knew that the Zener V will change with current."

True - even my attachment indicated the current would change with voltage - it has to!

I have built simple zener circuits before (as well as far more complex schemes without issues - at least for the tolerances I was after.

It just seemed stange that the voltage range you stated with fluctuating supply also reflects the manufacturing voltage tolerance for actual value of Vz with a "C" type Zener diode.
 

Dippy

Moderator
Well, all these things are related to the level of accuracy/precision/stability you want.

The point is that when ADCing/Comparing/measuring you need some fixed reference and that simple zener setup in this application won't provide it. When I say 'fixed' obv I mean fixed-ish as nothing is perfect. And also obv the lower the res then there will be also a minor self-heating and ambient heating contribution. Insignificant in many cases I realise.
A R+Z from a fixed voltage source will obviously provide a better result but in this app it is slightly variable. The amount of 'slightly variable' may be acceptable in some cases - depends on the app as usual. A higher R and lower Vz may also have some benefit.

However, as an exercise I would have thought this was useful to those who think that a zener is on-off at the value printed on the box. A college course on semi-conductor theory may shatter those illusions (delusions?).
Bottom line: Set it up and try it. Can't beat experiment. Quicker than posting unless the person is lazier than me.

Anyway, no doubt this sort of stuff will crop up again, so see you later on the same subject ;)
 
Top