Tiago Severino
New Member
I need to stop my program after 2 Minutes, is there any way to do it, like an internal timer or multi threading?
Something like this? :-I need to stop my program after 2 Minutes, is there any way to do it, like an internal timer or multi threading?
[COLOR=blue]Start0:
do
[/COLOR][COLOR=green];
; This is the main program...
; ...running at 16MHz
;
[/COLOR][COLOR=blue]Sertxd (cr[/COLOR][COLOR=black],[/COLOR][COLOR=blue]lf[/COLOR][COLOR=black],[/COLOR][COLOR=red]"Main program here"[/COLOR][COLOR=blue])
loop
Start1:
Pause [/COLOR][COLOR=navy]60000 [/COLOR][COLOR=green];wait one minute
[/COLOR][COLOR=blue]Pause [/COLOR][COLOR=navy]60000 [/COLOR][COLOR=green];wait another minute
;
; we could just stop both tasks...
;
[/COLOR][COLOR=blue]end [/COLOR][COLOR=green];(stop could be used - which doesn't power everything down)
;
; ...or just the main one...
;
[/COLOR][COLOR=blue]suspend [/COLOR][COLOR=navy]0
[/COLOR][COLOR=green];
; ...in which case, we can carry on and do other things here
;
[/COLOR][COLOR=blue]sertxd(cr[/COLOR][COLOR=black],[/COLOR][COLOR=blue]lf[/COLOR][COLOR=black],[/COLOR][COLOR=red]"Task 1 still alive"[/COLOR][COLOR=blue])
[/COLOR][COLOR=green];
[/COLOR][COLOR=blue]end [/COLOR][COLOR=green];?[/COLOR]
I just need to shutdown after 2 minutesHi Welcome
Doe's it need to restart after another time period
john
I know but time doesn't increment when in pause command, and I'm using some functions with pause commandOn the PICAXE M2 chips you can use the 'time' variable which increments about once every second, so can take action when 'time >= 120'.
Yes, but I need to know when it passed 2 minutes since program elapsedAnd after the 2 minutes / 120 seconds, use the
STOP command
Which will stop all action until the power is cycled.
Will Start0 and Start1 run in parallel? Gonna try itSomething like this? :-
Code:[COLOR=blue]Start0: do [/COLOR][COLOR=green]; ; This is the main program... ; ...running at 16MHz ; [/COLOR][COLOR=blue]Sertxd (cr[/COLOR][COLOR=black],[/COLOR][COLOR=blue]lf[/COLOR][COLOR=black],[/COLOR][COLOR=red]"Main program here"[/COLOR][COLOR=blue]) loop Start1: Pause [/COLOR][COLOR=navy]60000 [/COLOR][COLOR=green];wait one minute [/COLOR][COLOR=blue]Pause [/COLOR][COLOR=navy]60000 [/COLOR][COLOR=green];wait another minute ; ; we could just stop both tasks... ; [/COLOR][COLOR=blue]end [/COLOR][COLOR=green];(stop could be used - which doesn't power everything down) ; ; ...or just the main one... ; [/COLOR][COLOR=blue]suspend [/COLOR][COLOR=navy]0 [/COLOR][COLOR=green]; ; ...in which case, we can carry on and do other things here ; [/COLOR][COLOR=blue]sertxd(cr[/COLOR][COLOR=black],[/COLOR][COLOR=blue]lf[/COLOR][COLOR=black],[/COLOR][COLOR=red]"Task 1 still alive"[/COLOR][COLOR=blue]) [/COLOR][COLOR=green]; [/COLOR][COLOR=blue]end [/COLOR][COLOR=green];?[/COLOR]
time certainly does increment during pauses.I just need to shutdown after 2 minutes . . . I know but time doesn't increment when in pause command, and I'm using some functions with pause command
#picaxe 08M2
pause 5000
sertxd(#time)
Oh my bad, it just don't increment with sleep command, thank you!time certainly does increment during pauses.
This prints "5".Code:#picaxe 08M2 pause 5000 sertxd(#time)
If some of your pauses might carry you over the 120 second mark, break up the pauses into smaller pieces and check time in between pauses.