Countdown timer that runs in the background
xerim
✭
Hello,
I've put together this small program that counts down from a given amount of seconds and I would like it to display on the FlexPendant while the robot is running to let the operator know when the program will end. Because the cycle time is the same, this solution works as I can simply input the cycle time in seconds and have it count down from there. I am trying to get this program to run in the background because when you put in in the main program it always hangs on "WaitTime currentTimeStep" which makes sense, because it is an instruction telling the robot to wait. How can I get this program to run in the background so it doesn't get in the way of the main program?
I've put together this small program that counts down from a given amount of seconds and I would like it to display on the FlexPendant while the robot is running to let the operator know when the program will end. Because the cycle time is the same, this solution works as I can simply input the cycle time in seconds and have it count down from there. I am trying to get this program to run in the background because when you put in in the main program it always hangs on "WaitTime currentTimeStep" which makes sense, because it is an instruction telling the robot to wait. How can I get this program to run in the background so it doesn't get in the way of the main program?
MODULE WaitTimeModule CONST num timeStep:=1; PROC RemainingTime(num waitingTime) VAR num currentTimeStep; VAR num timeLeft:=0; VAR string displayString; timeLeft:=waitingTime; WHILE timeLeft>0 DO IF timeLeft<timeStep THEN currentTimeStep:=timeLeft; timeLeft:=0; ELSE Add timeLeft,-timeStep; currentTimeStep:=timeStep; ENDIF TPErase; TPWrite "Time Remaining is:" + SecondstoTime(timeLeft); WaitTime currentTimeStep; ENDWHILE ENDPROC FUNC string SecondstoTime(num s) VAR num seconds:=0; VAR num minutes:=0; VAR num hours:=0; s:=Round(s); seconds:=0; minutes:=0; hours:=0; IF s>=60 THEN minutes:= s DIV 60; seconds:= s MOD 60; ELSE seconds:=s; ENDIF minutes:=Trunc(minutes); IF minutes >= 60 THEN hours:= minutes DIV 60; minutes:= minutes MOD 60; ELSE minutes:=minutes; ENDIF RETURN NumToStr(hours,0) + "hr" + NumToStr(minutes,0) + "m" + NumToStr(seconds,0) + "s"; ENDFUNC PROC main() RemainingTime 11400; ENDPROC ENDMODULE
0
Answers
-
How about using ITimer instead? You can use it in the foreground as well.Lee Justice0
-
I am not very familiar with interrupts/traps yet, do you think I could easily implement ITimer into my code that already exists or are you suggesting to go in a new direction?0
-
I think that you could just put it in the main task that is running and just put in a TPWrite that says how long it has been running and subtract that from the total time to give time remaining.Lee Justice0
-
I just had an idea...it would be a bit less obnoxious that constantly writing to the pendant. You could make a virtual do, connect it to a programmable key and then an interrupt/trap. So the operator can "request" the runtime and remaining time by depressing the programmable key.Lee Justice0
-
Good idea, but you would be shocked by the sheer ineptitude of some of the operators, even for something as simple as a button push. I would prefer it to be constantly writing to the pendant in the background.0
-
I tried changing the module to SEMISTATIC by editing the controller section of the configuration editor, but then when I press pp to main it says there is not an active program pointer..I know the controller can run tasks in the background because there is already a task in there that is checking for errors while the robot is running.0
-
Did you reboot?Lee Justice0
-
Yes0
-
Have you configured it to be loaded automatically? Save it to the home directory and set it up to load from there if you have not yet. Then, you will probably have to P-Start. Save any necessary modules so they will not be lost.Lee Justice0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings