Shop OBEX P1 Docs P2 Docs Learn Events
How to use a timer function and monitor the inputs at the s... — Parallax Forums

How to use a timer function and monitor the inputs at the s...

ArchiverArchiver Posts: 46,084
edited 2002-02-18 13:04 in General Discussion
Instead of using one long PAUSE command, use a loop and insert a smaller
PAUSE and a check of your switch. Like this:

Wait_For_Start:
IF (StartSw = 1) THEN Wait_For_Start

Do_Process:
HIGH ProcessOut
FOR x = 1 TO 1000
IF (StopSw = 0) THEN Process_Stop
PAUSE 10
NEXT

Process_Stop:
LOW ProcessOut


The code assumes that you're using switches that read 1 when no pressed, 0
when pressed. The "Do_Process" section takes care of making ProcessOut high
for about 10,000 milliseconds (10 seconds) and checking for an emergency stop
every 10 milliseconds.

When using a loop like this, you'll need to fine-tune the loop and PAUSE
value to control the output duration as the loop and switch check adds time
to the process.

-- Jon Williams
-- Parallax



In a message dated 2/18/02 6:38:23 AM Central Standard Time,
Smalcor.AmusementsProducts@1... writes:


> I want to start a project with a start button. I want the stamp to hold
> an output high for an amount of time and then make it low again.
> During this timing I want to be able to read the other button for e.g. a
> emergency stop. I want to be able to stop the process before it reaches
> the end.
>
> When I use the pause command, I cannot control or read anything else!
>




[noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.