How to Pause the process for 45 minutes?
I am using the latest version of SX/B with SX28 chips.
I am trying to create an alert of blinking LEDs every 45 minutes, but so far I haven't been able to PAUSE for that amount of time.
I am using the following comand:
PAUSE 2700000
based on 1000 = one second.
Can someone tell me what I am doing wrong?
Thanks.
I am trying to create an alert of blinking LEDs every 45 minutes, but so far I haven't been able to PAUSE for that amount of time.
I am using the following comand:
PAUSE 2700000
based on 1000 = one second.
Can someone tell me what I am doing wrong?
Thanks.

Comments
RS_JIM
An alternative to the loops RS Jim mentioned, another way to do this is to set a variable to the current clock count + the number of ticks you need for your "delay" time. Then have a loop that does your other stuff, or checks for inputs, etc., and part of that loop does a compare to see if the count is >= your setting. If it is, do your thing, if not, repeat the loop.
I'm not an expert by any means, but you may also be able to look at the "sleep" function. Is there a way you could externally trigger a "wake up call" (maybe a 555 timer).
Another possibility is to incorporate a real time clock (RTC), and do a comparison based on the actual time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log
If you want to minimize power. Then you could use SLEEP with a WATCHDOG wakeup.
Basically, set the watchdog to it's maximum timeout (about 2.3 Seconds). When the program wakes-up it will increament a counter. When the counter reaches 1174 (45*60 / 2.3), then blink the LEDs.
DEVICE SX28, TURBO, STACKX, OPTIONX, OSC4MHZ, WATCHDOG ' NOTE you will not be able to debug this program because of the watchdog IRC_CAL IRC_4MHZ FREQ 4_000_000 ' Enable pullups for unused I/O pins UnusedRA PIN RA INPUT PULLUP UnusedRB PIN RB INPUT PULLUP UnusedRC PIN RC INPUT PULLUP LED PIN RB.0 WAITCNT CON 10 ' in 2.3Sec units, 1174 = 45 MINUTES cntr VAR WORD Program Start NOSTARTUP ' NOSTARTUP is important so the counter doesn't get zeroed Start: IF _TO = 1 THEN ' No timeout, must be power-up OPTION = %11111111 ' watchdog prescaler set to 1:128 or about 2.3sec cntr = 0 SLEEP ENDIF INC cntr IF cntr >= WAITCNT THEN OUTPUT LED FOR cntr = 1 TO 10 RESETWDT LED = 1 PAUSE 100 LED = 0 PAUSE 100 NEXT cntr = 0 ENDIF SLEEP ENDBean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
Post Edited (Bean (Hitt Consulting)) : 6/11/2009 5:22:51 PM GMT
Bean, I tried your code but when I run it tells me that _TO is not defined.
Any thoughts?
Thanks again.
· Make sure you have the latest version of the compiler.
· You can get it from here http://forums.parallax.com/showthread.php?p=780347
· Download the zip file, extract the files and copy them to C:\Program Files\Parallax Inc\SX-Key v3.2.92\Compilers\SXB
· Overwrite the existing files when asked.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
Post Edited (Bean (Hitt Consulting)) : 6/12/2009 2:01:27 AM GMT
For the sake of practicing and learning I also Tried RS_Jim suggestion and it did worked too. Thanks.
I also wanted to try John R. suggestion but I am not that knowledgeable yet; '...set a variable to the current clock count + the number of ticks you need for your "delay" time.'
Thank you all for your input, as I progress in my learning curve I am sure I will ask you again for help.
This will NOT change the watchdog timeout because the watchdog runs from it's own oscillator.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
Ideas are welcome.
Thanks.
' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- MilliSeconds VAR Byte HundredthsOfSeconds VAR Byte TenthsOfSeconds VAR Byte Seconds VAR Byte Minute VAR Byte Hours VAR Byte Days VAR Byte Weeks VAR Byte ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- Update_Clock SUB 0 ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: ' initialization code here Main: Update_Clock GOTO Main Update_Clock: INC MilliSeconds IF MilliSeconds = 10 THEN MilliSeconds = 0 INC HundredthsOfSeconds IF HundredthsOfSeconds = 10 THEN HundredthsOfSeconds = 0 INC TenthsOfSeconds IF TenthsOfSeconds = 10 THEN TenthsOfSeconds = 0 INC Seconds IF Seconds = 61 THEN Seconds = 0 INC Minute IF Minute = 61 THEN Minute = 0 INC Hours IF Hours = 25 THEN Hours = 1 INC Days IF Days = 8 THEN Days = 0 INC Weeks IF Weeks = 52 THEN Weeks = 0 ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF RETURNSomething to think about anyway.
Hope it helps.