0
0
Ev-technologyHow-ToBeginner · 4 min read

CNC Project for PCB Milling: Guide and Example G-code

A CNC project for PCB milling involves creating a G-code file that controls the CNC machine to precisely remove copper from a PCB blank. This includes defining tool paths, spindle speed, and feed rates using G-code commands tailored for PCB traces and drilling.
📐

Syntax

The basic syntax for a PCB milling CNC project uses G-code commands to control the machine. Key parts include:

  • G00: Rapid move to position without cutting.
  • G01: Linear move with cutting at set feed rate.
  • M03: Spindle on clockwise (start milling).
  • M05: Spindle stop.
  • F: Feed rate (speed of cutting).
  • X, Y, Z: Coordinates for movement.

These commands combined create the tool path for milling PCB traces and drilling holes.

gcode
G21 ; Set units to millimeters
G90 ; Use absolute positioning
M03 S10000 ; Spindle on at 10000 RPM
G00 X0 Y0 Z5 ; Move above start point
G01 Z-0.1 F100 ; Lower tool to cut depth
G01 X10 Y0 F200 ; Mill straight line
G01 X10 Y10 ; Mill vertical line
G01 X0 Y10 ; Mill back
G01 X0 Y0 ; Complete rectangle
M05 ; Stop spindle
G00 Z5 ; Raise tool
M30 ; End program
💻

Example

This example shows a simple square milling path for a PCB trace outline. It starts the spindle, moves the tool down to the cutting depth, mills a 10x10 mm square, then stops the spindle and raises the tool.

gcode
G21 ; Set units to millimeters
G90 ; Absolute positioning
M03 S12000 ; Spindle on at 12000 RPM
G00 X0 Y0 Z5 ; Move above start
G01 Z-0.15 F80 ; Lower to cut depth
G01 X10 Y0 F150 ; Mill bottom edge
G01 X10 Y10 ; Mill right edge
G01 X0 Y10 ; Mill top edge
G01 X0 Y0 ; Mill left edge
M05 ; Stop spindle
G00 Z5 ; Raise tool
M30 ; End of program
⚠️

Common Pitfalls

Common mistakes in PCB milling CNC projects include:

  • Setting incorrect Z depth causing no cut or cutting through the board.
  • Using too high feed rates causing tool breakage or poor cut quality.
  • Not starting or stopping the spindle properly (M03 and M05).
  • Forgetting to use absolute positioning (G90) leading to unexpected moves.
  • Skipping tool height safety moves causing crashes.

Always simulate your G-code before running on the machine.

gcode
Wrong:
G00 X0 Y0 Z-1 ; Rapid move down into material (dangerous)

Right:
G00 X0 Y0 Z5 ; Move above material safely
G01 Z-0.15 F80 ; Lower tool slowly to cut depth
📊

Quick Reference

CommandDescription
G21Set units to millimeters
G90Use absolute positioning
M03 SxxxxStart spindle at xxxx RPM
M05Stop spindle
G00Rapid move (no cutting)
G01Linear move with cutting
FxxxSet feed rate (speed)
X, Y, ZCoordinates for movement

Key Takeaways

Use G-code commands like G00, G01, M03, and M05 to control PCB milling.
Set correct feed rates and cutting depths to avoid tool damage or poor cuts.
Always use absolute positioning (G90) for predictable tool paths.
Include safe tool height moves to prevent crashes.
Simulate your CNC program before actual milling to catch errors.