Welcome

Thanks for visiting the Mike's Make blog. It is a compilation of many of my interests. I hope you find the articles in this blog helpful and entertaining. Leave a comment and let me know what you think.

Wednesday, May 30, 2012

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. 
 I use drawing programs such as AutoCAD and Draft Sight to create my designs, and then process the drawing file with the .dxf extension through a program called Ace. This creates the G-code program file, but unfortunately there is no rhyme or reason for the order of the axis movements that is produced.        
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.


Figure 3, Excel Sort Function

When I’m done, I save the spreadsheet as a Text (tab delimited) file then add the z-axis movements and comments to the file and then I’m done.  

One last note about using this method, in the example above I sorted the data by the B column (X-axis), but I could have just as easily sorted the data using the Y-axis. This method is not a perfect solution for optimizing your G-code, but it’s a start.




No comments:

Post a Comment