Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

How to Convert Gerber to G-Code for PCB Milling: Complete Guide

After years of etching PCBs with ferric chloride in my garage and dealing with the mess, fumes, and inconsistent results, I finally made the switch to CNC milling. The learning curve was steep, especially when it came to converting my Gerber files into G-Code that my machine could actually understand. This guide covers everything I wish someone had told me when I started.

Understanding the Gerber to G-Code Conversion Process

Before diving into software tools, let me explain what actually happens during this conversion. Your PCB design software exports Gerber files, which describe the copper traces, pads, and other features as geometric shapes. A CNC machine, however, needs G-Code instructions that tell it exactly where to move, how fast to travel, and when to raise or lower the cutting tool.

The conversion process involves several key steps:

  1. Importing your Gerber files (copper layers, typically in RS-274X format)
  2. Loading your Excellon drill files (hole locations and sizes)
  3. Generating isolation toolpaths around your traces
  4. Creating drilling operations for through-holes
  5. Adding board outline cutting paths
  6. Exporting everything as G-Code for your CNC controller

What Are Gerber Files?

Gerber files have been the industry standard for PCB fabrication data since the 1980s. The current format, RS-274X (also called Extended Gerber or Gerber X1), embeds all aperture definitions directly in the file, making data transfer much more reliable than the older RS-274D format that required separate aperture files.

When you export from KiCad, Eagle, Altium, or any other PCB design software, you typically generate several Gerber files for different layers and an Excellon drill file for hole locations. These text-based files contain coordinate data and drawing commands that describe your board’s geometry.

What Is G-Code for PCB Milling?

G-Code is the language CNC machines speak. For PCB milling, the most common commands include G0 for rapid movements (tool up, traveling between cuts), G1 for linear cutting moves (tool down, removing copper), spindle control commands like M3 (start) and M5 (stop), and various feed rate specifications.

The challenge is that Gerber files describe what the finished board should look like, while G-Code describes how to create it. Your CAM software bridges this gap by calculating the exact toolpaths needed to isolate traces by removing copper around them.

Choosing the Right Gerber to G-Code Software

I have tested most available options over the past few years. Here is an honest comparison based on real-world use:

SoftwarePricePlatformLearning CurveBest For
FlatCAMFreeWindows, Linux, MacModerateGeneral PCB prototyping
pcb2gcodeFreeLinux, Mac, WindowsSteep (CLI)Automated workflows
CopperCAM€80WindowsLowBeginners, professional results
Carbide CopperFreeWeb-basedVery LowQuick simple boards
Line GrinderFreeWindowsModerateBasic isolation routing
PCB-GCode (Eagle ULP)FreeEagle onlyLowEagle users

FlatCAM: The Most Popular Open-Source Option

FlatCAM is what most hobbyists and makers reach for first, and for good reason. It is free, open-source, and handles most PCB milling tasks competently. Written in Python, it runs on Windows, Linux, and Mac.

The workflow in FlatCAM follows a logical progression. You import your Gerber files for copper layers and your Excellon files for drill data. Then you generate isolation geometry by specifying your tool diameter, number of passes, and overlap percentage. From that geometry, you create a CNC job with your machine-specific parameters like cut depth, travel height, and feed rates. Finally, you export the G-Code.

One thing that frustrated me initially was FlatCAM’s interface, which requires navigating between tabs and clicking on specific objects in the project tree. Once you understand the workflow, it becomes second nature, but those first few boards can be confusing.

pcb2gcode: Command-Line Power

For those comfortable with the command line, pcb2gcode offers excellent results with highly configurable parameters. You create a millproject file that stores all your settings, then run the conversion with a single command. This approach shines for automated or repeated jobs where you want consistent results without clicking through a GUI every time.

The trade-off is a steeper learning curve. You need to understand all the parameters and how they interact. However, once dialed in, pcb2gcode produces clean, optimized toolpaths.

CopperCAM: Worth the Investment

At €80, CopperCAM is not free, but it is also not expensive compared to professional CAM software. The interface is intuitive, and it handles complex boards without fuss. If you are milling boards regularly and value your time, CopperCAM pays for itself quickly in reduced setup time and fewer failed boards.

Carbide Copper: Fastest Start

Carbide Copper (formerly Rapid PCB) is a web-based tool from Carbide 3D that generates G-Code from your Gerber files in minutes. The step-by-step interface guides you through the process, making it perfect for beginners or quick one-off projects. The limitation is less control over advanced parameters, but for simple boards, it works remarkably well.

Step-by-Step Guide: Converting Gerber to G-Code with FlatCAM

Since FlatCAM is the most widely used free option, I will walk through the complete process.

Preparing Your PCB Design Files

Before opening FlatCAM, export the following from your PCB design software:

For KiCad users: Go to File, Plot, select Gerber as the format, check the copper layers you need (F.Cu for front, B.Cu for back), and click Plot. Then use the Generate Drill Files button to create your Excellon file.

For Eagle users: Run the CAM Processor, select the Gerber RS-274X template, enable the layers you need, and process. Use the Excellon drill output for holes.

Make sure your Gerber files are in RS-274X format with embedded apertures. Files should include your copper layer(s), board outline (Edge.Cuts in KiCad), and the Excellon drill file.

Importing Files into FlatCAM

Open FlatCAM and use File, Open Gerber to load your copper layer. The board should appear in the plot area. Next, load your drill file with File, Open Excellon. Finally, if you have a separate outline layer, load it as another Gerber.

At this point, you are viewing the board from the top. For bottom-layer boards, you will need to mirror the design before milling.

Generating Isolation Geometry

Select your copper Gerber in the Project panel and look at the Isolation Routing section. The key parameters are Tool dia, which is the cutting width of your tool at the specified depth, Passes for how many isolation cuts around each trace, and Pass overlap which controls how much each subsequent pass overlaps the previous one.

For a 0.1mm tip V-bit cutting at 0.05mm depth, the effective cutting width might be around 0.15mm depending on the bit angle. Use the tool width calculator if your software provides one.

Click Generate Geometry. FlatCAM creates a new geometry object showing red lines where the tool will cut. Inspect this carefully, especially in tight areas between traces. If the geometry looks incomplete or traces touch, increase your number of passes or check your tool diameter setting.

Creating the CNC Job

Double-click the newly created isolation geometry in the Project panel. In the Create CNC Job section, set your Cut Z (typically -0.05mm to -0.08mm for standard 35μm copper), Travel Z (safe height for rapid moves, around 2mm works well), Feed Rate for cutting speed, and Spindle Speed if your machine supports it.

Click Generate to create the CNC job. The plot now shows the actual toolpaths in blue, representing the copper that will be removed.

Setting Up Drill Operations

For drilling, select your Excellon object and configure the drilling parameters. Set Cut Z deep enough to go through the board plus your spoilboard (typically -2mm to -3mm depending on material thickness), and appropriate Feed Rate for drilling (slower than routing). Generate the drill CNC job.

Board Outline Cutout

For the board outline, select your edge cuts Gerber and use the Board Cutout operation. Specify your cutting tool diameter (usually a larger bit than your isolation tool), margin around the board, and gap settings for holding tabs that prevent the board from shifting during the final cuts.

Exporting G-Code

Each CNC job object can be exported as G-Code. Select the object, click Export G-Code, and save. You will typically have three files: one for isolation routing, one for drilling, and one for the board cutout.

Recommended Tool Settings for PCB Milling

Getting your speeds and feeds right is crucial for good results. Here are settings that have worked well for me:

V-Bit Settings for Isolation Routing

ParameterConservativeOptimized
Spindle Speed8,000-10,000 RPM10,000-15,000 RPM
Feed Rate80-100 mm/min150-200 mm/min
Cut Depth0.05 mm0.06-0.08 mm
Tool Angle30°20-45°
Tip Width0.1 mm0.1-0.2 mm

Drill Bit Settings

Hole SizeFeed RateSpindle Speed
0.8 mm50-80 mm/min8,000 RPM
1.0 mm80-100 mm/min8,000 RPM
1.5 mm+100-150 mm/min6,000-8,000 RPM

Start conservative and increase speeds as you gain confidence. A broken bit teaches you where your limits are, but it is better to learn gradually.

Common Problems and Solutions

Traces Not Fully Isolated

This usually means your cut depth is too shallow or your tool is worn. Try increasing depth by 0.02mm increments. Also check that your spoilboard is truly flat and properly surfaced.

Burrs on Copper

Burrs indicate the feed rate is too high or the tool is dull. Reduce feed rate or replace the bit. A light sanding with 1000-grit sandpaper after milling removes most burrs.

Inconsistent Cut Depth Across the Board

Your board is not level relative to the machine bed. This is the most common issue with PCB milling. Solutions include surfacing your spoilboard, using a vacuum or tape-and-superglue holddown method, and implementing auto-leveling with software like bCNC or Candle that probe the board surface and adjust the G-Code accordingly.

Tool Breaking

V-bits with thin tips are fragile. Common causes include plunging too fast (reduce plunge rate), cutting too deep in one pass (use multiple shallow passes), hitting a clamp or screw, and worn bits that grab instead of cutting.

Double-Sided PCB Considerations

Milling double-sided boards requires precise alignment between the top and bottom layers. FlatCAM includes a Double-Sided PCB Tool that helps flip your design correctly.

The basic process involves milling the first side, then flipping the board around a defined axis (usually X), aligning to a reference point, and milling the second side. Drilling should be done last, after both copper layers are complete.

Many people use alignment pins drilled through the board at known locations to ensure registration. The key is planning your zero point carefully before starting.

Useful Resources and Downloads

Here are the tools and resources that have helped me most:

CAM Software

FlatCAM is available at flatcam.org with documentation, tutorials, and downloads for all platforms. The software is actively maintained with regular updates.

pcb2gcode can be found on GitHub at github.com/pcb2gcode/pcb2gcode with source code and pre-built binaries for various systems.

CopperCAM from Galaad Software at galaad.net/coppercam-eng.html offers a trial version to test before purchasing.

Carbide Copper at copper.carbide3d.com is web-based and requires no installation.

Line Grinder is hosted at ofitselfso.com/LineGrinder/LineGrinder.php with Windows binaries and source code.

G-Code Senders

Universal G-Code Sender (UGS) at winder.github.io/ugs_website works with most GRBL-based controllers.

bCNC at github.com/vlachoudis/bCNC includes auto-leveling features specifically useful for PCB work.

Candle at github.com/Denvi/Candle is a lightweight option with height map support.

PCB Design Software

KiCad at kicad.org is free, open-source, and exports excellent Gerber files.

Eagle is now part of Fusion 360 at autodesk.com/products/eagle with free hobbyist options.

Learning Resources

The FlatCAM manual at flatcam.org/manual provides comprehensive documentation.

The CNCZone forums at cnczone.com have active discussions about PCB milling with experienced users sharing tips.

Tips from Experience

After milling hundreds of boards, here are insights that are not in the documentation anywhere:

Keep your tool height consistent by using the same probe method every time. Electrical contact probing with a multimeter in continuity mode works reliably.

Start every session by surfacing a fresh area of your spoilboard. Even small warps cause problems with the shallow cuts used in PCB milling.

Use double-sided tape combined with thin CA glue for a secure, flat holddown. Apply tape to the spoilboard, CA to the board, press together, and wait 30 seconds.

Design your PCBs with milling in mind. Use wider traces (0.4mm minimum for reliability), larger clearances between traces, and avoid very fine pitch components until you have your process dialed in.

Run a test cut on copper-clad scrap before committing to your actual board. This catches zero point errors and verifies your settings.

Frequently Asked Questions

What minimum trace width can I reliably mill?

With a properly calibrated machine and sharp 0.1mm V-bit, trace widths down to 0.25mm (10 mil) are achievable. For consistent results with minimal failures, stay above 0.4mm (16 mil). The limitation is not just the tool but also machine rigidity, spindle runout, and board flatness.

Do I need a special CNC for PCB milling?

Not necessarily. Many hobbyists successfully mill PCBs on affordable 3018-style machines costing under $200. The keys are proper calibration, appropriate tooling, and realistic expectations about achievable precision. Higher-end machines offer better repeatability and faster cutting speeds but are not strictly required.

How long does a V-bit last?

A quality carbide V-bit typically handles 5-15 boards before showing significant wear, depending on board size and how much copper is being removed. Budget bits from generic suppliers may only last 1-3 boards. Watch for increasing burrs and incomplete isolation as signs of wear.

Can I mill boards with plated through-holes?

Standard CNC milling cannot create plated through-holes since that requires electroplating. For double-sided boards, you can use wire vias (manually inserting and soldering wire through holes) or rivet vias. Many hobbyist designs avoid the issue by using single-sided layouts with jumpers.

What is auto-leveling and do I need it?

Auto-leveling probes multiple points across your board surface, creates a height map, and adjusts the G-Code Z coordinates to follow the board’s actual contour. For PCB milling with its shallow cuts, auto-leveling dramatically improves consistency. Software like bCNC and Candle support this feature. While not strictly required, it makes a huge difference in results.

Conclusion

Converting Gerber files to G-Code is the critical bridge between designing a PCB and actually making one on your CNC. While the process involves multiple software tools and careful parameter tuning, the payoff is rapid prototyping without chemicals, shipping delays, or minimum order quantities.

Start with FlatCAM or Carbide Copper to learn the basics, invest in decent V-bits and a flat spoilboard, and expect your first few boards to be learning experiences. Once you have the process dialed in, you can go from design change to working board in under an hour, which fundamentally changes how you approach electronics development.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.