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

Interrupt not working when triggering condition is satisfied at activation time?

  • lionpeloux
  • November 8, 2018 at 4:10 PM
  • Thread is Resolved
  • lionpeloux
    Reactions Received
    1
    Trophies
    3
    Posts
    47
    • November 8, 2018 at 4:10 PM
    • #1

    Hello,

    KSS5.6, KRC2, KR5002MT

    I'm having a hard time to understand why one of my interrupt is not triggered.
    It seams to me that when I activate my interrupt, if the triggering condition is already satisfied then the interrupt will never get triggered.

    Just a word about the context :


      • I am launching "actions" from the KCP through a set of softkeys (UserTech / KFD).

      • An action is launched by the SPS through CWRITE($CMD, state, mode, "RUN R1\mdi()").

      • Each action as an ID (eg. action.ID = 101), used to run the corresponding code through a switch condition.

      • Each action is valid for a given set of modes (eg. action.ValidModeOP = 'B0011' = EX|AUT|T2|T1 means the action can execute only in T1, T2 modes)

    I want to listen to $MODE_OP changes in the program to ensure that when an action is launched, it won't be executed in a non valid mode. If the user changes the mode to an unauthorized mode for the running action, the interrupt must be triggered, inform the user he must change back the mode to a valid mode or the program will be automatically canceled by the SPS through CWRITE($CMD, state, mode, "CANCEL 1").

    The SPS is responsible for cyclically checking if $MODE_OP is valid for the running action. $FLAG[99] is set to true if the mode is invalid, and false otherwise.
    Then, In my program, I must respond to $FLAG[99]==true with an interrupt.

    My problem arises when I launch an action with a yet invalid $MODE_OP, that is $FLAG[99] is true at the very beginning of the program. I have set up the following MWE to test and understand my problem :

    In the SPS loop, set $FLAG[99] = true when any program is launched :

    Code
    SWITCH $PRO_STATE1
      CASE #P_RESET, #P_ACTIVE, #P_STOP, #P_END
        $FLAG[99] = true
      DEFAULT
        $FLAG[99] = false
    ENDSWITCH

    Then start this test src program :

    Code
    &ACCESS RV
    DEF IR_MDI_SPS()
    
    
      ; INIT
      BAS(#INITMOV,0)   
      INTERRUPT DECL 9 WHEN $FLAG[99]==TRUE DO ISR_OnFlagTrue()
      $ADVANCE = 2
    
    
      ; BCO
      PTP {A1 0, A2 -90, A3 90, A4 0, A5 0, A6 0, E1 0, E2 0}
    
    
      ; go end of track (E1 -2000)
      PTP_REL {E6AXIS: E1 -500} C_PTP
      PTP_REL {E6AXIS: E1 -500} C_PTP
      PTP_REL {E6AXIS: E1 -500} C_PTP
      PTP_REL {E6AXIS: E1 -500} C_PTP    
    
    
      WAIT SEC 0                         ; advance run stop
      INTERRUPT ON 9
      $FLAG[99] = false                  ; comment this line > interrupt does not occur
    
    
      ; go back home (E1 +2000)
      PTP_REL {E6AXIS: E1 500} C_PTP
      PTP_REL {E6AXIS: E1 500} C_PTP
      PTP_REL {E6AXIS: E1 500} C_PTP
      PTP_REL {E6AXIS: E1 500} C_PTP 
    
    END
    
    
    DEF ISR_OnFlagTrue()
    
    
      DECL BOOL bResult
    
    
      INTERRUPT OFF 9
      BRAKE
    
    
      DisplayDebugMsg("$FLAG[99] == TRUE")
      WAIT SEC 5
    
    
      ; this command asks the SPS to close the active robot program
      ; by calling : CWRITE($CMD, stat, mode, "CANCEL 1")
      bResult = TrySubmitCMD(#CANCEL1)
    
    
      INTERRUPT ON 9
    END
    Display More

    The interruption is working properly if I reverse $FLAG[99] just after activating the interrupt (ON 9). If I comment this line, the interrupt never gets triggered.

    Code
    $FLAG[99] = false                  ; comment this line > interrupt does not occur

    How would you explain that ? What I do not understand ?

    Thanks for your kind help,
    Lionel

  • Online
    SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,423
    • November 8, 2018 at 5:22 PM
    • #2

    That is exactly how interrupts work. They are "edge triggered."

    If you set an Interrupt to trigger on a condition being True, it will only trigger on a transition from False to True. If the condition is already True before you use INTERRUPT ON, the Interrupt will not trigger until after the condition has gone False, and then goes True again.

    This is a deliberate design feature, and goes back to classical electronics and circuits like flip-flops: https://electronics.stackexchange.com/questions/2188…-triggered-mean

  • lionpeloux
    Reactions Received
    1
    Trophies
    3
    Posts
    47
    • November 8, 2018 at 6:28 PM
    • #3

    Ok, thank you for your explanation !
    I didn't know about the "edge triggering" thing ... what a painful discovery for me ! :waffen100:
    It is clearly written in the doc and I can't believe I missed it....

  • lionpeloux
    Reactions Received
    1
    Trophies
    3
    Posts
    47
    • November 14, 2018 at 10:39 AM
    • #4

    I'm trying to understand the following statements (see code below). I believe this is related to the fact that interrupts are edge triggered as you told me but I might be wrong.
    What is the purpose of those PULSE statements ? I suppose it is, somehow, a way to arm/rearm the triggering.

    Why in the INIT section O_Flag_MoveEnable=FALSE is followed immediately by a PULSE (O_Flag_MoveEnable,FALSE,0.2 ) ? It is yet set to FALSE no ?
    Why in the MoveEnable_Management(1) subroutine the PULSE is not LOW to "rearm" the interrupt trigger after returning to the main program ?

    [list type=decimal]

    • O_Flag_MoveEnable = false at INIT

    • if O_Flag_MoveEnable goes to true at some point interrupt 97 gets triggered and throws MoveEnable_Management (1)

    • Then MoveEnable_Management (1) issues a PULSE (O_Flag_MoveEnable,TRUE,0.05 ) (case 1)

    [/list]

    Init function of systemcellmanagesps.sub (WOP 6) :

    Code
    CASE #INIT_SPS
      ;FOLD Init + Interruptions for management MOVE ENABLE
      O_Flag_MoveEnable=FALSE
      PULSE (O_Flag_MoveEnable,FALSE,0.2 )
      GLOBAL INTERRUPT DECL 97 WHEN O_Flag_MoveEnable DO MoveEnable_Management (1 )
      GLOBAL INTERRUPT DECL 98 WHEN NOT O_Flag_MoveEnable DO MoveEnable_Management (2 )
      INTERRUPT ON 97
      INTERRUPT ON 98
      ...

    And the subroutine :

    Code
    GLOBAL DEF MoveEnable_Management (M_Inc :IN )
      INT M_Inc ;--- Declarations ---
      M_MoveEnable_Cell=((($EXT OR $AUT) AND $USER_SAF AND NOT X_Rob_InReset) OR $T1 OR $T2) AND I_MoveEnable_Ok ;----This equation is to fill based on technology used
      Flag_Configuration ( )
      SWITCH M_Inc ;Management next interrupt triggering
        CASE 1
          PULSE (O_Flag_MoveEnable,TRUE,0.05 )
        CASE 2
          PULSE (O_Flag_MoveEnable,FALSE,0.05 )
      ENDSWITCH
    END
    Display More

    Edited once, last by lionpeloux (November 14, 2018 at 10:55 AM).

  • Online
    SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,423
    • November 14, 2018 at 6:24 PM
    • #5

    ...who wrote this? It seems unnecessarily over-complicated. Although without a larger context, it's hard to say for certain.

    The initial 0.2sec pulse appears to be to guarantee the starting condition of the signal before the Interrupts are declared, but it's redundant with the preceding explicit False setting. Also, DECLing the Interrupts immediately after the Pulse command... will probably work, but I would have added a WAIT FOR state before the DECLs to ensure no edge-condition timing issues could happen.

    After that, the entire use of Pulse commands in the ISR appears to be an attempt at creating a "heartbeat" timer of some kind. If the ISR is called by a False->True transition, the Pulse True command will "extend" the True time of the signal for another 0.05sec, after which it will turn False. This will call the ISR with an argument of True, which will cause the Pulse False command to extend the False time for 0.05sec, and so on forever.

    The trick to the Pulse command is that, if you use it on a signal that is already in the commanded state, the signal will "invert" at the end of the Pulse duration time. So you can set a "timer" on the signal that will "go off" at some moment in the future, regardless of what else the program is doing at that moment.

  • lionpeloux
    Reactions Received
    1
    Trophies
    3
    Posts
    47
    • November 28, 2018 at 1:24 PM
    • #6

    This code is from WOP 6.0 (Way of Programming by Kuka France).
    I have to dig more into this "heartbeat" sort of timer that I don't yet fully understand.

    I was not aware of this point :

    Quote

    The trick to the Pulse command is that, if you use it on a signal that is already in the commanded state, the signal will "invert" at the end of the Pulse duration time



    Could you confirm this behavior ? Is there any documentation where this is explained ? I couldn't find anything about this point in the expert programming manual ... but the documentation is often rather obscure !

    Thanks again for your kind help

  • Online
    panic mode
    Reactions Received
    1,278
    Trophies
    11
    Posts
    13,079
    • November 28, 2018 at 2:40 PM
    • #7

    That sounds odd to me. in my experience, like expected, PULSE command will set programmed state, then toggle it when completed, regardless if signal is used elsewhere or not...

    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

    Edited once, last by SkyeFire (November 28, 2018 at 4:11 PM).

  • Online
    SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,423
    • November 28, 2018 at 4:17 PM
    • #8

    I've used it quite a bit for "delayed actions."

    Example: At a particular line in the program, $OUT[1] is already true. I want $OUT to become FALSE in exactly 1.5 seconds, but I can't guarantee what line of the program will be executing in that time frame. So, I use PULSE($OUT[1], TRUE, 1.5). The effect here is that $OUT[1] will stay TRUE for exactly 1.5 seconds longer, then turn FALSE, regardless of what my program may be doing at that time.

    There are other ways to do this, of course ($TIMERs, SPS code, etc), but there were times when this particular trick was the cleanest solution to what I was trying to accomplish.

  • Online
    panic mode
    Reactions Received
    1,278
    Trophies
    11
    Posts
    13,079
    • November 28, 2018 at 5:29 PM
    • #9

    [size=2]i misread... yes, PULSE will change output state at the end so everything is in agreement.[/size]

    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,051
    Trophies
    12
    Posts
    9,423
    • November 28, 2018 at 7:39 PM
    • #10

    Yeah... I never tried doing

    Code
    PULSE($OUT[1], TRUE, 1.5)
    $OUT[1] = TRUE


    but I suspect that it would still go False after 1.5sec, as you said earlier.

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