Breaking the code of digital fabrication

Most of us learned to make a cabinet with a tape measure and a table saw. We measure, cut and repeat, over and over, until the job’s done. The basic…

Most of us learned to make a cabinet with a tape measure and a table saw. We measure, cut and repeat, over and over, until the job’s done.

The basic knowledge and skills of woodworking aren’t lost when a shop moves to digital fabrication. The tools are certainly different, but the steps are essentially the same: design, manufacture and assemble. The biggest hurdle for many is transitioning from a paper-and-pencil drawing to a software-generated manufacturing program and then properly controlling the movement of the CNC machine’s cutter.

Working with a design program simply takes time and practice. Believe it or not, you’ll get the hang of it pretty quickly and wonder how you ever worked any other way. Last month, we covered the basic components of the digital fabrication process. This time, I want to focus on how CAD drawings are changed from images on a computer’s monitor into a set of instructions that make a CNC router move from one point to another, both horizontally and vertically.

The tool that does this is broadly called computer-aided manufacturing (CAM) software that generates step-and-direction instructions, otherwise known as G-code.

I can hear you grumbling already: “Why do I have to learn all this G-code stuff if the computer is going to do it all for me?”

Believe it or not, operating a CNC machine still requires your woodworking knowledge. And while you might not share my need for understanding how things work — remember, I’ve built two working CNC machines — I sincerely hope that you know exactly what’s going to happen when you press the start button.

G-code is part of an environment known as the “rectangular coordinate system,” which every woodworker knows but probably never really thought about before.

To visualize the rectangular coordinate system, imagine you are standing in front of a sheet of plywood. The 8’ distance running away from you is known as the X-axis. The 4’ distance running left-to-right is known as the Y-axis. In the lower left-hand corner is a position called “home,” which is known numerically as 0,0 (X=zero and Y=zero). From the home position, the cutting tool is instructed to move in specified increments — expressed in the decimal system. It can be thought of as laying a giant sheet of graph paper over the plywood and plotting the path of the tool.

The Z-axis goes up and down vertically and at a right angle to the X and Y portion of the rectangular coordinate system. The zero point of the Z-axis is where the very tip of the tool just barely touches the material. So now with three axes, the “home” position is stated as 0,0,0.

For a CNC router used for woodworking, the X and Y axes are always stated in positive numbers. The position of the Z-axis can be stated in either positive numbers, when it is above the material to be cut, or in negative numbers, which means the bit is into the material. For example, if the router is moving a 1/4” above the material, the position is stated as Z=0.25. If the router is cutting at a depth of 1/4”, the Z-axis is Z=-0.25.

The movement of the cutting tool is known as the tool path, which is generally the outline of the object being cut.

Let’s go back to cutting a 12” x 12” piece of quarter-inch plywood using the tape measure and table saw method. We’d start with a piece of plywood larger than 12” x 12”, square up one side using a miter gauge or table saw sled, then rotate the plywood to produce a right angle to the previously cut side. Then we’d set the saw fence to 12” and make the remaining cuts.

Here’s the exact same process written in G-code:

N001 (Sample cutting 12 inch square 1/4 inch plywood)

N002 (Tool diameter: 0.25)

N003 (Manual write RWL 4/2/14)

N004 G17 (set xy plane)

N005 G90 (absolute mode)

N006 G80 (cancel canned cycle)

N007 G50 (reset scale 1:1)

N008 G20 (inch mode)

N009 G00 Z0.25 F100 (raise bit 0.25 inches above material at 100 inches per minute)

N010 G00 X0 Y0 F100 (move router to home position at 100 inches per minute)

N011 G00 X1.0000 Y1.0000 F350 (move router so bit is 1 inch from home position in both X and Y direction at 350 inches per minute)

N012 G00 Z0.1000 F100 (lower router so bit is 0.10 inch from top of material at 100 inches per minute)

N013 G01 Z-0.2500 F50 (begin cutting by lowering router bit into material 0.25 inches at 50 inches per minute)

N014 G01 X1.0000 Y13.0000 F350 (move while cutting material at 350 inches per minute)

N015 G01 X13.0000 Y13.0000 (move while cutting material at 350 inches per minute)

N016 G01 X13.0000 Y1.0000 (move while cutting material at 350 inches per minute)

N017 G01 X1.0000 Y1.0000 (move while cutting material at 350 inches per minute)

N018 G00 Z0.25 F100 (raise router bit 0.25 inch above material)

N019 G00 X0 Y0 F100 (move router to home position)

N020 M30 (end program and rewind to line N001)

This simple program took 28 seconds to run on my machine. A G-code program formalizes what a woodworker does every day with explicit alpha-numerical commands.

In this example G00 and F100 are a combination of alpha-numeric characters known as “words” that create a single instruction for the CNC’s controller system. G00 positions the router to a specific location and is a non-cutting movement. F100 specifies a feed rate of 100” per minute.

A combination of words is called a block, conveying multiple instructions in sequence. Blocks N001 to N003 specify the title of the program, the size of the tool to be used in the operation and how the program was complied and by whom and when.

Blocks N004 through N008 are setup instructions. The G17 command tells the CNC that the cutting is to be done on the XY plane or on a workpiece positioned horizontally. G90 commands that all measurements will be taken from the table’s home position. G20 commands that cuts be made in inches. Blocks N009 and N010 initialize where the router bit is going to start, which is 0.25” above the material, so it won’t be damaged in travel and for accuracy.

Blocks N011 and N012 move the router bit 1” away from both edges of the plywood for a square cut. Blocks N013 through N017 provide the commands to cut a 12” x 12” square.

Blocks N018 and N019 are non-cutting sets of instruction, moving the bit above the workpiece and back to the home position. Block N020 commands that the program is finished.

There are many more commands than the few shown in this short example. Organized sequentially in blocks, a CNC router can perform a great deal of work quickly, accurately and repeatedly.

There are other challenges associated with switching to digital fabrication, but learning the language of G-code is an important early step. Most CAM programs automatically generate the necessary G-code, but writing a program manually or having the ability to read the code puts the woodworker in control of the machine, just as you were with the tape measure and table saw. 

This article originally appeared in the May 2014 issue.

 A.J. Hamler is the former editor of Woodshop News and Woodcraft Magazine. He's currently a freelance woodworking writer/editor, which is another way of stating self-employed. When he's not writing or in the shop, he enjoys science fiction, gourmet cooking and Civil War reenacting, but not at the same time.