Introduction to Gerber Files
Gerber is a standard electronics industry file format used to communicate design
information to manufacturing for many types of printed circuit boards. In many ways,
Gerber is the electronics world's equivalent of PDF. This odd little format,
a hybrid machine control language and image, is a core component of the electronics
manufacturing supply chain. If you're involved in building electronics for fun or
profit you have (or soon will) come across it. You may even come to depend on it.
I've written this article to provide a general explanation of:
- The Contents of a Gerber file
- The use of Gerber Files in PCB Manufacturing
- Gerber Files and PCB Design Considerations
I hope you find this article useful, and generally accurate. In any case, I am happy
to receive your comments, suggestions and corrections – just drop an email to firstname.lastname@example.org.
The content of a Gerber file is ASCII text (i.e. English letters, digits and a few
special characters) and looks like a human could almost read and understand.
Here's an example:
When the format was first created, these commands called out instructions for a
special kind of machine called a
photoplotter which used them to create a picture on photographic film by
precisely controlling a light source. Today, however, photoplotters aren't always
a part of the process and Gerbers are treated more like image files. So why doesn't
the industry just use image files like postcript? It's a bit of a catch-22:
The machines use Gerbers because CAD/EDA/CAM software creates Gerbers; And, the
software creates Gerbers because the machines use Gerbers. Alternative formats
like ODB++ exist, and are probably superior to Gerber for the most part (except
for mandating the use of more expensive hardware and software, all controlled by
one company). Nonetheless, Gerber is here for the long-haul so we're well
served by a little understanding of it.
About RS-274D and RS-274X
There are two "standards" for Gerber files out there: the
"old" and the "new". The old standard (D) spreads information
for a single layer accross at least two files. The new standard (X) allows
all the information for a layer to be contained in a single file. The biggest
benefit of this comes down to data management (or in plain English, the fact that
it's much easier to keep track of one file than two files).
The types of instructions Gerber file instructions are (roughly):
- Configuration Parameters ("%...*%" blocks)
- Macro and Aperture Definitions (AM and AD parameters)
- Drawing Commands
- X/Y Coordinate information for the locations of features
Instruction types #3 and #4 are shared between the X and D variants of Gerbers.
That is, the old and new formats share the same commands and capabilities when it
comes to basic drawing of lines and simple shapes. However, the new "X"
version also allows the definition of some important options as well as reusable
blocks of data called apertures and macros. In a version "D" file
set (rememeber, always at least two files) the apertures are defined in an external
file that can be one of many different formats. This is why an "X" file
(ahem) can be viewed and rendered by CircuitPeople standalone -- all the pad shape
and line widths are built into the one file -- and why "D" files are considered
less desirable by PCB fabricators.
Gerber files containing blocks of text starting and ending with percentage symbols
("%...*%") are probably the RS-274X variety. Sometimes we see files
with parameters but with external aperture definitions, which is an error but our
software will accomodate it. Configuration parameters control various things in
the rendering process, including whether the geometry should be considered white
drawn on black, or black drawn on white.
Macro and Aperture Definitions
Apertures define the thickness of traces, size and shape of pads. Macros (AM
parameters) define complex shapes for registration marks, logo, lettering and other
special geometry that appears in a design. Macros are a "less often"
used feature of Gerber, though many CAD systems employ them for filling the gaps
in the original speficiation for features such as pad teardrops, rotated rectangles
and rectangles with rounded corners. Macros support complex composition rules,
and even some equation-driven parametrics. It's a shame they aren't
use more often in CAM output.
It's worth noting (reiterating, maybe?) that one reason manufacturers shy away
from the "D" variant gerbers (the ones with a apertures defined in an
external file) is that customers often forget to include them with their order.
Don't do that. If you do, the best thing that can happen is that
your order will be delayed. At worst, it won't be delayed and you'll discover
it only after assembling components only to find it non-functional.
Gerber has three drawing primitives: flashes, lines and arcs with thickness, and
polygon fills. It can be a challenge to represent complex geometry using only
these shapes. Luckly, RS-274X also adds "Step and Repeat" which
allows us to create patterns of features. CAM systems are clever in the way they
create Gerber files. For example, the system may "pour" a large
area of black (copper) then draw over it with a "scratch" layer of wide
geometry, then finally draw a copper trace down inside the clear. Only three
commands are issued, but the result seems more complex:
X/Y Coordinate Information
The purpose of the PCB is to mechanically support components as well as move the
proper number of electrons to where they are need. That is, the PCB is made with
channels (traces) of conductive material along which electricity flows (if you will)
from component to component.
A "bare" PCB is one that has yet to have components attached, and is generally
constructed of alternating layers of conductive material and non-conductive insulating
material. Copper is the most commonly used conductor with various forms of fiberglass,
FR-4 being the most common, as the insulator. However, due to requirements
for high thermal conductivity, strength or dielectric many other materials are used
as well. There are a lot of ways to make a PCB, but in this paper I'm
only going to talk about one common method. A subtractive PCB manufacturing
process is one that starts with sheets of composite material with a uniform layer
of copper plated of the entirty of one or both sides. Channels (traces) are formed
by selectively removing portions of the copper conductor, leaving behind the traces
we see on finished boards. In this process, Gerber files provide the "picture"
of where copper should remain:
I literally mean a picture of where the copper should exist on each layer – imagine
clear for no copper, black for copper. But there is more to a PCB than just copper,
which when exposed to air oxidizes making it difficult to adhere to with solder.
Over the copper will be a layer of solder mask (commonly green) and probably some
white letter referred to as silkscreen, legend or nomenclature.
As with the copper, Gerber files provide pictures of where the solder mask paint,
silkscreen paint, or cut-outs in a stencil will go. In addition, it isn't uncommon
to supply locations and for holes in a Gerber file – each size of hole represented
by a different symbol – as well as the shape of the board.
You can probably sympathize with the poor manufacturer. For a "simple"
two layer PCB, they can receive up to nine files:
- An image of the copper conductor for the top side of the circuit board.
- An image of the copper conductor for the bottom side of the circuit board.
- An image of where solder mask is to be applied on the top layer.
- An image of where solder mask is to be applied on the bottom layer.
- An image of where silkscreen is to be applied on the top layer.
- An image of where silkscreen is to be applied on the bottom layer.
- The locations of the drilled holes, and descriptions of the properties of the holes.
Often, PTH and NPTH (see below) are separated into different files.
- The outline of the board, including internal cutouts and other machining operations
(scoring, slots, etc.)
- A README file with the name and intended use of each of the above files.
In addition to these files, a manufacturer will need other information that generally
isn’t included (and shouldn’t be included, IMHO) in the Gerber data:
- Are the images for the solder mask and stencil layers supplied in "negative" (holes
drawn black) or "positive" (holes drawn white) convention?
- Are the bottom layers (copper, mask and silk) shown as viewed from the top (mirrored)
or as viewed from the bottom?
- How thick does the copper need to be on the outer layers, inner layers and in the
barrels of holes and vias?
- If the holes are supplied as a "drill drawing" in a gerber or DXF file, the table
of sizes has to be manually translated to NC (Excellon) file(s).
- If the holes are supplied in Excellon files (yet another numerical control language),
which holes are plated, non-plated, through, blind, or buried (and if blind or buried,
on which layers do they start/stop?).
- What colors should be used for the solder mask and silkscreen?
- What material should be used for the core?
- How thick does the finished PCB need to be?
And the list goes on. Obviously, this process leaves plenty of room for errors,
which brings up the topics of automation and DFM. But before going there, we need
to take a side-track into how the PCB manufacturing process works.
While the construction of a PCB is conceptually simple, correctly manufacturing
the circuit board can be complex. A general outline of the traditional PCB manufacturing
process for a simple two layer board (meaning a board with two conducting layers)
may look like the following:
- Drill all the holes in the panel that will be plated with copper. This step includes
preparation of an NC drill program for the automatic drill machines most shops use.
Excellon is a very common format for these NC programs, because Excellon drills
are very commonly found in shops around the world.
- Carefully clean the copper surfaces and carefully remove any "burrs" on the edges
of the holes caused by drilling.
- Coat the entire surface of the copper with photo resist. Resist is a material that
is soluble unless "cured" with heat or a strong light source, and that is chemically
inert during the following process.
- Attach the appropriate films to each copper side, and expose the "clear" sections
to light to cure them.
- Remove the uncured resist, leaving the cured resist to protect the copper from being
plated with tin in the next step.
- Put the panel in a chemical bath (various formulations are used) to add a very thin
layer of tin to the surfaces no longer protected by resist. This coating will protect
the copper from being removed in the etching step, below.
- Remove the cured etch resist using a different solvent, or mechanical means.
- Put the panel in a chemical bath (various formulations are used) to remove the unprotected
copper from the panel.
- Put the panel in another chemical solution that will deposit a thin (or thick, depending
on the design specifications) layer of copper on all remaining copper and hole barrels.
This layer of copper increases the thickness of the traces, and provides the copper
inside the holes to carry electrons between layers.
- At this point the board is electrically functional, but with bare copper exposed
it will oxidize very quickly rendering it difficult for solder to adhere. So, the
copper will be protected with solder mask (commonly green) and/or plating with an
inert material such as gold, silver, OSP or tin.
- At this point the entire panel is coated with solder mask paint. Like the resist,
the solder mask can be cured with strong light.
- Using artwork for the solder mask layer expose the parts of the solder mask that
are to remain on the board to UV light.
- Remove the unexposed solder mask.
- Cure the remaining solder mask using high heat (probably in an IR oven)
- Using the artwork for the legend layer, a silkscreen technique (yep, just like T-shirts)
is used to apply the white legend/nomenclature.
- Cure the solder mask and silkscreen ink in an oven.
Viola! Your board is ready to have components attached (aka. PCB "assembly") and
start service in your project or product.
From the above you might have noticed the part where Gerber files were made into
"films" sounds a little antique. Well, the truth is that it is antique. Although
these steps are commonly in use, many fabricators use a technique akin to inkjet
technology for applying silkscreen (aka. "nomenclature," or "legend") to the board.
Similarly, solder mask and etch resist can be applied in a computer-controlled "spray
painter". Hence, films may not actually ever be used, and for PCB designs involving
very small features or high layer counts almost certainly won't be.
Every shop has a unique variation on the above process, and new technologies are
available almost weekly. So, if you visit a fabrication shop, expect to find some
other technologies and processes to be in play. But the overall process should follow
the general outline above.
What's all that have to do with Gerber files? Well, lots of things. I'm going to
break them down into two areas: Legacy Issues and DFM.
As mentioned earlier, the Gerber format was originally used as NC to drive mechanical
systems that selectively exposed photographic film to light in a darkroom environment.
To make a pad, these machines would "flash" light through an appropriate shaped
aperture. To make a trace the machine would keep the light on while moving to create
a "drawn" line or arc. As you can probably guess, that isn't the way it's done today.
Those old photo plotters were functionally limited, notoriously unreliable and expensive.
Remember those "aperture definitions" in the Gerber format? Yep, those used to indicate
physical holes of different sizes that would be used to control the amount of light
exposed onto the film.
Today, the machines have evolved into something much more like a laser printer,
using a beam of light bounced-off rapidly moving mirrors to expose the film. And,
as I mentioned above, in some cases similar machines expose the etch resist and
solder mask directly rather than use films as well. In its role as a vector
image format, Gerber is not unlike Adobe PostScript, Windows Meta files, or SVG.
But, because it was not intended for this purpose, some nuisance issues come into
play when Gerbers are used for PCB specification:
- Uninterrupted Data. The Gerber format includes many commands for how to treat film.
These are largely meaningless when used as an image format. However, it's entirely
possible that the CAD system used to generate the Gerber file didn't know this,
and functional differences can result.
- Absence of hole data. Because photo plotters of old didn't drill holes, the format
didn't include hole data. Excellon NC files are often used to augment the Gerber
data with hole drilling information, but even that is incomplete since it doesn't
differential between though, buried and blind holes. Worse perhaps, is the lack
of assurance that the scale and offset of the hole data matches that in the Gerbers.
CAM technicians at PCB manufactures often have to rescale and offset hole data to
make it match the true hole locations.
- Absence of functional mapping for files. Imagine the files sent to a manufacture
were named A.gbr, B.gbr, etc. Nothing inside the files tells which part of the PCB
they're intended to define, if they are "positive" or "negative", or if they are
mirrored. Hence the need for a README.
- Inclusion of "out of bounds" data is common with Gerber files as a way to communicate
design intent. I often see files with "TOP SIDE" or "THIS SHOULD BE READABLE FROM
BOTTOM SIDE" notes to clue-in manufactures about important notes. This is great,
but all that data must be manually clipped from the files before fabrication to
avoid using excessive amounts of core material. It's best to put those notes elsewhere.
Whether you view it as an image format or NC data, Gerber doesn't include any sort
of "intent" about the design. Worse, it contains no protections from creating designs
that are very difficult, if not impossible to manufacture. Here are some common
errors to avoid with your PCB designs:
- Missing files
- Minimum feature size too small (you'll certainly pay in one way or another for anything
under 6 mil traces)
- Minimum gap size (likewise, spaces less than 10 mils lower yields and increase costs)
- Size of annular rings (good as they are, automated drills miss my a couple mils
- Acid traps (acute corners in copper features can get eaten into during etching)
- Slivers (very small, isolated islands or peninsulas of copper can actually flake-off
during processing and land somewhere else, potentially causing a short circuit)
- Silkscreen on pads (it's pretty difficult to solder over the top of white paint)
- Features too near, or even outside the outline (like the drill, the machine that
cuts out the shape of the board can wander and destroy features too close to edges
- Drilling into the same hole twice, also known as "double hits" (holes
end-up bigger than they should)
Holes in PCB can be plated with conductive material to carry electrons from one
"layer" to another (holes used in this way are referred to as vias) or non-plated.
Depending on which set of layers are connected by the hole, vias may be referred
to as "buried", "blind" or "though holes":
The above example 4-layer PCB cross-section shows a rigid core of material prelaminated
with conductor on each side and two "foil" layers separated from the core
by a thin layer of insulating material The different types of plated holes
are labeled. A non-plated through hole (NPTH) is drilled after the board has been
fabricated, so it doesn't contain any plating on the internal wall and therefore
doesn't electrically connect traces on one layer to another. These types of holes
are generally used for mounting hardware (stand-off, push-tabs, etc.) or other non-electrical
uses. Plated through holes (PTH) penetrate all layers of the PCB and have interior
walls plated with copper. Such holes can be used for mounting "through hole" components,
or as mentioned above exist only to carry electrons between conductive layers (vias).
The goal of this article was to provide readers with a little background on the
Gerber file format(s) as well as provide some hints on common pitfalls when communicating
with manufacturing. I hope I have acheived that goal. If I have, please
let me know. If I haven't, definately let me know. Thanks, and enjoy!