OK, so I've wired up the tool turret with a forward, reverse and locking pin enable for outputs. For inputs, I have 4 bit grey, all mapped correctly, a strobe input (not currently being used) and an input which tells me that the turret is in the locking position. Please see my code below. I'm not going out till tomorrow so cant test this. Should this work?
Essentially what the logic should say is fairly simple.
Rotate the Turret Forward (M94/111)
When you see that the required tool number has been reached, then enable the locking pin (M94/113), stop rotating the turret forward (M95/111) and check that the proximity sensor says that you are 'located' which is checked on Input 6 on the Eth1616 (M101/50039).
Rotate the Turret Backwards (M94/112), count 0.25 secs, stop rotating backwards (M95/112)
Ends
Does this line effectively create the 'for while loop', in otherwords, it will continue the action until the Tool Change is completed (ie, 4120 matches 4203)?
In terms of the various guides, should I be doing something with M18 or M21 which is included in the ATC files?
Thanks
;------------------------------------------------------------------------------
; Filename: mfunc6.mac
; Description: Tool Change Macro - Emco 320
; Notes:
; Requires: CNC12 V5.20
; Revision Date: 14 December 2024
; Please see TB300 or the following link for tips on writing custom macros.
;
https://www.centroidcnc.com/centroid_di ... amming.pdf
;------------------------------------------------------------------------------
; Parameters:
; Variables from PLC:
; #96052 = CurrentTurretPosition_W
; #9830 = #96028 = ATCType_W
;
; System Variables Used:
; #4120 = requested tool
; #20601-#20604 = Counts per unit for axes1-4
; #5021-#5024 is the current machine position for axes 1(#5021) through 4(#5024)
;
; Parameters:
; #9161 = Number turret positions (Parameter 161)
;
; User Variables:
; #100 = Display Message Timer
; #101 = Calculated Current Turret Position.
; #102 = Calculated Requested Turret Position.
;------------------------------------------------------------------------------
IF #50001 ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 ;Skip macro if graphing or searching
IF #4120 == #96052 THEN GOTO 1000 ;Skip macro if at requested tool position
#100 = 0 ;Ensure M225 Messages appear for indefinite time
;---------------------------------------------------------------------------------
; Determine Correct Tool Change Sequence
;---------------------------------------------------------------------------------
IF #9006 != 0 && #9830 == 0 THEN GOTO 100 ;Manual Tool Change
IF #9830 == 2 || #9830 == 3 || #9830 == 4 || #9830 == 5 THEN GOTO 200 ;Graycode,Counter,Timer
IF #9830 == 6 THEN GOTO 300 ;Axis Tool Changer
;---------------------------------------------------------------------------------
; Manual Tool Change
;---------------------------------------------------------------------------------
N100
M225 #100 "Please Change to Tool Number %.0f\nThen Press Cycle Start to continue" #4120
GOTO 1000
;------------------------------------------------------------------------------
IF #50001 ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 ;Skip macro if graphing or searching
IF #4120 == #96052 THEN GOTO 1000 ;Skip macro if at requested tool position
#100 = 0 ;Ensure M225 Messages appear for indefinite time
#151 = #4120 ;Requested Tool
#152 = #4203 ;Current Tool, Last T Number called
;---------------------------------------------------------------------------------
; Counter & GrayCode 2 and 1 Output Turret Section
;---------------------------------------------------------------------------------
N200 ;Insert your code between N100 and N1000
M107 ;Send requested Tool number to PLC Program
G4P1 ;Dwell for 1 second
M94 /7 ;Turn on request to change tool
;---------------------------------------------------------------------------------
; Tool Turret Rotation Start
;---------------------------------------------------------------------------------
M94/111 ;Rotate the Tool Turret Forward
M101 /70052 ;Wait for memory bit ToolChangeComplete_M
;---------------------------------------------------------------------------------
; Tool Turret Rotation Stop and Stop Solenoid
;---------------------------------------------------------------------------------
M94/113 ;Activate the Locking Solenoid
M95/111 ;Stop Rotating the Tool Turret Forward
M101/50039 ;Waits for Input 6 on Ether1616 to Close which incicates that the Locking Pin is in the correct position
;---------------------------------------------------------------------------------
; Tool Turret Reverse and Lock
;---------------------------------------------------------------------------------
M94/112 ;Reverse the Tool Turret
G4P0.25 ;Wait for 0.25 seconds
M95/112 ;Stop Reversing the Tool Turret
IF #50001 ;Prevent lookahead from parsing past here
G4 P0.5 ;Wait 0.5 seconds
M95 /7 ;Turn off request to change tool
GOTO 1000 ;End Macro