Working with a CNC machine

CNC milling machines are an important part of the maker’s tool chest. They can be understood as a router mounted on X, Y and Z axes. The router’s position on the X, Y and Z axes can be controlled by software.

The below image is a PCB / hobby sized CNC machine. These are often used to prototype the design of PCB boards for electronics, or prototype parts made in timber, aluminium (and brass) and plastics (such as perspex).


Here’s a video of a CNC machine in action, making some wooden cogs.

CNC machines often talk in a language called G-Code. G-Code is a ‘numerical control (NC) programming language’. G-Code is essentially concerned with encapsulating movements on a three dimensional coordinate system. It looks like this:

G17 G20 G90 G94 G54
G0 Z0.25
X-0.5 Y0.
G01 Z0. F5.
G02 X0. Y0.5 I0.5 J0. F2.5
X0.5 Y0. I0. J-0.5
X0. Y-0.5 I-0.5 J0.
X-0.5 Y0. I0. J0.5
G01 Z0.1 F5.
G00 X0. Y0. Z0.25

TinyGIn the above example a 1″ diameter circle is drawn about the origin in the X-Y plane. It should begin by seeking the Z-axis to 0.25″, travel to X=-0.5 and Y=0.0, and lower back to Z=0.0. The program will then draw a clockwise circle at a slow feedrate. When finished, it will lift the Z-axis up 0.1″ and then seek back to X=0.0, Y=0.0, and Z=0.25 to complete (from

A reference to G-Code commands is available here.

For hobby-grade CNC machines, such as the Shapeoko 3, an Arduino is used to translate the G-Code commands into rotation positions for the 3 Stepper motors that drive the 3 axes. The image on the right shows an Arduino with a motor shield designed to drive 3 steppers.

The image below shows how a stepper motor is connected to a screw rod which, when turned, results in the motion of the axis’ chassis.


We don’t necessarily need to know know G-Code. It is possible to write G-Code by hand, or to have a software package do it for you. These packages are called CAM packages. MeshCam is one such package. Notice how the below image shows MeshCam suggesting a “Toolpath” for the user to accept. A Toolpath refers to how exactly a particular router bit will move over the object and cut away material.


But Cam packages don’t (all) allow you to draw these virtual objects. For that you need a CAD package that exports DXF files. One such package is Google’s Sketch Up. So the beginning of the process incolves drawing a virtual form in a CAD packages such as Sketch Up.

To summarise the process:

  1. Design in CAD (eg Sketch Up, AutoCAD, etc.)
  2. Output as a DXF file
  3. Import into CAM software(eg. MeshCam)
  4. Confirm Toolpaths etc.
  5. CAM software sends G-Code to the Arduino connected to the CNC machine
  6. the Arduino then controls the 3 steppers as is necessary.

To see a review of the entire process, have a look at the video below, in which a model is taken from Google Sketch-Up and translated through to a CAM package.