Measuring Voltage of a Project's Own Batteries - a recursion problem
![John Kauffman](https://forums.parallax.com/uploads/userpics/555/nZBNEPT0B6FMD.jpg)
I'm running an SX project by batteries and need to watch the decline in voltage of those batteries.
In prior projects I've used ICs or SX/B code to determine an unknown voltage of a point in a circuit. But the techniques I have used are always relative to the supply voltage.
Unless I'm missing something, as the project's battery voltage goes down, these measurement techniques will always show 100%, since the "unknown" voltage of the batteries will be the same as the "supply voltage" coming from the same batteries.
Is there an IC or SX/B routine that can give me an absolute measurement of voltage without reference to the supply voltage?
My best thought so far is to use a hearing aid battery for reference. Obviously, that introduces a set of design compromises including a prayer that the auxilliary battery's voltage drop is significantly slower then the primary battery's decline.
As always, thanks for sharing your expertise.
- John Kauffman
In prior projects I've used ICs or SX/B code to determine an unknown voltage of a point in a circuit. But the techniques I have used are always relative to the supply voltage.
Unless I'm missing something, as the project's battery voltage goes down, these measurement techniques will always show 100%, since the "unknown" voltage of the batteries will be the same as the "supply voltage" coming from the same batteries.
Is there an IC or SX/B routine that can give me an absolute measurement of voltage without reference to the supply voltage?
My best thought so far is to use a hearing aid battery for reference. Obviously, that introduces a set of design compromises including a prayer that the auxilliary battery's voltage drop is significantly slower then the primary battery's decline.
As always, thanks for sharing your expertise.
- John Kauffman
Comments
·
If you are looking for a certain threshold voltage, typically a zener diode (<- plus a resistor) can be used as a reference voltage to one leg of a·comparator.· Then, the other leg of the comparator would go through a voltage divider·producing·a voltage·at the selected zener voltage·level.
Since the SX can be configured to have a comparator function on the I/O's, all you need is a zener diode, and a few resistors.
·
Another method, still using a zener as a reference voltage, would use an external ADC (Analog-to-Digital Converter) that makes use of a voltage reference input.
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Then use 2 pins of the SX to perform sigma delta ADC on a voltage that has been divided down (using resistor dividers).
You may want a small mosfet that can switch on the voltage dividers only when you need to check the battery voltage,
for further savings.
I do that all the time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
That makes sense. Let me reiterate your technique so I understand.
power supply = 4.8 volts and as discharges drops to 4.0 volts
power supply to regulator makes a regulated output of 3.3 volts (regardless of power supply drain)
regulated output becomes the reference voltage (always steady)
divide power supply into half to output = 2.4 dropping to 2.0
(Use your trick of transistor to turn off the voltage divider when not in use)
Use regulated output of 3.3 volts as reference voltage and use divider output as test voltage.
Test with SX comparator.
Math: With 256 bit resolution, each bit measured in the test voltage will = 3.3v/256 = 13 mV. Since test voltage is half power voltage, power voltage = bits*26mV.
Question #1
I looked at the data sheet for the regulator http://www.national.com/ds/LP/LP2950.pdf
It has a drop-out voltage of around 100mV. AS I understand, this is the amount of voltage that is used by the IC itself. Does that mean that once once the power supply drops to within 100 mV of its output (3.31 volts) then I can not be sure of the accuracy of the 3.3 volt regulated supply?
Question #2
I have not built a circuit with a MOSFET (I don't even own one), so I started the research. But in the meantime, could I use a simple 2N3904?
Thanks.
Thanks. I think William's solution to use the regulator is a glorified version of using a Zener diode. Since the project has a regulator anyhow, I can use that & get the advantages of temperature correction & etc built into the regulator. Thanks for the idea that in a project with no regulator I could get by with just a zener.
I've already used the comparator to measure voltage, so will stick with that rather then add an ADC. The code is very simple, but I like to think of it as a VP in the spirit of the SX architecture.
Thanks.
Which MOSFET part number do you use? I'll get the same so I can replicate your circuit.
What value resistor do you use between the SX pin used for ON/OFF and the G pin of the MOSFET?
THanks
Yes, only as long as there is sufficient drop-out can the measurement be fairly accurate.
If you want to squeeze more juice further, use LP2950-3.0v
Question #2
Can be used but more current is wasted driving the base, but its only for a while, so its ok.
I wouldn't use the SX's comparator, because it has problems comparing voltages near the power rails.
Any 2 IO pins for the ADC will do, but the ADCs resistors' values should be higher than the
voltage divider's resistor values.
You could use 10k for the voltage divider and 50k for the ADC.
For the resistor driving the gate of the mosfet, any value between 1k to 50k can be used. ( the gate takes zero current )
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Post Edited (william chan) : 11/8/2008 10:06:48 AM GMT
Try to find a smaller equivalent that can be switched on from as low as 3v.
You can't use a zener to replace the low q regulator b'cos it wastes too much current.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Post Edited (william chan) : 11/8/2008 10:12:01 AM GMT
· Set the ANALOGIN input pin to TTL instead of CMOS.
· When set to TTL ANALOGIN has a range of 0 to 2.8V regardless of the supply voltage.
· Instead of running the supply voltage through a single resistor to the ANALOGIN cap, use two resistors of twice the value to make a voltage divider.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
www.iElectronicDesigns.com
Post Edited (Bean (Hitt Consulting)) : 11/10/2008 5:10:01 PM GMT
There was a slight mistake to my advice.
You may need a P-Type mosfet instead of a N-Type mosfet like the IRL510, because once the the divider is blocked from accessing ground by the transistor,
it would no longer "divide" voltage, the middle point would rise to the voltage of the battery.
When that happens, current would start to leak into the 2 IO pins of the SX. Not much harm done but it defeats the purpose of the mosfet/transistor.
It may be better to just use a higher resistance value for the divider like 50k and 100k for the ADC without any transistors.
In this setup, the divider would continuously "waste" almost 50 micro amps, which is not bad considering that the LP2950 regulator also waste about the same amount continuously. ( this is much much better than a 7805 which leaks 3mA ).
This is the compromise you have to make to allow monitoring of the battery.
Good Luck.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Post Edited (william chan) : 11/9/2008 1:55:37 AM GMT
I tried using the ANALOGIN command with TTL input pin.
I had to modify the resistor values, but it does work pretty well.
See my previous post for the schematic and code.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
www.iElectronicDesigns.com
·
Something to be aware of here....
If you use the TTL settings, and as you say the switching point on the input line is fixed regardless of supply voltage, then, (and only if the supply voltage selected is NOT 2 times that TTL switching level) the output line will obviously not drive the DAC capacitor symmetrically, resulting in a conversion error. The error observed will be a function of how far off the TTL switch point is relative to half the supply rails.
Now the good part about what you said....
Actually, I had never realized that the TTL switches at a fixed voltage, independent of the supply level, and that provides a very interesting opportunity. If one were to create a single resistor feedback TTL ADC (one without an "input" resistor, and have the software contiuously (read regularly) loop, sensing the the over/under condition of the input cell, and then setting the output cell as low/high respectively, then you have created a voltage reference of the TTL switching level. And supposibly that is independent of the supply voltage.
Next, in the same SX chip you could create a standard CMOS ADC which switches at half the supply range and hence does not suffer from the error cited in the first paragraph, and connect its input to the TTL voltage reference created as per the second paragraph, so now you could determine the supply (battery) voltage by measuring that reference voltage. Since its level is constant, the reading you get will be a function of the supply voltage.
Once you know the supply voltage, you can implement other ADC's in the same chip and read or correct for power supply values appropriately.
Will need to try this soon.... almost sounds too good to be true.
Neat!
P.S. Hey, what if sensing the levels in the TTL mode do not transition at the same point, rising vs falling. Then you could not use TTL levels at all as it will gereate assymetry on top of assymetry..... a frightful mess.
Hmmmm... need to understand that better.
Cheers,
Peter (pjv)
Post Edited (pjv) : 11/10/2008 6:30:36 PM GMT