Briefly, and in very basic terms - Automatic tool changes rely on 3 things:
1. Parameter 6 must be set to 1 to indicate that an ATC is installed. parm 161 = maximum tools/turret positions
2. A tool change macro -mfunc6.mac for mills and cnctch.mac for lathes must be written to sequence the tool change such as moving to a return point, notify the PLC that a tool change has been requested, waiting for the PLC to indicate that the tool change is complete etc.. This macro must reside in c:\cncm or c:\cnct respectively.
3. The PLC monitors the current turret/magazine position and rotates the turret/magazine to the requested position if needed and notifies the tool change macro when complete.
The tool number/requested turret position is sent to the PLC in decimal form(not BCD) the tool change macro when an M107 is issued. This is received in the system variable SV_TOOL_NUMBER which the PLC can read and determine if the requested turret position does not = the current turret position and therefore needs to rotate to the requested position.
In the example below, the turret is at position 1.
In the cnctch.mac macro:
; #4120 = contains the requested tool number from the g code program
; #90014 = contains the value of W14 in the PLC program which the PLC uses to ; store the current turret position
For instance, if your g-code program calls for a T0404 and parameter 6 is set to 1 to indicate it is an ATC, the control will automatically call cnctch.mac to perform the tool change:
example cnctch.mac:
;------------------------------------------------------------------------------
; Filename: cnctch.mac
; Tool change request macro
; Description: User Customizable Macro
; Notes:
; Requires: Machine home must be set prior to use.
; Please see TB300 for tips on writing custom macros.
; #4120 = contains the requested tool number from the g code program
; #90014 = contains the value of W14 in the PLC program which the PLC uses to ; store the current turret position
;------------------------------------------------------------------------------
IF #50010 ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 ;Skip macro if graphing or searching
IF #4120 == #90014 THEN GOTO 1000 ;Skip macro if already at requested position
N100 ;Insert your code between N100 and N1000
M107 ;Send tool number
G4 P.5 ;Wait .5 second
M94 /6 ;Request tool change
M101 /70001 ;Wait for toolChangeComplete (MEM1)
M95 /6 ;Turn off tool change request.
N1000 ;End of Macro
Since the turret is at position 1 (not 4 as requested), the M94/6 tells the PLC to begin a tool change and waits until the PLC sets MEM1 M101/70001
before continuing.
In the PLC:
This section below monitors the current turret position. The turret being used has a 3 bit gray code encoder that uses 3 inputs INP5-INP7 on the Acorn for ToolBit1, ToolBit2, ToolBit3 to report the turret position as follows.
IF TRUE THEN CurrentTurretPosition_W = 0
IF ToolBit1 && ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 1
IF !ToolBit1 && ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 2
IF !ToolBit1 && !ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 3
IF ToolBit1 && !ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 4
IF ToolBit1 && !ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 5
IF !ToolBit1 && !ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 6
IF !ToolBit1 && ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 7
IF ToolBit1 && ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 8
IF TRUE THEN SV_PLC_CAROUSEL_POSITION = CurrentTurretPosition_W
This section below gets the requested tool position when a tool change is requested -Note M6 is set by the M94 /6 request in the cnctch.mac:
IF M6 THEN (M6PD), SET DoingTurretIndex_M
IF M6PD THEN RequestedLocation_W = SV_TOOL_NUMBER ; <------Decimal # sent when m107 is issued in cnctch.mac
The section below rotates the turret to the requested position. This particular turret requires that the turret "settle" for 700 milliseconds after the requested position is reached before turning the TurretMotor output off. After the TurretMotor ouput is turned off, it needs to reverse for 1.5 seconds in order to lock before completing the tool change.
;Setup timers
IF TRUE THEN TurretTimer = 700, ReversingTimer = 1500
;If current position != requested position, rotate turret
IF DoingTurretIndex_M && RequestedLocation_W != CurrentTurretPosition_W THEN SET TurretMotor
;After requested position has been reached, start timer to allow turret to settle
IF RequestedLocation_W == CurrentTurretPosition_W THEN SET TurretTimer
;After turret has settled, turn off TurretMotor, start reversing timer
IF TurretTimer THEN RST TurretMotor, SET ReversingTimer, RST TurretTimer
;After turret has reversed for 1.5 seconds, notify cnctch.mac that tool change is complete
;Tell cnctch.mac that tool change is complete by setting MEM1
IF ReversingTimer THEN RST ReversingTimer, SET ToolChangeComplete
There is more to it susch as error checking and fault reporting, checking for valid tool numbers etc..
that I didn't have time/space to post here but are included in the complete PLC program and macro I have attached for your reference. If you provide details of your particular turret, I may be able to provide more specific help.