Shop OBEX P1 Docs P2 Docs Learn Events
Calculating battery voltage and displaying results with a flashing LED when low — Parallax Forums

Calculating battery voltage and displaying results with a flashing LED when low

geometrixgeometrix Posts: 27
edited 2005-12-31 05:24 in BASIC Stamp
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

Comments

  • Clock LoopClock Loop Posts: 2,069
    edited 2005-12-31 04:56
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-31 05:07
    Geometrix -

    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
  • agentileagentile Posts: 101
    edited 2005-12-31 05:24
    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.



    Andrew
Sign In or Register to comment.