Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: Tomashi on October 20, 2022, 05:40:32 AM

Title: G54 is changed in Z when using M6 tool change
Post by: Tomashi on October 20, 2022, 05:40:32 AM
Hi. I have an issue with my ATC router.
I would be very grateful if someone can help me out.
I have been strugling with this for some time and I'm not (yet) capable of understanding the M6 script.

Background:
I use Fusion 360 for CAD/CAM and Mach3 to run my router.

I have set the G54 and every thing works fine till the tool change.
The M6 is activated and the tool is changed and then at the end of M6 the G54 is changed in Z!

It seems like something in the M6 script is taking the Z position of the machine exactly when it is leaving the tool change position and puts in that figure in to the G54 Z.

I provide the M6 script, can someone please have a look on it?

Regards Tomas


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   



M6 End
REM 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


Title: Re: G54 is changed in Z when using M6 tool change
Post by: TPS on October 20, 2022, 06:11:43 AM
the code:

Code: [Select]
SetCurrentTool(newtool)

will set the toollength witch is in tooltable, and therefore your Z will be "corrected" with new toollength.
Title: Re: G54 is changed in Z when using M6 tool change
Post by: Tomashi on October 20, 2022, 06:30:16 AM
Hi TPS. Thanks for this promt reply!

Ok so lets say: tool 1, H20mm, I have my ref point at the top of the work piece so I touched my work piece with tool 1 and it turns out that the G54 Z is -100

When M6 put in the new tool, no2, H10mm, the new G54 Z would be -110, right?

What is actually happening is that the G54 Z is changed to the Z position where the tool change is taking place (Z-200) + it takes in to account the new tool length. The G54 Z will be set to -210.

Can you see where in the M6 script the tool change position is taken in to count?

Regards Tomas

I   
Title: Re: G54 is changed in Z when using M6 tool change
Post by: TPS on October 20, 2022, 06:33:53 AM
normaly toolchange is done with activated G54.

so first activate G54 then touch your surface with toolA and the do a toolchange to toolB
Title: Re: G54 is changed in Z when using M6 tool change
Post by: Tomashi on October 20, 2022, 06:56:18 AM
what do you mean by activating G54?

Can you figure out why the Z tool change position is taken in to account when the G54 is updated?
Title: Re: G54 is changed in Z when using M6 tool change
Post by: TPS on October 20, 2022, 07:04:32 AM
i mean G54 is enabled before you do a toolchange with M6.

can't see what your toolchange function is doing because is in

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

this lib.

G54 will allways effect your workcoordinates if there are offset's stored.

have a look to you fixtures, with offsets are in there for G54.
Title: Re: G54 is changed in Z when using M6 tool change
Post by: Tomashi on October 20, 2022, 07:36:01 AM
Ok.

I will try to check out what the plugin is doing. If I make a screen shot perhaps you can have a look?

Probably a very silly question, but i thought that the G54 was supposed to keep the same Z-value even that a new tool with different H was used? When I do manual tool change this is the case.

Do you confirm that G54 Z shall change as a function of the tool length when a new tool is put in place by the M6?

Regards
Title: Re: G54 is changed in Z when using M6 tool change
Post by: TPS on October 20, 2022, 08:04:33 AM
https://www.machsupport.com/wp-content/uploads/2013/02/Mach3Mill_1.84.pdf

have a look to chapter 7
Title: Re: G54 is changed in Z when using M6 tool change
Post by: Tomashi on October 20, 2022, 11:34:06 AM
Thanks for the advise.
I have studied chapter 7 and my conclusion is that once i have set the G54 in X, Y and Z the values stays.
Then by using G52 and G92 it is possible to offset in relation to the G54.

This is confusing! When my program is doing the tool change I see live that the G54 Z is changed at the very moment the M6 macro ends, to the Z-value the machine has at that moment. 
Title: Re: G54 is changed in Z when using M6 tool change
Post by: TPS on October 20, 2022, 12:17:24 PM
as sayed, without seeing the code from function ChangeTool() it is hard to say what is going on.
Title: Re: G54 is changed in Z when using M6 tool change
Post by: Tomashi on October 25, 2022, 07:09:59 PM
Hi. Comming back to this now. Was in the workshop today so I did some photos och the plugin .\Plugins\NcEther-8ts

Thanks and regards

Title: Re: G54 is changed in Z when using M6 tool change
Post by: TPS on October 26, 2022, 12:21:42 AM
pls check, if there is a file like this   C:\Mach3\Plugins\NcEther-8ts.m1s ?
Title: Re: G54 is changed in Z when using M6 tool change
Post by: Tomashi on October 26, 2022, 04:17:30 AM
There is a C:\Mach3\Plugins\NcEther-8ts 2.dll, see photo

Title: Re: G54 is changed in Z when using M6 tool change
Post by: Tweakie.CNC on October 26, 2022, 05:51:05 AM
Hi Tomashi,

I have sent you a PM.

Tweakie.
Title: Re: G54 is changed in Z when using M6 tool change
Post by: TPS on October 28, 2022, 12:01:24 PM
ok, it is a dll, and we are not able to "see" the macro code.
only thing what's left is to use a "selfmade" M6Start macro for the ATC.


here:

https://www.machsupport.com/forum/index.php?topic=36417.msg249874#msg249874

is an example i posted some years ao.
Title: Re: G54 is changed in Z when using M6 tool change
Post by: kf2qd on March 22, 2023, 05:47:58 PM
G54 sets the X Y & Z coordinates to your reference tool. One of the pieces of data you enter for each tool is the LENGTH.What is happening as you change tools the Ddiplay value for Z will change to reflect the currently called out tool. So - if for your reference tool - the Z position at a certain height of the machine is 3", then is you change to a tool that is an inch shorter and have an M6 T?? line matching the new tool, the Z value would read 4 reflecting the current position of the now active tool.