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 Using FlatCAM: Complete PCB Milling Guide

If you’ve ever wanted to mill your own PCBs at home, you’ve probably discovered that your CNC router doesn’t understand Gerber files. Your PCB design software exports Gerbers, but your machine needs G-Code. This gap used to be a serious headache until FlatCAM came along. I’ve been milling boards on my desktop CNC for about six years now, and FlatCAM has become an essential part of my workflow for converting Gerber files to machine-ready G-Code.

FlatCAM is free, open-source CAD/CAM software specifically designed for PCB prototyping. It takes the Gerber and Excellon drill files generated by any PCB design package and converts them into the G-Code your CNC router understands. The learning curve is real, but once you understand the process flow, you’ll be churning out prototype boards faster than any fab house could ship them.

What is FlatCAM and Why Do PCB Engineers Use It

FlatCAM stands for Flat Computer-Aided Manufacturing, and it’s written in Python to run on Windows, Linux, and macOS. The software bridges the gap between electronic design and physical manufacturing by handling the CAM processing that commercial software charges thousands of dollars to provide.

The core workflow involves importing your Gerber files, generating isolation geometry around your traces, creating toolpaths from that geometry, and exporting everything as G-Code. This process is called isolation routing because you’re literally isolating the copper traces by milling away the copper around them.

Beyond basic isolation routing, FlatCAM handles drilling operations from Excellon files, board cutout with holding tabs, copper clearing for ground planes, and double-sided PCB registration. It visualizes everything before you commit to cutting, which has saved me from plenty of expensive mistakes.

Preparing Your Gerber Files for FlatCAM Import

Before touching FlatCAM, you need properly formatted Gerber and Excellon files from your PCB design software. Most modern packages export RS-274X format Gerbers, which FlatCAM handles well. The critical files you’ll need include your copper layer Gerbers (top and bottom if double-sided), drill files in Excellon format, and board outline or edge cuts.

File TypeCommon ExtensionsPurpose
Copper Layer.gbr, .gtl, .gbl, .cuDefines trace patterns
Drill File.drl, .xln, .excHole positions and sizes
Edge Cuts.gm1, .gko, .gmlBoard outline
Soldermask.gts, .gbsSolder mask openings
Silkscreen.gto, .gboComponent labels

When exporting from your PCB software, pay attention to the coordinate format and zero suppression settings. FlatCAM defaults to inches with leading zero suppression. If your files use trailing zeros or metric units, you may see scaling issues that make your drill holes appear in the wrong locations. EAGLE users particularly need to watch this since EAGLE uses trailing zeros but doesn’t properly indicate this in the Excellon header.

Installing FlatCAM on Your System

The installation process varies by operating system. For Windows users, download the installer from flatcam.org and run it directly. The current stable version is 8.5, though development versions with additional features are available from the Bitbucket repository.

Linux and macOS users need to install from source, which requires Python and several dependencies including PyQt4 or PyQt5, NumPy, and Shapely. The FlatCAM manual provides detailed installation instructions for each platform, but expect some troubleshooting if you’re on a newer Linux distribution since PyQt4 compatibility can be problematic.

After installation, launch FlatCAM and take a moment to configure your default settings under the Options tab. Setting your preferred units, default tool diameters, and feed rates here saves time on every subsequent project. I recommend starting with metric units if that matches your machine configuration, as mixing unit systems creates unnecessary conversion headaches.

Step-by-Step Gerber to G-Code Conversion Process

The conversion happens in four main stages: importing files, generating geometry, creating toolpaths, and exporting G-Code. Each stage builds on the previous one, and FlatCAM shows your progress visually so you can catch problems before they become expensive scrap boards.

Step 1: Import Your Gerber and Excellon Files

Open FlatCAM and navigate to File, then Open Gerber to load your copper layer files. The imported Gerber appears in the Project tab on the left side of the screen and displays graphically in the main viewing area. Load your drill file using File, then Open Excellon. If you have a board outline file, import that as another Gerber.

Verify that all files loaded at the correct scale and position. Hover your mouse over known features and check the coordinates displayed at the bottom of the screen. If your drill holes appear ten times larger than expected or your board is in the wrong position, you have a format mismatch that needs addressing before proceeding.

Step 2: Generate Isolation Geometry

Select your copper Gerber in the Project tab, then look at the Selected tab on the right side. Under Isolation Routing, you’ll set parameters that define how FlatCAM calculates the milling path around your traces.

The Tool Diameter setting must match your actual engraving bit. For V-bits, use the cutting width at your intended depth, not the overall bit diameter. A 60-degree V-bit cutting 0.1mm deep produces roughly a 0.15mm cut width. Getting this wrong means either shorts between traces or unnecessarily wide isolation gaps.

