Here's my mfunc6.mac content
Code: Select all
;----------------------------------------------------------------
; Setting Up the Touch Probe
;----------------------------------------------------------------
; Variables used:
; #100 = Reset current Z part 0 selection. 0 = skip, 1 = Reset Z0
#101 = 5 ;Length of time to display temporary M225 messages
; #102 = Fast probing rate
; #103 = Slow probing rate
; #104 = TT1 PLC input.
; #105 = Current user entered configuration value
#106 = 0 ;Length of time to wait for cycle start M225 messages
; #107 = Z0 location after probing
IF #50001
IF #4201 || #4202 THEN GOTO 1000
IF #50001
#100 = 0
#102 = 0
#103 = 0
#104 = 0
#105 = 0
#107 = 0
M5
;Turn off spindle
N100
;Check to make sure a TT1 is correctly configured
IF !#9011 && !#9044 THEN M225 #106 "No PLC input has been configured for the Tool Touch Off device.\nPlease enter the PLC input for the Tool Touch Off device in parameter 11\nPress Cycle Cancel to end job now."
IF #50001
IF !#9011 && !#9044 THEN GOTO 100
IF [#9044 > 8] && [#9044 <= 50000] THEN M225 #106 "The PLC input entered into parameter 44 in invalid.\nPlease enter a value of between 1 and 8 into parameter 44\nPress Cycle Cancel to end job now."
IF #50001
IF [#9044 > 8] && [#9044 <= 50000] THEN GOTO 100
IF #50001
IF [[#9044 != 0] && [#9044 < 50000]] && [[#9044 < 1] || [#9044 > 8]] THEN M225 #106 "The PLC input entered into parameter 44 in invalid.\nPlease enter a value of between 1 and 8 into parameter 44\nPress Cycle Cancel to end job now."
IF #50001
IF [[#9044 != 0] && [#9044 < 50000]] && [[#9044 < 1] || [#9044 > 8]] THEN GOTO 100
IF #50001
IF [[#9044 != 0] && [#9044 >= 50000]] && [[#9044 < 50001] || [#9044 > 50008]] THEN M225 #106 "The PLC input entered into parameter 44 in invalid.\nPlease enter a value of between 1 and 8 into parameter 44\nPress Cycle Cancel to end job now."
IF #50001
IF [[#9044 != 0] && [#9044 >= 50000]] && [[#9044 < 50001] || [#9044 > 50008]] THEN GOTO 100
IF #50001
IF [#9044 == 0] && [#9011 < 50000] && [[#9011 < 1] || [#9011 > 8]] THEN M225 #106 "The PLC input entered into parameter 11 in invalid.\nPlease enter a value of between 1 and 8 into parameter 11\nPress Cycle Cancel to end job now."
IF #50001
IF [#9044 == 0] && [#9011 < 50000] && [[#9011 < 1] || [#9011 > 8]] THEN GOTO 100
IF [#9044 == 0] && [#9011 >= 50000] && [[#9011 < 50001] || [#9011 > 50008]] THEN M225 #106 "The PLC input entered into parameter 11 in invalid.\nPlease enter a value of between 1 and 8 into parameter 11\nPress Cycle Cancel to end job now."
IF #50001
IF [#9044 == 0] && [#9011 >= 50000] && [[#9011 < 50001] || [#9011 > 50008]] THEN GOTO 100
IF #50001
IF #9071 == 0 THEN M225 #106 "The height for the tool touch off device has not been set in parameter 71.\nPlease measure the height of your tool touch off device and enter it parameter 71\nPress Cycle Cancel to end job now."
IF #50001
IF #9071 == 0 THEN GOTO 100
IF #50001
IF #9044 != 0 THEN #104 = #9044
IF #50001
IF #9044 == 0 THEN #104 = #9011
IF #50001
IF #104 > 50000 THEN #104 = #104 - 50000
IF #50001
IF [#9014 == 0] && [#4006 == 20] THEN #102 = 10
IF #50001
IF [#9014 != 0] && [#4006 == 20] THEN #102 = #9014
IF #50001
IF [#9014 == 0] && [#4006 == 21] THEN #102 = 254
IF #50001
IF [#9014 != 0] && [#4006 == 21] THEN #102 = #9014
IF #50001
IF [#9015 == 0] && [#4006 == 20] THEN #103 = 1
IF #50001
IF [#9015 != 0] && [#4006 == 20] THEN #103 = 1
IF #50001
IF [#9015 == 0] && [#4006 == 21] THEN #103 = 25.4
IF #50001
IF [#9015 != 0] && [#4006 == 21] THEN #103 = 25.4
IF #50001
N150
;G28 ;Hamid changed this default location
;G53 X-100 Y100 ;Instead move spindle to this location
M225 #106 "#)You may change the tool bit #%.0f\nPress CYCLE START to continue" #4120
N200
;Prompt user for resetting Z0 position
M224 #100 "#)Would you like to RESET the current Z0 position?\n#)Press 0 to continue without resetting Z0\n#)Press 1 to auto reset current Z0\n#)Press CYCLE START to continue"
IF #50001
IF #100 == 0 THEN GOTO 400 ;Skip if user chose not to reset Z0
IF #50001
IF #100 == 1 THEN GOTO 250 ;Reset Z0
IF #50001
IF #100 > 1 THEN GOTO 200 ;Go back to prompt user if invalid value was selected
IF #50001
N250
M200 "#)If needed, jog the spindle over the touch plate\nPress CYCLE START to touch plate"
N300
M115 /Z P[#104] F[#102] ;Move at fast probing rate until TT1 detected
G91 Z#9013 F[#102] ;Move up the distance set in P13.
M115 /Z P[#104] F[#103] ;Move at slow probing rate until TT1 detected
G90
G92 Z[#9071] ;Set Z position to 0 + height stored in parameter 71
G4 P1 ;Wait 1 second
G53 Z0 ;Retract Z
;M225 #106 "#)Turn spindle On\nPress CYCLE START to continue"
N350
;Prompt user for moving bit to X0Y0Z0
M224 #107 "#)Would you like to move the cutter to X0Y0Z0?\n#)Press 0 to continue without moving the cutter to Z0\n#)Press 1 to move the cutter to X0Y0Z0\n#)Press CYCLE START to continue"
IF #50001
IF #107 == 0 THEN GOTO 400 ;Skip if user chose not to reset Z0
IF #50001
IF #107 == 1 THEN GOTO 375 ;Move bit to Z0
IF #50001
IF #107 > 1 THEN GOTO 350 ;Go back to prompt user if invalid value was selected
IF #50001
N375
G0X0Y0Z0
M200 "#) If it's all GOOD, jog cutter up Z axis and TURN ON SPINDLE :) \nPress CYCLE START to continue"
N400
IF #50001
N1000
;End of macro