Hi there,
I generate my milling programs from Sprutcam and sometimes it generates duplicated points or circles with middle point equal to start point (I found how to fix this last). I'm actually developing a little code to check the .src file before loading it to the KRC, however I would like to develop a safety function that stops the spindle whenever to KRC stops the program for an error within the code. At the moment, like in the cases I mentioned before, I get the KRC stopping the motion and enabling brakes, but the spindle keeps running, which is really dangerous. How and where can I set an instruction that switches off the spindle as well if the KRC stops the program? Any help is really welcome.
This is my SPS:
DEF sps( )
;FOLD DECLARATIONS
;FOLD BASISTECH DECL
;Automatik extern
DECL STATE_T STAT
DECL MODUS_T MODE
;ENDFOLD (BASISTECH DECL)
;FOLD USER DECL
; Please insert user defined declarations
;ENDFOLD (USER DECL)
;ENDFOLD (DECLARATIONS)
;FOLD INI
;FOLD DEFAULT MSG_T
$MSG_T={MSG_T: VALID FALSE,RELEASE FALSE,TYP #NOTIFY,MODUL[] " ",KEY[] " ",PARAM_TYP #VALUE,PARAM[] " ",DLG_FORMAT[] " ",ANSWER 0}
;ENDFOLD (DEFAULT MSG_T)
;FOLD AUTOEXT INIT
INTERRUPT DECL 91 WHEN $PRO_STATE1==#P_FREE DO RESET_OUT ()
INTERRUPT ON 91
$LOOP_MSG[]=" "
MODE=#SYNC
$H_POS=$H_POS
;Automatik extern
IF $MODE_OP==#EX THEN
CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()")
ENDIF
;ENDFOLD (AUTOEXT INIT)
;FOLD USER INIT
; Please insert user defined initialization commands
;REMOTE PENDANT INITIALIZATION
$OUT[5] = TRUE ;+24V to pendant
$OUT[6] = FALSE ;Resume Pendant LED (white)
$OUT[7] = FALSE ;Stop Pendant LED (white)
$OUT[8] = FALSE ;Reset Pendant LED (white)
$OUT[9] = FALSE ;Communication LED (blue)
$OUT[17] = TRUE ;TOOLCHANGER EV A (LOCK)
$OUT[18] = FALSE ;TOOLCHANGER EV B (UNLOCK)
;ENDFOLD (USER INIT)
;ENDFOLD (INI)
LOOP
WAIT FOR NOT($POWER_FAIL)
TORQUE_MONITORING()
;FOLD USER PLC
;Make your modifications here
SC() ;call custom subprogram
$OV_PRO = 100-(99*$ANIN[1]) ;Robot override (pot)
;ENDFOLD (USER PLC)
ENDLOOP
;FOLD ;%{H}
;FOLD
END
;ENDFOLD
DEF RESET_OUT ( )
INT N
$LOOP_MSG[]=" "
IF REFLECT_PROG_NR == 1 THEN
FOR N = 0 TO PGNO_LENGTH - 1
$OUT[PGNO_FBIT_REFL + N] = FALSE
ENDFOR
ENDIF
IF (PGNO_REQ>0) THEN
$OUT[PGNO_REQ]=FALSE
ELSE
IF (PGNO_REQ<0) THEN
$OUT[-PGNO_REQ]=TRUE
ENDIF
ENDIF
END
;FOLD USER SUBROUTINE
; Integrate your user defined subroutines
Display More
and this is my security check sub:
DEF SC( ) ; -- This Subrutine is ment to start running from system startup and check all security systems and external sensorsSC
;FOLD DECLARATIONS
;FOLD USER DECL
; Please insert user defined declarations
;ENDFOLD (USER DECL)
;ENDFOLD (DECLARATIONS) ; Declare the variables
;FOLD INI
;FOLD USER INIT
; Please insert user defined initialization commands
;ENDFOLD (USER INIT)
;ENDFOLD (INI)
;HSD_ALBERO_FERMO=$IN[3] ;Check if Spindle is running
; RELEASE CONE WHEN HSD_BUTTON IS PRESSED
IF $IN[4] == TRUE THEN
PULSE($OUT[1], TRUE, 1) ;OPEN VALVE
PULSE($OUT[9], TRUE, 1) ;COM LED ON
ENDIF
; REMOTE PENDANT FUNCTIONS
IF $IN[9] == TRUE THEN ;PAUSE BUTTON
$OUT[7] = TRUE ;PAUSE LED (RED)
$OUT[6] = FALSE ;RESUME LED (GREEN)
$OUT[10] = FALSE ;FILEDBUS REFERENCE VALUE ENABLE
ENDIF
IF $IN[10] == TRUE THEN ;RESUME BUTTON
$OUT[7] = FALSE
$OUT[6] = TRUE
$OUT[10] = TRUE ;FIELDBUS REFERENCE VALUE ENABLE
ENDIF
IF $IN[11] == TRUE THEN ;RESET BUTTON PRESSED
PULSE ($OUT[8], TRUE, 3) ;LED ON
PULSE ($OUT[11], TRUE, 1)
ENDIF
;--TOOLCHANGER CONTROL
;$OUT[17] = TRUE ;EV A STAY LOCK AT START UP
;$OUT[18] = FALSE ;EV B RELEASE WHEN TRUE
;-- CHECK IF EMERGENCY BUTTONS ARE HIGH OR LOW AND TAKE ACTIONS
$OUT[2] = NOT $ALARM_STOP ;Switch on E-Stop Led
$OUT[3] = NOT $ALARM_STOP ;Switch on E-Stop Led (pendant)
IF ($ALARM_STOP==FALSE) THEN ; !!!When it is false there is an emergency stop breaking the circuit!!!
HSD_LOGIC_SET = 5
HSD_SPEED_SET = 0
WAIT FOR HSD_SPEED_IN < ABS(50)
HSD_LOGIC_SET = 0
ENDIF
;FOLD USER PLC
;Make your modifications here
;ENDFOLD (USER PLC)
;FOLD ;%{H};
END
;ENDFOLD
;FOLD USER SUBROUTINE
;Integrate your user defined subroutines
;ENDFOLD (USER SUBROUTINE)
Display More