Method for
Optimizing CNC Machine G-Code Programs
by Michael Shaw, May 2012
This article explains a simple and inexpensive method I use
for making the axis movements of my CNC machine more efficient (optimizing).
There may be program packages available that optimize G-code for you, but
here’s a method I came up with that will do something similar, but using
software you probably already have, like Microsoft Excel.
There are several reasons you might want to optimize the
G-code programs for your CNC machine; one of them is to reduce the time needed
to operate the machine. If the G-code tells the CNC machine tool to move from
one side of the table to the other and back again, the process will take longer
than if the CNC machine tool moves in an orderly fashion. By optimizing your
G-code program you can save a significant amount of time.
An example is a G-code program I made for drilling holes in
a printed circuit board (PCB). A map of the axis movements before optimization
is performed is shown in figure 1, and the axis movements after optimization is
shown in figure 2.
Figure 1, drill locations before optimization |
Figure 2, drill locations after optimization |
The G-code program
in figure 2 actually ran 5% faster than the program in figure 1. How did I do
it? It’s simple; I import the G-code X-Y coordinates into an Excel spreadsheet
and then use the sort function in Excel to arrange the coordinates in ascending
order as shown in figure 3.