1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. Fanuc Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

Variable for program's status

  • Pano
  • August 27, 2019 at 1:13 PM
  • Thread is Unresolved
  • Pano
    Trophies
    3
    Posts
    9
    • August 27, 2019 at 1:13 PM
    • #1

    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?

    Thanks

  • fastfingers
    Reactions Received
    25
    Trophies
    5
    Posts
    190
    • August 27, 2019 at 1:40 PM
    • #2

    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.

  • Pano
    Trophies
    3
    Posts
    9
    • August 27, 2019 at 3:22 PM
    • #3

    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.

  • fastfingers
    Reactions Received
    25
    Trophies
    5
    Posts
    190
    • August 27, 2019 at 3:25 PM
    • #4

    Can you issue the the RUN above the loop to avoid the error? I'm guessing this would cause another problem.

  • Pano
    Trophies
    3
    Posts
    9
    • August 27, 2019 at 4:22 PM
    • #5

    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

  • fastfingers
    Reactions Received
    25
    Trophies
    5
    Posts
    190
    • August 27, 2019 at 4:52 PM
    • #6

    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.

  • HawkME
    Reactions Received
    568
    Trophies
    10
    Posts
    3,268
    • August 27, 2019 at 8:13 PM
    • #7

    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.

  • domo_arigato
    Reactions Received
    8
    Trophies
    3
    Posts
    14
    • August 27, 2019 at 9:16 PM
    • #8

    I just ran into these yesterday so take this with a grain of salt (meaning, I'd advise testing these first).

    $PGTRACECTL[n].$TASK_STATUS may be what you need (where n is the task number).

    0 is running

    1 is paused

    2 is aborted

    Edited once, last by domo_arigato (August 27, 2019 at 9:47 PM).

  • Pano
    Trophies
    3
    Posts
    9
    • August 28, 2019 at 10:16 AM
    • #9
    Quote from domo_arigato

    I just ran into these yesterday so take this with a grain of salt (meaning, I'd advise testing these first).

    $PGTRACECTL[n].$TASK_STATUS may be what you need (where n is the task number).

    0 is running

    1 is paused

    2 is aborted

    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:

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

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

  • domo_arigato
    Reactions Received
    8
    Trophies
    3
    Posts
    14
    • August 28, 2019 at 2:12 PM
    • #10
    Quote from Pano

    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.

  • jay
    Reactions Received
    25
    Trophies
    3
    Posts
    82
    • September 18, 2019 at 4:21 PM
    • #11

    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:

    CALL TASK_STATUS('TASK_TWO', 1) ;

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

    ! task is aborted ;

    ! ok to run ;

    RUN TASK_TWO ;

    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.

    ONE Robotics Company

  • Errorcode
    Reactions Received
    2
    Trophies
    3
    Posts
    24
    • October 1, 2019 at 8:32 AM
    • #12

    I use UO[10: Busy]=ON/OFF which automatically tells if program is running or not

  • HawkME
    Reactions Received
    568
    Trophies
    10
    Posts
    3,268
    • October 1, 2019 at 12:54 PM
    • #13
    Quote from Errorcode

    I use UO[10: Busy]=ON/OFF which automatically tells if program is running or not

    UO[10] won't help in a multitasking situation, because the main program will already be running.

  • dha
    Reactions Received
    28
    Trophies
    6
    Posts
    397
    • October 16, 2019 at 2:00 PM
    • #14
    Quote from jay

    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:

    CALL TASK_STATUS('TASK_TWO', 1) ;

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

    ! task is aborted ;

    ! ok to run ;

    RUN TASK_TWO ;

    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.

    Display More

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

    Code
    %NOLOCKGROUP
  • jay
    Reactions Received
    25
    Trophies
    3
    Posts
    82
    • October 16, 2019 at 8:01 PM
    • #15

    Yep, thanks dha ! No reason for this routine to lock motion, etc... I'll update and publish a new build. Thanks again!

    ONE Robotics Company

  • moelsayed
    Reactions Received
    3
    Trophies
    3
    Posts
    98
    • February 10, 2021 at 5:09 AM
    • #16

    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 ....)

  • dha
    Reactions Received
    28
    Trophies
    6
    Posts
    397
    • February 12, 2021 at 11:47 AM
    • #17

    Your error means PROG-016 - Task is not found

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Similar Threads

  • Variable for Frame 3 point method

    • DaveP
    • April 20, 2016 at 10:29 PM
    • Fanuc Robot Forum
  • Fanuc Karel Server, MSG_CONNECT exits with status 67206 without blocking

    • KlausSu
    • April 18, 2019 at 11:14 AM
    • Fanuc Robot Forum
  • Communication going between cognex and fanuc robot

    • pramtekkar
    • June 5, 2019 at 4:42 PM
    • Fanuc Robot Forum
  • Background Program Status

    • Im not a robot
    • May 9, 2019 at 8:25 PM
    • Fanuc Robot Forum
  • DELETE a FILE in MD: using KAREL(FILE NAME TOBE EXTRACTED FROM DATA STRINGS REGI

    • balajitdm2000
    • November 9, 2018 at 2:03 AM
    • Fanuc Robot Forum
  • Help with Karel code

    • beanluke
    • January 24, 2018 at 10:42 PM
    • Fanuc Robot Forum
  • karel help

    • TomTom889
    • January 24, 2018 at 1:05 AM
    • Fanuc Robot Forum
  • Karel Systax error

    • hugogalarza
    • October 21, 2016 at 9:19 AM
    • Fanuc Robot Forum
  • SET_POS_REG in KAREL

    • vega2005
    • February 19, 2016 at 8:22 AM
    • Fanuc Robot Forum
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download