Hello Guest it is April 20, 2024, 12:57:05 AM

Author Topic: G54 is changed in Z when using M6 tool change  (Read 2128 times)

0 Members and 1 Guest are viewing this topic.

G54 is changed in Z when using M6 tool change
« 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


Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: G54 is changed in Z when using M6 tool change
« Reply #1 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.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: G54 is changed in Z when using M6 tool change
« Reply #2 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   

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: G54 is changed in Z when using M6 tool change
« Reply #3 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
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: G54 is changed in Z when using M6 tool change
« Reply #4 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?

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: G54 is changed in Z when using M6 tool change
« Reply #5 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.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: G54 is changed in Z when using M6 tool change
« Reply #6 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

Offline TPS

*
  •  2,505 2,505
    • View Profile
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: G54 is changed in Z when using M6 tool change
« Reply #8 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. 

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: G54 is changed in Z when using M6 tool change
« Reply #9 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.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.