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

Problem with the loop of autostart.pc

  • Robotic_90382
  • April 4, 2025 at 10:16 AM
  • Thread is Resolved
  • Robotic_90382
    Reactions Received
    4
    Posts
    19
    • April 4, 2025 at 10:16 AM
    • #1

    Hi everyone, i'm trying to do a structure of autostarts where autostart5.pc is the main pc program that gets activated when the robot turns on, autostart5.pc checks if autostart2.pc is on, if not it turns it on. (pc2 does the same with the 3rd)

    In all others autostart i check if autostart5.pc is on if not i turn it on.

    This way if an autostart is aborted it gets immediately executed by another and you can oly stop them all togheter.

    I'd like to use these autostart to check alarms and errors.

    The problem is they stops and wait when they reach the line "TWAIT 0.1" (i use this timer for the load on the CPU).

    i'll leave you the images with the code and the terminal with the statuses of the pc programs.

    Any tips would be helpful


    (p.s.)

    i tried to insert a print to see if it was looping but it doesn't print

    Images

    • Immagine 2025-04-04 094938.png
      • 147.36 kB
      • 341 × 827
      • 9
    • Immagine 2025-04-04 095037.png
      • 81.71 kB
      • 438 × 582
      • 4
  • Go to Best Answer
  • Alexandru
    Reactions Received
    49
    Trophies
    6
    Posts
    407
    • April 4, 2025 at 12:22 PM
    • #2

    Hi,

    AUTOSTART.PC programs must be ON if you want to use it.

    You can use this kind of syntax if you want to check if the autostart programs are running or not, but is the same like in the picture.

    IF TASK(1002)<>1 THEN
    PCABORT 2:
    PCEX 2: pc2
    END

  • Robotic_90382
    Reactions Received
    4
    Posts
    19
    • April 4, 2025 at 12:49 PM
    • #3

    Hi alexandru, thank you for the answer but i don't think they need to be on...

    i did a very simple new program in wich i execute autostart1 from terminal the first time and then it will always be on when i turn on the robot, then it will execute 2,3....

    This new program works fine but i dint put the "TWAIT 0.1"

    Images

    • Immagine 2025-04-04 124538.png
      • 80.74 kB
      • 358 × 636
      • 4
  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • April 4, 2025 at 1:11 PM
    • Best Answer
    • #4

    PC Tasks and managing them is not the easiest thing to achieve and can be a very frustrating journey..........:censored:

    PRINT commands fall into this category as PRINT requires a device to send it to as that is it's purpose really, not locally.
    Check out the PRINT command in the AS manual for further information on this.

    If you locally PCEXE the PC Task, then you can get it to print locally.
    If you are connected to a live controller, then I think from memory, you need to set PRINT as PRINT 3:

    Only advice I can give is avoid the PRINT.
    Instead set a string window on the IFP of the teach pendant and use IFPWPRINT but only use IFPWPRINT when a change occurs and not constantly as it can hog resources.

    Regarding the management of PC Tasks, many ways can be done but fundamentally you always need the master running in order to monitor and restart other tasks, so it is better to just have that master doing that and nothing else - similar to what you've posted above.

    I use a very different method that allows PC2 to start up on initial start of PC1 if it's not running after 1 sec has elapsed.
    Then if PC2 turns off, it restarts and also I can independently turn off PC2 to debug it without PC1 firing it back up again.

    Code
    .PROGRAM pc1();
    ;========================================================================
    ;
      RUNMASK 2001,2;		set int sig as runmask
      SIGNAL 2001;			turn on the signal
      UTIMER @ut.wtchdog = 0; 	define and set user timer
    ;
    again:
    ;
      IF (SIG(2001)==TRUE) THEN;
    ;
        IF ((TASK(1002)<>1 AND UTIMER(@ut.wtchdog)>1 AND SWITCH(ERROR )==FALSE)) OR (SIG(2003)==TRUE) THEN;
          PCABORT 2: 
          MC PCKILL 2:
          IF (SIG(2003)==FALSE) THEN;
            PCEXECUTE 2: pc2;
            UTIMER @ut.wtchdog = 0;
          END;
        END;
    ;
        TWAIT 0.016;
        GOTO again;
      ELSE;
        GOTO eof;
      END;
    ;
    eof:
    ;
      PCABORT 2:
      MC PCKILL 2:
    ;
    ;========================================================================
    .END
    
    
    .PROGRAM pc2();
    ;========================================================================
    ;
      SIGNAL 2002;			turn on the signal
    ;
    again:
    ;
      IF (SIG(2002)==TRUE) THEN;
        TWAIT 0.016;
        GOTO again;
      ELSE;
        GOTO eof;
      END;
    ;
    eof:
    ;
    ;========================================================================
    .END
    Display More

    Have a play with it and see if you can use it.

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • Robotic_90382 April 4, 2025 at 2:02 PM

    Selected a post as the best answer.
  • Robotic_90382
    Reactions Received
    4
    Posts
    19
    • April 4, 2025 at 2:04 PM
    • #5

    Hi kwakisaki thank you for the answer, i'll definetly try that variant!

    One thing i still can't understand is why with a TWAIT it stops running....

    Thanks for everything else:thumbs_up:

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • April 4, 2025 at 2:21 PM
    • #6
    Quote from Giacomo Pellegrini

    One thing i still can't understand is why with a TWAIT it stops running....

    It shows waiting, so if your conditions return false than it's just constantly scanning through executing TWAIT isn't it?

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • April 4, 2025 at 2:23 PM
    • #7

    I'll post a little demo of my variant in action later today.

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • Robotic_90382
    Reactions Received
    4
    Posts
    19
    • April 4, 2025 at 2:55 PM
    • #8
    Quote from kwakisaki

    It shows waiting, so if your conditions return false than it's just constantly scanning through executing TWAIT isn't it?

    Yes i'm sorry... my head is all over the place :sleeping_face:

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • April 4, 2025 at 5:43 PM
    • #9
    Quote from Giacomo Pellegrini

    Yes i'm sorry... my head is all over the place

    Lol.......We've all been there.
    I myself am a regular customer of Mrs face palmer, she's knows me very well indeed.

    Attached is the video of it in action using 3 PC Tasks, one as the 'master' waking the others up, restarting them if they stop, stopping them all and clearing them down from the stack but not restarting them if I am wanting to debug them instead.

    I like this method as it gives plenty of scope and works and you can just have 1 task like wdog.pc in my demo JUST doing that monitoring and control, therefore it will never stop or fail.

    PCTask Management.mp4

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • Robotic_90382
    Reactions Received
    4
    Posts
    19
    • April 4, 2025 at 5:57 PM
    • #10

    Very helpful, thank you kwakisaki...:grinning_squinting_face:

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • April 4, 2025 at 6:07 PM
    • #11

    You're welcome......:top:

    It's quite common actually, I think KRG (Kawasaki Germany) have a similar variant.
    All depends on what you intend it for really, it may not suit your purpose but gives you an idea and hopes it helps towards your end target.

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • ShAdOwDrAgOnS
    Reactions Received
    37
    Trophies
    3
    Posts
    64
    • April 16, 2025 at 6:20 AM
    • New
    • #12

    Instead of trying to use TWAIT in your autostarts, have a look at PCSCAN to reduce the CPU load.



    Having said that I take a completely different approach to Autostarts.

    I always leave slot 1 open so it's easy to run any stand along programs manually without having to specify which slot it needs to run in.

    I have a watchdog timer that Prints out a message if any of the autostarts takes longer than a certain threshold to execute a single scan so that you can easily see if something in your code starts hogging all the CPU time or if anything falls into and infinite loop.

    Be careful with prints as they holdup program execution until the message is printed. You can see this easily if you make a motion loop and add a bunch of print statements everywhere and monitor the cycle time. Then comment out all the prints and check the cycle time again.

    Generally in PC programs the loop continuously never use TWAIT or PRINTS or anything that will hold up the code execution within the loop.

    Autostart 2 Is used for TCP/IP comms. Medium priority

    Autostart 3 Is for data mapping to/from PLC and Faults . Medium priority like 100ms

    Autostart 4 has very little code and on the highest priority 40ms for storing accurate locations on and interrupt from the motion code.

    Autostart 5 is super low priority like second and used for Logging errors, rates etc.

  • Robotic_90382
    Reactions Received
    4
    Posts
    19
    • April 16, 2025 at 9:27 AM
    • New
    • #13

    thank you for the answer!

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