Width (number of passes) determines how many parallel paths FlatCAM creates around each trace. Two passes with 60% overlap typically provides good isolation for most boards. Pass Overlap controls how much each successive pass overlaps the previous one, expressed as a decimal from 0 to 1.

ParameterTypical ValueNotes
Tool Diameter0.1-0.4mmMatch your actual cutting width
Width (passes)2-3More passes = wider isolation
Pass Overlap0.4-0.6Higher values = more overlap
Combine PassesCheckedMerges passes into single geometry

Click Generate Geometry when ready. FlatCAM creates a new object with “_iso” appended to the name. The red lines displayed represent the centerline of your tool path. Zoom in and inspect closely, especially where traces run close together. If red lines from adjacent traces overlap, you’ll have shorts. Either increase your isolation width or revise your PCB design with more spacing.

Step 3: Create CNC Job from Geometry

Select the newly created isolation geometry object and scroll down to Create CNC Job in the Selected tab. This section converts the geometric path into actual machine movements with specified depths and speeds.

Cut Z defines how deep the tool plunges into the copper. For standard 1oz copper (about 35 microns thick), a depth of -0.05mm to -0.1mm typically works. Going too deep wastes time and wears your bits faster. Going too shallow leaves copper bridges that cause shorts.

Travel Z sets the safe height for rapid movements between cuts. One to two millimeters above the surface works for most machines. Feed Rate controls cutting speed in your project’s units per minute. Start conservatively around 100-200mm/min and increase as you gain confidence in your setup.

Step 4: Export G-Code

Select the CNC Job object (named with “_cnc” suffix) and find the Export G-Code button. FlatCAM generates standard RS274NGC format G-Code compatible with most CNC controllers including GRBL, Mach3, LinuxCNC, and others.

Before saving, check the Prepend and Append fields. Some controllers require specific startup commands like spindle speed (S24000 for typical PCB spindles) or coordinate system selection. LinuxCNC users often need M30 added at the end of their files. Add any machine-specific commands your controller requires.

Processing Excellon Drill Files

Drilling follows a similar workflow but uses different settings appropriate for plunge operations rather than lateral cutting. Select your Excellon file and configure the drilling parameters under Create CNC Job.

The Tools table shows all drill sizes detected in your file. Select which tools to include by clicking in the selection column. If you only have one or two drill sizes available, select the tools closest to your available bits. FlatCAM can also mill oversized holes if needed.

Cut Z for drilling should penetrate completely through your board plus a small margin. For 1.6mm FR4, a value of -1.8mm to -2.0mm ensures complete through-holes. Feed Rate for drilling can typically run faster than isolation routing since you’re only moving in Z.

Drill ParameterTypical ValueNotes
Cut Z-1.8 to -2.0mmThrough board + margin
Travel Z1.0-2.0mmSafe rapid height
Feed Rate150-300mm/minZ plunge speed
Tool ChangeYes/NoEnable for multiple drill sizes
Tool Change Z25-50mmHeight for tool changes

Enable Tool Change if you plan to use multiple drill sizes. Set Tool Change Z high enough to comfortably swap bits. The generated G-Code will pause at each tool change with an M6 command, waiting for you to change bits and confirm.

Creating Board Cutout Geometry

Most boards need to be cut from larger stock material. FlatCAM’s Board Cutout feature creates the perimeter milling path with optional holding tabs that prevent the board from flying loose at the end of the cut.

Select your edge cuts Gerber or create a rectangular cutout around your copper geometry. Set the Tool Diameter to match your cutting endmill, typically 1.0mm to 2.0mm for board cutouts. The Margin value adds extra space around your defined edge. Set Gap Size and Gap count to create holding tabs that keep the board attached until milling completes.

Generate the cutout geometry, then create a CNC Job with appropriate parameters. Board cutout typically requires multiple depth passes since you’re cutting through the entire board thickness. Enable Multi-Depth and set Depth Per Pass to something your machine handles comfortably, usually 0.4-0.6mm per pass for FR4 material.

Double-Sided PCB Workflow in FlatCAM

Double-sided boards add complexity because top and bottom patterns must align precisely after you flip the board. FlatCAM includes a Double-Sided PCB Tool under the Tools menu specifically for this challenge.

The process involves creating alignment holes that pass through both sides, then mirroring your bottom layer geometry around a defined axis. Mill the top side first, drill alignment holes, flip the board onto alignment pins, then mill the bottom.

Select Mirror Axis Y for typical horizontal flipping. Set Axis Location to a known point, usually one corner of your board or the center. Mirror your bottom copper Gerber, your drill file if drilling from the bottom, and any other bottom-side geometry.

