Shop OBEX P1 Docs P2 Docs Learn Events
Pause problems — Parallax Forums

Pause problems

SabaiSabai Posts: 27
edited 2009-10-07 22:19 in BASIC Stamp
I have a problem that I do not know how to fix.

My program has a main routine and two Sub routine. The problem is that the sub routine need to stop for 2 minutes in order to do the task, opening a ventilation hatch.

My sub:
Alarm :

IF ((tc/10)<AlarmTmp) THEN
HIGH Closeled ' Close hatch
PAUSE Motortm ' Time to run motor
LOW Closeled ' Stop motor

ENDIF

The problem is that this sub is checking for user input, system set up.
In side Main:
GOSUB Get_165
IF switches.BIT7 = 1 THEN GOSUB menu

But is sub Alarm is pausing for 2 minutes when the user cannot enter the system menu by pressing the button they will need to wait two minutes.

My first ide was to change Alarm to:
Alarm :

IF ((tc/10)<AlarmTmp) THEN
DO WHILE cycleTm < motorTm
HIGH Closeled ' Close hatch
cycleTm = cycleTm + 1
GOSUB Get_165
IF switches.BIT7 = 1 THEN GOSUB menu
LOOP
LOW Closeled ' Stop motor

ENDIF

But for some strange reason did it not work! Can anybody clear this up for me?

B

Comments

  • dev/nulldev/null Posts: 381
    edited 2009-10-07 22:19
    I have to make some guesses about your code, since you didn't post the complete code.

    This might work better.

    Counter VAR Word
    
    Main:
      GOSUB Get_165
      IF switches.BIT7 = 1 THEN GOSUB menu
      GOSUB Alarm
      GOTO Main
    
    Alarm:
      IF ((tc/10)<AlarmTmp) THEN ' Alarm triggered
         HIGH Closeled ' Close hatch
         FOR Counter = 1 TO 12000 ' You might lower this a little bit to account for processing time
            GOSUB Get_165
            IF switches.BIT7 = 1 THEN GOSUB menu
            PAUSE 10 ' Pause 10 milliseconds
         NEXT
         LOW Closeled ' Stop motor
      ENDIF
      RETURN
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy

    Post Edited (dev/null) : 10/8/2009 6:10:30 AM GMT
Sign In or Register to comment.