Variable for program's status

  • Hi to all,

    my purpose is to run (RUN not CALL) a program at the top of the main program that manages and checks timers (because of is not possible use timers in a bg_logic :pouting_face:) and that runs continuously parallel to the main program.

    Is there a variable about its status (paused, aborted, running) that allow me not to run it again if it's already running and avoid the error?


  • Place your Ad here!
  • I've done this before by turning on a flag at the top of the RUN program and turning it off at the end of the RUN program. You can then monitor the flag status and use that information to RUN the program with the timers again.

    I'm not sure if there are variables that can be used to monitor the status; hopefully, others will chime in.

  • yes, I usually use the same idea with runned programs that start and end but in this case I use a JUMP to the top of the program in order to check timers continuously.

    The problem is that if I return on top of the MAIN program without a "FCTN->ABORT ALL" COMMAND the RUN is executed again and I get the error; this is way I would use a system variable to avoid this.

  • the RUN command is above the main loop but if I move to the top manually (I mean line 1) is not possible to avoid another execution of the RUN (I need a variable or I need to understand that a ABORT ALL has been done and so I can run it again).

    I can remove the final JUMP from the runned program so that it starts and ends and RUN it from a bg_logic (instead of the main program) using a flag as suggested. By this way the bg_logic runs it continuously

  • This isn't the easiest one to solve...

    If you have a newer controller, you can setup a digital output for 'Program Aborted' on the Cell Interface I/O screen and you'd know if an Abort All has taken place, then RUN the timer program if the aborted output is on. I don't recall if the aborted output will remain on if you restart the main loop. If it doesn't stay on, its state could be captured with a flag using bg logic. This isn't the best solution and it's getting a bit sloppy.

    I looked around in the docs for a variable that tracks multitasking programs and didn't have any luck.

  • You can time in BG logic. There a couple methods, 1. Increment a counter, which will occur at the scan time (8ms default) or monitor the difference in the $FASTCLOCK system variable, which counts in 2ms increments.

  • I have seen that it's an array of 4 but how to link a target program to its task number? I can see from MENU->STATUS->PROGRAM the currently value but is it always the same?

    at the top of all .ls program I can see this lines:

    BUSY_LAMP_OFF    = 0,
    ABORT_REQUEST    = 0,
    PAUSE_REQUEST    = 0;

    what are them? can them be helpfull to my purpose?

  • I have seen that it's an array of 4 but how to link a target program to its task number? I can see from MENU->STATUS->PROGRAM the currently value but is it always the same?

    Looking into this further, the system variables I listed don't show which program is running for each task, only the status of the task itself. Unfortunately this will only be a part of the puzzle for you. I will defer to FastFingers and HawkME.

  • I know this post is a couple weeks old, but I've run into this problem a number of times over the years. I wrote a little KAREL program that you can use to get the status of a task by name and also wrote up a longer article about TPE's RUN statement.

    I haven't used it in production (yet), but I plan to next time I have to spawn off a concurrent task.

    example usage:


    IF R[1:TASK STATUS]<>2,JMP LBL[500] ;

    ! task is aborted ;

    ! ok to run ;


    END ;


    LBL[500] ;

    ! if R[1:TASK STATUS]=0, task is running ;

    ! if R[1:TASK STATUS]=1, task is paused ;

    ! there are other statuses detailed in the article.

  • jay, very useful program. I had problems with your program in a multitasking multigroup robot cell until I added :

  • I am trying to use TASK_STATUS Karel file to monitor one parallel program is it running or not but am getting 3016 as output from TASK_STATUS.

    what does it mean and I have anyway to debug the karel file ( like break points , going online by the source code ....)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners