Shop OBEX P1 Docs P2 Docs Learn Events
Timed output with pushbutton input — Parallax Forums

Timed output with pushbutton input

SkabikeSkabike Posts: 1
edited 2005-09-21 19:26 in BASIC Stamp
I am a brand new user so bear with me....

I have written a simple routine which turns on an output with the push of a button.· Now I want to turn on that same output for a very brief time -milisec range.· Do I use the BUTTON command?·· COUNTER?· If one of these, then how do I configure?

I have woked with PLCs before, but programmed them with an entirely different approach.· Also programmed using Compumotor's propriatary language, so I guess I'm not used to the freedom the pbasic is giving me.· I need structure!

Comments

  • metron9metron9 Posts: 1,100
    edited 2005-09-21 19:26
    ' turn on pin 1
    High 1
    ' wait 50 milliseconds
    pause 50
    'turn it back off
    Low 1

    thats one way, your program stops for 50 ms at the pause command though.

    Another would be using a timer and flags to poll how long an event is going to take.

    Another way using just program execution with variable time dependinh on how many instructions get run is


    time=0

    loop:

    time=time+1

    if time =100 then
    high 1
    endif

    if time = 200 then
    low 1
    time=0
    endif


    .... other code here.......

    goto loop

    Above the program increments a counter till its 100 and turns it on, after another 100 times it turns off , resets the timer and continues
    With a clock pulse external clock you can dial in the timing, but this would work for some applications.
Sign In or Register to comment.