Shop OBEX P1 Docs P2 Docs Learn Events
Battery low indicator ? — Parallax Forums

Battery low indicator ?

Luis_PLuis_P Posts: 246
edited 2010-05-28 18:12 in BASIC Stamp
There is any way to allert when battery is low in Bs2 module?
· I have a project that requires 9V battery the Bs2 and a couple components.
Any suggestions?


Gracias!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-25 22:51
    Look at www.emesystems.com. At the bottom of the page there's a link "app-notes" that takes you to lots of information on programming and using Stamps. One of the topics is using the RCTIME statement and a few passive components to measure battery voltage.
  • Luis_PLuis_P Posts: 246
    edited 2010-05-28 15:21
    www.emesystems.com.
    Monitoring battery voltage with RCtime:

    Suppose you want to monitor the voltage of a 12 or a 6 volt battery being used to power a project. There is no need to buy an analog to digital converter just for that. To measure the battery voltage, you can let it charge a capacitor through a resistor, and you can calculate the voltage from the charging time of the capacitor using the Stamp's RCtime command. Here is a circuit and some BS2 code. The following RC circuit is connected to BS2 pin P0:



    ······ · 681 kohm······ 470 ohm
    Vx··· ----/\/\/\---o
    /\/\/\----P0 to stamp
    unknown··········· |
    voltage········ ===== 0.01 uF film
    ·························|
    ······················ Vss



    Use stable components for best results, a 1% 681kohm resistor and a polystyrene or polycarbonate film capacitor. A BS2 test program is:

    rct var word ' RCtime value
    Vx var word ' voltage value calculated
    ' we want this to = applied voltage Vx
    Cn1 con 48576 ' first constant, see below
    Cn2 con 8 ' second constant, ditto'
    circuit attached to P0
    low 0
    loop:
    RCtime 0,0,rct
    low 0
    Vx=Cn1 / rct + Cn2
    debug home,dec? rct,"Vx=",dec Vx/10,".",dec1 Vx
    pause 500
    goto loop
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2010-05-28 18:12
    Hi Luis_P,

    Mike has shown you·an excellent resource which actually measures the voltage of the battery. Tracy Allen's emesystems website is full of great gems like that!

    If you just need to know when the batteries are getting too low without needing to know the actual voltage,·a very·simple method that might be good enough is to add a piezospeaker circuit to the project. With a single FREQOUT command as part of the program initialization, you can·hear a "BEEP" whenever the program starts. This is the method used in the Robotics with the Boe-Bot text.

    If battery voltage is getting low, or browns out when the servos load the system by changing direction, this can cause the BASIC Stamp to reset. Hearing the "BEEP" in this case is really helpful on a moving robot, since one can tell if the erratic motion is caused by the batteries, instead of a program error or a sensor failure. And, the robot does not need to be connected to the computer's Debug Terminal.

    For those not familiar with it, you can read about piezospeakers, the FREQOUT command, and this start/reset indicator in Chapter 3, Activity 3 of Robotics with the Boe-Bot, which is a free download· - just hit the Stamps in Class button at www.parallax.com/downloads. It's the second title in the table.

    Not sure which approach will work best for you, but now you have two options to start with.

    -Steph Lindsay

    Editor, Parallax Inc.
Sign In or Register to comment.