Shop OBEX P1 Docs P2 Docs Learn Events
Managing multiple events with a BS2 — Parallax Forums

Managing multiple events with a BS2

StevezilaStevezila Posts: 35
edited 2010-12-20 02:37 in BASIC Stamp
Can anyone give me any ideas on how I can manage more than one event simultaniously without negatively effecting each other? I have a simple program that evaluates an input and turns on an output for a "pause " amount of time. How do I make more than one such programs than can do this same type of evaluation without creating a timming problem by "pausing" for the first one. Please, I need a little direction here.

Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-12-19 22:49
    It takes some effort. Basically, you set up a single loop to do everything. This loop executes periodically. If your "pauses" are on the order of 20ms, then you arrange for the loop to execute every 20ms by using a PAUSE statement. You then keep an event clock by using a variable with a count in it. When the input for the event turns on, you set the variable to the number of times through the loop that the event should remain active. Every time through the loop, the variable gets decreased by 1. When it gets to zero, you turn off whatever was turned on when the input went on. If the variable is already zero, you do nothing.

    You can manage several timed events this way. Because the statements making up the loop take some time to execute, you may have to decrease the size of the loop's PAUSE. It make take some experimenting to get things just right.
  • StevezilaStevezila Posts: 35
    edited 2010-12-20 02:37
    Thanks Mike, I had an idea it might be something like that, just could'nt quite get started in the right direction. Seems tomake perfect sense now, I'll give it a try. Thanks so much for the help!!!
Sign In or Register to comment.