Repeat until command?
GrantmcF
Posts: 30
I am trying to run a pump for a set amount of time without slowing down the main program. I am starting the the pump in a new cog and trying to run it for 4 minutes. I can only get the pump to come on if I don't use the until command. Am I configuring it wrong or is there a better way to do this? The display functions are just to verify that a new cog was started and are not necessary to the final code. Yes I know about indents but the auto correct keeps taking them out.
Var
Long Relay_cog
Long Relay_Stack[32]
OBJ
Lcd : "Debug_Lcd"
Lcd.init(Lcd_Pin, 19200,4)
Relay_cog := cognew( Prewet2,@ Relay_Stack)+1
Lcd.cls
Lcd.decx(Relay_cog,2)
cogstop(Relay_cog~ -1)
Pub Prewet2
repeat until (clkfreq*240 + cnt)
Dira[13..15] :=1 'Sets direction of pins 13-15 to output
outa[13..15] :=0 'Sets pin 13 high and pins 14 and 15 low
Var
Long Relay_cog
Long Relay_Stack[32]
OBJ
Lcd : "Debug_Lcd"
Lcd.init(Lcd_Pin, 19200,4)
Relay_cog := cognew( Prewet2,@ Relay_Stack)+1
Lcd.cls
Lcd.decx(Relay_cog,2)
cogstop(Relay_cog~ -1)
Pub Prewet2
repeat until (clkfreq*240 + cnt)
Dira[13..15] :=1 'Sets direction of pins 13-15 to output
outa[13..15] :=0 'Sets pin 13 high and pins 14 and 15 low
Comments
As it is written now your loop will always stop whenever "(clkfreq*240 + cnt)" isn't zero (which is almost all the time).
You also need to keep in mind the "cnt" rolls over in less than one minute.
I'd suggest keeping track of how many seconds pass and check the number of seconds against 240.
It would also help if you used code blocks when posting code. Here's a link to Phil's tutorial on how to use them.
Andy
-Phil