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

Task reentrance

  • quarz
  • March 29, 2022 at 1:00 AM
  • Thread is Unresolved
  • quarz
    Reactions Received
    1
    Trophies
    3
    Posts
    28
    • March 29, 2022 at 1:00 AM
    • #1

    Hello.

    I have just started programming on AS.

    For example I want to create wrapper subroutines for PRINT instruction to add some additional info to log output:

    Code
    .PROGRAM LOG.pc (.$msg)
        PRINT $TIME + ": " + .$msg
    .END

    then I call it from two background programs:

    Code
    .PROGRAM main.pc ()
      WHILE TRUE DO
        IF TASK (1002) <> 1 THEN
          PCEXECUTE 2:program1.pc
        END
        
        IF TASK (1003) <> 1 THEN
          PCEXECUTE 3:program2.pc
        END
        
        TWAIT 5.0
      END  
    .END
    Display More

    each program1.pc and program2.pc calls LOG.pc in infinite loops:

    Code
    .PROGRAM program1.pc ()
      WHILE TRUE DO
        CALL LOG.pc ("program1")
        TWAIT 0.5
      END
    .END
    
    .PROGRAM program2.pc ()
      WHILE TRUE DO
        CALL LOG.pc ("program2")
        TWAIT 0.5
      END
    .END
    Display More

    When I start main.pc I got an error: (P1014) Cannot execute because program already in use. No = 1002.

    But why? LOG.pc does not use any global variables

  • quarz
    Reactions Received
    1
    Trophies
    3
    Posts
    28
    • March 29, 2022 at 1:05 AM
    • #2

    For the same reason I cannot call example subroutine TcpOpenSrv.pc from two background tasks simultaneously.

    Is this really a limitation of AS system or am I wrong?

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • March 29, 2022 at 2:37 AM
    • #3

    It seems logical to me that this error occurs.

    How can the same program be called at the same time by a different program.

    When calling a subroutine you are placing it in the execution stack, so therefore it will be in use.

    I am pretty sure no 'caching' or 'prefetching' occurs with PC Programs as there are no motion instructions allowed.

    PC programs executed (including calls) are asynchronous.

    Personally with a simple print instruction like that, replace the call, with the print command and it'll more than likely work fine, but as you are waiting 0.5s per cycle, I would expect you to probably see more than one consecutive print instruction for each program.

    ie

    Time + program1

    Time + program1

    Time + program2

    Time + program2

    Not too sure what your intentions are with this?

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • quarz
    Reactions Received
    1
    Trophies
    3
    Posts
    28
    • March 29, 2022 at 10:52 AM
    • #4

    Yes, I found it in AS manual.

    It's a pity that it is impossible to move common parts of code to subroutines and call them independently

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • March 29, 2022 at 11:20 AM
    • #5
    Quote from quarz

    It's a pity that it is impossible to move common parts of code to subroutines and call them independently

    Yes, you can by using the parse parameter feature in step 0 as you're doing.

    What you can't do is simultaneously call the same program.

    Variables/values which are parsed in, get grabbed and stored locally at the start of execution.

    What you are doing fails at the start because they are starting together and stops one of the PC tasks.

    With your auto restart routine every 5 secs, then starts it back up and as long as it starts it back up when the other task is not using the subroutine, it'll run as they are executing at different times now.

    An alternative (haven't tried it, something for you to try).

    PCSCAN instruction.

    You can set the PC Scan time using this, so logically thinking, you should be able to introduce an offset between the PC Tasks......not sure whether this would be reliable enough, but worth a shot

    View my channel at Industrial Robotics Consultancy Limited - YouTube

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

Tags

  • P1014
  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