Introduction to Gerber Standard
The Gerber format, also known as RS-274D or Standard Gerber, is a file format used to describe the printed circuit board (PCB) images like copper layers, solder mask, legend, drill data, etc. It is the de facto standard used by PCB industry software to describe the circuit board images.
Gerber is an open ASCII vector format for 2D binary images. It consists of a sequence of commands like draw line, flash aperture, etc. that an image writer machine can interpret. An image writer is a photoplotter that draws the PCB image on film or a Gerber viewer software that displays the PCB images on screen.
History of Gerber Format
The Gerber format was originally developed by the Gerber Systems Corp., a division of Gerber Scientific, founded by Joseph Gerber. The format is based on a subset of the Electronic Industries Association RS-274-D specification. In 1980, the specification was extended to support aperture information embedded in the Gerber file. This is known as Extended Gerber or RS-274X format.
In 1998, Gerber Systems Corp. was acquired by Ucamco. Ucamco now manages the Gerber format. In 2012, Ucamco published an official specification called “The Gerber File Format Specification”. In 2014, Ucamco revoked RS-274X from the specification and made Standard Gerber (RS-274D) with separate aperture definitions as the current format.
Gerber File Structure
A Standard Gerber file has two sections:
- Gerber image data – contains the commands to draw the image
- Aperture list – defines the apertures used in the image
The two sections are typically in separate files, although they can be in the same file. The image file has the extension .GBR or .PLT and the aperture file has the extension .APT.
Here is an example of a simple Gerber file with image and aperture list:
Image file:
G04 Simple example*
%FSLAX25Y25*%
%IPPOS*%
%LPD*%
%AMOC8*
5,1,8,0,0,1.08239X$1,22.5*
%
G01*
G75*
%LPC*%
G36*
X1215Y598D02*
X1115Y598D01*
X1115Y698D01*
X1215Y698D01*
X1215Y598D01*
G37*
M02*
Aperture file:
%ADD10C,0.01*%
%ADD11C,0.02*%
Coordinate Format
Gerber uses a 2D Cartesian coordinate system to define the image. The X-axis runs from left to right and the Y-axis from bottom to top. The origin (0,0) is at bottom left.
Coordinates are defined using the FS (Format Specification) command. It specifies:
– Coordinate units: mm or inch
– Number of integer and decimal places
– Absolute or incremental coordinates
For example:
– %FSLAX26Y26*%
specifies 2 integer and 6 decimal places in absolute coordinates (Absolute mode).
– %FSLIX25Y25*%
specifies 2 integer and 5 decimal places in incremental coordinates (Incremental mode).
Apertures
An aperture is a 2D shape that is used to draw or flash onto the image plane. Common shapes are circle, rectangle, obround and polygon. An aperture definition has the following syntax:
%ADDnnTtGc,d,s,r*%
Where:
– nn = aperture number (10 to 999)
– Tt = aperture type (C=circle, R=rectangle, O=obround, P=polygon)
– Gc = type dependent geometric parameters (e.g. diameter, width x height, etc.)
For example:
– %ADD10C,0.5*%
defines a round aperture with diameter 0.5
– %ADD22R,0.25X0.5*%
defines a rectangular aperture of size 0.25 x 0.5
Aperture Macro
An aperture macro allows defining custom aperture shapes. It has the following syntax:
%AMname*
<macro_body>
%
Where name is the name of the macro and macro_body contains primitives to define the shape. For example:
%AMDONUT*
0 0 0.5 0 0*
0 0 0.25 0 0*
%
This defines an annular ring macro named DONUT with outer diameter 0.5 and inner diameter 0.25.
The macro can be referenced in an aperture definition:
%ADD22DONUT*%
Drawing Commands
The basic drawing commands in Gerber are:
- Move (D01) – moves the current point to a new location
- Linear Interpolation (G01) – draws a straight line
- Circular Interpolation (G02/G03) – draws an arc
- Flash (D03) – flashes the aperture at the current point
- Region (G36/G37) – fills a polygon region
For example:
D10*
G01X100Y100D02*
X500Y100D01*
X500Y500D01*
X100Y500D01*
X100Y100D01*
This draws a 400×400 square using aperture D10 by moving to location (100,100), then drawing lines to (500,100), (500,500), (100,500) and back to (100,100).
Attributes
Attributes provide meta-information about the file. They are akin to labels on the file. Standard attributes are:
– .Part – part name
– .FileFunction – file function like Copper, Soldermask, etc.
– .FilePolarity – Positive or Negative
– .SameCoordinates – Defines the file is in same coordinates as another
For example:
G04 #@! TF.FilePolarity,Positive*
G04 #@! TF.Part,Single*
G04 #@! TF.FileFunction,Copper,L1,Top*
Header
The header of a Gerber file contains directives for units, format specification, imaging polarity, etc. Some common directives are:
- MO – Mode (IN=Inch, MM=Millimeter)
- AD – Aperture Definition
- FS – Format Statement
- AS – Axis Select
- IP – Image Polarity (POS=Positive, NEG=Negative)
- OF – Offset
- LN – Layer Name
An example header:
G04 Preamble*
%MOMM*%
%FSLAX26Y26*%
%IPPOS*%
%LPD*%
%AMOC8*
5,1,8,0,0,1.08239X$1,22.5*
%
Standard Apertures
The standard apertures available are:
Code | Shape | Parameters |
---|---|---|
C | Circle | Diameter |
R | Rectangle | Width x Height |
O | Obround | Width x Height |
P | Polygon | Diameter x Vertices x Rotation |
T | Thermal | Inner x Outer x Gap x Rotation |
Example Gerber File
Here is a complete example showing a Gerber file for a simple PCB with a circular pad and a track:
Image file (example.GBR):
G04 Simple PCB*
%MOMM*%
%FSLAX26Y26*%
%IPPOS*%
%LPD*%
%ADD10C,2*%
%ADD11C,0.5*%
%LNTop Copper*%
G01*
G75*
%LPC*%
X1000Y1000D03*
D11*
X1000Y1000D02*
X5000Y1000D01*
M02*
Aperture file (example.APT):
%ADD10C,2*%
%ADD11C,0.5*%
This draws a 2mm diameter pad at location (10,10) and a 0.5mm track from the pad to (50,10).
FAQ
What is the current Gerber format standard?
The current format is RS-274D, also known as Standard Gerber X2. It was standardized by Ucamco in 2014.
What is the difference between RS-274D and RS-274X?
RS-274X, also known as Extended Gerber, has aperture information embedded in the Gerber data block. RS-274D keeps the aperture information separate in an aperture file. RS-274X was officially revoked in 2014.
What is an aperture?
An aperture is a 2D shape like a circle, rectangle, etc. that is used to draw pads and tracks on the image.
What is an aperture macro?
An aperture macro allows defining custom aperture shapes using primitives. It is defined in the aperture file and referenced by the aperture number.
What are the common file extensions used for Gerber?
.GBR or .GBX – Gerber image data
.APT – Aperture file
.DRL – NC drill data
The article provides a comprehensive introduction to the Gerber format, covering the history, file structure, syntax, commands, attributes, apertures and macros. Examples illustrate the concepts. The FAQ answers some common questions. Let me know if you would like me to modify or expand the article further.
Leave a Reply