I need to run a routine if the robot sits idle for a certain amount of time. Any examples?
Example of Trap Routine
-
mball209 -
May 3, 2016 at 8:54 PM -
Thread is marked as Resolved.
-
-
You can do this with a timed interrupt. If the robot enters the idle state, just set a bit Idle:=TRUE; Every x second run a timed interrupt, and see if the idle bit is TRUE. If so, you can just do something.
VAR intnum timeint;
PROC main()
CONNECT timeint WITH check_idle;
ITimer 2, timeint; ! Check every 2sec the idle bit.
...
TRAP check_idle
if Idle THEN! - do something
ENDIFENDTRAP
Good luck, regards,
Jeroen
-
Thanks for your help. I may be wrong but in my case the robot sits idle waiting on a signal to start and can be idle for a few seconds, a few minutes, a few hours and even many hours. I need to set a timer after the robot completes a cycle. If the timer elapses, say 1 hour, the robot will perform a task and then go back to waiting for that signal and the timer will reset. I am afraid the robot could be idle when I do not necessarily want it to perform that task. Thanks again.
-
Add the max wait time flag to your WaitDI and create an error handler to catch the error, do whatever you want it to do and then return to waiting....
QuoteArguments
WaitDI Signal Value [\MaxTime] [\TimeFlag]
Signal
Data type: signaldi
The name of the signal.
Value
Data type: dionum
The desired value of the signal.
[\MaxTime]
Maximum Time
Data type: num
The maximum period of waiting time permitted, expressed in seconds. If this time
runs out before the condition is met then the error handler will be called, if there
is one, with the error code. If there is no error handler then
the execution will be stopped.