Countdown timer that runs in the background

  • 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 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. Perhaps I have too many background tasks now..

  • Well, you could just add your Timer code to the existing background task, maybe as a new PROC. As long as you program it without any Wait commands, it shouldn't disrupt the existing task.


    I don't recall exactly, and don't have an ABB to try it on, but I'm not sure "SemiStatic" is the correct setting. Once I had it working, this is what the entry in BACKINFO.TXT looked like when I took a backup:

    Code
    >>TASK3: (Background,,)
    SYSMOD/user.sys @ 
    PROGMOD/MainModule.mod @ 

    Task 3 was my background Task, and I literally just named it "Background."

    USER.SYS was an empty file auto-created by the robot when I created Task 3.


    Pretty sure most ABBs can handle multiple background tasks... I think the original IRC5s could handle 5 or 8 running in parallel.


    This is the background task module I created that I mentioned before. It's literally a completely ordinary RAPID module, it's just the Task that is set to Background. As you can see, I only put subroutine calls in the Main, making it easy to add/subtract subroutines for future edits. No Waits, to ensure no subroutine blocks another. No loops, b/c a Background Task loops inherently (basically, it keeps calling Main over and over).

  • As long as you program it without any Wait commands, it shouldn't disrupt the existing task.

    I think that is my main problem, my program to count time relies on line 24 of the code I posted above (WaitTime currentTimeStep;) I'm going to have to find another solution, thanks for your help

  • I haven't tried this in a background task, but CTime() should allow you to check the time, then do some math on it. This is an old program that autosaved certain files once a day, but it was part of the foreground task, not a background.


    (the FileTime variables are leftover from when I attempted to check the age of the existing backup file, and base the Save on that. But I was never able to get the age to parse correctly from Unix Epoch to a date/time that I could compare against CTime and CDate)

  • Good idea, I have actually been working on this in a different direction now by using CTime() to output the current time + the duration of the cycle as opposed to constantly updating the remaining duration. The plan is to convert the output from CTime() to seconds, add it to the duration (in seconds) and then use a function to convert total seconds to a time format.

Advertising from our partners