
1) I need to change the Parameter 161 to 8 ?
Here is the macro.
;-------------------------------------------------------------------------------
; Tool Change Macro (M6) Linear Rack ATC for Router 8 tools
; Date: 9-11-2017
; Requires: that user set #150 to the tool number that is currently in the spindle.
; If no tool is in the spindle, the macro will command the
; machine to move directly to the new tool location while
; at the Z axis tool change clearance position.
;
;---------------------------NOTES--------------------------------
; The user must set the value for #105 below to the incremental
; distance between pots on the X axis and set #103 to the Y axis
; position for tool changes and #104 to the X axis position of the
; first tool pot. The macro then determines the positions for the
; put back tool and the new tool as follows:
; Putback location for variable axis = [[[[#150]-1]*7.530] + 33.865]
; ((("tool in spindle" -1) * (Incremental distance between pots))
; + "variable axis (X) tool change position for tool 1")
; Requested tool location for variable axis = [[[[#4120]-1]*7.530] + 33.865
; ((("requested tool number" -1) * (Incremental distance between pots))
; + "variable axis (X) tool change position for tool 1")
; Skip tool change macro if in search or graphing mode
If #4201 || #4202 THEN GOTO 600
;---------------------Begin Tool change--------------------------
; Initialize variables
N50
;M0
If !#50001 then
M107 ; Send tool number
G4 P.25
If #4120 == #150 THEN GOTO 600 ; Skip if tool already in spindle
If #151 == 1 THEN GOTO 450 ; Previous unsuccessful - FAULT
#151 = 1 ; Set tool change flag
;M103 /10 ; Start action timer. If tool change
; > 10 seconds to complete - issue fault
M107 ; Send tool number
#100 = [#4003] ; Store positioning mode -G90 or G91
G90 ; Set to absolute
#101 = -14.275 ; Set Z axis tool change position
#102 = -2.125 ; Set Z axis tool change clearance position
#103 = -0.4 ; Set fixed axis (Y) tool change position for was 62.95 when y homed to front
; tool 1
#104 = 33.865 ; Set variable axis (X) tool change position
; for tool 1
#105 = 7.530 ; Incremental distance between pots
#106 = 8 ; Number of tool bins in rack
#107 = 0 ; Message timer 0 = force cycle start
#108 = 1.00 ; Pull Back Increment in Y
; Check for valid tool and putback number
If #4120 < 0 THEN GOTO 400 ; Go to fault if tool number invalid
If #4120 > [#106] THEN GOTO 400 ; Go to fault if tool number invalid
If #150 > [#106] THEN GOTO 400 ; Go to fault if putback location invalid
If #150 < 0 THEN GOTO 400 ; Go to fault if putback location invalid
If !#50011 THEN ; Force update to variables before proceeding
N100 ;Turn off spindle/coolant, move Z to clearance extend rack
;M0
If !#50001 then
M5 ; Turn off spindle
G53 Z#102 ; Rapid Z axis tool change clearance position
N200 ;Putback previous tool
;M0
If !#50001 then
If [#150] == 0 Then GOTO 300 ; Skip putback if no tool in spindle
G53 X[[[[#150]-1]*#105]+#104]Y[#103-#108] ; Rapid to putback X,Y clearance pos.
G53 Z#101 ; Rapid to Z axis tool change pos
G53 X[[[[#150]-1]*#105]+#104]Y#103 ; Rapid to putback X,Y pos.
M15 ; Unclamp Tool
G91 Z.1 ; Move Z up slightly to allow tool to release
G90 ; Set back to absolute
G4 P1
If !#50001 then
G53 Z#102 ; Rapid Z axis tool change clearance position
N300 ;Get new tool
;M0
If #4120 == 0 Then GOTO 500
If !#50001 then
M15 ; Turn On Unclamp
G53 X[[[[#4120]-1]*#105]+#104]Y#103 ; Rapid to requested X,Y tool pos
G53 Z#101 ; Rapid to Z axis tool change pos
M16 ; Turn off unclamp output
G4 P1
If !#50001 then ; Wait for tool to clamp (input 24 to open)
G53 X[[[[#4120]-1]*#105]+#104]Y[#103-#108] ; Rapid to putback X,Y clearance pos.
If 1 == 1 Then GOTO 500 ; Tool change complete, skip fault
N400 ; #150 not intialized or tool number out of range fault
;M0
If !#50001 then
If #150 > #106 Then M225 #107 "FAULT: Putback location(%.0f) invalid" #150
If #150 < 0 Then M225 #107 "FAULT: Putback location(%.0f) invalid" #150
If #4120 > #106 Then M225 #107 "FAULT: Invalid tool location(%.0f) invalid" #4120
If #4120 < 0 Then M225 #107 "FAULT: Invalid tool location(%.0f) invalid" #4120
If 1 == 1 Then GOTO 400
N450 ;Previous tool change did not complete successfully
;M0
If !#50001 then
If 1==1 Then M224 #150 "FAULT: Previous Tool Change Unsuccessful\nPlease enter the putback location for the\ntool which is currently in the spindle:\n(Enter 0 if no tool present)"
#151 = 0
If 1 == 1 Then GOTO 50 ;Restart tool change
N500 ; Tool change succesfull, End macro
;M0
G53 Z#102
If !#50001 then
#150 = #4120 ;Set #150 = tool in spindle
#151 = 0 ;Clear tool change flag
G[#100] ;Restore positioning mode
;M104 ;Cancel program action timer
N600 ; Done
G43 H#4120 ;Set correct tool height offset
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
2) The other question is. The macro call the M107 but what is really happened?

Best Regards.