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

Cancel a sub program and back to my main routine

  • ruitorres
  • February 13, 2024 at 6:41 PM
  • Thread is Resolved
  • ruitorres
    Trophies
    1
    Posts
    7
    • February 13, 2024 at 6:41 PM
    • #1

    Hi there!

    I ve a robot intalled on a machine, controlled by a PLC, and i noted that when we had a emergency stop the robot stops the movement, but when it back again the robot keep its move from the line that stopped. And this is very dangerous for the operator.

    I want that the robot goes back to my main, and after the acknwoleged the PLC will sent the new command.

    Example (code Below) :

    If im in the case 1 i will call the Station_Pick() func. and if i had an emergency stop, i will remove my flag I_Kuka_PLC_Start (FALSE) and remove the code pointer from the Station_Pick() and bring it again to my main().

    it is possible do this ?

    Obviously im not an expert in robots, i just want to reolve this situation on my machine. I will apreciate your help!

    THKS

    Quote

    DEF Main ( )

    GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )


    INTERRUPT ON 3


    BAS (#INITMOV,0 )


    ;FOLD PTP HOME Vel=100 % DEFAULT;%{PE}%R 8.5.19,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT, 9:0


    $BWDSTART=FALSE


    PDAT_ACT=PDEFAULT


    FDAT_ACT=FHOME


    BAS(#PTP_PARAMS,100)


    SET_CD_PARAMS( 0)


    $H_POS=XHOME


    PTP XHOME


    ;ENDFOLD

    LOOP


    IF ( I_Kuka_PLC_Start ) THEN

    SWITCH Kuka_Command

    CASE 0

    Execute_State_mirror = 0

    CASE 1

    Execute_State_mirror = 1

    Station_pick ( )

    Execute_State_mirror = 0

    Case 4

    Execute_State_mirror = 4

    Setup ( )

    Execute_State_mirror = 0


    DEFAULT

    MsgQuit("Numero de programa invalido")


    HALT


    ENDSWITCH

    ENDIF


     ENDLOOP

  • Fubini February 13, 2024 at 6:47 PM

    Approved the thread.
  • SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,426
    • February 13, 2024 at 9:19 PM
    • #2
    Post

    RE: Reset KUKA robot with E-Stop

    (Code, 33 lines)

    The CWRITE to the $CMD channel in the SPS can perform STOP, CANCEL, and RUN operations on the Robot Interpreter. Use of these commands needs to be carefully managed with the $PRO_STATE1 variable to ensure each command is only fired once, and in proper sequence, instead of "hammering" the command repeatedly.

    In the above example, the user inputs I_PROG_STOP and I_PROG_RESET could stop the program, or Cancel it and then call the program ROBOT() (this can be replaced with whatever…
    SkyeFire
    December 14, 2023 at 9:40 PM
    Quote from ruitorres

    but when it back again the robot keep its move from the line that stopped. And this is very dangerous for the operator.

    How is the operator close enough to the robot to be in danger?

  • Online
    panic mode
    Reactions Received
    1,280
    Trophies
    11
    Posts
    13,080
    • February 13, 2024 at 9:20 PM
    • #3

    that is not simple... you need someone experienced with KUKA to make the change.

    aborting subprogram is done with an interrupt and RESUME. that is the easy part.

    getting robot back to home position SAFELY is more involved and process dependent...

    one need to consider state of grippers etc. and send robot back safely. this involves bunch of comparisons etc.

    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

  • ruitorres
    Trophies
    1
    Posts
    7
    • February 14, 2024 at 11:17 AM
    • #4
    Quote from SkyeFire
    Post

    RE: Reset KUKA robot with E-Stop

    (Code, 33 lines)

    The CWRITE to the $CMD channel in the SPS can perform STOP, CANCEL, and RUN operations on the Robot Interpreter. Use of these commands needs to be carefully managed with the $PRO_STATE1 variable to ensure each command is only fired once, and in proper sequence, instead of "hammering" the command repeatedly.

    In the above example, the user inputs I_PROG_STOP and I_PROG_RESET could stop the program, or Cancel it and then call the program ROBOT() (this can be replaced with whatever…
    SkyeFire
    December 14, 2023 at 9:40 PM

    How is the operator close enough to the robot to be in danger?

    skyeFyre it could be a unexpected movement to the operator.

    In the code that you sent i could call any function ?

    CWRITE($CMD,STAT,MODE,"RUN /R1/ROBOT()")

    instead robot() i could call a fucntion that will do always a safe movement to home ?

  • ruitorres
    Trophies
    1
    Posts
    7
    • February 14, 2024 at 11:33 AM
    • #5
    Quote from panic mode

    that is not simple... you need someone experienced with KUKA to make the change.

    aborting subprogram is done with an interrupt and RESUME. that is the easy part.

    getting robot back to home position SAFETLY is more involved and process dependent...

    one need to consider state of grippers etc. and send robot back safely. this involves bunch of comparisons

    Panic mode, i a litle bit confused about this interrupt.

    Quote

    def mainprogram()
    ; GLOBAL INTERRUPT DECL 1 WHEN INPUT_HOMERUN==TRUE DO restart ( )
    INTERRUPT DECL 1 WHEN INPUT_HOMERUN==TRUE DO restart ( )
    interrupt off 1


    loop
    mainloop()
    interrupt off 1
    endloop
    end ; of mainprogram()

    Def mainloop() ; Move to home according to actual position
    movetohome()
    loop
    interrupt on 1 ; !!!!!
    ; make jobs here
    ; this is what cell does normally
    ; ....
    endloop
    end ; of mainloop()


    Global DEF restart ()
    brake
    interrupt off 1
    wait sec 1
    resume
    end

    Display More

    when we had Input_Homerun == true we call Restart and after ? how i call the home return and make turn off the interrupt?

  • mR.PCX
    Reactions Received
    4
    Trophies
    3
    Posts
    29
    • February 14, 2024 at 11:46 AM
    • #6

    You need to create a specific "AutoHome" program before get back to your Main program.

    For exemple, you have an E-stop, you need to known first where your robot is (tracker ID, register, bit of work area...). In this case you abort the current program, go to the Autohome (the robot go back to home ont a safety path) and you can go back to your Main program after.

    You need to separate the programmation of the normal cycle and the fault cases.

    It could be long to write this program (welcome in robotic world) but if you need to manage this fault case in automatic mode you don't have choice.

  • ruitorres
    Trophies
    1
    Posts
    7
    • February 14, 2024 at 1:49 PM
    • #7
    Code
    DEF Main ( )
    
        GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
        GLOBAL INTERRUPT DECL 5 WHEN $Estop ==TRUE DO ResetEStop( )
        INTERRUPT ON 3 
     
    PTP XHOME 
    
       LOOP
    
    IF  ( I_Kuka_PLC_Start ) THEN
    
    INTERRUPT ON 5
       
          SWITCH Kuka_Command
             CASE 0 
                Execute_State_mirror = 0
             CASE 1
                Execute_State_mirror = 1
                Station_pick ( )
                Execute_State_mirror = 0
             CASE 2
                Execute_State_mirror = 2
                Station_Unload_ok ( )
                Execute_State_mirror = 0
             DEFAULT
                MsgQuit("Numero de programa invalido")
                HALT
          ENDSWITCH
     ENDIF
     ENDLOOP 
     END
     
    
     Global DEF ResetEstop()
     Interrupt off 5
     BRAKE
     RESUME
     
     END
    Display More

    Could this interrupt work ??

    if im running one of the sub functions in my switch case, ex. StationPick (), as i had activated the interrupt before, if ESTOP == true, the stationPick is canceled and the pointer goes to ResetEstop.

    And the resume inside of the resete stop put the pointer again in my main loop waiting to I_Kuka_PLC_Start?

    thank you very much Guys!

  • SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,426
    • February 14, 2024 at 2:42 PM
    • #8
    Quote from ruitorres

    skyeFyre it could be a unexpected movement to the operator.

    If the robot is able to come into contact with the operator by moving "unexpectedly", the safety design of this work cell is incomplete.

    Quote from ruitorres

    In the code that you sent i could call any function ?

    CWRITE($CMD,STAT,MODE,"RUN /R1/ROBOT()")

    instead robot() i could call a fucntion that will do always a safe movement to home ?

    Yes, anything you like. Most often, we choose CELL, and then have CELL programmed to perform some kind of smart, careful auto-homing.

    Keep in mind, the normal behavior of a robot after an E-Stop is to resume the interrupted program. What you are proposing to do here is to break that. If you use the CANCEL function, you are erasing all the robot's memory of what program(s) it was running, and where it going. That means that it is now incumbent upon you to build an auto-homing program that can find a safe path from anywhere in the working volume, back to Home position. Depending on your cell layout, this can become extremely complicated very quickly.

  • Online
    panic mode
    Reactions Received
    1,280
    Trophies
    11
    Posts
    13,080
    • February 14, 2024 at 3:18 PM
    • #9

    That interrupt will not work. Cannot use resume with global interrupt. Cannot have resume with the switch statement at the same level as interrupt declaration, this must be moved to a subprogram and have advance run stop at the end of the sub.

    That was the easy part and you can find examples if you search for previous discussions about RESUME.

    The harder part is automatic homing.

    Both are advanced topics and likely to lead to crash if not done carefully

    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

  • ruitorres
    Trophies
    1
    Posts
    7
    • February 14, 2024 at 4:10 PM
    • #10

    Guys Thank you a lot.

    I´m trying to check wich options are easier.

    But it seems that both have the same issue... automatic homing.

    So..i will study both and will try create some automatic conditions to automatic home.

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

  • Motion stop

    • ALUCAST
    • July 8, 2020 at 11:26 AM
    • KUKA Robot Forum

Tags

  • robot
  • KUKA
  • main program
  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