Shop OBEX P1 Docs P2 Docs Learn Events
How to integrate an alarm........ — Parallax Forums

How to integrate an alarm........

4fun4fun Posts: 3
edited 2009-04-29 14:42 in BASIC Stamp
Hello basic stamp users,

I am working on a project which consists on using the DS1307 Real Time Clock chip. I have no experience with basic stamp and by using the parallax source codes I have seen how to display real time on an LCD Display. I would like to add an alarm option to the code but have no idea how to start it or where to put the code.

I have attached the sample code from parallax for the real time display. Can anybody give me some pointers on how to integrate an alarm option to the code?

thank you,

4fun

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-04-29 14:42
    Hello,

    In order to add an alarm function it is necessary to understand the flow of the code and the basic structure. In this case there is a main loop running which calls each subroutine needed to read data from the clock chip and display it. This routine is appropriately named, “Main”. Within Main are a series of GOSUB statements which essentially jump to smaller pieces of code and back. The call to check for your alarm should occur in this loop. How you set the alarm time is another thing. You could examine the code for setting the time using the buttons. If you want to be able to set the alarm on the fly you will need to do the same thing. In this program the time is not being dealt with in the manner it is stored on the RTC (BCD) but rather being converted to decimal values. So if you’re going to compare with one or the other type of value, you need to store your alarm time in that format.

    I have written some code for the DS1302 which implements an alarm function. This has been done different ways depending on how the code was set up. For example, in a Digital Thermostat I built I needed to monitor for multiple events, so I stacked the events within a subroutine. This code is attached. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.