Kirkpatrick Consulting

Providing CNC (Computer Numeric Control) Programming Services
To Dallas, Texas and the surrounding area.

CNC / G-code Machine Programming

For practical purposes and applications, one must have a firm understanding of general machining principles and practices. To be most effective, G-code programs must be written with the limits of the machine and tooling to be used in mind. Below can be found some basic G-code programming examples with brief explainations:

At machine start up, most machines will be started with certain G-code and M-code parameters in effect. Because the machine starts in this condition, there is no need to be redundant and repeat these setup codes in the program. Refer to the specific machine's programming manual to determine which of these codes are active at startup. Most mills are started with G17 G20 G40 G53 and G98 enabled. So, what must be called out at the beginning of a program? Below is an example for a Haas VMC mill:

Most programs start with:

G00 G54 X(POS) Y(POS) with the X and Y positions determined as a safe move

Then a tool callout and tool change is needed.

T01 M06

Then it is needed to turn the spindle on and indicate spindle speed:

S1000 M03

So, a sample program might end up looking something like this:

G00 G54 X6.0 Y6.0
T01 M06
S1000 M03
G00 X0.0 Y0.0
G00 G43 Z1.0 H01 M08
G01 Z-0.1 F2.0
G01 X1.0 F5.0
G00 Z1.0 M09
G00 X6.0 Y6.0 M05
G28 G91 Z0.0

G-code chart

M-code chart

Back to KirkCon Home