Shop OBEX P1 Docs P2 Docs Learn Events
Remembering a sequence of Events — Parallax Forums

Remembering a sequence of Events

PrestymanPrestyman Posts: 5
edited 2008-03-12 04:02 in BASIC Stamp
Hello.

I am hoping someone can tell me whether the following is possible with the BASIC Stamp:

I would like to have·the stamp to "remember" a sequence of user input events, and then play those events back when required.·Also, the sequence should be able to be reprogrammed at any time.· For sake of clarity, I'll give a simple·example, and then I can expand the idea.

I have two switches, one for·"set"·and one for "run".· I also have a pushbutton that turns an LED on and off.···When in "set" mode, I would like to have the stamp monitor the LED pushbutton, recording the sequence of on/off switching with the duration of time in between each.

At this point I need to be able to shut the unit off, since it is now "programmed." At a later date, I would like to turn it on to "run" the sequence of the on/off switching of the LED.· And of course, at anytime·it should be able to be switched back to "set" and have it memorize a new sequence of button pushes.

Is this possible?· If so, could someone point me in the right direction?

Thanks,
Clinton

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-03-12 02:00
    Yes.

    You set the original sequence with DATA statements. You can read the sequence with "READ"

    You can then update the sequence with "WRITE". But don't "WRITE" more than once a minute, or you'll wear out the eeprom. It only allows 1 million writes per location -- which isn't a problem unless you try to write to the same location once a milli-second.
  • PrestymanPrestyman Posts: 5
    edited 2008-03-12 02:25
    But don't "WRITE" more than once a minute, or you'll wear out the eeprom. It only allows 1 million writes per location -- which isn't a problem unless you try to write to the same location once a milli-second.
    Thanks for your quick response.· Interestingly enough, this is the part that confuses me.· It must be possible for the stamp to temporarily remember the sequence, and then only WRITE the needed information.... in this case, on/off and the the time delay in between.· It doesn't need to be writing constantly during the "set" stage does it?

    Also, I should make it clear that the·recording of the events is something that might happen one or twice a MONTH.··The sequence of events is only going to be changed when the user·gets tired of the old sequence, which may be never!· So I am assuming that wearing out the EEPROM really isn't an issue.· Or am I wrong about this?

    As you can see thtis is my first post, and I am very new to the BASIC stamp, and microcontrollers in general.· I just have a neat (I think) idea, and want to play with it.

    Thanks.
  • FranklinFranklin Posts: 4,747
    edited 2008-03-12 02:53
    The stamp has no way to tell time. You would need something like a RTC to keep time for you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • PrestymanPrestyman Posts: 5
    edited 2008-03-12 03:30
    The stamp has no way to tell time.
    Wow!· I didn't know that.· Okay, I guess i'll have to go another route.· Thanks, Stephen.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-12 03:38
    It is fairly easy and cheap to attach an external real time clock/calendar to a Stamp. There are plenty of worked examples between the StampWorks manual and several Nuts and Volts columns.
  • PrestymanPrestyman Posts: 5
    edited 2008-03-12 03:44
    This project only requires it to be accurate to one second, and it only needs to know how long to wait between events.· can't I just do a For..Next counter, with a 1000 ms pause, and the WRITE the number of loops to the EEPROM for replaying later?
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-12 03:51
    Yes, you could do that. The PAUSE statement is the most accurate of the time-related statements, particularly if you adjust the PAUSE for the execution time between PAUSEs. That would require using a stopwatch or similar time standard.

    The easiest way to avoid "write fatigue" is to check the contents of an EEPROM location before you WRITE to it and skip the WRITE if the location already contains the desired value. Other things include keeping counters in ordinary (RAM) variables and only writing them to EEPROM when something else changes if that fits with your needs.
  • PrestymanPrestyman Posts: 5
    edited 2008-03-12 04:02
    Thanks Mike.

    Great suggestion about preventing "write fatigue."· i think I'll start playing with this tomorrow.· Anything else you think i should be aware of?

    Cheers,
    Clinton

    ·
Sign In or Register to comment.