So, you have some "random" routine to run through·inside a Loop, say, and that takes·some given time to execute.· You time it once and then program it to repeat so that it's running for 90 seconds (e.g. once through = 5 seconds, then repeat it 18 times)·--
FOR X = 0 TO 17
GOSUB Dry_Run
END
Dry_Run:
'the random movement subroutine program
RETURN
Because the moters need to be pulsed at 20ms (50 times a second), just increment a counter every time you send
out a pulsout command. After 4500 increments, you can power off.
Also, if you are truly dependent on shutdown @ 90seconds(I'm assuming this is for a competition where they disqualify you if you run over) make the first action set the ALARM time on a time keeping chip(Pocket Watch B or that new shiny Dallas time chip) and make it so the ALARM pin triggers a relay which physically cuts power to the bot.
rokicki said...
Because the moters need to be pulsed at 20ms (50 times a second), just increment a counter every time you send
out a pulsout command. After 4500 increments, you can power off.
My experience with timing based on loops with PAUSE xx is that the overhead of even a small loop
(IF THEN) is already 1-2 ms. So depending on what the robot is doing - remember, it's a random process -
the loop·cycle time·will vary or even vary a lot.
I think that reasonable timing can not be done without an RTC or a 555 as described in
the thread I mentioned earlier.
Comments
Thx,
Ed
Check this out:
http://forums.parallax.com/forums/default.aspx?f=5&m=180588
out a pulsout command. After 4500 increments, you can power off.
(IF THEN) is already 1-2 ms. So depending on what the robot is doing - remember, it's a random process -
the loop·cycle time·will vary or even vary a lot.
I think that reasonable timing can not be done without an RTC or a 555 as described in
the thread I mentioned earlier.
have a nice day
Ed