View Full Version : Calculating battery voltage and displaying results with a flashing LED when low
12-31-2005, 10:22 AM
How can I calculate the power supply voltage (battery)·using a BS2 and·cause an LED to flash when a low power condition is calculated?· This would basically tell the user to replace the batteries.· Happy New Year!
12-31-2005, 11:56 AM
Read this thread http://forums.parallax.com/showthread.php?p=548418
12-31-2005, 12:07 PM
Here is one method you can use. You will need to connect an ADC (analog to digital converter) chip to the supply voltage. Then you use the Stamp to "read" the ADC. The use of an ADC with a serial output is highly recommended. Parallax sells the ADC0831 here in thier IC Accessories Section:
Any of the following Parallax Educational Texts should have sample programs and explainations of how to use this ADC part: "StampWorks", "Basic Analog and Digital", and "Industrial Controls". Any of those texts can be download for FREE by following the links at this location:
Once you have that wired up, and the Stamp programmed to fetch the voltage, all you need do then is to compare the fielded battery voltage with some fixed value (of your choosing). That arbitrary value determines at what point the LOW BATTERY indication should be given. If/when that point is reached, you merely need to utilize the HIGH (on) and LOW (off) PBASIC commands, to send +5 VDC, then 0 VDC, +5 VDC, then 0 VDC, to an LED, connected through a resistor, to another of the Stamp pin ports. You do this in a programmed loop, either for a fixed number of iterations, or continuously, as you see fit.
I hope that's enough to get you started.
Post Edited (Bruce Bates) : 12/31/2005 5:23:42 AM GMT
12-31-2005, 12:24 PM
If you are only looking for one voltage value, such as the point at which the voltage is too low, then I would recommend using an LM311 comparator.· You can set the positive input of the 311 to the threshold value for the battery, then·tie the·negative input to the battery.· When the battery·voltage drops below the threshold value, the output of the 311 will go high.··The output of the 311 can then be monitored by·a stamp, and you can have the stamp do anything you want once the·low voltage trigger has been detected.
Now if you wanted to monitor the·battery·voltage for all·possible values, then you would need an analog to digital converter.