What Do CNC Machines Use to Control Tool Motion?

CNC machines control tool motion using a combination of programmed instructions (primarily G-code), a central controller that interprets those instructions, and motors that physically move the cutting tool along precise coordinates. No single component handles this alone. It’s a chain: software tells the controller where the tool should go, the controller converts that into electrical signals, and motors execute the movement in real time.

G-Code: The Language of Tool Motion

G-code is the primary programming language CNC machines use to direct tool movement. The “G” stands for geometry, and each G-code command tells the machine how and where to move. A few core commands handle the majority of cutting work:

  • G00 moves the tool in a straight line at maximum speed (called a rapid move), used to reposition without cutting.
  • G01 moves the tool in a straight line at a specified cutting speed, which is how most straight cuts happen.
  • G02 moves the tool in a clockwise arc at a set speed.
  • G03 moves the tool in a counterclockwise arc.

Alongside G-codes, M-codes handle machine functions that aren’t about geometry. M03 turns the spindle on, M05 stops it, M06 triggers a tool change, and M08 activates coolant. Together, G-codes and M-codes form a complete set of instructions for producing a part.

Some manufacturers use proprietary alternatives. Mazak machines, for example, can run a language called Mazatrol in addition to standard G-code. But G-code remains the universal standard across the industry.

From 3D Model to Machine Instructions

Most G-code isn’t written by hand. The typical workflow starts with a 3D model created in CAD (computer-aided design) software. That model is then loaded into CAM (computer-aided manufacturing) software, where a programmer defines toolpaths: the exact routes the cutting tool will follow to shape raw material into the finished part. The CAM software calculates speeds, depths of cut, and tool angles based on the geometry of the design.

Once the toolpaths are set, a step called post-processing converts them into G-code formatted for the specific machine that will run the job. Different CNC machines may interpret certain codes slightly differently, so the post-processor acts as a translator between the CAM software and the controller. The final G-code file is then loaded onto the machine, either through a network connection or a USB drive.

The Machine Control Unit

The machine control unit, or MCU, is the brain of a CNC machine. It reads the G-code file line by line and translates each instruction into electrical signals that drive the motors. Every movement, speed change, and tool swap passes through the MCU. It coordinates timing so that multiple axes move simultaneously when needed, keeping the tool on its programmed path with high precision.

Coordinate Systems and Axes

CNC machines map tool motion using a Cartesian coordinate system, the same X-Y-Z grid you learned in math class. The X axis runs horizontally, the Y axis runs vertically, and the Z axis represents depth (typically the direction the tool plunges into or retracts from the material). Every point in the workspace has a unique set of coordinates, and the G-code tells the machine exactly which coordinates to move to.

A basic 3-axis mill moves along X, Y, and Z. More advanced machines add rotational axes. A 5-axis machine, for instance, can tilt and rotate the tool (or the workpiece) to reach complex angles without repositioning the part. But the underlying principle is the same: every movement is defined as a coordinate in space.

How the Controller Calculates Smooth Paths

G-code typically defines endpoints: move from point A to point B. But the controller needs to generate all the intermediate positions between those points so the tool follows a smooth, continuous path. This process is called interpolation.

For straight lines (G01), the math is simple. The controller divides the distance into tiny increments and sends a pulse to each motor at regular intervals. For arcs (G02 and G03), the controller calculates a series of small straight-line segments that approximate the curve. The segments are so short that the result is a smooth arc to the naked eye. More advanced controllers use higher-order calculations to maintain a constant cutting speed even as the curvature of the path changes, which improves surface finish and reduces tool wear.

Motors That Execute the Movement

Two types of motors handle the physical motion in CNC machines: stepper motors and servo motors.

Stepper motors divide a full rotation into discrete steps, typically between 50 and 400 per revolution. Each electrical pulse moves the shaft one step, making them predictable and straightforward. They work well for lighter machines, moderate speeds, and applications where loads stay consistent. Their main limitation is that they operate without feedback. If something forces the motor off position (a heavy cut, for example), the controller has no way to know a step was missed.

Servo motors use a closed-loop system with a built-in encoder that continuously reports the motor’s actual position back to the controller. If the motor drifts even slightly from its commanded position, the controller corrects it in real time. This makes servo motors the preferred choice for CNC machining, robotic arms, and any application requiring high accuracy under varying loads. They also maintain consistent power across a wider range of speeds, whereas stepper motors lose torque rapidly as speed increases.

Feedback and Closed-Loop Control

The encoder on a servo motor is typically an optical disk mounted to the motor shaft. Inside, a glass disk with precisely etched lines spins with the shaft while an optical sensor reads those lines to measure rotation. Most CNC encoders measure relative motion (how far the shaft has turned) rather than absolute position, though absolute encoders exist for applications that need them.

This feedback loop is what separates a reliable CNC machine from one that drifts over time. The controller constantly compares the commanded position to the encoder’s reading. If there’s a discrepancy, it adjusts the motor output to close the gap. This happens thousands of times per second, which is how CNC machines achieve positioning accuracy measured in thousandths of an inch or hundredths of a millimeter.

Machines that use stepper motors without encoders run in open-loop mode. They’re cheaper and simpler, which is why many hobbyist and benchtop CNC machines use them. But for production work where tolerances are tight, closed-loop servo systems are the standard.

Putting It All Together

The full chain works like this: a designer creates a 3D model, CAM software generates toolpaths and post-processes them into G-code, the G-code is loaded into the machine’s control unit, the MCU interprets each line and sends precisely timed electrical signals to the motors, and the motors move the tool along the X, Y, and Z axes to cut the part. If servo motors are used, encoders feed real-time position data back to the controller, which makes corrections on the fly. The result is a system that can reproduce complex shapes with repeatable accuracy, part after part.