Calculating battery voltage and displaying results with a flashing LED when low
geometrix
Posts: 27
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!
TIA ,
Geometrix
TIA ,
Geometrix
Comments
Read this thread http://forums.parallax.com/showthread.php?p=548418
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:
http://www.parallax.com/detail.asp?product_id=ADC0831
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:
http://www.parallax.com/html_pages/edu/curriculum/sic_curriculum.asp
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.
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 12/31/2005 5:23:42 AM GMT
Now if you wanted to monitor the·battery·voltage for all·possible values, then you would need an analog to digital converter.
Andrew