How to Mill PCBs with FlatCAM: Gerber Import to Isolation Routing G-Code
Introduction
FlatCAM is a free, open-source CAM program specifically designed for PCB milling. It takes Gerber and Excellon files from your PCB design software (KiCad, Eagle, EasyEDA) and generates isolation routing toolpaths, drilling toolpaths, and board outline cuts. Unlike general-purpose CAM software that requires manual toolpath creation, FlatCAM understands PCB terminology: traces, pads, vias, drills, soldermask, and silkscreen. It automatically calculates isolation routing paths that follow your trace geometry with precise kerf compensation. This guide covers the complete PCB milling workflow: importing Gerbers, generating isolation toolpaths, handling double-sided boards with alignment, drilling, and cutting out the finished board.
What You Need
- FlatCAM (download from bitbucket.org/jpcyp/flatcam, or the community fork flatcam.org)
- Gerber and Excellon files exported from your PCB design software
- CNC router with 0.1-0.2 mm V-bit or engraving bit
- Drill bits (0.8 mm, 1.0 mm, 1.5 mm typical)
- End mill for board outline (1-2 mm diameter)
- Copper-clad FR1 or FR4 board
- Z-probe for setting precise Z-zero
Step 1: Export Gerbers from KiCad
In KiCad PCB Editor:
- File > Fabrication Outputs > Gerbers
- Select these layers:
- F.Cu: Top copper (required for isolation routing)
- B.Cu: Bottom copper (for double-sided boards)
- F.Mask: Top soldermask (optional, for reference)
- B.Mask: Bottom soldermask (optional)
- F.SilkS: Top silkscreen (optional, for reference)
- Edge.Cuts: Board outline (required for cutting out)
- Set format: 4.6 trailing (standard)
- Set output directory
- Click Plot
- File > Fabrication Outputs > Drill Files
- Generate Excellon drill file (.drl)
Step 2: Import into FlatCAM
- Launch FlatCAM.
- File > Open Gerber > Select your F.Cu.gbr file.
- The top copper layer appears on the canvas. Traces are shown in color, the board outline as a rectangle.
- File > Open Excellon > Select your .drl file.
- Drill holes appear as circles.
- File > Open Gerber > Select Edge.Cuts.gbr (for board outline).
Project organization:
FlatCAM lists all imported files in the Project panel on the right. Double-click a file to view its properties.
Step 3: Generate Isolation Routing Toolpath
Isolation routing cuts a gap around each trace, electrically isolating it from the surrounding copper.
- Select the F.Cu Gerber in the Project panel.
- Go to the Selected tab (below the project panel).
- Under Isolation Routing, set parameters:
- Tool Diameter: The effective diameter of your engraving bit. For a 60-degree V-bit with 0.1 mm tip, the effective diameter at cutting depth is approximately 0.2-0.3 mm.
- Pass Depth: How deep each pass cuts into the copper. 0.05-0.1 mm per pass for FR4. Start with 0.05 mm.
- Width (# Passes): Number of concentric isolation passes. 1 pass = minimum isolation. 2-4 passes = wider isolation gap (recommended for higher voltage or noise immunity).
- Pass Margin: Additional spacing between passes. 0.1 mm default.
- Combine Passes: Yes (combines all passes into one toolpath for efficiency).
- Click Generate Geometry
- FlatCAM calculates the isolation paths around all traces
- The geometry appears as red lines on the canvas
Understanding the toolpath:
The red lines show where the tool will travel. Each pass widens the gap around traces. Multiple passes ensure no copper bridges remain between adjacent traces.
Step 4: Convert Geometry to CNC Job (G-Code)
Geometry is the path definition. A CNC Job adds feed rates, spindle speeds, and Z movements.
- Select the generated isolation geometry in the Project panel.
- In the Selected tab, click Generate under the CNC Job section.
- Set parameters:
- Cut Z: The Z depth for cutting. This is the depth the tool cuts into the copper. For a 60-degree V-bit, -0.05 to -0.1 mm is typical.
- Travel Z: 2 mm (safe travel height above the board).
- Feed Rate Z (plunge): 50-100 mm/min (slow plunge to avoid breaking the bit).
- Feed Rate X-Y: 100-200 mm/min (moderate speed for clean edges).
- Spindle Speed: 10,000-20,000 RPM (lower for V-bits to prevent burning).
- Click Generate
- The CNC Job appears in the project panel
- Double-click the CNC Job to preview the G-code
Step 5: Generate Drill Toolpaths
- Select the Excellon drill file in the Project panel.
- In the Selected tab, set drill parameters:
- Cut Z: Drill depth (board thickness + 0.5 mm, e.g., -1.7 mm for 1.6 mm board).
- Travel Z: 2 mm.
- Feed Rate Z: 100-200 mm/min (plunge speed for drilling).
- Click Create Drills
- FlatCAM generates drill points at each hole location
- For multiple drill sizes, generate separate CNC jobs for each tool diameter
Step 6: Generate Board Outline Toolpath
- Select the Edge.Cuts Gerber in the Project panel.
- Click Generate Geometry (follow)
- Set the tool: use a 1-2 mm end mill for the outline cut
- Set Cut Z: -1.8 mm (through the 1.6 mm board, into the spoilboard slightly)
- Set Feed Rate X-Y: 300-500 mm/min
- Generate the CNC Job
Step 7: Export G-Code
- For each CNC Job (isolation, drills, outline), select it in the Project panel.
- Click Export G-Code (save as .nc or .tap file).
- Save each operation as a separate file, or combine them into one file with tool changes.
Combined file order:
- Isolation routing (V-bit)
- Drilling (drill bits, largest to smallest)
- Board outline (end mill)
Step 8: Double-Sided Board Alignment
Double-sided boards require flipping the board and aligning the bottom layer precisely.
Method 1: Alignment Holes
- Design two or three alignment holes (3 mm diameter) at the corners of your board in KiCad.
- Drill these holes first on the top side.
- Insert pins (3 mm drill bits or dowels) into the holes to register the board.
- Flip the board over. The pins ensure perfect alignment.
- Run the bottom copper isolation routing.
Method 2: Edge Alignment
- Cut the board outline first, keeping the board attached with tabs.
- Use the straight edges of the board as alignment references.
- Flip and clamp against a fence or corner fixture.
Method 3: Camera Alignment (if available)
- Some CNC setups include a camera mounted on the spindle.
- Mark alignment points on the board.
- Use the camera to align the bottom toolpath to the flipped board.
Step 9: Physical Setup on the CNC
Secure the PCB:
- Double-sided tape on a flat spoilboard (carpet tape works well)
- Or vacuum table with gasket around the board
- Or clamp with toe clamps (be careful not to bend the thin board)
Set Z-zero precisely:
- Jog the tool to approximately where you want to start.
- Lower the tool until it just touches the copper surface.
- Use a multimeter in continuity mode: one probe on the tool, one on the copper. When the beep sounds, the tool is touching.
- Set Z=0 at this position.
- Alternatively: use a Z-probe or the paper method (slide paper under tool, lower until paper drags).
Surface leveling (critical for fine traces):
PCB copper is thin (0.035 mm). Any variation in board flatness causes uneven cutting depth.
- Use a spoilboard that has been surfaced flat.
- For best results, use auto bed leveling (if your CNC supports it).
- Alternatively: mill a shallow pocket in a waste board, seat the PCB into the pocket.
Step 10: Run the G-Code
- Load the isolation routing G-code first.
- Run at conservative speeds on the first attempt.
- Inspect the traces with a magnifying glass or microscope.
- Check for:
- Uncut copper between traces (increase isolation passes or cutting depth)
- Over-cut traces (decrease cutting depth)
- Burrs (increase RPM or decrease feed rate)
- Run the drill file.
- Run the outline cut.
Troubleshooting PCB Milling
- Traces lifting during cutting: The cut is too deep or the feed is too aggressive. Reduce depth to 0.05 mm and slow down.
- Shorts between traces: Insufficient isolation. Increase the number of isolation passes to 3-4.
- Rough trace edges: Dull bit, too high feed rate, or too low RPM. Replace the bit or adjust speeds.
- Board warping: FR4 is sensitive to heat. Use air blast or mist cooling. FR1 is easier to mill but less durable.
- Drill wander: Drill bits wander in copper before engaging. Use a center drill or engrave a pilot dimple first.
- Inconsistent depth: Board not flat. Use a surfaced spoilboard or pocket the mounting area.
Tips for PCB Milling Success
- Use sharp V-bits. A dull bit tears copper instead of cutting it. Replace frequently.
- Start with FR1. FR1 (phenolic paper) mills much easier than FR4 (fiberglass). Use FR1 for prototypes.
- Use air blast. Copper chips pack in the groove and cause rough edges. Air blast clears chips.
- Test on scrap first. Always mill a test pattern on scrap copper board before your actual design.
- Keep traces wide. 0.5 mm trace width is the practical minimum for CNC milling. 0.3 mm requires perfect setup.
- Use thermal reliefs on pads. Without thermal reliefs, large copper pours suck heat away during soldering.
- Mill soldermask. For professional results, apply UV-curable soldermask after milling, expose through a transparency mask, and develop.
Conclusion
FlatCAM transforms PCB milling from a manual, error-prone process into a streamlined CAM workflow. By importing Gerber files directly, calculating isolation paths automatically, and generating toolpaths optimized for V-bits and engraving tools, FlatCAM eliminates the guesswork from PCB prototyping. The key to success is precise Z-zero setting, flat board mounting, sharp tools, and conservative feed rates. With practice, you can produce two-layer PCBs with 0.5 mm traces in under 30 minutes — no chemical etching, no exposure box, no photoresist. For rapid PCB prototyping, CNC milling with FlatCAM is the fastest path from design to physical board.
Related Guides
- How to Use EstlCAM for CNC Routing: Toolpaths, G-Code, and GRBL Control
- How to Do a V-Carve Sign on the CNC Router
- CNC Router Bit Guide: Choosing End Mills by Flute Type, Geometry, and Coating
- How to Use a Drag Knife and Pen Plotter on Your CNC Router
- How to Surface Your CNC Spoilboard and Machine Aluminum on a Desktop Router
- How to V-Carve Inlays and Precision Signs on a Desktop CNC Router
- How to Order PCBs from JLCPCB: From KiCad Upload to Delivery
- How to Design PCBs with KiCad: From Schematic to Gerber Export