Generate alignment holes using the tool’s Create Alignment Holes feature. These produce small drill operations at specified positions that you’ll use to register the flipped board. Drill these holes during top-side processing, insert pins, flip, and the bottom pattern aligns automatically.

Common FlatCAM Issues and Troubleshooting

Scale problems rank as the most common headache when importing files. If everything appears ten times too large or small, check your Excellon zero format settings. Use the shell command set_sys excellon_zeros T to switch to trailing zeros if your files come from EAGLE or similar software.

Missing isolation between close traces indicates your tool diameter setting doesn’t match reality. Measure your actual cutting width at the specified depth and update your settings. Alternatively, redesign your board with greater trace spacing.

Gerber parse errors sometimes occur with files from certain software packages. Try exporting using Gerber X2 format instead of RS274X, or check for non-standard aperture definitions in your files. FlatCAM’s discussion group has extensive troubleshooting threads for specific software compatibility issues.

Recommended FlatCAM Settings for Common Scenarios

These starting points work for typical hobby CNC setups. Adjust based on your specific machine, tooling, and material.

ScenarioTool DiaCut ZFeed RatePasses
Fine pitch isolation0.1-0.2mm-0.05mm100mm/min2-3
Standard isolation0.3-0.4mm-0.1mm150mm/min2
Copper clearing0.5-1.0mm-0.1mm200mm/min1
Drilling through-holePer hole size-1.9mm200mm/minN/A
Board cutout1.0-2.0mm-1.8mm100mm/minMulti-depth

Useful Resources for FlatCAM Users

The official FlatCAM manual at flatcam.org/manual provides comprehensive documentation of every feature and parameter. The discussion group linked from the main site offers community support for troubleshooting and advanced techniques.

For downloading FlatCAM, visit flatcam.org/download for stable releases or access development versions through Bitbucket. The software is completely free with no registration required.

Tool width calculators help determine actual cutting width for V-bits at specified depths. Several online calculators exist, and HobbyCNC offers a particularly useful one for PCB milling applications.

For sending G-Code to your machine, Universal G-Code Sender (UGS) works well with GRBL-based controllers and provides visualization of your toolpaths before cutting. bCNC offers similar functionality with additional probing and autoleveling features critical for consistent PCB milling.

FAQs

What Gerber format does FlatCAM support?

FlatCAM supports RS-274X extended Gerber format, which is the standard output from virtually all modern PCB design software. It also handles older RS-274D format files, though these are increasingly rare. For best compatibility, export your Gerbers using RS-274X format from your PCB software. If you encounter import errors, try Gerber X2 format as an alternative.

Why do my drill holes appear in the wrong positions?

Drill hole misalignment typically results from mismatched zero suppression settings between your CAD software and FlatCAM. EAGLE uses trailing zeros but doesn’t properly declare this in the Excellon header. Run the command set_sys excellon_zeros T in FlatCAM’s shell before importing your drill file to fix this issue.

Can FlatCAM mill double-sided PCBs?

Yes, FlatCAM includes dedicated tools for double-sided PCB production. The Double-Sided PCB Tool provides mirroring functions and alignment hole generation. You’ll mill the top side, drill alignment holes, flip the board onto registration pins, then mill the bottom. The process requires careful attention to your mirror axis and registration hole placement.

What cutting depth should I use for isolation routing?

For standard 1oz copper PCB material, a cutting depth of -0.05mm to -0.1mm typically provides complete isolation. The key is cutting just deep enough to remove the copper without excessive depth that wastes time and wears tooling. If you’re using an autoleveling probe system, you can often use shallower depths since the probe compensates for board surface variations.

How do I add spindle speed commands to my G-Code?

FlatCAM version 8.4 and later includes a spindle speed field in the CNC Job creation panel. For older versions, add the spindle command manually in the Prepend field before exporting. The format is S followed by RPM value, such as S24000 for 24,000 RPM. This command should appear before any cutting movements in your G-Code file.

Conclusion

Converting Gerber files to G-Code using FlatCAM opens up serious PCB prototyping capability for anyone with a CNC router. The software handles everything from simple single-sided boards to complex double-sided designs with multiple drill sizes and board cutouts.

The learning curve is worth climbing. Once you’ve processed a few boards and dialed in your settings for your specific machine and tooling, the workflow becomes second nature. Start with simple single-sided designs, master those before tackling double-sided work, and keep detailed notes on what settings work for your setup.

FlatCAM continues active development with regular updates and an engaged community. As you gain experience, explore the TCL shell commands for automation and batch processing of multiple boards. The software has far more capability than most users ever need, but that depth is there when your projects demand it.

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.