Introduction
KiCad is a popular open-source printed circuit board (PCB) design tool used by engineers and hobbyists. After completing a board layout in KiCad, manufacturing output files called Gerber files need to be generated to hand off for PCB fabrication. This article provides a step-by-step guide on properly exporting Gerber files from a KiCad PCB design including setup, configuration, layer mapping, and validation checks.
Overview of Gerber Files
Gerber files are the standard image format used by PCB manufacturers to represent copper layers and other fabrication data for photolithographic reproduction. Key facts about Gerber files:
- 2D vector images defining PCB layer artwork geometries
- Each layer such as copper, silkscreen, solder mask outputs as a separate file
- Contains photoplotter commands to image shapes in each layer file
- RS-274X file format standardized by Gerber Group
- Requires specific mapper settings to generate properly from CAD tools
Correctly configured Gerber files are required for the PCB fabrication house to produce the design as intended.
Before Exporting Gerbers from KiCad
Prior to exporting Gerber files, it’s important the KiCad PCB design is fully complete and validated through:
- All routing and layout changes finished
- Electrical rule check (ERC) passed with no errors
- All footprints updated to match sourced components
- Design rule check (DRC) passed with no errors
- 3D visualization checked for errors and clearances
Any layout changes made after generating Gerbers won’t be reflected in the files. It’s vital to freeze the design prior to Gerber export.
Step 1 – Validate Design Rules
The first step is running a full design rule check:
- Open the PCB file in KiCad and select Design Rules from the toolbar.
- In the Design Rules window, browse each rule category like Routing, Sizing, Masks etc.
- Verify all settings like track width, clearance, annular ring size, and mask margins meet fabrication requirements.
- Click OK after confirming rules are set as needed for manufacturing.
- Run Tools → Design Rule Check and resolve any errors before proceeding.
Correct design rules prevent errors like trace sizes or spacings that violate fabrication limits.
Step 2 – Generate Drill Files
The Excellon drill files defining hole sizes and locations are exported first:
- With the PCB open in KiCad, go to File → Fabrication Outputs → Drill Files.
- Choose a directory to save the drill files and enter a Drill File Prefix like ‘boardname-RoundHoles’.
- Select ‘File Format’ as Excellon 2′.
- Set ‘Map Files’ to ‘PTH and NPTH into single file’ for combining plated and non-plated holes.
- Enable ‘Minimal header’ and ‘Mirror y axis’ options.
- Click ‘Generate Drill File’ to create the Excellon NC drill file.
These steps properly configure the Excellon file expected by fabrication shops.
Step 3 – Generate Gerber Job File
- Staying in the Fabrication Outputs menu, next click ‘Gerber Files’.
- Select ‘Protel filename conventions’ since this matches how KiCad maps layers.
- Choose a directory to store output files and enter a File Name Prefix like ‘boardname’.
- Click ‘Generate Gerber job file (RS-274X)’ to create a .gbrjob project.
This .gbrjob file will configure and contain all the PCB layer Gerber files.
Step 4 – Map Layers to Gerber Files
Within the .gbrjob, map PCB layers to Gerber files:
- Double click the .gbrjob in File Explorer to open the Cam Processor job.
- In the Layers/Files map table, click each ‘File’ cell and set the corresponding file name (F.Cu, B.Cu, etc).
- Verify each PCB layer maps to the expected Gerber file based on standard conventions.
- Click each file hyperlink to validate proper file extensions like .GTL, .GTO, and .GTP.
mapping or extension could cause fabrication errors.
Step 5 – Generate Gerbers
With layer mapping configured, now generate Gerber files:
- In Cam Processor, click the Process Job button.
- A prompt will warn if there are any unmapped layers detected. Ensure all layers show a mapped file.
- Click OK to start Gerber file generation.
- The job log will display each layer file as its generated.
- After completion, click Close to exit Cam Processor.
The needed Gerber fabrication and assembly files are now created!
Step 6 – Validate Gerbers
Before sending to fabrication, validate the files:
- Visually inspect each layer file in a Gerber viewer. Check for any missing copper or openings.
- Confirm all file names match chosen convention like .GTO, .GTS, .GTL, etc.
- Verify file polarity (dark/clear) came out as expected
- Load files into CAM software like FlatCAM for additional checks and DFM analysis
- Confirm board outline matches mechanical layer with no unwanted opened cutouts
Fixing issues in the source PCB design is needed if any discrepancies are observed.
Gerber File Function
Here are the typical Gerber files generated from KiCad and their purpose:
File | Purpose |
---|---|
.GTL | Top layer copper |
.GBL | Bottom layer copper |
.GTS | Top soldermask layer |
.GBS | Bottom soldermask layer |
.GTO | Silkscreen print legend layer |
.GTP | Solder paste layer |
.GND | Board profile contour |
.DRD | NC drill file |
Configuring Gerber Export Settings
Several export options are available under File → Fabrication Outputs:
- Units – Inches or millimeters
- Precision – Number of decimal places in output files
- Polygon filling – Smooth filled regions or hatched polygons
- Gerber extensions – Change from standard .Gxx if required
- Exclude PCB edge layer – Omit board mechanical outline
- Subtract mask from silk – Remove soldermask below silkscreen text
- Drill Units – Inch or mm Excellon format
- Mirror axes – Flip plot to traditional Gerber orientation
Ensure options match requirements of the target PCB fabrication shop.
KiCad Gerber Generation – FAQs
Here are some frequently asked questions about generating Gerber files from KiCad:
What is the standard Gerber mapping convention?
KiCad follows the Protel filename convention like .GTL for Top Layer where the first letter indicates layer and second letter indicates function.
How can Gerber files be validated?
Use a free Gerber viewer like the one built into FlatCAM to visually inspect each file layer, check polarity, confirm board outline, etc.
Do Gerbers require a specific coordinate origin?
The origin set under File → Page Settings when creating the KiCad project will establish the coordinate system zero reference for output files.
What if KiCad is missing needed layers?
Not all fabrication layer types like non-plated holes or finishing notes have default mappings. Custom Gerber jobs can add mappings for any additional files.
How are internal cutouts and holes represented?
KiCad outputs cutouts, slots, and holes as clear polygons or regions in each respective layer file. No additional drill or aperture info is needed.
Conclusion
Exporting properly mapped and validated Gerber files from KiCad provides PCB fabricators the manufacturing information they need to accurately produce a board design. Configuring the layer-to-file mapping table along with output settings generates the correct fabrication files expected from CAD tools. Visually inspecting layers and running design rule checks verifies completeness before release. Taking care to meet Gerber format requirements avoids delays, added costs, or impediments during PCB production. Manufacturing can proceed smoothly with clean verified Gerber output from KiCad designs.