Hey guy, I'm walking against a big wall.
I have made a code that measures the lenght of a tool when the robot pushes a button with the tool, after that it then automaticlly calculates the lenght of the tool. However now there is a request that it measures the toollenght once the button is not pushed in anymore. So to clearify the robot will move from a starting position with a tool over the z axis until the button is pushed a signal will trigger a interrupt and then the robot will start to move back up on the z axis. Once the robot isnt activating and touchting the button anymore the POS has to be recorded and a new toollenght will be calculated. I tried to do this with a interrupt inside a interrupt but this isnt working (probably because it isnt allowed to use interrupts inside of interrupts). This way of measuring toollenght is common in CNC machines to ensure higher measurment accuracy and is requested from my costumer.
Now my question is, does anyone know how I can measure my toollenght once the button isnt pushed in anymore after being pushed in? I have attached my current code for clearification (and my working code for measurement once the toolsetter/button is pushed):
NOT WORKING CODE (when trying to measure the toollenght when not pressing a the toolsetter/button)
DEF Meting_UP_4( )
;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=30 % DEFAULT;%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:30, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,30)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
;FOLD PTP P1 Vel=30 % PDAT1 Tool[0] Base[0];%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P1, 3:, 5:30, 7:PDAT1
$BWDSTART=FALSE
PDAT_ACT=PPDAT1
FDAT_ACT=FP1
BAS(#PTP_PARAMS,30)
PTP XP1
;ENDFOLD
ST=$POS_ACT ;Gather robotcoördinates
StartPos=ST.z ;Safe location on the Z axis as starting position
ToolLenght_2Z=ST.z ;Safe location on Z axis
ToolLenght_2X=ST.x ;Safe location on X axis
ToolLenght_2Y=ST.y ;Safe location on Y axis
INTERRUPT DECL 1 WHEN $IN[1]==TRUE DO moveUP()
INTERRUPT DECL 2 when $IN[1]==FALSE DO TOOLM()
MOVEZ() ;Start Z axis movement
INTERRUPT OFF 1 ;Turn off interrupt
INTERRUPT OFF 2
IF $OUT[2] THEN
TOOLM()
ELSE
ENDIF
;RETURN HOME
;FOLD PTP HOME Vel=30 % DEFAULT;%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:30, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,30)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
$OUT[1]=FALSE ;Deactivate output 1
END
DEF MOVEZ() ;Moving the robot from position 1 to position 2 on the Z axis
INTERRUPT ON 1 ;Activate interrupt
$out[2]= FALSE
;FOLD LIN P3 Vel=0.5 m/s CPDAT1 Tool[0] Base[0];%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:P3, 3:, 5:0.5, 7:CPDAT1
$BWDSTART=FALSE
LDAT_ACT=LCPDAT1
FDAT_ACT=FP3
BAS(#CP_PARAMS,0.5)
LIN XP3
;ENDFOLD
WAIT FOR TRUE
END
DEF moveUP()
INTERRUPT OFF 1
BRAKE
INTERRUPT ON 2
;FOLD LIN P6 Vel=0.05 m/s CPDAT1 Tool[0] Base[0];%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:P6, 3:, 5:0.05, 7:CPDAT1
$BWDSTART=FALSE
LDAT_ACT=LCPDAT1
FDAT_ACT=FP6
BAS(#CP_PARAMS,0.05)
LIN XP6
;ENDFOLD
RESUME
END
DEF TOOLM() ;Subroutine for toolsetter
INTERRUPT OFF 2
BRAKE ;Stop robotarm movement
;MOVE UP
Z1=$POS_INT ;Register location on the Z axis at moment of interrupt
ToolLenght_1=StartPos-Z1.z ;Calculate distance traveled on the Z axis
ToolLenght_2=ToolCorecction-ToolLenght_1 ;Subtract distance traveld on the z axis from work area
ToolLenght_1Z=Z1.z ;Safe location on Z axis
ToolLenght_1X=Z1.x ;Safe location on X axis
ToolLenght_1Y=Z1.y ;Safe location on Y axis
$OUT[1]=TRUE ;turn on output 1
;FOLD WAIT Time=1 sec;%{PE}%R 5.5.31,%MKUKATPBASIS,%CWAIT,%VWAIT,%P 2:1
WAIT SEC 1
;ENDFOLD
RESUME ;Continue program
END
Display More
WORKING TOOL MEASURE (when pushing the toolsetter/button)
DEF toolsetter_measure15( )
;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=30 % DEFAULT;%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:30, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,30)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
;FOLD PTP P1 Vel=30 % PDAT1 Tool[0] Base[0];%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P1, 3:, 5:30, 7:PDAT1
$BWDSTART=FALSE
PDAT_ACT=PPDAT1
FDAT_ACT=FP1
BAS(#PTP_PARAMS,30)
PTP XP1
;ENDFOLD
ST=$POS_ACT ;Gather robotcoördinates
StartPos=ST.z ;Safe location on the Z axis as starting position
ToolLenght_2Z=ST.z ;Safe location on Z axis
ToolLenght_2X=ST.x ;Safe location on X axis
ToolLenght_2Y=ST.y ;Safe location on Y axis
INTERRUPT DECL 1 WHEN $IN[1]==TRUE DO TOOLM() ;Declare interrupt
MOVEZ() ;Start Z axis movement
INTERRUPT OFF 1 ;Turn off interrupt
;FOLD PTP HOME Vel=30 % DEFAULT;%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:30, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,30)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
$OUT[1]=FALSE ;Deactivate output 1
END
DEF MOVEZ() ;Moving the robot from position 1 to position 2 on the Z axis
INTERRUPT ON 1 ;Activate interrupt
;FOLD LIN P3 Vel=0.5 m/s CPDAT1 Tool[0] Base[0];%{PE}%R 5.5.31,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:P3, 3:, 5:0.5, 7:CPDAT1
$BWDSTART=FALSE
LDAT_ACT=LCPDAT1
FDAT_ACT=FP3
BAS(#CP_PARAMS,0.5)
LIN XP3
;ENDFOLD
;FOLD WAIT Time= 0.0 sec;%{PE}%R 8.3.22,%MKUKATPBASIS,%CWAIT,%VWAIT,%P 2:0.0
WAIT SEC 0.0
;ENDFOLD ;Wait for interrupt
END
DEF TOOLM() ;Subroutine for toolsetter
INTERRUPT OFF 1 ;Deactivate interrupt
BRAKE ;Stop robotarm movement
Z1=$POS_INT ;Register location on the Z axis at moment of interrupt
ToolLenght_1=StartPos-Z1.z ;Calculate distance traveled on the Z axis
ToolLenght_2=ToolCorecction-ToolLenght_1 ;Subtract distance traveld on the z axis from work area
ToolLenght_1Z=Z1.z ;Safe location on Z axis
ToolLenght_1X=Z1.x ;Safe location on X axis
ToolLenght_1Y=Z1.y ;Safe location on Y axis
$OUT[1]=TRUE ;turn on output 1
;FOLD WAIT Time=1 sec;%{PE}%R 5.5.31,%MKUKATPBASIS,%CWAIT,%VWAIT,%P 2:1
WAIT SEC 1
;ENDFOLD
RESUME ;Continue program
END
Display More
Thankyou in advance for your time and effort,
MH