Hello Guest it is April 20, 2024, 01:14:36 AM

Author Topic: Array G-Code Macro  (Read 3140 times)

0 Members and 1 Guest are viewing this topic.

Array G-Code Macro
« on: November 01, 2019, 09:18:26 PM »
Hello all. I've been using Mach3 for a couple years with just the basic settings to run my CNC Router. I've recently started making items that are duplicates. I don't have an auto tool-changer and most of my projects required 2-3 tools. Right now, I will create a program for each tool, complete all cuts with one tool, change to the 2nd, and then change to the third. This requires me to swap the part out multiple times. I've recently made a fixture that allows me to nest up to 6 parts at one time, with equal spacing in X and Y (2 rows, 3 columns). Is it possible to create a macro that will come up with a prompt to input the number of parts in the fixture and then run the g-code file for each part in the fixture by offsetting my X and Y values? I could create this array in my CAM software, but I won't always be machining the same amount of each part; sometimes i may need 4, and other times 6.

Offline Graham Waterworth

*
  • *
  •  2,672 2,672
  • Yorkshire Dales, England
    • View Profile
Re: Array G-Code Macro
« Reply #1 on: November 02, 2019, 07:59:57 PM »
Check out the G52 command.
Without engineers the world stops

Offline rcaffin

*
  •  1,054 1,054
    • View Profile
Re: Array G-Code Macro
« Reply #2 on: December 19, 2019, 05:08:54 AM »
I do this all the time for small production use.

If I am lazy, I use G52 inside subroutine loops. When the program loads all the parts are visible.
The downside is that the Mach3 display does not remember the G52 when the program is actually running (as opposed to loading), so all the parts appear overlaid during runtime. It's annoying, but you get used to it.

If I have to, I go through the code and set it up so every op uses an offset X & Y variable. Takes some effort to set it all up, but it can be worth while.

Up at the start of the program I define lots of parameters, including the number of rows and columns of parts to machine. The attached picture shows an array of plastic parts I was machining. It is even possible to offset into the physical array - to skip say the first column or so.

Cheers
Roger