Posted by SainSmart on

Turning a PCB design into a physical board does not always require sending the files to a fabrication service. With KiCad, FlatCAM, and a desktop CNC such as the Cubiko CNC, you can convert Gerber and Excellon drill files into toolpaths for isolation routing, copper clearing, and through-hole drilling.

This guide follows the workflow demonstrated in the How to Mill Your Own PCB: Gerber to CNC in FlatCAM video. It focuses on preparing the CNC files; machine setup, probing, and the actual milling process should be completed only after carefully reviewing the generated G-code.

What You Will Create in FlatCAM

The process starts with manufacturing files exported from KiCad and ends with several CNC files:

  • One G-code file for routing around the copper traces
  • An optional copper-clearing toolpath for larger non-copper areas
  • Separate drilling files for each drill diameter used by the board

Keeping operations separate makes it easier to inspect each toolpath, change tools at the correct time, and verify the settings before the CNC starts cutting.

Prepare the Gerber and Drill Files in KiCad

Before opening FlatCAM, export the required manufacturing files from KiCad. The video uses the front copper Gerber, the board-edge file, and the Excellon drill file. The front copper layer defines the conductive areas, while the drill file contains the hole locations and diameters for through-hole components.

Confirm that the files use a consistent unit system and coordinate origin. A mismatch here can shift, mirror, or scale a toolpath later. It is also worth opening the generated files in a Gerber viewer before continuing so that missing layers or incorrect drill positions can be caught early.

Import the Copper Gerber into FlatCAM

Open FlatCAM and use File > Open Gerber to import the front copper layer. In the video, the green areas represent copper that should remain, while the surrounding areas are where material may need to be removed.

Front copper Gerber file selected for import into FlatCAM
Select the front copper Gerber before generating any machining geometry.

Zoom in and inspect the narrowest gaps between traces and pads. These small clearances determine whether the selected cutter can physically isolate the copper without damaging the intended conductors.

Calculate the Effective Diameter of the V-Bit

A V-bit does not cut at one fixed width. Its effective cutting diameter depends on the tip diameter, included angle, and cutting depth. The demonstration uses FlatCAM’s tool calculator with the following example values:

Setting Video example
Tip diameter 0.2 mm
Tip angle 20° for the initial isolation calculation
Cut depth 0.07 mm
Spindle speed 10,000 RPM

These values are examples from one board and tool combination, not universal presets. Measure the actual cutter, confirm the copper thickness, and account for spindle runout and board flatness. A small change in Z depth can noticeably widen a V-bit cut.

Generate the Isolation-Routing Geometry

Select the imported copper Gerber and open the isolation-routing tool. Enter the calculated effective tool diameter, then choose the number of passes and the overlap between them.

FlatCAM Isolation Tool settings beside the imported PCB copper layout
FlatCAM’s Isolation Tool controls the cutter diameter, pass count, overlap, and routing direction.

The video first illustrates how disabling Combine creates separate geometry objects for individual passes. It then enables the combined approach so multiple isolation passes are stored as one geometry object. A three-pass route with 35% overlap is used to create additional clearance around the copper.

Before generating the CNC object, turn off snap-to-grid if it interferes with inspecting the geometry. Follow the red toolpath lines around pads and traces, paying special attention to areas where two copper features are close together.

V-bit settings and isolation geometry displayed around PCB traces in FlatCAM
Review the generated isolation geometry together with the V-bit and cutting parameters.

Inspect Narrow Gaps Before Exporting G-Code

After generating a CNC object, FlatCAM displays the planned cutting paths. In the video, blue lines show where the cutter is expected to remove copper. If a narrow gap contains no toolpath, the effective cutter diameter may be too large for that space.

Do not assume that adding more passes will solve this problem. Extra passes expand the cleared area outside the trace, but they do not make the cutter fit between features that are closer together than its effective width. Possible remedies include using a finer cutter, reducing the cutting depth where appropriate, or revising the PCB layout to increase clearance.

Clear Larger Non-Copper Areas with the Paint Tool

Isolation routing separates traces, but it can leave broad areas of unused copper on the board. To make the milled PCB more closely resemble the KiCad design, the video creates a non-copper region around the Gerber geometry and then uses FlatCAM’s Paint Tool.

