Professional Documents
Culture Documents
RS-274X Extended Gerber Format Specification 201201
RS-274X Extended Gerber Format Specification 201201
Karel Tavernier
Managing Director,
Ucamco
Preface......................................................................................................................................... iii
1 Introduction ............................................................................................................................ 9
Note: Gerber readers sometimes handle the zero default wrongly. For clarity and
robustness it is recommend not to count on the zero default, but always to specify the
first coordinate explicitly, also if it is zero.
Offsets are not modal. If I or J is omitted the default zero is used.
2.6 Parameters
Parameters define characteristics applying to an entire image or to a single layer.
They are used to interpret the other data types. (Originally, they were called Mass
Parameters.)
Parameters operating on the entire image are usually placed at the beginning of the
file. Parameters generating a new layer are place at the appropriate place in the file
Parameters consist of two alphabetic characters followed by one or more optional
modifiers.
Parameters are delimited by the parameter delimiter “%”. Each parameters is
contained in a data block that itself must be ended by an *. The parameter delimiter
must immediately follow the end-of-block without intervening spaces.
For example:
%FSLAX23Y23*%
Parameters may be entered single or grouped between delimiters, up to a maximum
of 4096 characters between delimiters.
For example:
%SFA1.0B1.0*ASAXBY*%
Line breaks are permitted between parameters to improve readability.
For example:
%SFA1.0B1.0*
Syntax Comments
Mandatory Optional
KO Knockout Off
Parameter Overview.
Parameters in bold are current, those in italic are deprecated.
Parameters are usually placed at the beginning of the file in the order shown above.
Layer-specific parameters are in the file at the appropriate location.
Gerber writers cannot use the deprecated parameters anymore. As they can be
present in legacy files, readers can either implement them or not. If they are present,
their meaning is specified below.
Syntax Comments
Syntax Comments
For example,
%ADD22R,0.020X0.040*%
D-code 22 is a .02 x .04 solid rectangle.
4.1.6 Examples
Syntax Comments
4.2.1 Contents
An aperture macro contains the following elements:
Aperture macro name
One or more of the seven aperture primitives. (See table below)
Primitive modifiers specifying exposure, position, dimensions, etc.
Variable primitive modifiers supplied by the AD parameters
Optional embedded comment block
Arithmetic operators
Operator Function
+ Add
- Subtract
/ Divide
x Multiply
= Equate
n Number, with or without decimal point
The standard arithmetic precedence rules apply.
Exposure can be on or off. Exposure on creates a solid part of the aperture.
Exposure off creates a hole in it. (Note: A hole is transparent. One sees the
objects below it. This is not the same as clear Layer Polarity, where all object
below are cleared or erased.)
Syntax Comments
$2 Diameter
$3 X center position
$4 Y center position
$4 Y start point
$5 X end point
$6 Y end point
$3 Rectangle height
$4 X center point
$5 Y center point
$4 Y center point
$5 Outer diameter
$3 Outer diameter
$4 Inner diameter
$5 Gap thickness
Exposure is always on. $6 Rotation angle around the center
point of the thermal. Without
Note: $5 must be rotation, the gaps are on the
smaller than $3. The inner axes through the center.
circle disappears when $5 is
bigger than $4,
4.2.5 Examples
All units are inch
Example 1
Defines an aperture macro named DONUTFIX consisting of two concentric circles
with fixed diameter sizes.
%AMDONUTFIX*1,1,0.100,0,0*1,0,0.080,0,0*%
Syntax Comments
The AD parameter using this aperture macro will look like the following:
%ADD33DONUTFIX*%
Example 2
Defines an aperture macro named DONUTVAR consisting of two concentric circles
with variable diameter sizes:
%AMDONUTVAR*1,1,$1,$2,$3*1,0,$4,$2,$3*%
Syntax Comments
1,0,$4,$2,$3 Circle (1), exposure off (0), diameter ($4), X center and Y
center ($2 and $3, same as first circle)
The AD parameter using this aperture macro might look like the following:
%ADD34DONUTVAR,0.100X0X0X0.080*%
Example 3
Defines an aperture macro named DONUTCAL consisting of two concentric circles
with diameter of the second circle defined as a function of the diameter of the first:
%AMDONUTCAL*1,1,$1,$2,$3*$4=$1x0.75*1,0,$4,$2,$3*%
Syntax Comments
1,0,$4,$2,$3 Circle (1), exposure off (0), diameter ($4), and center point
The AD parameter using this aperture macro might look like the following:
%ADD35DONUTCAL,0.020X0X0*%
This defines a donut with outer circle 0.02 and inner circle 0.015 inch
Example 4
Defines an aperture macro named TRIANGLE_15 rotated 15 degrees around the
origin.
%AMTRIANGLE_15*4,1,3,1,-1,1,1,2,1,1,-1,15*%
Syntax Comments
Note: It is recommended not to use the SM parameter. Avoid it like the plague.
The exception for special apertures is confusing and leads to mistakes.
Syntax Comments
4.2.6.2 Examples
Syntax Comments
Syntax Comments
4.3.1.2 Example
Syntax Comments
%ASAYBX*% Assign output device axis A to data axis Y and output device
axis B to data axis X
Note: The implementation limit on integer and decimal places was 6 in the past.
However, some applications started to generate 7 decimal places because they
needed the accuracy. To cater for this need we have raised this limit to 7. However,
there are probably still a number of Gerber readers in use that can only handle 6.
Therefore we recommend using 7 decimal places only if the extra accuracy is
needed.
Syntax Comments
<Xnm> and <Ynm> Enter X or Y and the number n of integer and m decimal
places in the coordinate data for each axis. The value of n
and m ranges from 0 to 7. The X and Y coordinates must
have the same format!
4.3.2.5 Example
Syntax Comments
Note: It is recommended not to use the MI parameter. Avoid it like the plague.
The exception for special apertures is confusing and leads to mistakes.
Use the AS parameter to correlate data axes with output device axes.
Syntax Comments
4.3.3.2 Examples
Syntax Comments
Note: Use the FS parameter to specify the integer and decimal place format.
Syntax Comments
MO M for Mode
4.3.4.2 Examples
Syntax Comments
Syntax Comments
OF OF for Offset
4.3.5.2 Examples
Syntax Comments
Note: Use the AS parameter to correlate data axes with output device axes
Syntax Comments
4.3.6.2 Example
Syntax Comments
Syntax Comments
4.4.1.2 Examples
Syntax Comments
Syntax Comments
4.4.2.2 Examples
Syntax Comments
Note: Generating a new layer resets the graphic state, including the current
point.
Syntax Comments
4.5.1.2 Examples
Syntax Comments
Syntax Comments
4.5.2.2 Examples
Syntax Comments
Note: Layer polarity is not the same as image polarity, see the IP parameter.
Syntax Comments
4.5.2.4 Examples
Syntax Comments
Syntax Comments
X<repeats> The number of times the data is repeated along the X-axis
Y<repeats> The number of times the data is repeated along the Y-axis
I<X-axis step> The step between the repeats along the X-axis
J<Y-axis step> The step between the repeats along the Y-axis
4.5.3.2 Example
Syntax Comments
%SRX1Y1I0J0*% Step and Repeat with 1 repeat, i.e. not repeated (default)
%SRX2Y3I2.0J3.0*% Repeat the image 2 times along the X axis and 3 times
along the Y axis. X-axis repeats are spaced 2.0 units
apart. Y-axis repeats are spaced 3.0 units apart.
%SRX4I5.0J2*% Repeat the image 4 times along the X axis with 5.0 units
from one step to the next. The J modifier is ignored because
no Y repeats are specified.
5.1 Overview
Code Function Comments
D01 Exposure and Draw mode Draws a line using the current aperture. (There
on. are strict limitations on the apertures that can
be used for drawing.) The current point is
moved to the end point.
D02 Exposure and Draw mode Generates no image. The current point is
off. moved. This is the default state
D03 Set Flash mode. Flash the current aperture. The current point is
moved to the flash point.
D-codes
G-codes
M00 Program stop This historic code has no effect on the image. It
is deprecated.
M01 Optional stop This historic code has no effect on the image. It
is deprecated.
M02 End of program Ends image generation. Every file must end in
a M02
M-codes
Syntax Comments
Dn Exposure
n = 01 => On
n = 02 => Off
The orientation is defined around the center of the arc, moving from begin to end.
There are two quadrant modes:
single quadrant mode
multi quadrant mode
In single quadrant mode the arc is not allowed to extend over more than 90°. The
following relation must hold: 0° =< |arc angle| =<90°. If the start point of the arc is
equal to the end point, the arc has length zero, i.e. it covers 0°. A data block is required
for each quadrant. A minimum of four data blocks is required for a full circle.
In multi quadrant mode the arc is allowed to extend over more than 90°. To avoid
ambiguity between 0° and 360° arcs the following relation must hold: 0° < |arc angle|.
If the start point of the arc is equal to the end point, the arc is a full circle of 360°.
The default mode is single quadrant. The G74 and G75 command allow switching
between the two modes. A data block containing G75 enables multi quadrant mode.
Every block following it will be interpreted as multi quadrant, until cancelled by a G74.
A data block containing G74 code turns off multi quadrant mode, reverting to single
quadrant mode.
Some Gerber writers erroneously take G75 as a default. This leads to obscure
errors when readers try deal with these wrong files by guessing the default used. If
you specify G74/G75 explicitly the mode is unequivocal for both reader and writer.
This is safer and more robust than relying on the default. We strongly recommend
always specifying the G74/G75 explicitly when creating a Gerber file.
Syntax Comments
In n = The offset between the arc start point and the center
parallel to the X axis. The value is always positive. A sign
is not allowed. The direction to the center is determined
implicitly.
Jn n = The offset between the arc start point and the center
parallel to the Y axis. The value is always positive. A sign
is not allowed. The direction to the center is determined
implicitly.
Dn Exposure
n = 01 => On
n = 02 => Off
5.3.1.2 Image
Syntax Comments
G74* Single quadrant mode
G54D10* Use aperture D10
G01X1100Y600D02* Start from 11,6
G03X700Y1000I400J0D01* Quarter arc (radius 4) to 7,10
X300Y600I0J400* Quarter arc (radius 4) to 3,6
X700Y200I400J0* Quarter arc (radius 4) to 7,2
X1100Y600I0J400* Quarter arc (radius 4) to 11,6
G01X300D02* Start from 3,6
X1100D01* Line to 11,6
X700Y200D02* Start from 7,2
Y1000D01* Line to 7,10
Resulting Image
Note: The I and J offsets are signed. If no sign is present, the offset is positive.
Syntax Comments
5.3.3 Example
Syntax Comments
G75* Multi quadrant mode
G01X300Y-200D02* Start from 3,-2
G03X-300Y-200I-300J400D01 Arc counterclockwise (rel. center -
G01* 3,4) to -3,-2
Back to linear interpolation mode
Resulting Image
If the aperture is aligned with the draw the result is a line with a straight line ending:
Note: The rectangle is not automatically rotated to be aligned with the draw.
Care must be taken that rounding errors, especially with arcs, does not turn a
proper outline into a self-intersecting one, with unpredictable results; construct
outlines defensively and round carefully.
Outline area fill is much more efficient than the obsolete method of stroke fill.
In previous versions of this document “outline fill” was also called “polygon fill” This
was a misnomer as arcs can be used in the outline, whereas a polygon is usually
understood to have only straight edges.
Syntax Comments
G36* Outline fill mode
X200Y300D02* Start at 2,3
X700D01* Line to 7,3
Y100D01* Line to 7,1
X1100Y500D01* Line to 11,5
X700Y900D01* Line to 7,9
Y700D01* Line to 7,7
X200D01* Line to 2,7
Y300D01* Line to 7,1
G37* End of outline fill mode
Syntax Comments
G36* Outline fill mode
X200Y1000D02* Start at 2,10
X1200D01* Line to 12,10
Y200* Line to 12,2
X200* Line to 2,2
Y600* Line to 2,6
X500* Line to 5,6
G75* Multi quadrant mode
G3X500Y600I0J300D01* Full arc ccw (radius = 300)
G74* Single quadrant mode
G1X200D01* Line to 2,6
Y1000* Line to 2,10
G37* End of outline fill mode
Resulting Image
G36*
X1220000Y2570000D02*
X1250000D01*
Y2600000*
X1290000*
Y2640000*
X1250000*
Y2670000*
X1290000*
Y2700000*
X1250000*
Y2670000*
Y2640000*
Y2600000*
Y2570000*
X1310000*
Y2720000*
X1220000*
Y2570000*
G37*
G36*
X1110000Y2570000D02*
Y2600000D01*
X1140000*
Y2640000*
X1110000*
Y2670000*
X1140000*
Y2700000*
X1110000*
Y2570000*
X1170000*
Y2720000*
X1090000*
Y2570000*
X1110000*
G37*
Some RS-274X files do not produce the desired image due to incorrect interpretation of the specifications. Some common errors:
APERTURE: A shape that is used for drawing lines or flashing. (The name is historic; one used to
expose shapes on film by shining light through an aperture in an aperture wheel.)
APERTURE MACRO: A parameter describing the geometry of a special aperture and assigns it
to a D-code.
APERTURE PARAMETER: A parameter (AD or AM) that assigns an aperture definition to a D-code.
INCREMENTAL POSITION: Position expressed as a distance in X and Y from the current point.
KNOCKOUT: A rectangular region around an information layer whose polarity is the opposite of the
layer polarity.
LAYER: An information section of RS-274X data that is treated as a unit, for example, rotated or
repeated. (In the RS-274X context it does not mean the layer of a PCB.)
LAYER-SPECIFIC PARAMETER: A parameter that applies to a single information layer (KO, LN, LP,
and SR).
NUMERICAL PRECISION: The number of integer and decimal places used to express a number.
POLARITY: When applied to the file image, positive polarity means the image is exposed black on
white, and negative that it is exposed white on black. When applied to a layer, dark means that the
object exposes the image area in dark (black) and clear means that the object clears or erases
everything underneath it.
OUTLINE FILL: A feature to create solid (filled) areas. (Previously called polygon fill.)
SINGLE QUADRANT MODE: The arc cannot extend over more than 90°. If the start point of the arc is
equal to the end point, the arc has length zero, i.e. covers 0°.
STEP AND REPEAT: A method by which successive exposures of a single image are made to
produce a multiple image production master.
9.1.1 Example 1
Example 1 is a single layer image with two square boxes.