RS-274D : Standard Gerber with separate aperture tables

Posted by

Introduction to the Gerber File Format Standard

The Gerber file format, named after Joseph Gerber, is the de facto standard used by printed circuit board (PCB) industry software to describe the printed circuit board images: copper layers, solder mask, legend, drill data, etc.

History and Evolution of the Gerber Format

The Gerber file format has a long history dating back to the 1960s:

  • In 1980, the Gerber format was extended to support apertures and image parameters.
  • In 1991, the RS-274X format added support for embedded aperture information.
  • In 1998, the RS-274X format was updated to add support for attributes.

Throughout the years, the Gerber format has steadily evolved to incorporate new features while maintaining backward compatibility.

Understanding the RS-274D Format

RS-274D, also known as Standard Gerber, is a 2D bi-level image description format. It uses X,Y coordinates and simple codes to construct planes and traces on a PCB layer.

Coordinate Format

RS-274D uses 2.3 format for integer coordinates and 2.4 format for decimal coordinates:

Coordinate Type Format Example
Integer IIIX.IIIY 0520.0650
Decimal IIIX.DDDY 0012.40370061.7500
  • The part before the decimal point represents the X coordinate
  • The part after the decimal point represents the Y coordinate
  • Leading zeros are required

G-Code Commands

RS-274D uses G-code commands to define the image. Here are some of the most common commands:

G-Code Description
G01 Linear interpolation
G02 Clockwise circular interpolation
G03 Counterclockwise circular interpolation
G04 Ignore data block
G36 Turn on polygon area fill
G37 Turn off polygon area fill
G54 Tool prepare (select aperture)
G70 Specify inches
G71 Specify millimeters
G74 Disable 360 circular interpolation
G75 Enable 360 circular interpolation

Commands are placed on separate lines, for example:

G01X0500Y0650D01*

D-Code Commands

RS-274D also uses D-codes to specify the current aperture. The D-code corresponds to an entry in the aperture list. For example:

G54D11*
X0500Y0650D01*
X0550Y0720D01*  

This selects aperture D11, moves to coordinate (500,650), then moves to (550,720) with the draw mode enabled (D01).

Aperture Definitions

The aperture list defines the sizes and shapes of the “tools” used to create the PCB image. In RS-274D, the aperture list is defined in a separate file.

Aperture File Format

The aperture file uses a human-readable format:

%ADD10C,0.010*%
%ADD11R,0.060X0.020*%  
%ADD12O,0.040X0.060*%
%ADD13P,0.016X0.032X0.008*%
  • The % characters indicate the start and end of the aperture definition
  • ADD indicates this is an aperture being added to the list
  • The number (e.g. 10) is the D-code that refers to this aperture
  • The letter indicates the aperture shape:
  • C = circle
  • R = rectangle
  • O = obround
  • P = polygon
  • The following comma-separated measurements define the size and shape of the aperture based on the aperture type

Standard Aperture Shapes

Here are the common aperture shapes and their required parameters:

Letter Shape Parameters
C Circle Diameter
R Rectangle X-axis size, Y-axis size
O Obround X-axis size, Y-axis size
P Polygon Outer diameter, number of sides, rotation

For the polygon shape:
– Outer diameter is measured vertex to opposite vertex
– Number of sides is an integer value
– Rotation is in degrees counterclockwise, expressed in 0.1 degree increments

Constructing the PCB Image

To construct the PCB image from RS-274D Gerber and aperture files:

  1. Initialize the apertures from the aperture file
  2. Read the Gerber file line by line
  3. Use the G-codes and D-codes to select apertures and create draw/flash operations at specified coordinates
  4. Render the image based on the draw/flash operations

Draw vs Flash

Apertures can operate in draw or flash mode:

  • In draw mode, the aperture moves along the linear or circular interpolation path to draw the shape
  • In flash mode, the aperture is stamped down at the current coordinate

The D01 code enables draw mode. The D03 code disables draw mode (and therefore implies flash mode).

Creating Planes and Traces

Closed loops of linear/circular interpolation paths with polygon fill enabled (G36) create filled planes.

Linear paths with draw mode enabled (D01) create traces.

The width of the trace is determined by the X-axis size of the current aperture. The shape of the trace ends is determined by the aperture shape.

Tips and Best Practices

Here are some tips for working with RS-274D Gerber files:

  • Always use a separate aperture file to maximize compatibility with Gerber file readers
  • Be mindful of the current unit (mm or inch) as set by G70/G71 codes
  • Use a consistent precision/format for coordinates throughout the file
  • Clearly comment and organize your G-code to enhance human readability
  • Double-check your aperture and G-code commands to ensure proper draw vs flash behavior
  • Inspect rendered images layer-by-layer to catch any errors

Avoiding Common Mistakes

Some common mistakes to avoid:

  • Mixing units (e.g. using mm in one place and inch in another)
  • Incorrect aperture sizes relative to the unit
  • Leaving out leading zeros in coordinates
  • Inadvertently disabling polygon fill, resulting in open/unfilled planes
  • Forgetting to select the correct aperture with D-code before drawing

Careful review of your Gerber and aperture files can help catch these mistakes before they become a problem.

FAQ

What is the difference between RS-274D and RS-274X?

RS-274X is an updated Gerber format that allows embedding the aperture definitions within the Gerber file itself. RS-274D requires a separate aperture file. RS-274X also adds support for attributes.

Are RS-274D Gerber files still used?

While RS-274X is now more common, RS-274D is still widely supported due to its simplicity and compatibility with older software. Many modern PCB design programs can output either format.

What is the recommended precision to use for coordinates?

For general usage, 2.3 format (3 decimal places) provides precision to 1 mil (0.001 inch) which is sufficient for most PCB designs. For designs requiring finer resolution, 2.4 format can be used.

How do I create more complex aperture shapes?

Complex apertures can be created using the polygon (P) shape type with a higher number of sides. Custom aperture shapes are also possible but require special support in the Gerber file reader.

What is the purpose of the G70 and G71 codes?

G70 sets the file units to inches. G71 sets the file units to millimeters. It is important to ensure your coordinates and aperture sizes are expressed in the correct unit based on this setting.

Conclusion

The RS-274D Gerber format, while older than its RS-274X successor, remains a viable and widely-supported standard for PCB image data exchange. By understanding the key components of RS-274D—the use of G-codes, D-codes, and aperture definitions—you can create and interpret Gerber files describing the copper layers, solder mask, drill data and other elements needed to fabricate a PCB.

With careful construction and review of your Gerber files, and by following best practices such as using separate aperture files, consistent coordinate formats, and clear organization, you can ensure your PCB design data is accurately transferred to manufacturing.

By mastering RS-274D, you have an essential tool in your PCB design toolkit, enabling effective communication between design and manufacturing.

Leave a Reply

Your email address will not be published. Required fields are marked *