The demonstrated workflow uses a 0.5 mm boundary with rounded corners, followed by a paint operation with 45% overlap. Different path-generation methods are previewed, and the seed-based result is selected for the board shown.

Non-copper region boundary created around the PCB layout in FlatCAM
A non-copper boundary defines the area available for the clearing operation.

Copper clearing can significantly increase machining time. Use it when removing unused copper is important for the design, appearance, or later handling of the board; otherwise, isolation routing alone may be sufficient.

Copper-clearing paint toolpath generated between PCB traces in FlatCAM
The paint tool fills larger non-copper regions with additional machining paths.

Generate and Review the Copper-Milling G-Code

Select the isolation or painted geometry, enter the tool and motion settings, and generate the CNC object. Before saving the file, inspect the G-code and confirm at least the following:

  • The units match the FlatCAM project and CNC controller
  • The cutting depth and safe Z height are appropriate
  • The XY and Z feed rates are suitable for the cutter and material
  • The spindle command and intended RPM are present
  • The tool diameter matches the cutter that will be installed
  • The preview shows cuts in every required isolation gap

The spindle check is especially important. A tool moving across the board before the spindle reaches speed can scratch the copper, break the tip, or damage the workpiece.

Generated PCB milling G-code opened for review in FlatCAM
Inspect the generated code header and motion commands before exporting the milling file.

Create Separate CNC Files for Each Drill Diameter

Next, use File > Open Excellon to import the drill file from KiCad. FlatCAM displays the hole locations and groups them by diameter. The example board contains three drill sizes, so the video generates a separate CNC file for each size.

Excellon drill layer and annotated drilling paths displayed in FlatCAM
The imported Excellon layer identifies the drilling locations across the PCB.

The demonstrated drilling depth is 1.7 mm for a board described as approximately 1.6 mm thick. That extra depth is intended to ensure that the drill passes through the board. Your value should reflect the measured board thickness, spoilboard setup, surface probing method, and safe penetration allowance.

For each drill group:

  1. Select only the required drill diameter.
  2. Open the drilling tool and enter the cut depth, travel height, feed rate, and spindle speed.
  3. Generate the CNC object.
  4. Review the G-code and verify the selected diameter and motion settings.
  5. Save the file with a name that clearly identifies the drill size.

Clear filenames reduce the chance of installing one drill bit while accidentally running the code intended for another.

PCB drilling G-code and tool settings reviewed in FlatCAM
Review the selected drill diameter, cut depth, feed rates, and spindle speed before saving each file.

Transfer the Files and Perform a Final Safety Check

The video finishes by copying the copper-routing file and the three drill files to the CNC machine’s SD card. Before running them, secure the PCB blank to a flat spoilboard, install the correct tool, set or probe the work origin, and confirm that the job fits within the usable machine area.

A dry run above the material is a practical way to catch an incorrect origin, unexpected travel, or a mirrored toolpath. The copper layer is thin, so reliable Z-height control and a flat work surface are essential for consistent isolation width.

Common Problems to Watch For

  • Copper remains between traces: Check whether the cutter can fit in the gap and whether the selected cut depth produces too wide an effective V-bit diameter.
  • Isolation width varies across the board: Improve board flatness, workholding, and surface probing before changing the toolpath.
  • Large copper areas remain: Add a non-copper-region paint operation if full clearing is required.
  • Drill holes do not align: Verify that the Gerber and Excellon files share the same units, origin, orientation, and mirroring.
  • The cutter scratches before cutting: Confirm the spindle-start command, RPM setting, safe Z height, and controller behavior.

From Gerber Files to CNC-Ready Toolpaths

The essential workflow is straightforward: import the copper Gerber, calculate the cutter’s effective diameter, generate and inspect isolation paths, clear non-copper regions if needed, create drill files by diameter, and verify every G-code file before machining.

The most important step is not generating the code—it is validating that the code matches the cutter, PCB blank, and CNC setup in front of you. Careful previews, clear filenames, conservative test runs, and accurate Z control turn FlatCAM from a file converter into a dependable part of a desktop PCB-milling workflow.

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.