CNC Programming

Continuing our discussion on the basic understanding of CNCs, the next logical topic would be a CNC program. While you could stand at your machine and type individual commands for it to go to a certain XYZ position and do something, and then type another command to have it go somewhere else, this is generally handled by a "program" that you (or some CAM software) would write. Don't worry, we'll get to what CAM is shortly.

A CNC program is nothing more than a list of XYZ coordinates, or moves, that the machine executes line by line. These programs are also called G-Code. G-Code is a standard of instructions that was developed for controlling CNC machines, and there's a lot to learn about G-Code, and you can do a lot more than simple XYZ movements with G-Code. We will get to G-Code as well, but for this simple example, we don't need it yet.

Ok so a simple CNC program might look like this, for this example lets assume we have a CNC router, and that router is above a board we are going to cut, and the TOP of the board is at Z0 (Z Zero) and the board is 1/2" thick


Lets examine this simple program line by line...

G1Z.5 - This line tells the machine to go to the position where .5 or 1/2 inch is in the positive Z axis... what will happen is, if the machine is positioned currently BELOW Z.5 then it will raise the Z axis until it reaches .5" and if it is ABOVE .5 then it will come down. You will normally see a Z movement as the first movement because you'd want to make sure you move at a height ABOVE your workpiece so that you don't make cuts that you're not intending to.

G1X2.5Y3.6 - This line tells the machine to go to the position of 2.5 inches in X and 3.6 inches in Y

G1Z-.5 - This line tells the machine to plunge down into your workpiece 1/2 inch, basically going all the way through it

G1Y0 - This line tells the machine to move to Y0, and what the machine will do, since it's still 1/2" into the piece is rout a line from Y3.6 to Y0

G1X0 - This line tells the machine to move to X0, routing a line from X2.5 to X0

G1Y3.6 - This line tells the machine to move to Y3.6 again, so now we should have a U shape routed out so far

G1X2.5 - This line completes the box by taking the machine back to X2.5, so the machine is now at X2.5Y3.6 basically back where we started

G1Z.5 - This line takes the Z axis back up to a "safe" spot above the workpiece at .5 inches

Ok so basically what this little program has given us is a 1/2" part that is 2.5" wide and 3.6" long - pretty simple, right?