PCB router machines, as precision tools for cutting, profiling, and drilling printed circuit boards (PCBs), rely on accurate programming to transform digital designs into physical boards. The core of this process lies in G-code programming (the universal language of CNC machines) and design file optimization (ensuring CAD/CAM data translates seamlessly to machine movements). A single programming error—whether a misplaced G-code command or an unoptimized design—can lead to defects like overcuts, tool breakage, or misaligned features, increasing scrap rates by up to 30% in high-volume production. This guide breaks down G-code essentials for PCB routing, design file preparation workflows, and optimization techniques to maximize precision and efficiency.
G-Code Basics for PCB Router Machines
G-code (Geometric Code) consists of alphanumeric commands that dictate a machine’s movements, speeds, and tool changes. For PCB routers, which handle delicate materials (FR-4, aluminum, flex substrates) and fine features (down to 0.1mm traces), G-code must balance speed with precision to avoid damaging the board or tools.
1. Core G-Codes for PCB Routing
G-Code
Function
Application in PCB Routing
G00
Rapid positioning
Move tool quickly between non-cutting positions (e.g., from home to board edge).
G01
Linear interpolation (feed move)
Execute cutting/profiling at a specified feed rate (e.g., cutting PCB outline at 500 mm/min).
G02
Circular interpolation (clockwise)
Cut curved edges (e.g., rounded corners of PCB panels).
G03
Circular interpolation (counterclockwise)
Same as G02 but in reverse direction.
G20
Units in inches
Rarely used for PCBs; most machines use metric.
G21
Units in millimeters
Standard for PCB routing (metric precision critical for fine features).
G90
Absolute positioning
Tool moves to coordinates relative to a fixed origin (e.g., X=10, Y=5 from home).
G91
Incremental positioning
Tool moves relative to current position (e.g., X+5 moves 5mm from current X).
G94
Feed rate in mm/min
Standard for controlling cutting speed (adjust based on material: FR-4 uses 300–800 mm/min).
G54
Work offset 1
Define a custom origin (e.g., set PCB corner as (0,0) for easier programming).
2. M-Codes for Machine Setup and Control
M-codes manage auxiliary functions, ensuring the machine operates safely and efficiently during routing:
M03: Spindle on (clockwise) – Starts the router bit spinning (critical: set spindle speed first with S-code, e.g., S15000 = 15,000 RPM for FR-4).
M05: Spindle off – Stops the spindle after cutting to prevent accidental damage.
M08: Coolant on – Activates mist/coolant (essential for high-speed routing of aluminum PCBs to reduce heat-induced warping).
M30: Program end – Resets the machine to home position after completing the job.
3. Critical Parameters for PCB Materials
Spindle Speed (S-code): Depends on material hardness:
FR-4 (fiberglass): 10,000–20,000 RPM
Aluminum PCBs: 15,000–25,000 RPM (higher speed reduces burring)
Flex substrates (polyimide): 8,000–12,000 RPM (lower speed prevents tearing).
Feed Rate (F-value in G01): Balances cutting efficiency and tool life:
FR-4: 300–800 mm/min (faster for thick boards to avoid overheating).
Flex materials: 200–500 mm/min (slower to prevent delamination).
Design File Optimization: From CAD to Machine-Ready Code
PCB design files (Gerber, DXF, or ODB++ formats) rarely translate directly to G-code without optimization. Issues like overlapping paths, excessive tool changes, or uncompensated tool diameters can cause errors. Optimization ensures the machine follows the shortest, safest path while preserving design intent.
1. File Format Selection
Gerber (RS-274X): Preferred for PCB-specific features (traces, vias, solder masks). Contains metadata (aperture sizes) that CAM software uses to generate accurate toolpaths.
DXF: Suitable for simple outlines or mechanical features (e.g., mounting holes). Avoid for fine traces, as DXF may lose precision in conversion.
ODB++: Comprehensive format integrating electrical and mechanical data, ideal for high-complexity boards (e.g., multi-layer PCBs with blind vias).
2. Key Optimization Steps
(1)Toolpath Simplification
Remove redundant points: CAD files often include unnecessary vertices (e.g., 100 points for a straight line). CAM software (Altium, Fusion 360) can simplify paths to reduce G-code lines, speeding up execution.
Merge overlapping cuts: Avoid multiple passes over the same area (e.g., double-cutting a PCB edge), which wastes time and wears tools.
Optimize lead-in/lead-out: Add small diagonal segments (0.5–1mm) at the start/end of cuts to prevent tool marks. For example, when cutting a slot, start 0.5mm outside the slot, then move into the cut to ensure clean edges.
(2)Tool Diameter Compensation
Router bits (e.g., 1mm, 0.8mm) have a physical diameter that must be accounted for to avoid undersized/undersized features:
G41/G42: Tool radius compensation. G41 offsets the tool to the left of the path; G42 offsets to the right. For a 1mm bit cutting a 5mm slot, compensation ensures the slot remains 5mm wide (bit radius = 0.5mm).
Calibration: Regularly measure tool wear (e.g., a 1mm bit may wear to 0.95mm after 100 boards) and update compensation values in G-code.
(3)Layer Management for Multi-Layer PCBs
Separate toolpaths by layer: Use different tools for different layers (e.g., 0.5mm bit for inner layers, 1mm bit for outer profiling). CAM software can assign layers to specific tools to minimize tool changes (each change adds 10–15 seconds to cycle time).
Avoid cross-layer interference: Ensure toolpaths for upper layers don’t cut through lower layers (e.g., stop at layer 2 when routing layer 1 of a 4-layer board).
3. Material-Specific Adjustments
FR-4 (rigid PCBs): Use higher feed rates (500–800 mm/min) and spindle speeds (15,000–20,000 RPM) to prevent resin melting.
Flex PCBs (polyimide): Lower feed rates (200–400 mm/min) and sharp tools (tungsten carbide) to avoid tearing the flexible substrate.
Aluminum PCBs: Use lubricated coolant (via M08) and slower speeds (300–500 mm/min) to reduce heat buildup, which can warp the board.