Shop OBEX P1 Docs P2 Docs Learn Events
PAUSE limitations — Parallax Forums

PAUSE limitations

adamlightingadamlighting Posts: 6
edited 2010-03-11 18:09 in BASIC Stamp
I need to control two relays 8 hours apart. The max I can tell a PAUSE command to do is 56k or so.

Would it be possible to string together PAUSE commands to get me 8 hours?

For example:
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000

repeat this until there are 480 PAUSE commands.

·

Comments

  • kf4ixmkf4ixm Posts: 529
    edited 2010-03-11 14:51
    i would use a count with the pause statement...
    timer:
    i=i+1
    pause 1000
    if i=28800 then timeout
    else timer
    timeout:
    i=0 'to reset timer
    'what you want to do here
  • stamptrolstamptrol Posts: 1,731
    edited 2010-03-11 14:53
    Or, have one subroutine of say 1 minute duration. Then call it with a loop 480 times.

    If you want to be able to use the Stamp for something else while waiting for 8 hours to elapse, make the subroutine much shorter, say 10 seconds and increase the number of loops accordingly. Note that doing a timing in this fashion is not very accurate.

    If accuracy is needed, nothing beats a clock.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • adamlightingadamlighting Posts: 6
    edited 2010-03-11 14:57
    Ok. I follow so far.

    Here's my application. Maybe I only need one relay. I just will turn the relay on and off.

    I will control a relay to turn lights on for 8 hours and off for 8 hours continuously.

    With the timeout command mentioned above, won't that just reset everything. Sorry. It's been a few months since I've used my stamp.

    Any code examples would be extremely helpful at this point.
  • kf4ixmkf4ixm Posts: 529
    edited 2010-03-11 15:10
    you could use the toggle command with the above code, like:
    ' {$STAMP BS2}
    DIR2 = 1····························· ' pin 2 in output mode
    OUT2 = 0···························· ' pin 2 output driver low dark for first 8 hrs, change to OUT2 = 1 for light for first 8 hrs
    i VAR Word
    timer:
    ·i = i+1
    PAUSE 1000
    IF i=28800 THEN timeout
    ·else
    GOTO timer
    timeout:
    i=0 'to reset timer
    TOGGLE 2 'this would toggle pin 2 every 8 hours
    GOTO timer 'this tells it to go back to timing after toggling pin 2

    Post Edited (kf4ixm) : 3/11/2010 3:24:23 PM GMT
  • adamlightingadamlighting Posts: 6
    edited 2010-03-11 15:41
    Perfect, thank you!
  • MoskogMoskog Posts: 554
    edited 2010-03-11 18:09
    Hey, that most be a very boring task for a BasicStamp. If you are going to control 110 or 220V AC why not use a Timer instead?
Sign In or Register to comment.