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
  5. Manuals, Software and Tools for KUKA Robots
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

Interrupt Example

  • SkyeFire
  • March 18, 2021 at 8:25 PM
  • Thread is Unresolved
  • Online
    SkyeFire
    Reactions Received
    1,039
    Trophies
    12
    Posts
    9,380
    • March 18, 2021 at 8:25 PM
    • #1

    There have been a lot of redundant questions about Interrupt handling lately, so I decided to make a heavily-commented example file that should (Hopefully!) point people with the same questions to as a starting point.

    I don't have a KRC handy to test this on, though, so I can't guarantee I haven't missed something subtle here.

    Code
    &ACCESS RVO1
    &COMMENT 
    DEF InterruptExample ( )
      ;FOLD INI
      ;FOLD BASISTECH INI
      GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
      INTERRUPT ON 3 
      BAS (#INITMOV,0 )
      ;ENDFOLD (BASISTECH INI)
      ;FOLD USER INI
      ;Make your modifications here
      
      ;ENDFOLD (USER INI)
      ;ENDFOLD (INI)
      
      ;FOLD PTP HOME  Vel= 100 % DEFAULT;%{PE}%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
      $BWDSTART = FALSE
      PDAT_ACT=PDEFAULT
      FDAT_ACT=FHOME
      BAS (#PTP_PARAMS,100 )
      $H_POS=XHOME
      PTP  XHOME
      ;ENDFOLD
      
      ;=============================================================================
      ; First example:  Perform search motion and stop when the interrupt is tripped
      
      ; Set up Interrupt condition
      ; Interrupt will only fire when $IN[1] changes from False to True
      INTERRUPT DECL 10 WHEN $IN[1] DO SearchAndStopISR()
      
      ;FOLD PTP StartSearch  Vel=100 % PDAT1 Tool[0] Base[0];%{PE}%R 8.3.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:StartSearch, 3:, 5:100, 7:PDAT1
      $BWDSTART=FALSE
      PDAT_ACT=PPDAT1
      FDAT_ACT=FStartSearch
      BAS(#PTP_PARAMS,100)
      PTP XStartSearch 
      ;ENDFOLD
      
      ; execute motion during which Interrupt is expected  
      SearchAndStop()
      ; The program pointer will jump back to this line
      ;when the RESUME command in SearchAndStopISR executes
      ; That is because the INTERRUPT DECL is in this subroutine
      
      ; Move to where the robot was when the Interrupt fired
      ; This can be used to "fix" the robot's stopping distance
      IF Interrupted THEN
        LIN $POS_INT
      ELSE
        MsgNotify("No Interrupt during Search motion")
      ENDIF
      ;============================================================================
      
      ; Second Example:  Multiple interrupts WITHOUT stopping motion
      ; This could be used to measure a hole with a laser sensor by
      ;"dragging" the laser across the hole
      
      ; Set up Interrupt -- 10 on the False-to-True change of $IN[1],
      ; 11 on the True-to-False transition
      ; Note the re-use of Interrupt 10 -- an interrupt number can be "recycled" by
      ;re-DECLing it
      INTERRUPT DECL 10 WHEN $IN[1] DO RecordFirstEdgeISR() ; when laser "falls into" hole
      INTERRUPT DECL 11 WHEN NOT $IN[1] DO RecordSecondEdgeISR() ; when laser "climbs out" of hole
      
      ; position to start "dragging" the laser across the hole
      ;FOLD PTP HoleMeasureStart  Vel=100 % PDAT2 Tool[0] Base[0];%{PE}%R 8.3.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HoleMeasureStart, 3:, 5:100, 7:PDAT2
      $BWDSTART=FALSE
      PDAT_ACT=PPDAT2
      FDAT_ACT=FHoleMeasureStart
      BAS(#PTP_PARAMS,100)
      PTP XHoleMeasureStart 
      ;ENDFOLD
      
      ; Call the subroutine that will be interrupted
      SearchWithoutStopping()    
      
      ;===============================================================================
      
      ; Third example:  Stop and continue
      ; In this example, the Interrupt *pauses* the motion, but does not cancel it
      ; This example also uses a $CYCFLAG to allow the Interrupt to be fired
      ;by a complex Boolean expression
      
      ; CYCFLAG updates "live" in the background
      $CYCFLAG[1] = ($IN[1] AND NOT $IN[2]) OR $IN[3]
      
      ; Interrupt condition and action
      INTERRUPT DECL 10 WHEN $CYCFLAG[1] DO StopAndGoISR()
      
      ;FOLD PTP StopAndGoStart  Vel=100 % PDAT3 Tool[0] Base[0];%{PE}%R 8.3.22,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:StopAndGoStart, 3:, 5:100, 7:PDAT3
      $BWDSTART=FALSE
      PDAT_ACT=PPDAT3
      FDAT_ACT=FStopAndGoStart
      BAS(#PTP_PARAMS,100)
      PTP XStopAndGoStart 
      ;ENDFOLD
      
      ; Subroutine to be interrupted
      StopAndGoMove()  
      
      ;FOLD PTP HOME  Vel= 100 % DEFAULT;%{PE}%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
      $BWDSTART = FALSE
      PDAT_ACT=PDEFAULT
      FDAT_ACT=FHOME
      BAS (#PTP_PARAMS,100 )
      $H_POS=XHOME
      PTP  XHOME
      ;ENDFOLD
      
    END
    DEF SearchAndStop()
      ; This subroutine should only contain the motion that is expected to be interrupted
      
      ; arm the interrupt
      ; receiving the input before this will have no effect
      INTERRUPT ON 10
      
      ; .DAT file variable to indicate if interrupt fired
      ; not necessary, but handy  
      Interrupted = FALSE 
      
      ;FOLD LIN SearchEnd  Vel=2 m/s CPDAT1 Tool[0] Base[0];%{PE}%R 8.3.22,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:SearchEnd, 3:, 5:2, 7:CPDAT1
      $BWDSTART=FALSE
      LDAT_ACT=LCPDAT1
      FDAT_ACT=FSearchEnd
      BAS(#CP_PARAMS,2)
      LIN XSearchEnd 
      ;ENDFOLD
      
      ; If the interrupt fires, no code below this line will execute
      ; due to the RESUME command in the ISR
      ; Instead, the RESUME command will "cancel" the rest of this subroutine
      ; and jump the program pointer back to one line after where this subroutine was called
      
      INTERRUPT OFF 10 ; always turn off the Interrupt as soon as it's no longer needed
      
      MsgNotify("Reached SearchEnd without triggering Interrupt")
      
      ; break Advance Run Pointer.
      ; This is needed to ensure the ARP does not 
      ;get back to the top level program before the interrupt fires
      WAIT SEC 0
      
    END
    DEF SearchAndStopISR()
      ; This routine is only called when the Interrupt fires
      
      ; this should always be first in any Interrupt Service Routine (ISR)
      ; to protect against double-firing the interrupt
      INTERRUPT OFF 10
      
      Interrupted = TRUE 
      
      ; Stops the robot physical motion.  
      ; The 'F' is optional, but makes the robot stop faster
      BRAKE F ;
      
      ; cancel the motion that was active when the Interrupt fired
      RESUME
      
    END
    DEF SearchWithoutStopping()
      
      ; Arm interrupts
      INTERRUPT ON 10
      INTERRUPT ON 11
      
      ; use these to check if edges were found
      FoundFirstEdge = FALSE
      FoundSecondEdge = FALSE
      
      ; move to be interrupted
      ;FOLD LIN HoleMeasureEnd  Vel=2 m/s CPDAT2 Tool[0] Base[0];%{PE}%R 8.3.22,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:HoleMeasureEnd, 3:, 5:2, 7:CPDAT2
      $BWDSTART=FALSE
      LDAT_ACT=LCPDAT2
      FDAT_ACT=FHoleMeasureEnd
      BAS(#CP_PARAMS,2)
      LIN XHoleMeasureEnd 
      ;ENDFOLD
      
      ; in case the ISRs did not fire
      ; this is an important safety net
      INTERRUPT OFF 10
      INTERRUPT OFF 11
      
      ; Check if both edges were found
      IF NOT FoundFirstEdge THEN
        MsgNotify("Did not find first edge!")
      ENDIF
      IF NOT FoundSecondEdge THEN
        MsgNotify("Did NOT find second edge!")
      ENDIF
      
      ; break Advance Run Pointer.
      ; This is needed to ensure the ARP does not 
      ;get back to the top level program before the interrupt fires
      WAIT SEC 0
      
    END
    DEF RecordFirstEdgeISR()
      ; This routine is only called when the Interrupt fires
      ; without a BRAKE command, the robot will not stop!
      ; without a RESUME command, the active motion will complete normally!
      
      ; this should always be first in any Interrupt Service Routine (ISR)
      ; to protect against double-firing the interrupt
      INTERRUPT OFF 10
      
      ; Record TCP position when iterrupt fired
      ; Robot DOES NOT STOP!
      FirstEdgePos = $POS_INT
      
      ; flag that edge was found
      FoundFirstEdge = TRUE ;
      
    END
    DEF RecoredPos2()
      ; This routine is only called when the Interrupt fires
      ; without a BRAKE command, the robot will not stop!
      ; without a RESUME command, the active motion will complete normally!
      
      ; this should always be first in any Interrupt Service Routine (ISR)
      ; to protect against double-firing the interrupt
      INTERRUPT OFF 11
      
      ; Record TCP position when iterrupt fired
      ; Robot DOES NOT STOP!
      SecondEdgePos = $POS_INT
      
      ; flag that edge was found
      FoundSecondEdge = TRUE
      
    END
    DEF StopAndGoMove()
      
      ; arm the interrupt
      ; receiving the input before this will have no effect
      INTERRUPT ON 10
      
      ; record if Interrupt fired
      Interrupted = FALSE
      
      ; An interrupt can be active for more than one motion, if need be
      ;FOLD LIN StopAndGoMid CONT Vel=2 m/s CPDAT4 Tool[0] Base[0];%{PE}%R 8.3.22,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:StopAndGoMid, 3:C_DIS C_DIS, 5:2, 7:CPDAT4
      $BWDSTART=FALSE
      LDAT_ACT=LCPDAT4
      FDAT_ACT=FStopAndGoMid
      BAS(#CP_PARAMS,2)
      LIN XStopAndGoMid C_DIS C_DIS
      ;ENDFOLD
      ;FOLD LIN StopAndGoEnd  Vel=2 m/s CPDAT3 Tool[0] Base[0];%{PE}%R 8.3.22,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:StopAndGoEnd, 3:, 5:2, 7:CPDAT3
      $BWDSTART=FALSE
      LDAT_ACT=LCPDAT3
      FDAT_ACT=FStopAndGoEnd
      BAS(#CP_PARAMS,2)
      LIN XStopAndGoEnd 
      ;ENDFOLD
      
      ; always make sure to disarm the interrupt after it's no longer needed
      INTERRUPT OFF 10
      
      IF NOT Interrupted THEN
        MsgNotify("No Interrupt during StopAndGo motion!")
      ENDIF
      
      ; break Advance Run Pointer.
      ; This is needed to ensure the ARP does not 
      ;get back to the top level program before the interrupt fires
      WAIT SEC 0
      
    END
    DEF StopAndGoISR()
      ; Interrupt Service Routine
      ; This ISR simply stops the robot temporarily,
      ;then lets the interrupted motion continue
      
      INTERRUPT OFF 10 ; disarm interrupt
        
      $OUT[1] = TRUE ; turn on output while motion is paused
      
      BRAKE ; bring the robot to a halt
      
      WAIT SEC 5 ; wait for 5 seconds
      
      $OUT[1] = FALSE ; turn output off as motion continues
      
      ; Re-arm interrupt
      ; This will allow the robot to be paused at multiple
      ;times during the StopAndGo motion
      INTERRUPT ON 10 
      
    END
    Display More
    Code
    ;&ACCESS RVO1
    &COMMENT 
    DEFDAT InterruptExample PUBLIC
    ;FOLD EXTERNAL DECLARATIONS;%{PE}%MKUKATPBASIS,%CEXT,%VCOMMON,%P
    ;FOLD BASISTECH EXT;%{PE}%MKUKATPBASIS,%CEXT,%VEXT,%P
    EXT  BAS (BAS_COMMAND  :IN,REAL  :IN )
    DECL INT SUCCESS
    ;ENDFOLD (BASISTECH EXT)
    ;FOLD USER EXT;%{E}%MKUKATPUSER,%CEXT,%VEXT,%P
    ;Make here your modifications
    
    ;ENDFOLD (USER EXT)
    ;ENDFOLD (EXTERNAL DECLERATIONS)
    
    DECL BOOL Interrupted = FALSE
    DECL BOOL FoundFirstEdge = FALSE
    DECL BOOL FoundSecondEdge = FALSE
    
    DECL E6POS FirstEdgePos = {X 0}
    DECL E6POS SecondEdgePos = {X 0}
    
    DECL BASIS_SUGG_T LAST_BASIS={POINT1[] "StopAndGoMid",POINT2[] "StopAndGoMid",CP_PARAMS[] "CPDAT4",PTP_PARAMS[] "PDAT3",CONT[] " ",CP_VEL[] "2",PTP_VEL[] "100",SYNC_PARAMS[] " ",SPL_NAME[] " "}
    DECL E6POS XStartSearch={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FStartSearch={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL PDAT PPDAT1={VEL 100,ACC 100,APO_DIST 100,APO_MODE #CPTP,GEAR_JERK 50}
    DECL E6POS XSearchEnd={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FSearchEnd={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL LDAT LCPDAT1={VEL 2,ACC 100,APO_DIST 100,APO_FAC 50,AXIS_VEL 100.0,AXIS_ACC 100.0,ORI_TYP #VAR,CIRC_TYP #BASE,JERK_FAC 50.0,GEAR_JERK 50.0,EXAX_IGN 0}
    
    
    DECL E6POS XHoleMeasureStart={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FHoleMeasureStart={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL PDAT PPDAT2={VEL 100,ACC 100,APO_DIST 100,APO_MODE #CPTP,GEAR_JERK 50}
    DECL E6POS XHoleMeasureE nd={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FHoleMeasureE nd={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL LDAT LCPDAT2={VEL 2,ACC 100,APO_DIST 100,APO_FAC 50,AXIS_VEL 100.0,AXIS_ACC 100.0,ORI_TYP #VAR,CIRC_TYP #BASE,JERK_FAC 50.0,GEAR_JERK 50.0,EXAX_IGN 0}
    DECL E6POS XHoleMeasureEnd={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FHoleMeasureEnd={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL E6POS XStopAndGoStart={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FStopAndGoStart={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL PDAT PPDAT3={VEL 100,ACC 100,APO_DIST 100,APO_MODE #CPTP,GEAR_JERK 50}
    DECL E6POS XStopAndGoEnd={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FStopAndGoEnd={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL LDAT LCPDAT3={VEL 2,ACC 100,APO_DIST 100,APO_FAC 50,AXIS_VEL 100.0,AXIS_ACC 100.0,ORI_TYP #VAR,CIRC_TYP #BASE,JERK_FAC 50.0,GEAR_JERK 50.0,EXAX_IGN 0}
    DECL E6POS XStopAndGoMid={X 0,Y 0,Z 0,A 0,B 0,C 0,S 0,T 0,E1 0,E2 0,E3 0,E4 0,E5 0,E6 0}
    DECL FDAT FStopAndGoMid={TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
    DECL LDAT LCPDAT4={VEL 2,ACC 100,APO_DIST 100,APO_FAC 50,AXIS_VEL 100.0,AXIS_ACC 100.0,ORI_TYP #VAR,CIRC_TYP #BASE,JERK_FAC 50.0,GEAR_JERK 50.0,EXAX_IGN 0}
    ENDDAT
    Display More
  • Go to Best Answer
  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • March 18, 2021 at 9:22 PM
    • #2

    line 136 should be moved directly after line 41.

    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

  • Online
    SkyeFire
    Reactions Received
    1,039
    Trophies
    12
    Posts
    9,380
    • March 19, 2021 at 2:40 PM
    • #3

    Hm... to avoid the ARP? I wanted the INTERRUPT OFF to follow immediately after the interruptable motion... maybe I should move the WAIT SEC 0 from 143 to 135?

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • March 19, 2021 at 2:53 PM
    • #4

    no, that should stay....

    the issue with 136 is that it would only be processed IF the interrupt is triggered... but if there was no trigger, interrupt would remain active even after program returns to line 42. and that is bad.... if for whatever reason that input get triggered after that line, bad things could happen. this is why programming interrupts requires good housekeeping:

    declare interrupt

    activate it

    use it

    deactivate it !!!

    this last part should be done unconditionally... regardless if it was triggered or not.

    the way example is structured, this would only happen IF interrupt was triggered and ISR was visited. this is something to be avoided, specially when RESUME was used.

    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

  • Online
    SkyeFire
    Reactions Received
    1,039
    Trophies
    12
    Posts
    9,380
    • March 19, 2021 at 3:05 PM
    • #5

    Hold on... Line 136 should only ever execute if the Interrupt doesn't trigger. If the Interrupt does trigger, the RESUME command at line 160 should jump the program pointer straight back to line 42, because everything in the stack below the level where the interrupt was DECL'd gets cancelled.

    Line 136 is my "cleanup" in the event that the Interrupt doesn't fire.

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • March 19, 2021 at 4:00 PM
    • #6

    ooops... you are right, i missed that there is another one inside SearchAndStopISR()

    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

  • Online
    SkyeFire
    Reactions Received
    1,039
    Trophies
    12
    Posts
    9,380
    • March 19, 2021 at 4:25 PM
    • #7

    No problem. Yeah, I try to always have INTERRUPT OFF as the first line of executable code in any of my ISRs.

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • March 19, 2021 at 5:54 PM
    • #8

    i am trying to change bad habit of skimming through volume of text and picking out details, specially when responding... :winking_face:

    btw. kudos for effort on such detailed example.

    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

  • Online
    SkyeFire
    Reactions Received
    1,039
    Trophies
    12
    Posts
    9,380
    • March 19, 2021 at 7:27 PM
    • #9
    Quote from panic mode

    i am trying to change bad habit of skimming through volume of text and picking out details, specially when responding... :winking_face:

    Well, I'm sure that I've never done that. :pfeif:

    Quote from panic mode

    btw. kudos for effort on such detailed example.

    :icon_redface:

  • davidina
    Reactions Received
    3
    Trophies
    3
    Posts
    95
    • March 22, 2021 at 5:48 PM
    • #10
    Quote from SkyeFire

    There have been a lot of redundant questions about Interrupt handling lately, so I decided to make a heavily-commented example file that should (Hopefully!) point people with the same questions to as a starting point.

    I don't have a KRC handy to test this on, though, so I can't guarantee I haven't missed something subtle here.

    Code
    &ACCESS RVO1
    &COMMENT 
    DEF InterruptExample ( )
    .....

    Thank you for this work!

  • DenisCa
    Reactions Received
    1
    Trophies
    2
    Posts
    38
    • July 1, 2021 at 10:38 PM
    • #11

    Hi,

    Is it good to use WAIT FOR TRUE instead of WAIT SEC 0 in a motion subroutine ?

    Thanks

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • July 2, 2021 at 12:29 AM
    • #12

    both accomplish the same thing - trigger single advance run stop. it comes to personal preference. some may feel that one is more descriptive than another.

    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

  • dogeautomate
    Reactions Received
    1
    Trophies
    2
    Posts
    4
    • July 19, 2021 at 3:41 PM
    • #13
    Quote from SkyeFire

    There have been a lot of redundant questions about Interrupt handling lately, so I decided to make a heavily-commented example file that should (Hopefully!) point people with the same questions to as a starting point.

    I don't have a KRC handy to test this on, though, so I can't guarantee I haven't missed something subtle here.

    Code

    SkyeFire to the rescue yet again with another awesome post :smiling_face: One day I will get my KUKA programming course, interrupt is probably in course two.
    Thank you all again i'm just lurking around here and trying to learn from all of you. Keep it up!

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • July 19, 2021 at 4:32 PM
    • #14

    that is correct...

    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

  • iiQKA
    Trophies
    2
    Posts
    31
    • December 9, 2021 at 11:15 PM
    • #15

    Fantastic resource, thanks SkyeFyre, if only more of KUKA's documentation had such intensive examples!

  • ChristianLiinHansen
    Reactions Received
    3
    Trophies
    2
    Posts
    37
    • December 30, 2021 at 8:02 PM
    • #16

    Hi panic mode and SkyeFire. First of all, thanks for your effort in trying to make KUKA ISR to a pretty easy topic...

    Well... I have spend almost the whole day on looking in the forum, and I am struggling with the error "Instruction $ADVANCE in interrupt inadmissible (Module: BAS Line: 154):

    So how it looks in the real world is like this:

    - The red cirlce indicates a sensor on the robots tool.
    - The blue circle indicates a mock-up with a tri-pod with cardboard sticking out, that is used as trigger for the ISR.

    I.e. when the robot starts its search towards the object, which is the mock-up in this example, I would like the robot to stop the movement and drive to home position.

    The things that is happening now is that, when the robot starts its seach path and gets to the triggering point, the interrupt is fired, but I get the prompt error of: Error KSSo1425 - Instruction $ADVANCE in interrupt inadmissible

    For quick overview, I have three positions:

    1) xstack1home. That is a position nearby.
    2) xstack1prep. That is the position, which the robot is in, in the attached left side picture.
    3) xstackCalib. That is the end search position, where the interrupt will happen between the xstack1prep and xstackCalib.


    As a last notice, I was not able to stop the interrupt at the tri-pod cardboard triggering point, unless I in the interrupt decl was using "WITH BRAKE". So if I remove this, the result is that the robot will move from start search position, i.e. xstack1prep to end search position, i.e. xstackCalib (and collide with the mockup) and then throw the error of $ADVANCE.

    Lastly, I am pretty sure that this is all about having in control where the advance run pointer is located. I have seen different attempts to "tame the lion/ARP", but I have tried WAIT FOR TRUE, WAIT 0.1, WAIT 0, $ADVANCE = 0, etc.

    Please notice, that I am using the $OUT[15-20] as pure debugging. Just for me to know if everything has carried out well.

    So I would really appreciate, if there is some clue out there. For reference, the systems information are:

    • Robot: KUKA KR50 R2100
    • Controller: KR C5 dualcabinet
    • KSS 8.7.2 HF3
    • HMI version: 8.7 B394
    • Kernel system version: KS V8.7.53394
    • WorkVisual V6.0.18_Build0748

      The code is below for the three modules, i.e.
      - TestISR.src --> Main program
      - SeachForStacks --> Submodule with starts the seach motion and awaits that the interrupt is fired.
      - ISR_StackIsFound --> The interrupt service rutine, ISR.
    Code: TestISR.src
    &ACCESS RVP
    &REL 1
    &PARAM EDITMASK = *
    &PARAM TEMPLATE = C:\KRC\Roboter\Template\vorgabe
    &PARAM DISKPATH = KRC:\R1\Program
    DEF TestISR( )
    DECL REAL toolValue
    ;FOLD INI;%{PE}
      ;FOLD BASISTECH INI
        GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
        INTERRUPT ON 3 
        BAS (#INITMOV,0 )
      ;ENDFOLD (BASISTECH INI)
      ;FOLD USER INI
        ;Make your modifications here
        
        ;Just some debugging outputs signal to monitoring the program
        $OUT[15] = FALSE
        $OUT[16] = FALSE
        $OUT[17] = FALSE
        $OUT[18] = FALSE
        $OUT[19] = FALSE
        $OUT[20] = FALSE
        toolValue = $ANIN[1]
    
      ;ENDFOLD (USER INI)
    ;ENDFOLD (INI)
    
    ; Using the cycle flag to check the analog input. The value is without stack equal to 10.0, but the program sees it as 1.0.
    ; Therefore the values is between 0.0 and 1.0. If the value is equal to 1.0, there is no stacks. 
    $CYCFLAG[1]= ($ANIN[1] < 1.0)
    
    ;// Interrupt instruction -- Using the WITH BRAKE in in oreder to stop the break function right away.
    INTERRUPT WITH BRAKE DECL 21 WHEN $CYCFLAG[1] DO ISR_StackIsFound()
    
    ;FOLD SPTP stack1home Vel=100 % PDAT1 Tool[2]:ForkNew Base[4]:EUpalletNEW ;%{PE}
    ;FOLD Parameters ;%{h}
    ;Params IlfProvider=kukaroboter.basistech.inlineforms.movement.spline; Kuka.IsGlobalPoint=False; Kuka.PointName=stack1home; Kuka.BlendingEnabled=False; Kuka.MoveDataPtpName=PDAT1; Kuka.VelocityPtp=100; Kuka.VelocityFieldEnabled=True; Kuka.ColDetectFieldEnabled=True; Kuka.CurrentCDSetIndex=0; Kuka.MovementParameterFieldEnabled=True; IlfCommand=SPTP
    ;ENDFOLD
    SPTP Xstack1home WITH $VEL_AXIS[1] = SVEL_JOINT(100.0), $TOOL = STOOL2(Fstack1home), $BASE = SBASE(Fstack1home.BASE_NO), $IPO_MODE = SIPO_MODE(Fstack1home.IPO_FRAME), $LOAD = SLOAD(Fstack1home.TOOL_NO), $ACC_AXIS[1] = SACC_JOINT(PPDAT1), $APO = SAPO_PTP(PPDAT1), $GEAR_JERK[1] = SGEAR_JERK(PPDAT1), $COLLMON_TOL_PRO[1] = USE_CM_PRO_VALUES(0)
    ;ENDFOLD
    
    ;FOLD SLIN stack1prep Vel=2 m/s CPDAT2 Tool[2]:ForkNew Base[4]:EUpalletNEW ;%{PE}
    ;FOLD Parameters ;%{h}
    ;Params IlfProvider=kukaroboter.basistech.inlineforms.movement.spline; Kuka.IsGlobalPoint=False; Kuka.PointName=stack1prep; Kuka.BlendingEnabled=False; Kuka.MoveDataName=CPDAT2; Kuka.VelocityPath=2; Kuka.VelocityFieldEnabled=True; Kuka.ColDetectFieldEnabled=True; Kuka.CurrentCDSetIndex=0; Kuka.MovementParameterFieldEnabled=True; IlfCommand=SLIN
    ;ENDFOLD
    SLIN Xstack1prep WITH $VEL = SVEL_CP(2.0, , LCPDAT2), $TOOL = STOOL2(Fstack1prep), $BASE = SBASE(Fstack1prep.BASE_NO), $IPO_MODE = SIPO_MODE(Fstack1prep.IPO_FRAME), $LOAD = SLOAD(Fstack1prep.TOOL_NO), $ACC = SACC_CP(LCPDAT2), $ORI_TYPE = SORI_TYP(LCPDAT2), $APO = SAPO(LCPDAT2), $JERK = SJERK(LCPDAT2), $COLLMON_TOL_PRO[1] = USE_CM_PRO_VALUES(0)
    ;ENDFOLD
    
    ; execute motion during which Interrupt is expected  
    SeachForStack()
    ;The program pointer will jump back to this line
    ;when the RESUME command in ISR_StackIsFound executes
    ;That is because the INTERRUPT DECL is in this subroutine
    
    
    $OUT[20] = TRUE
    
    
    ;FOLD SLIN stack1prep Vel=2 m/s CPDAT2 Tool[2]:ForkNew Base[4]:EUpalletNEW ;%{PE}
    ;FOLD Parameters ;%{h}
    ;Params IlfProvider=kukaroboter.basistech.inlineforms.movement.spline; Kuka.IsGlobalPoint=False; Kuka.PointName=stack1prep; Kuka.BlendingEnabled=False; Kuka.MoveDataName=CPDAT2; Kuka.VelocityPath=2; Kuka.VelocityFieldEnabled=True; Kuka.ColDetectFieldEnabled=True; Kuka.CurrentCDSetIndex=0; Kuka.MovementParameterFieldEnabled=True; IlfCommand=SLIN
    ;ENDFOLD
    SLIN Xstack1prep WITH $VEL = SVEL_CP(2.0, , LCPDAT2), $TOOL = STOOL2(Fstack1prep), $BASE = SBASE(Fstack1prep.BASE_NO), $IPO_MODE = SIPO_MODE(Fstack1prep.IPO_FRAME), $LOAD = SLOAD(Fstack1prep.TOOL_NO), $ACC = SACC_CP(LCPDAT2), $ORI_TYPE = SORI_TYP(LCPDAT2), $APO = SAPO(LCPDAT2), $JERK = SJERK(LCPDAT2), $COLLMON_TOL_PRO[1] = USE_CM_PRO_VALUES(0)
    ;ENDFOLD
    
    END
    Display More
    Code: SearchForStack
    &ACCESS RVO1
    DEF  SeachForStack ( )
    ;FOLD INI;%{PE}
      ;FOLD BASISTECH INI
        GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
        INTERRUPT ON 3 
        BAS (#INITMOV,0 )
      ;ENDFOLD (BASISTECH INI)
      ;FOLD USER INI
        ;Make your modifications here
    
      ;ENDFOLD (USER INI)
    ;ENDFOLD (INI)
    
    $OUT[15] = TRUE
    
    INTERRUPT ON 21
    
    ; Do to page 614 in KSS_87_SI_en.pdf, it is required to wait 12ms as minimum 
    ;WAIT SEC 0.1 ; Waiting 100 ms. 
    
    $OUT[16] = TRUE
    
    ;FOLD SLIN stack1Calib Vel=2 m/s CPDAT3 Tool[2]:ForkNew Base[4]:EUpalletNEW ;%{PE}
    ;FOLD Parameters ;%{h}
    ;Params IlfProvider=kukaroboter.basistech.inlineforms.movement.spline; Kuka.IsGlobalPoint=False; Kuka.PointName=stack1; Kuka.BlendingEnabled=False; Kuka.MoveDataName=CPDAT3; Kuka.VelocityPath=2; Kuka.VelocityFieldEnabled=True; Kuka.ColDetectFieldEnabled=True; Kuka.CurrentCDSetIndex=0; Kuka.MovementParameterFieldEnabled=True; IlfCommand=SLIN
    ;ENDFOLD
    SLIN Xstack1Calib WITH $VEL = SVEL_CP(2.0, , LCPDAT3), $TOOL = STOOL2(Fstack1), $BASE = SBASE(Fstack1.BASE_NO), $IPO_MODE = SIPO_MODE(Fstack1.IPO_FRAME), $LOAD = SLOAD(Fstack1.TOOL_NO), $ACC = SACC_CP(LCPDAT3), $ORI_TYPE = SORI_TYP(LCPDAT3), $APO = SAPO(LCPDAT3), $JERK = SJERK(LCPDAT3), $COLLMON_TOL_PRO[1] = USE_CM_PRO_VALUES(0)
    ;ENDFOLD
    
    ; If the interrupt fires, no code below this line will execute
      ; due to the RESUME command in the ISR
      ; Instead, the RESUME command will "cancel" the rest of this subroutine
      ; and jump the program pointer back to one line after where this subroutine was called
    
    ; Do to page 614 in KSS_87_SI_en.pdf, it is required to wait 12ms as minimum 
    ;WAIT SEC 0.1 ; Waiting 100 ms. 
    ;WAIT FOR TRUE ;// this is causing the error.
    WAIT SEC 0 ;// This is also causing the error of $ADVANCE in interrupt inadmissible.
    END
    Display More
    Code: ISR_StackIsFound
    &ACCESS RV1
    DEF  ISR_StackIsFound()
    ;FOLD INI;%{PE}
      ;FOLD BASISTECH INI
        GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
        INTERRUPT ON 3 
        BAS (#INITMOV,0 )
      ;ENDFOLD (BASISTECH INI)
      ;FOLD USER INI
        ;Make your modifications here
    
      ;ENDFOLD (USER INI)
    ;ENDFOLD (INI)
    
    ;From KSS_87_SI_en, page 620
    INTERRUPT OFF 21
    BRAKE
    RESUME
    END
    Display More

    So please, let me know if you need any further information. I would strongly apprecirate your support. Thanks in advance :smiling_face:

    My current system contains the following information:

    • Robot: KUKA KR50 R2100
    • Controller: KR C5 dualcabinet
    • KSS 8.7.2 HF3
    • HMI version: 8.7 B394
    • Kernel system version: KS V8.7.53394
    • WorkVisual V6.0.24_Build1632
  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • December 30, 2021 at 8:22 PM
    • #17

    ISR_StackIsFound() is an ISR and as such it cannot have INI and inline form motions.

    In fact INI and BCO are only needed once - when program is starting. Doing this later on is undesirable in most cases.

    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

  • ChristianLiinHansen
    Reactions Received
    3
    Trophies
    2
    Posts
    37
    • December 30, 2021 at 8:31 PM
    • #18
    Quote from panic mode

    ISR_StackIsFound() is an ISR and as such it cannot have INI and inline form motions.

    In fact INI and BCO are only needed once - when program is starting. Doing this later on is undesirable in most cases.

    So you are saying, that is should just be like this?

    Code: ISR_StackIsFound
    &ACCESS RV1
    DEF  ISR_StackIsFound()
    INTERRUPT OFF 21
    BRAKE
    RESUME
    END

    My current system contains the following information:

    • Robot: KUKA KR50 R2100
    • Controller: KR C5 dualcabinet
    • KSS 8.7.2 HF3
    • HMI version: 8.7 B394
    • Kernel system version: KS V8.7.53394
    • WorkVisual V6.0.24_Build1632
  • ChristianLiinHansen
    Reactions Received
    3
    Trophies
    2
    Posts
    37
    • December 30, 2021 at 8:36 PM
    • #19

    panic mode You are the BEST!!!! I removed it like above, and now the ISR is WORKING!!!!

    So I gave you a :red_heart: like, but I hope the next people do not make the same mistake by using "Modules" generation instead of "Functions".

    My current system contains the following information:

    • Robot: KUKA KR50 R2100
    • Controller: KR C5 dualcabinet
    • KSS 8.7.2 HF3
    • HMI version: 8.7 B394
    • Kernel system version: KS V8.7.53394
    • WorkVisual V6.0.24_Build1632
  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • December 30, 2021 at 10:40 PM
    • #20

    well it should have been the Expert module (if this is external) but KRL is forgiving and all of the templates are just text files that can be easily converted to other types.

    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

Similar Threads

  • Debugging EKI Error: Access to empty elementmemory

    • impartialist
    • December 1, 2020 at 4:56 PM
    • KUKA Robot Forum
  • Pausing a program with an input

    • Orange_Will
    • August 2, 2020 at 6:46 PM
    • KUKA Robot Forum
  • Using interrupt to store values

    • chis
    • February 25, 2020 at 11:10 PM
    • KUKA Robot Forum
  • Recommendations to search a part?

    • robotecnik
    • December 27, 2019 at 10:54 AM
    • KUKA Robot Forum
  • Detecting Torque Levels To Divert Robot KRC2 KR210

    • drkuzzie
    • April 12, 2019 at 3:13 AM
    • KUKA Robot Forum
  • Informal Instruction to skip Motion Instruction

    • ravitejagali
    • June 24, 2018 at 8:54 AM
    • Yaskawa Motoman Robot Forum
  • Reading and Writing to KRC4 IOs?

    • n0909
    • February 20, 2018 at 5:33 AM
    • KUKA Robot Forum
  • krc2 moving on Z

    • rawad
    • January 28, 2018 at 9:42 PM
    • KUKA Robot Forum
  • Interrupt in Motion

    • daxter
    • September 29, 2017 at 9:08 AM
    • KUKA Robot Forum

Tags

  • Brake
  • interrupt
  • resume
  • $POS_INT
  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