Newbie help with battery voltage variation....

Mikler

Member
Hi!

I have put together a circuit that appears to work... but....

OK - I have a 14M that is using pwmout (at 4Khz) at varying duty cycles, across a 100K/220uf, to drive an LM3914 and a 10-bar LED unit. The unit needs to build up from zero to a full set of bars and then back to zero again every few seconds. It continuously loops, with a 'beep' of sound when it hits min and max. The unit works fine.

However, I have found that if I set the duty-cycle for a new set of batteries (2xAA), as the battery voltages deteriorate, my initial calibration becomes useless and after a while, just 5 of the bars are ever illuminating.

(For various reasons, I would rather not use a higher voltage battery and a voltage regulator)

Question-1: Do my problems sound correct or could I have done something stupid?

Question-2: I was wondering if I could somehow monitor the battery voltage using the ADC and adjust my calibration accordingly using a formula based on the current voltage, to re-adjust exactly at what stage each bar illuminates....

If this sounds a sensible option (any other ideas?), assistance in what components/code I should be using to action the above would be gratefully received.

Detailed replies greatly appreciated.

Kind regards

Mik
 

Andrew Cowan

Senior Member
I don't know how much the voltage is dropping, but it could be that you are going below the voltage at which a 14M can happily run.

As far as checking the battery voltage via ADC, this is only possible if you are running the PICAXE off a voltage regulator or other known supply voltage.

A
 

papaof2

Senior Member
As the batteries age, they will deliver less voltage and you will only get enough voltage to light part of the LEDs. The 1.5 volts from each battery will begin to drop off as soon as you start using it. As the voltage drops, there will be less voltage to your RC circuit: 2.5 volt pulses cannot charge the capacitor to the same voltage as 3 volt pulses.

Some of the PICAXE chips will work fine on 3 volts, but will not work on much less than 3 volts. There's a chart somewhere on the Forum that lists the minimum operating voltage for each chip.

Some options are:
- three NiCd or NiMH rechargeables at 1.2 volts each for 3.6 volts total. They will hold their voltage for about 80% of their charge.
- three 1.5 volt batteries with a 3.3 volt low drop out (LDO) regulator. These will provide a constant 3.3 volts until the total battery voltage drops below 4 volts.

READADC uses the supply voltage as the reference when reading a voltage. To read the battery voltage, you must provide a seperate voltage reference that is independent of the battery voltage. It's usually cheaper/simpler to use one of the other options.

John
 

MPep

Senior Member
You could also use a DC-DC converter (switch mode power supply) in order to supply a steady 3V, or 5V.
Then with ADC, check the primary side of the converter, in order to determine the state of charge. If this is too low, sound an alarm.
 

lbenson

Senior Member
Along with monitoring the battery using some constant reference (an LED voltage drop has been suggested), could you not increase the duty cycle of your pwm as the battery drops? This would require calibration. If you had access to a bench power supply you could dial down the voltage and see what combination of ADC reading off an LED+R and PWM duty cycle gave you your desired results.

What voltage gives you the full range on your 10-bar LED? Of course, if it takes 100% duty cycle to fully light it at 3 volts, the then above suggestion will not work without modification.
 

Andrew Cowan

Senior Member
You can actually measure the battery voltage. If you can have a constant voltage on an input (eg 1.2V from a zener), the ADC reading of this will rise as the battery falls.

Thus you can determine the bettery voltage.

A
 

BeanieBots

Moderator
Your best bet is to follow the advise given by lbenson.
Use another ADC input reading as a 'reference' such as the volt-drop on an LED or diode. Use that reading to re-calibrate your PWM value.
The realtionship will not be linear so some form of lookup and/or conversion will be required. Experimentation will probably be quicker than trying to work it out.
 

Mikler

Member
Thanks to everyone for their help.

>>Use another ADC input reading as a 'reference' such as the volt-drop on an LED or diode

Could someone advise how I physically actually do this?

Also, does it mean that I need to have two ADC inputs? One to measure my battery voltage and another to measure the reference voltage?

Thanks

M
 

Andrew Cowan

Senior Member
Yup - you could use the voltage drop from an LED or diode (I think). As the battery falls, the ADC reading will increase.

A
 

BeanieBots

Moderator
Correct,
the 'number' returned by the ReadADC command, is a represention of how the measured voltage compares to the supply rail voltage. That's why it is not possible for a PICAXE to measure its own supply rail with a simple ADC connection even if it's via a potential divider.

Anything which does not have a linear voltage to current relationship can be used. The simplest would be a diode or LED. Slightly better would be a zener diode but for more predictable and accurate results you would need a proper reference voltage. If you just want a trip point, then just use a diode and determine the trip value by experiment.

A quick example.
Consider an analogue input with 10k to positive supply and a diode to 0v.
What's important is that the voltage across the diode will remain fairly constant irrespective of supply voltage.
Let's say you take a reading when the supply is at 5v.
Let's also assume the diode has about 0.6v across it.

At 5v the readadc will return (255/5)*0.6=25
At 4v the readadc will return (255/4)*0.6=38

The important thing to note, is that as the supply voltage goes down, the readadc number will go up.

If you swap the resitor and diode over, the opposite will be true.

At 5v (255/5)*(5-0.6)=234
At 4v (255/4)*(4-0.6)=216

Note, these are only approximate values. You will need to test and calibrate depending on the type of diode you use. You should also note that the volt-drop of a diode can change quite a bit with temperature.
 

Dippy

Moderator
Mikler,

Yes, 2 ADC inputs.

Bat. Supply V
|
|
Res
|
|----ADC1
|
Diode
\/
|
Gnd.

As said above.
Remember, the PICAXE naturally uses the Vsupply as its own reference for the ADC.
So, IF the Vsupply remained constant, the ADC value from ADC1 (shown above) would be a ratio of the Vsupply to the voltage-drop across the diode and would remain constant.
When the battery droops, the Voltage drop across the diode remains constant*.
So, the reading at ADC1 gets bigger as its ratio to the Vsupply (i.e. battery voltage) changes.

* as we all know the 'real world' voltage drop across your average diode will reduce slightly as the supply voltage droops, but you can still use this simple method effectively with simple calibration. Temperature will have a slight effect.

For greater precision you could use a precision voltage reference or a constant current ic+diode+res to generate the 'constant' voltage to ADC1.


You then measure the battery supply, if necessary via a pot-div, to a SECOND ADC input and compare the 2 ADC values.

Experimentation would be easiest using a good quality variable bench power supply to simulate the voltage of battery-full down to battery-flat.
 

lbenson

Senior Member
I don't understand why 2 ADCs are needed. In Dippy's diagram, the readADC value will rise as the battery voltage drops. If the correlation is measured, e.g. by using a DVM or by adjusting the voltage on a bench power supply, then either an algorithm or a table can be derived to let the program know what the battery voltage is (exclusive of temperature variations). The program can then adjust the pwm (providing there is scope) to give the desired output at the varying voltage levels.
 

Dippy

Moderator
You're right - I've gone mad.
I'm off for a rest.....

I'd forget any fancy Al Gore Rythm.
Just a simple Full/OK/Watch-Out/Yuk set of calibrated thresholds should be enough for most people.
I really don't think huge accuracy can be claimed unless you use a precision reference.
 
Last edited:

BeanieBots

Moderator
I think sight of the original problem has been lost.
It will need some sort of compensation maths because the object is not to test for a flat battery, it is to compensate for reduced average voltage on the PWM output.
The LM3914 has only 10 steps, so compensation can be quite crude but will be required.
 
Top