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

Aborting the cell program and reloading it.

  • newuserpl123
  • May 8, 2025 at 10:07 AM
  • Thread is Unresolved
  • newuserpl123
    Posts
    2
    • May 8, 2025 at 10:07 AM
    • New
    • #1

    Good morning,
    I am interfacing a Kuka robot with a PLC. I would like to be able to restart the Cell program in case of an emergency or just want to start over. I would like to be able to restart the Cell program in case of an emergency or just want to start over. I have one solution that is based on an interrupt and it looks like this. I found in one topic that someone does it similarly and for him to work. Here's code for my solution. Please do not judge not using Kuka's PGNO mechanism to inflict programs. This is the universal standard of my company that we use to handle robots of different companies.

    Quote

    DEF CELL ( )

    INTERRUPT DECL 1 WHEN InSig_bRestart == TRUE DO CellInterrupt()
    INTERRUPT OFF 1
    WAIT SEC 0.012
    INTERRUPT ON 1
    WAIT SEC 0.012
        
    labelStartMain:
       
    MainCell()
       
       GOTO labelStartMain
       
    END

    DEF MainCell()
    labelStart:
       
    IF InSig_bExecute THEN
          
    SWITCH InSig_nActionNumber ; Select with Programnumber
             
    CASE 10
    P10_BaseCheck()
                
    CASE 20
    P20_ClampsCheck()
                
    CASE 30
    P30_Welding()
                
    CASE 40
    P40_Cleaning()   
                
    CASE 100
    P100_Homing()
                
    CASE 110
    P110_ServicePos()   
                
    CASE 120
    P120_DisassemblyPos()
                
    CASE 130
    P130_TcpCheckPos()
                
    CASE 140
    P140_VisionCheck()  
                
    CASE 150
    P150_Cleaning()      
                
    DEFAULT
                GOTO labelEnd
                
    ENDSWITCH
          
    WAIT FOR InSig_bExecute==FALSE
    OutSig_nActionNumber = 0
          
    labelEnd:
          
    ENDIF
       
    OutSig_bDone = FALSE
    OutSig_bBusy = FALSE
    OutSig_nActionNumber = 0
       
    WAIT SEC 0
          
       GOTO labelStart

    END


    GLOBAL DEF CellInterrupt()
    INTERRUPT OFF 1
       BRAKE
    INTERRUPT ON 1
    WAIT SEC 0.1
       RESUME
    END

    Display More

    This solution works very well when the robot is in some sub program such as p10. It restarts the program and I can start working again. But only when we have MoveEnable signals etc. given, that is, the robot is in external automation mode. But what if I don't have these signals. There is a situation that the automatic mode of the machine from the PLC level is turned off which means the robot, also does not have the automatic on. I want to be able to restart Cell when I don't have MoveEnable, ExtStart etc signals. How to make the interrupt active when the robot is not running? Maybe the MoveEnable signal alone without DrivesOn and ExtStart is enough? Is the only option left is to restart the program from SPS with CWRITE commands(STOP>CANCEL>RUN)?

    Code
     ;Restart cell.src
     IF InSig_bRestart AND NOT sps_bRestart THEN
    	sps_bRestart = TRUE
     ENDIF
     IF NOT InSig_bRestart THEN
    	sps_bEndRestartSeq = FALSE
     ENDIF         
     IF sps_bRestart AND NOT sps_bEndRestartSeq THEN
    	CWRITE($CMD,s,m,"STOP 1")
    	WAIT SEC 0.1
    	CWRITE($CMD,s,m,"CANCEL 1")
    	WAIT SEC 0.1
    	CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()")
    	WAIT SEC 0.1
    	sps_bRestart = FALSE
    	sps_bEndRestartSeq = TRUE            
     ENDIF
    Display More

    I'm testing this in KukaSIM, but it doesn't work. The simulation stops after a stop, and further when I start it again, the Cell does not restart and the program continues.

    Edited 2 times, last by newuserpl123 (May 8, 2025 at 11:26 AM).

  • Fubini May 8, 2025 at 11:17 AM

    Approved the thread.
  • Online
    Leon
    Reactions Received
    32
    Trophies
    5
    Posts
    463
    • May 9, 2025 at 4:14 PM
    • New
    • #2
    Quote from newuserpl123

    I want to be able to restart Cell when I don't have MoveEnable, ExtStart etc signals.

    Not possible, MoveEnable,DrivesOn and Extstart are necessary to be able to start.

    Quote from newuserpl123

    the Cell does not restart and the program continues.

    which program continues if cell is stopped? How is cell stopped? why isn't it looping and waiting for commands from the PLC?


    Quote from newuserpl123

    Is the only option left is to restart the program from SPS with CWRITE commands(STOP>CANCEL>RUN)?

    It is possible, the question is it necessary? If have been through your post several times and i have still trouble understanding what happened to the robot that you have to restart Cell.


    Also it would be nice if you mention what type of controller you are working with (KRC2,KRC4 or KRC5) with the KSS version as stated in the "Read first" topic.

    Every problem has a solution, that isn't the problem. The problem is the solution.

  • Online
    panic mode
    Reactions Received
    1,262
    Trophies
    11
    Posts
    13,026
    • May 9, 2025 at 6:10 PM
    • New
    • #3

    "This solution works very well when the robot is in some sub program such as p10."
    This 'solution' is done by someone not concerned with things like cost, downtime, collisions... There is ZERO validation if called program number is really correct. in other words this is a time bomb. single corrupt bit or loose I/O wire can result in calling wrong program and when that happes it will be a big and expensive mess. sure it works now but give it time...

    "It restarts the program and I can start working again."
    you mean robot can continue working.

    "But only when we have MoveEnable signals etc. given, that is, the robot is in external automation mode. But what if I don't have these signals."
    MoveEnable is there for a reason... and only ONE reason ... quick and uncomplicated stop of the robot when PLC has detected problem that is not handled so the safest options is to stop the robot. Actual use depends on application. Normally i would have PLC turn move enable if robot is in correct mode (EXT or T1) plus whatever conditions are met for each of selected modes. If really needed, one can tailor PLC program and also allow operation in AUT mode. this is not common for cells that are meant to run in EXT mode but hey, anyone can do what works for them.

    "There is a situation that the automatic mode of the machine from the PLC level is turned off which means the robot, also does not have the automatic on."
    So...?

    "I want to be able to restart Cell when I don't have MoveEnable, ExtStart etc signals."
    What do you mean by "restart Cell"? robot program CANNOT run when move enable is false - that is by design. If you want to be able to select and run CELL (or whatever program) in other modes, you need to evaluate application needs and adapt PLC code, because that is what controls move enable. one common case is use of T1 to test and modify programs so normally move enable SHOULD be true when robot is in T1 mode.

    "How to make the interrupt active when the robot is not running? Maybe the MoveEnable signal alone without DrivesOn and ExtStart is enough?"
    Someone wrestling with basic things like move enable, Drives on etc is not qualified to PROGRAM robots... And certainly should NOT be allowed to mess with advanced concepts such as use of interrupts.

    "Is the only option left is to restart the program from SPS with CWRITE commands(STOP>CANCEL>RUN)?"
    No it is not. One of the options is to manually select the program. in fact standard CELL.SRC that KUKA supplies in form of a template is meant for just that - manually select and start CELL program until robot is at home and BCO is done, THEN change mode to EXT and let PLC take over. and once it runs it should NEVER need deselecting of CELL.src. what kind of "emergency situations" you are running into that require reseleting of your CELL?

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • newuserpl123
    Posts
    2
    • May 9, 2025 at 7:49 PM
    • New
    • #4

    Thank you all for you answers.

    Quote from Leon

    Not possible, MoveEnable,DrivesOn and Extstart are necessary to be able to start.

    Okay, I just needed confirmation that these signals needed to be there for the interrupt to work. I was hoping there was a chance that this interrupt could work "somehow in the background".

    Quote from Leon

    which program continues if cell is stopped? How is cell stopped? why isn't it looping and waiting for commands from the PLC?

    I am testing my program in KukaSIM. I set the active program Cell.src and Submit SPS is running in the background. When I force RESTART simulating PLC. Sps responds to this, the STOP 1 command is executed and the simulation pauses. When I resume the simulation, the program lines in SPS fly through, i.e. CANCEL 1 and RUN CELL.src. But the simulation continues from the place where the STOP 1 command was triggered. The Cell.src program does not start from beginning and does not loop in this program waiting for the bExecute signal. It only continues to work in the program in which STOP 1 occurred, i.e. P10. Perhaps this is related to the fact that I am testing it in KukaSIM and not on a real controller or at least OfficeLite?

    Quote from Leon

    It is possible, the question is it necessary? If have been through your post several times and i have still trouble understanding what happened to the robot that you have to restart Cell.

    I think I have developed this issue above. After the unpause, the robot continues to work from the place where STOP 1 occurred.

    Quote from Leon

    Also it would be nice if you mention what type of controller you are working with (KRC2,KRC4 or KRC5) with the KSS version as stated in the "Read first" topic.

    Currently I don't have the robot with me yet, I'm preparing the entire project offline for now. But the controller will be KRC5 and I think it will be version KSS 8.7

    Quote from panic mode

    This 'solution' is done by someone not concerned with things like cost, downtime, collisions... There is ZERO validation if called program number is really correct. in other words this is a time bomb. single corrupt bit or loose I/O wire can result in calling wrong program and when that happes it will be a big and expensive mess. sure it works now but give it time...

    All of this is managed by the PLC controller. In our applications, it assigns the program to the robot based on many conditions. The robot in our applications is a regular tool, such as a servo drive. I give it a program number and a start command, and the robot, being in program P10, for example, returns number 10 to me, and I, on the PLC controller side, know about it. The robot executes the program and returns the DONE status to me and waits until I turn off the bExecute signal. Like an ordinary MoveAbsolute movement in a servo drive.

    Quote from panic mode

    you mean robot can continue working.

    Yes, I meant the robot. The Cell program is restarted/The program pointer is in Cell.src and not in the Subprogram and waits for a signal from the PLC controller which program should be executed again and the bExecute command.

    Quote from panic mode

    So...?

    The thing is that the interrupt solution won't work and I guess I have to handle it in SPS.

    Quote from panic mode

    What do you mean by "restart Cell"? robot program CANNOT run when move enable is false - that is by design. If you want to be able to select and run CELL (or whatever program) in other modes, you need to evaluate application needs and adapt PLC code, because that is what controls move enable. one common case is use of T1 to test and modify programs so normally move enable SHOULD be true when robot is in T1 mode.

    Sure, I understand, here I only meant to outline the situation in which I need to restart the Cell.src program, so that the program pointer loops and waits again for the program number from the PLC and the bExecute signal. I simply want the robot not to be in any subprogram after my restart, but for the Cell.src program to be loaded again. But without giving it the MoveEnable, DrivesOn and ExtStart signals. So everything then comes down to handling it in the SPS.

    Quote

    Someone wrestling with basic things like move enable, Drives on etc is not qualified to PROGRAM robots... And certainly should NOT be allowed to mess with advanced concepts such as use of interrupts.

    I will leave this without comment.

    Quote

    No it is not. One of the options is to manually select the program. in fact standard CELL.SRC that KUKA supplies in form of a template is meant for just that - manually select and start CELL program until robot is at home and BCO is done, THEN change mode to EXT and let PLC take over. and once it runs it should NEVER need deselecting of CELL.src. what kind of "emergency situations" you are running into that require reseleting of your CELL?

    This solution is not for me. I need to be able to remotely start the Cell.src program from beginning. I have several robots in my applications and I can't imagine going to the robot teachpedant/smartpad and selecting the Cell.src program on each one after a certain situation. For me, as a programmer responsible for starting the entire line, the robot is one of many subsystems that has to perform a task and return a signal that it has completed the task. Depending on the machine, the robot manufacturers often change and each robot has a different control, so please don't tell me that I shouldn't start programming robots because I've already started more than one. I just wanted to ask about certain issues, because everything happens differently on each robot.


    To sum up all my ramblings. I wanted to restart the Cell.src program - that is, for the robot to exit all sub-programs and the Cell.src program to load again with the program pointer in line 0. All this was to take place without giving the MoveEnable, DrivesOn, ExtStart signals. Only then does the superior PLC controller start the automatic cycle of the entire machine and the robot receives the MoveEnable > DrivesOn > ExtStart signals accordingly. And only then does the PLC controller give it the program number to execute and the bExecute signal to start for example program P10. And I wanted to get confirmation whether doing this from the SPS level with the commands: STOP 1, CANCEL 1 and RUN Cell.src will achieve this. And additionally, get the answer that testing this in KukaSIM has certain limitations and it may not work entirely.

    Edited once, last by newuserpl123 (May 9, 2025 at 7:57 PM).

  • Online
    panic mode
    Reactions Received
    1,262
    Trophies
    11
    Posts
    13,026
    • May 10, 2025 at 2:26 AM
    • New
    • #5
    Quote

    I give it (robot) a program number and a start command, and the robot, being in program P10, for example, returns number 10 to me, and I, on the PLC controller side, know about it. The robot executes the program and returns the DONE status to me and waits until I turn off the bExecute signal.


    without verification any start command will make robot run whatever subprogram number robot sees that it should run. if the value is corrupted for some reason you may tell robot run program 10, and send start. but that 10 may become something else. in case of single bit error, that could be 8, 2, 11,14... but nobody says that corruption is to be limited to single bit. so based on what is see. robot will run that subprogram and tell you that it is running something else. and PLC will get to know that but depending on - it may be too late. which is why verification of program number is used. as i don't see it, i think it you may want to be aware of that. i don't really care if that is done or not.

    Quote

    I wanted to restart the Cell.src program - that is, for the robot to exit all sub-programs and the Cell.src program to load again with the program pointer in line 0. All this was to take place without giving the MoveEnable, DrivesOn, ExtStart signals.

    ....

    I have several robots in my applications and I can't imagine going to the robot teachpedant/smartpad and selecting the Cell.src program on each one after a certain situation. For me, as a programmer responsible for starting the entire line, the robot is one of many subsystems that has to perform a task and return a signal that it has completed the task.

    the saying goes that one need to learn to walk before being able to run. managing line of robots is more demanding than managing single robot. than it would benefit you to understand how Kuka handshake with higher level controller (PLC) is done before you can implement own variant. and i don't mean "your personal" as this may be something you inherited and need to work with without doing too many changes. this should be used as opportunity to request bosses to send you for some KUKA training.

    normally on startup robots are either already at home, or need to be homed manually or by program. also if some sort of "abort request" was received while robot is in the middle of some program, it is best to let that program navigate back to home position and end. ending subprogram simply puts you back into the main loop of the cell. i still see no explanation why cell.src need to be restarted instead of simply continue running loop but whatever...

    to get what you want involves replicating what KUKA normally does in cases like this (hence the template etc.). making own variant is fine as long as you are ready to tackle few things like getting robot home (and confirming that it is home before it is allowed to run some subprogram, see comments below in your program lines 22-24).

    the part you are missing (or trying to work around) is that some of the handshake signals must be used and how. don't fight it, work with it.

    have Submit detect mode change. and if mode was changed to EXT, check if selected program is CELL.SRC or not. if it is not, stop and cancel current robot program and select CELL.SRC, clear alarms, turn on drives, and - issue start. that will start CELL.SRC... like you want... and it will run from the first line, like you want. and now that robot program is running your interrupt works too...


    the NEXT part is actual selection of subprogram. this should of course be managed by PLC. and one of the things that PLC should do is reset program number, practically all the time... except the moment when calling some subprogram. once subprogram is called, program number should be reset again - preferably immediately (before or while the subprogram is starting).

    if during production robot is stopped for some reason (anything) and you wish to resume, PLC will still need to clear alarms, make sure move enable and drives are on... and how you proceed here depends on you. if safe to proceed (careful here) and you issue start, robot will continue running current subprogram. but maybe it is not safe to continue, maybe robot is moved by operator or programmer, etc. usually one would check if anyone entered cell, if robot is on or at least near programmed path and near return position, if BCO is required (program was deselected or robot was moved) etc.


    Code
    DEF CELL ( )
    
    INTERRUPT DECL 1 WHEN InSig_bRestart == TRUE DO CellInterrupt()
    INTERRUPT OFF 1
    WAIT SEC 0.012
    INTERRUPT ON 1
    WAIT SEC 0.012
        
    labelStartMain:
       
    MainCell()
       
       GOTO labelStartMain
       
    END
    
    DEF MainCell()
    labelStart:
       
    IF InSig_bExecute THEN
    
      ; This is a PROBLEM..! There is no check if robot is at home.
      ; if not at home, robot will run next subprogram and most likely crash.
      ; At the very least add here line of code such as:
      ; WAIT FOR $IN_HOME
        
    SWITCH InSig_nActionNumber ; Select with Programnumber
             
    CASE 10
    P10_BaseCheck()
                
    CASE 20
    P20_ClampsCheck()
                
    CASE 30
    P30_Welding()
                
    CASE 40
    P40_Cleaning()   
                
    CASE 100
    P100_Homing()
                
    CASE 110
    P110_ServicePos()   
                
    CASE 120
    P120_DisassemblyPos()
                
    CASE 130
    P130_TcpCheckPos()
                
    CASE 140
    P140_VisionCheck()  
                
    CASE 150
    P150_Cleaning()      
                
    DEFAULT
                GOTO labelEnd
                
    ENDSWITCH
          
    WAIT FOR InSig_bExecute==FALSE
    OutSig_nActionNumber = 0
          
    labelEnd:
          
    ENDIF
       
    OutSig_bDone = FALSE
    OutSig_bBusy = FALSE
    OutSig_nActionNumber = 0
       
    WAIT SEC 0
          
       GOTO labelStart
    
    END
    
    
    GLOBAL DEF CellInterrupt()
    INTERRUPT OFF 1
       BRAKE
    INTERRUPT ON 1
    WAIT SEC 0.1
       RESUME
    END
    Display More

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

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