Hello Guest it is March 28, 2024, 08:20:01 PM

Author Topic: Changing G54 inside script  (Read 2558 times)

0 Members and 1 Guest are viewing this topic.

Changing G54 inside script
« on: June 19, 2019, 09:01:23 AM »
Hello, I am retrofitting an machine with multiple tools on the head with mach4. The machine has an head which is mounted to a Z axis. I need to give an offset to each tool on the head. I think the best way is to change the G54 according to the position on the tool on the head. We use g54 standard because our work origin is fixed on the table but it is not directly under the machine zero.  So let's say our x in G54 is 150mm and the tool on the head is -50 in relation to the primairy tool. So I would make the G54 x coordinate 200mm.

Is this possible to do it this way within a script. Or does someone have a better idea on how to achieve the correct x an y offset when a different tool is selected?

Thanks in advance.

Jelle

Offline MN300

*
  •  297 297
    • View Profile
Re: Changing G54 inside script
« Reply #1 on: June 19, 2019, 10:02:34 AM »
Mach4 has 106 fixture offsets, including G54.1 P1 ... G54.1 P100. Your tool change script could change the trailing number in G54.1 Pxx to match the new tool number and select a different fixture offset for each tool.
Re: Changing G54 inside script
« Reply #2 on: June 19, 2019, 10:40:48 AM »
Mach4 has 106 fixture offsets, including G54.1 P1 ... G54.1 P100. Your tool change script could change the trailing number in G54.1 Pxx to match the new tool number and select a different fixture offset for each tool.

Thanks for the reply I did not see that I think that will be a great solution. To be fair I am not very good in the lua scripting. Do you know how to change these g54.1 pxx to the correct one per tool. I  want to use an if statement which reads the tool and set some parameters for different tools. But how do I say that the machine needs to use an certain g54?

Thanks in advance

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Changing G54 inside script
« Reply #3 on: June 19, 2019, 11:14:15 AM »
Why not just use the X and/or Y offset for each tool? View, tool table, edit, table fields, optional fields.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Changing G54 inside script
« Reply #4 on: June 19, 2019, 11:19:51 AM »
Why not just use the X and/or Y offset for each tool? View, tool table, edit, table fields, optional fields.

I used that feature. But when try a test code which mills an pocket the head goes down on the original location where the mill would plunge inside the workpiece. After that it slowly moves to the changed ''new'' pocket location.  The feature works for the offsets but has te problem I described.

Maybe you know a way to solve this?

Offline MN300

*
  •  297 297
    • View Profile
Re: Changing G54 inside script
« Reply #5 on: June 19, 2019, 11:31:56 AM »
Your M6 tool change script should already have lines like this,

local inst = mc.mcGetInstance()
local selectedtool = mc.mcToolGetSelected(inst)

Add this at the end to select a tool fixture to match the tool number.

mc.mcCntlGcodeExecuteWait(inst, " G54.1 P" .. tostring(selectedtool))

Offline MN300

*
  •  297 297
    • View Profile
Re: Changing G54 inside script
« Reply #6 on: June 19, 2019, 11:47:25 AM »
Chaoticone's solution does sound easier.

If your change script automatically probes to check the tool length, the X and Y offsets would have to be changed before probing.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Changing G54 inside script
« Reply #7 on: June 19, 2019, 12:07:05 PM »
Did you set the offset using G43 H(Tool number)?
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Changing G54 inside script
« Reply #8 on: June 19, 2019, 12:39:56 PM »
Did you set the offset using G43 H(Tool number)?

Yes it uses g43 H2 . It does work the offset.  I am using fusion 360 to make the gcode. But when I run the program with x and y offset the tool goes to the workpiece surface fast. and then you can see the position of the pocket change in the toolpath window inside mach4. Then the tool moves to the ''new'' position of the pocket ,which correspondence with the offsets of the tool, with the feedrate for cutting(which is much slower then the normal moving speed above the workpiece) So how can I get mach4 to move quickly above the surface to the ''new'' pocket location without going to the ''old'' location first? Did you have the same problem with the offsets?

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Changing G54 inside script
« Reply #9 on: June 19, 2019, 01:30:07 PM »
It sounds like it is doing exactly what the Gcode is telling it to do. Have you verified that? If not, you need to. Put it in single block and execute one line at the time. Read the line, understand what it is telling the machine to do, watch the machine. If the machine does something contrary to what the Gcode is telling it to do, tell us what that is.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!