RS-274D : Standard Gerber with separate aperture tables

Posted by

What is an Aperture Table in Gerber?

An aperture table in Gerber is a list of all the apertures (shapes) used in a PCB design. Each aperture is identified by a unique code called an aperture number or D-code. The aperture table defines the shape, size, and type of each aperture.

In RS-274D, the aperture table is stored separately from the main Gerber file. This allows for easy modification and reuse of apertures across different designs. The aperture table is typically stored in a file with a .apr extension.

Example Aperture Table

Here is an example of an aperture table in RS-274D format:


In this example:
– D10 is a circular aperture with a diameter of 0.010 inches
– D11 is a rectangular aperture with a size of 0.050 x 0.030 inches
– D12 is an obround (oval) aperture with a size of 0.060 x 0.040 inches
– D13 is a polygon aperture approximating a circle with a diameter of 0.015 inches

Aperture Types and Shapes

RS-274D supports several standard aperture types and shapes:

Aperture Type Shape
C Circle
R Rectangle
O Obround (rounded rectangle/oval)
P Regular polygon (approximates a circle)

The size of each shape is defined using one or more parameters after the shape letter. For example, %ADD10C,0.010*% defines a circular aperture with a 0.010 inch diameter.

In addition to standard shapes, RS-274D also allows custom aperture shapes to be defined using aperture macros. Aperture macros use primitive shapes and operations to build up complex custom apertures.

Referencing Apertures in Gerber Data

Once the apertures are defined in the aperture table, they can be referenced in the main Gerber file to draw pads, traces, and other features on the PCB layers.

Apertures are selected using the “D” code followed by the aperture number. For example, D10* selects aperture D10. The selected aperture is then used for all subsequent drawing commands until a new aperture is selected.

Here is an example of drawing commands in RS-274D using the example apertures defined earlier:


This would:
1. Select aperture D10 (0.010″ circle)
2. Flash (draw) the aperture at location X1000, Y1000
3. Flash the same aperture at X1500, Y1000
4. Select aperture D11 (0.050″ x 0.030″ rectangle)
5. Flash aperture D11 at X2000, Y1500
6. Flash aperture D11 again at X2500, Y1500

Advantages of Separate Aperture Tables

Using separate aperture tables in RS-274D provides several advantages over embedding the aperture definitions directly in the Gerber data:

  1. Reusability: Aperture tables can be saved and reused across many different PCB designs. This promotes standardization and saves time defining the same apertures over and over.

  2. Smaller file sizes: By factoring aperture definitions out into a separate file, the main Gerber data file can be made smaller. Only the aperture numbers need to be referenced, not the full definitions.

  3. Easier editing: Aperture tables can be edited independently of the main Gerber data. Shapes, sizes, and types can be tweaked without having to regenerate the full Gerber file.

  4. Simpler macros: Using an aperture table allows aperture macros to be defined once and referenced multiple times. Without an aperture table, the full macro definition would need to be embedded each time it is used, bloating the file size.

Gerber File Structure with Aperture Tables

A complete Gerber data package using RS-274D with separate aperture tables typically consists of two files:

  1. Main Gerber file (.gbr) – contains the layer image data referencing the apertures by number
  2. Aperture file (.apr) – contains the aperture table definitions

The two files are linked using the %ADD command in the main Gerber file. The %ADD command references the aperture definitions in the .apr file.

Here is an example of the structure:

Main .gbr file:

G04 This is the main Gerber file*

.apr aperture file:

G04 This is the aperture file*

In this example, the main .gbr file references aperture D10 defined in the separate .apr file. The .apr file contains additional aperture definitions that could be used by the main file.


What is the current Gerber format standard?

The current Gerber format standard is RS-274X, also known as Extended Gerber or GerberX. It extends RS-274D with new commands and features while maintaining backwards compatibility.

Are aperture tables required in RS-274D?

No, using separate aperture tables is optional in RS-274D. Aperture definitions can also be embedded directly in the main Gerber file. However, using aperture tables is considered a best practice for the reasons outlined above.

Can multiple .gbr files share the same aperture table?

Yes, multiple .gbr files can reference the same .apr aperture file. This is useful for defining common apertures used across different PCB layers.

How do I view or edit Gerber files?

Gerber files can be viewed and edited using various PCB CAD tools, such as KiCad, Eagle, Altium, etc. There are also standalone Gerber viewer applications available.

What is the file extension for Gerber files?

The official file extension for Gerber files is .gbr or .art. However, other extensions like .gtl (top layer), .gbl (bottom layer), etc. are also sometimes used to specify the PCB layer.

In conclusion, RS-274D with separate aperture tables is a powerful and flexible way to define PCB artwork in the Gerber format. By separating aperture definitions from the main image data, designs are more modular, reusable, and compact. Understanding how to create and utilize aperture tables is a key skill for any PCB designer working with Gerber files.