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 :
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 :
&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.
How would you explain that ? What I do not understand ?
Thanks for your kind help,
Lionel