Tool change to wrong tool???

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
MatterHKR42
Posts: 16
Joined: Tue Oct 01, 2024 7:05 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C165673
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Tool change to wrong tool???

Post by MatterHKR42 »

Just when I thought I had the atc turret on my lathe figured out.. :lol:

The lathe uses a ratchet and pawl style turret so it has to reverse to lock. its stepper driven, with a current limit set to 20% so it can stall on reverse and not break anything. for the macro, theres a snippet of it below. its just the OE axis driven tool macro with an M26 line added to keep wind up error in check. that little change fixed the previous issue it had with lock up.

The issue... It doesn't seem to like moving to the correct tool position when running a single program with multiple tool changes. its like when its in program, it cant read what the current tool position is so it assumes T0101, and moves the number of positions that corresponds with the next tool.. so lets say its on t0101, which is often the case, and t0303, is called.. it moves 3 positions to position 3, seems right, right?.. this is where it gets weird. lets say t0505 is the next tool, instead of moving 2 positions to get to tool 5, it moves 5 positions to tool 8.. with a simple program that basically just changes tools (created by my cam software, Fusion) this is the case for every tool change. calling T0404 next moves 4 positions (from position 8) and lands on T0303.. Calling T0707 (from t0303) lands on T0202. So on and so forth...

To make things more confusing.. calling tools via MDI works absolutely fine. Even breaking out my tools paths, grouped by tool and running each one individually works fine, even if the current tool isn't the requested tool. For these cases, its actually been flawless. Not a single wrong position.

I'm at a loss here so any help is greatly appreciated.

;Check to ensure turret is not at requested position, if so then skip tool change.
IF [ABS[#4120-#101] < .002] THEN GOTO 1000

;If tool requested is not a valid tool, Skip macro and send message to operator.
IF #4120 < 1 || #4120 > #9161 THEN GOTO 500

;Calculate Requested Position to move Turret to.
IF #101 > #4120 THEN #102 = [#103 + #9161 + #4120 - #101] ELSE #102 = [#103 + #4120 - #101]

G53 A[#102 + #9853] ;Move past tool by P853 Amount
G53 A[#102 - #9854] ;Move back behind toold by P854 Amount
IF #50001
M26 /A L[#4120*#20604]


IF #50001 ;Prevent lookahead from parsing past here
G10 P1976 R[#4120] ;Set parameter 976 to tool number
Output from the post processor
;1001
;TEST
N10 G98 G90
N11 G20
N12 G50 S1200
N13 G28 U0.
N14 G28 W0.

;OD FINISH
N15 T0300
N16 G54
N17 M8
N18 G90 G99
N19 G97 S370 M3
N20 G0 X1.55 Z0.1969 T0303
N21 G50 S1200
N22 G96 S150 M3
N23 G4 P1.
N24 G0 Z0.0654
N25 X0.4201
N26 G1 X0.3838 F0.003
N27 Z-0.0146
N28 X0.4323 Z-0.0388
N29 Z-0.386
N30 X0.5675
N31 X0.6252 Z-0.4148
N32 Z-0.5378
N33 X0.75
N34 X0.8631 Z-0.4812
N35 X0.8754
N36 G0 X1.55
N37 Z0.1969
N38 G97 S370 M3

N39 M9
N40 T0300
N41 G28 U0.
N42 G28 W0.


cncsnw
Community Expert
Posts: 4536
Joined: Wed Mar 24, 2010 5:48 pm

Re: Tool change to wrong tool???

Post by cncsnw »

What is the meaning of variable #103 in your tool change macro? Your code fragment above references it, but must assume it was set somewhere previously.

The code fragment above seems to assume that #101 is equal to the current turret position (approximately 1 - 16).

Ignoring the mystery of #103 for now, the code above seems to be calculating a distance in variable #102: something that increases with #4120, and decreases with #101, so presumably it is the incremental number of positions to move to get from #101 to #4120.

However, you then use G53 to move to the position in #102 (plus and minus your pawl overshoot requirement).

G53 always makes an absolute move, never an incremental one.

If you want to use G53, you will need to calculate an absolute target.


MatterHKR42
Posts: 16
Joined: Tue Oct 01, 2024 7:05 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: C165673
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Tool change to wrong tool???

Post by MatterHKR42 »

cncsnw wrote: Sat May 10, 2025 10:34 pm What is the meaning of variable #103 in your tool change macro? Your code fragment above references it, but must assume it was set somewhere previously.

The code fragment above seems to assume that #101 is equal to the current turret position (approximately 1 - 16).

Ignoring the mystery of #103 for now, the code above seems to be calculating a distance in variable #102: something that increases with #4120, and decreases with #101, so presumably it is the incremental number of positions to move to get from #101 to #4120.

However, you then use G53 to move to the position in #102 (plus and minus your pawl overshoot requirement).

G53 always makes an absolute move, never an incremental one.

If you want to use G53, you will need to calculate an absolute target.
Heres my full macro.
Can confirm that it also affects oneshot programs. if I set up a oneshot turn for example, with both a main and finishing tool, if the machine isn't on the correct tool for the roughing cycle, it will index to the correct tool but then wont index to the correct finishing tool.
I just ran a cycle with t0101 roughing, t0303 finishing, and it was on tool t0606 prior to starting.
It did index to T0101 to start the roughing cycle but indexed to T0404 instead of T0303 for finishing

looks like the macro works fine without the M26.. but then I don't get turret lock up so is there some error-proofing in CNC12/Centroid that prevents an M26 from being executed while in program? or maybe the g10 needs to run first?
;------------------------------------------------------------------------------
; Filename: cnctch.mac
; Description: Tool change request macro
; Notes:
; Requires:CNC12 v5.08
;
; 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)
; #9853 : Travel Past Distance
; #9854 : Travel Back Distance
;
; User Variables:
; #100 = Display Message Timer
; #101 = Calculated Current Turret Position.
; #102 = Calculated Requested Turret Position.
; #103 = A Axis 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 == 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

;---------------------------------------------------------------------------------
; Axis Driven Turret Section
;---------------------------------------------------------------------------------
N300

;Determine A Axis Position
IF #20101 == 65 THEN #103 = #5021
IF #20102 == 65 THEN #103 = #5022
IF #20103 == 65 THEN #103 = #5023
IF #20104 == 65 THEN #103 = #5024
IF #20105 == 65 THEN #103 = #5025
IF #20206 == 65 THEN #103 = #5026
IF #20107 == 65 THEN #103 = #5027
IF #20108 == 65 THEN #103 = #5028

#101 = #103 % #9161 ;Get Current Turret Location

;Check to ensure turret is not at requested position, if so then skip tool change.
IF [ABS[#4120-#101] < .002] THEN GOTO 1000

;If tool requested is not a valid tool, Skip macro and send message to operator.
IF #4120 < 1 || #4120 > #9161 THEN GOTO 500

;Calculate Requested Position to move Turret to.
IF #101 > #4120 THEN #102 = [#103 + #9161 + #4120 - #101] ELSE #102 = [#103 + #4120 - #101]

G53 A[#102 + #9853] ;Move past tool by P853 Amount
G53 A[#102 - #9854] ;Move back behind toold by P854 Amount
IF #50001
M26 /A L[#4120*#20604]

IF #50001 ;Prevent lookahead from parsing past here
G10 P1976 R[#4120] ;Set parameter 976 to tool number

GOTO 1000

N500
M225 #100 "Invalid Tool Number Requested!\nPress Cycle Start to Skip Tool Change.\nPress Cycle Cancel to abort Program"

N1000 ;End of Macro


Post Reply