First time in this forum so the post went off quickly.

New try

So Hi.

The issue is that the Z-value in the G54 is changed when I change tool by the ATC.

I strongly think it is due to the M6, but I'm not (yet) understanding the code in the M6 well enough.

This is what I do:

I use Mach3 on a router with ATC

I use Fusion 360 for the CAD/CAM and post processing

Example when the issue occures:

I have designed a part using 2 tools, T1 and T3, the G-code is below.

I set the tool offset by touching the top of the stock with both T1 and T3.

Positive values are used on the tool offsets.

My Z-axis is set up to be positive going up from the table.

I set the G54 at the top of the stock. My Z-value is always negative, as an example -115mm.

When I start the program I have the T1 in the spindle, and I have choosen tool 1 in Mach3

It machines fine.

When the machine goes to change the tool I see live while looking at the G54 that the Z-value is changed.

Below is the G-code and I have indicated the precise line when the change in Z in the G54 occures

The new Z-value seems to be very random, it can be a reasonable -30 but also a stupid +150.

As said before that I think it is the M6 code causing the problem, but as the new Z-value seems random I wonder if it might be something else.

Example my computer seems slow or something else is wrong? I say that because when I look on the DRO and push the button switch between Machine coordinates and Local coordinates it is not updating the position XYZ always.

Long message but please help!!!

Below the G-code and the M6 start and stop.

G-code:

(1001)

(T1 D=8. CR=0. - ZMIN=-20. - FLAT END MILL)

(T3 D=5. CR=0. - ZMIN=-20. - FLAT END MILL)

G90 G94 G91.1 G40 G49 G17

G21

(2D CONTOUR2)

M5

T1 M6

S5000 M3

G54

G0 X-21.415 Y-1.669

G43 Z15. H0

Z5.

G1 Z1. F333.

Z-19.2

X-21.408 Z-19.304 F1000.

X-21.388 Y-1.67 Z-19.407

X-21.354 Z-19.506

X-21.308 Y-1.671 Z-19.6

X-21.25 Y-1.673 Z-19.687

X-21.181 Y-1.674 Z-19.766

X-21.102 Y-1.676 Z-19.835

X-21.015 Y-1.677 Z-19.893

X-20.921 Y-1.679 Z-19.939

X-20.822 Y-1.681 Z-19.973

X-20.72 Y-1.683 Z-19.993

X-20.615 Y-1.686 Z-20.

X-19.815 Y-1.702

G3 X-18.999 Y-0.918 I0.016 J0.8

G2 X-17.646 Y2. I3.999 J-0.082

X-19. Y5. I2.646 J3.

G1 Y15.

G2 X-15. Y19. I4. J0.

G1 X15.

G2 X19. Y15. I0. J-4.

G1 Y-15.

G2 X15. Y-19. I-4. J0.

G1 X-15.

G2 X-19. Y-15. I0. J4.

G1 Y-1.

X-18.999 Y-0.918

G3 X-19.783 Y-0.102 I-0.8 J0.016

G1 X-20.583 Y-0.086

X-20.687 Y-0.084 Z-19.993

X-20.79 Y-0.082 Z-19.973

X-20.889 Y-0.08 Z-19.939

X-20.982 Y-0.078 Z-19.893

X-21.069 Y-0.076 Z-19.835

X-21.148 Y-0.074 Z-19.766

X-21.217 Y-0.073 Z-19.687

X-21.275 Y-0.072 Z-19.6

X-21.321 Y-0.071 Z-19.506

X-21.355 Y-0.07 Z-19.407

X-21.376 Z-19.304

X-21.382 Z-19.2

G0 Z15.

(2D CONTOUR3)

M5

T3 M6

S5000 M3 The G54 change in Z occures on this line!!!

G54

G0 X-17.161 Y1.597

G43 Z15. H0

Z5.

G1 Z1. F333.

Z-19.5

X-17.156 Y1.603 Z-19.587 F1000.

X-17.141 Y1.62 Z-19.671

X-17.118 Y1.648 Z-19.75

X-17.086 Y1.687 Z-19.821

X-17.047 Y1.735 Z-19.883

X-17.001 Y1.79 Z-19.933

X-16.951 Y1.851 Z-19.97

X-16.898 Y1.915 Z-19.992

X-16.842 Y1.982 Z-20.

X-16.524 Y2.368

G3 X-16.591 Y3.072 I-0.386 J0.318

G2 X-17.5 Y5. I1.591 J1.928

G1 Y15.

G2 X-15. Y17.5 I2.5 J0.

G1 X15.

G2 X17.5 Y15. I0. J-2.5

G1 Y-15.

G2 X15. Y-17.5 I-2.5 J0.

G1 X-15.

G2 X-17.5 Y-15. I0. J2.5

G1 Y-1.

G2 X-15. Y1.5 I2.5 J0.

G1 X-0.418

G3 Y2.5 I0. J0.5

G1 X-15.

G2 X-16.591 Y3.072 I0. J2.5

G3 X-17.295 Y3.005 I-0.318 J-0.386

G1 X-17.614 Y2.619

X-17.669 Y2.552 Z-19.992

X-17.722 Y2.487 Z-19.97

X-17.773 Y2.426 Z-19.933

X-17.818 Y2.371 Z-19.883

X-17.857 Y2.324 Z-19.821

X-17.889 Y2.285 Z-19.75

X-17.913 Y2.257 Z-19.671

X-17.927 Y2.239 Z-19.587

X-17.932 Y2.233 Z-19.5

G0 Z15.

M30

My M6 are looking like this:

M6END

EM The default script here moves the tool back to m6start if any movement has occured during the tool change..

x = GetToolChangeStart( 0 )

y = GetToolChangeStart( 1 )

z = GetToolChangeStart( 2 )

a = GetToolChangeStart( 3 )

b = GetToolChangeStart( 4 )

c = GetToolChangeStart( 5 )

if(IsSafeZ() = 1) Then

SafeZ = GetSafeZ()

if SafeZ > z then StraightTraverse x, y,SafeZ, a, b, c

StraightFeed x, y, z , a, b, c

else

Code"G00 X" & x & "Y" & y

end if

M6START

chengdu xhc technology ,all right reserved |

'please don't modify these code if you don't know what you doing |

'

Declare Function ChangeTool Lib ".\Plugins\NcEther-8ts" () As Integer

dim newtool

Dim XWork, YWork,ZWork

dim chanok

Sub Main

newtool=GetSelectedTool()

OldTool = GetOEMDRO (824)

If newtool = OldTool Then

Message"Tool No Change"

If Not FileName() = "No File Loaded." Then

ActivateSignal(Output6)

end if

Exit Sub

End If

DoSpinStop() 'stop spindle

SetUserDro(1384,newtool)

XWork = GetOEMDRO(800) ' Get Current X Work Coordinate

YWork = GetOEMDRO(801) ' Get Current Y Work Coordinate

ZWork = GetOEMDRO(802)

Call ChangeTool()

chanok=GetUserDro(1338)

If(chanok>2) Then

SetCurrentTool(newtool)

end if

SetUserDro(1338,1)

If Not FileName() = "No File Loaded." Then

ActivateSignal(Output6)

Sleep(100)

DoSpinCW()

'Code "G0 X" & XWork & " Y" & YWork

'Sleep(500)

'While IsMoving()

'sleep(50)

'Wend

Code"G0Z"& ZWork

Sleep(500)

While IsMoving()

sleep(50)

Wend

DoOEMButton(1000) ' Cycle Start

end if

End Sub