Shop OBEX P1 Docs P2 Docs Learn Events
Please help with time control using BS2. — Parallax Forums

Please help with time control using BS2.

LandonLandon Posts: 1
edited 2008-06-25 23:48 in BASIC Stamp
···· I have the project that I need to use BS2 to turn on the bell at some specific time. For example at 6am the bell will ring for start of shift to remind people and it will ring again at 12pm for break time, so on and so on.
···· I’ve already written the code to control the bell but I don’t know how to use the code to turn the BS2 to sleep mode and reactivate it again at the end or beginning of each day, because this machine suppose to be on all the time.
···· Does anyway that I can know the time by using the code. For instance: if “the current time” equal 6am then do action X.
···· Please help,
···· Thank you,
···· LN

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-25 23:40
    How do you know "the current time"? The BS2 has no built-in ability to provide this. It does have the SLEEP and NAP statements which put the Stamp into a low power mode for a specified period of time, but these are not very accurate, particularly for long periods of time (on the order of hours). If you don't need high accuracy, you can use the SLEEP statement repeatedly to keep the Stamp asleep for 6 hours (see the description of the SLEEP statement in the manual). If you need high accuracy, you may need an external real time clock chip. The Stamp would still use the SLEEP statement to go into low power mode for periods of time, but it would wake up before the expected time and check the actual time from the real time clock chip. If the actual time has not come yet, the Stamp would take a NAP for a short period of time, then wake up and check the time again.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-06-25 23:48
    The easiest way to do this would be to add a 1302 chip with a clock crystal and a coin-cell battery backup.

    Is there some reason you want the BS2 in "low power" mode? I'd assume this contraption would be on a wall-wart wall power most of the time, no?

    And even if you DID want to 'sleep' the BS2, you could have it 'wake up' close to the time it was supposed to go off (like within 10 or 30 minutes) and have it 'read' the clock chip until the accurate time to go off arrived.

    Personally, I like a blinking LED blinking at me every 5 seconds or so from a program loop -- it gives me warm fuzzies that the program is still working.
Sign In or Register to comment.