Searching \ for '[SX] Measuring Voltage of a Project's Own Batterie' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/power.htm?key=sx
Search entire site for: 'Measuring Voltage of a Project's Own Batterie'.

Exact match. Not showing close matches.
'[SX] Measuring Voltage of a Project's Own Batterie'
2008\11\07@225736 by

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote:

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
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Beau Schwabe wrote:

John Kauffman,

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.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306023

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, william wrote:

Use a low quiescent current and low drop out regulator like the LP2950-3.3v and run the SX at 3.3v.
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.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306025

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote:

William Chan -
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.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306028

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote:

Beau:

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.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306029

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote:

William:
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
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306030

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, william wrote:

Question #1.

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.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306031

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, william wrote:

You can try IRL510 mosfet but it's a bit bulky.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306032

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

John,
When set to TTL ANALOGIN has a range of 0 to 2.8V regardless of the supply voltage.

Bean
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306041

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, william wrote:

Sorry Ron,
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.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306158

In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

John,
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.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306487

2008\11\10@102622 by
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hi Bean;
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!

Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=306018#m306514