Hello,
I'm currently using an interrupt to monitor a signal and trigger a subroutine depending on the condition.
If the signal is FALSE, then I want to stop the robot, prompt a MsgDialog then take action according to the user's input.
To put it in code, it looks like this:
main_program.src
BAS (#INITMOV,0 )
startWeld()
LIN { X 183.935, Y -202.468, Z 57.010, A 86.7689, B 89.9992, C 0.0086, E1 -0.7420, E2 0.0000, S 'B00010', T 'B001010' } C_DIS
LIN { X 363.850, Y -196.939, Z 57.010, A 86.7689, B 89.9992, C 0.0086, E1 -0.7420, E2 0.0000, S 'B00010', T 'B001010' } C_DIS
LIN { X 369.380, Y -376.854, Z 57.010, A 86.7689, B 89.9992, C 0.0086, E1 -0.7420, E2 0.0000, S 'B00010', T 'B001010' } C_DIS
LIN { X 189.483, Y -382.382, Z 57.010, A 86.7689, B 89.9992, C 0.0086, E1 -0.7420, E2 0.0000, S 'B00010', T 'B001010' } C_DIS
LIN { X 189.465, Y -382.383, Z 57.010, A 86.7689, B 89.9992, C 0.0086, E1 -0.7420, E2 0.0000, S 'B00010', T 'B001010' } C_DIS
LIN { X 187.914, Y -331.920, Z 57.010, A 86.7689, B 89.9992, C 0.0086, E1 -0.7420, E2 0.0000, S 'B00010', T 'B001010' }
stopLongWeld()
Inside startWeld, I am defining the following:
GLOBAL DEF startWeld()
DO_weld = TRUE
handleWeldFail()
END
GLOBAL DEF stopLongWeld()
stopHandleWeldFail()
stopWeld()
END
GLOBAL DEF stopWeld()
DO_weld = FALSE
END
Display More
And finally, my interrupt routine looks like this:
DEF mid_arc_failure ( )
END
DEF failureMidWeld()
DECL INT I_userChoice
BRAKE
; Always disable interrupts!
stopHandleMidWeldFail()
; Make sure to stop the welding
stopWeld()
MsgDialog(I_userChoice, "Arc failure during the middle of a weld detected", "ARC FAILURE",,,,, "Weld", "Skip weld")
WAIT FOR I_userChoice<>0
IF I_userChoice == 4 THEN;
;retry weld
turnOnInterrupt()
DO_weld = TRUE
ELSE
;skip weld
CONTINUE
ENDIF
END
DEF declareInterrupt()
GLOBAL INTERRUPT DECL 2 WHEN $CYCFLAG[1] == TRUE DO failureMidWeld()
END
DEF turnOnInterrupt()
B_continuousWeld = TRUE
$CYCFLAG[1] = (B_continuousWeld == TRUE) AND (DI_arcPresence==FALSE)
INTERRUPT ON 2
waitInterpolationCycle()
END
DEF turnOffInterrupt()
INTERRUPT OFF 2
$CYCFLAG[1] = FALSE
END
GLOBAL DEF handleWeldFail()
declareInterrupt()
turnOnInterrupt()
END
GLOBAL DEF stopHandleWeldFail()
turnOffInterrupt()
B_continuousWeld = FALSE
END
Display More
In an Submit program, I'm also deciding when to turn off DO_weld. DO_weld is turned off when an emergency stop is triggered.
The interrupt works, but in a inconsistent way. I am expecting the interrupt to be triggered whenever DI_arcPresence is False no matter where DO_weld is turned off from.
I'm unsure why the interrupt is triggered every once in a while and sometimes not.