SparkFun Forums 

Where electronics enthusiasts find answers.

Questions about the BatchPCB service

Moderator: robacarp

By jdm
Hi All,

I am looking for a link to Gerber RS274X format specifications,
and all of the ones I found so far (3 I think) were dead. If
someone has a good link, please post it. Thanks.

Jim Monte
By wiml
The pages have some links to technical references, including a reasonably complete-looking pdf doc. If you want the actual, official, normative reference, you'll probably have to pay money to EIA.
By jdm
Thanks for the link. rs274xrevd_e.pdf appears to be the complete spec.
aside from what its authors consider to be obsolete portions.
By Steve
Thanks for the link. rs274xrevd_e.pdf appears to be the complete spec.
aside from what its authors consider to be obsolete portions.
I've seen a much more complete spec than that pdf file. That is, the 'Gerber Format Guide' from Gerber Systems Corp (before Barco bought them). It has lots of obsolete stuff and specialised commands. I'd say it's not only safe but advisable to stick to what's in the pdf.

There are some codes in the pdf that can also be safely ignored, in my opinion. These are:-

Axis Select
Mirror Image
Scale Factor
Image Justify
Image Offset
Image Rotation
Plotter Film
Include File
Sequence Numbers

If you're writing code to import a gerber file I suppose you should at least recognise these commands and throw an error if they're not set to defaults or not handled. But if you're creating gerber files, then don't bother to specify them in the gerber file unless you really need to for some reason.

M01 can probably be ignored and M00, M02 interpreted indentically, but use M02 if you're creating gerber files.

The modality of some codes is a thorny issue. Technically D03 (flash) is modal, but not everybody treats it as such, so when creating gerber files it's probably best to put the D03 command on every flash coordinate.

for example, as:-


Avoid this:-


because the importing software might not treat D03 as modal.

Also avoid this:-

because if D03 *is* treated as modal, the X02 would be flashed twice,
and the X01Y01 might have some other modal command applied to it before being flashed.

The pdf file is as vague on certain issues as the 'Gerber Format Guide'. For example, the pdf states "Note: Generating a new layer may result in unanticipated results because it causes certain RS-274D values (such as interpolation mode) to be reset." but it never specifies exactly what is reset. I assume that we revert to D01, G01, Step and Repeat 1 x 1.

Aperture macro primitives have an exposure state of 0 = off, 1 = on, or 2 = reverse current state. After wondering for years what 'reverse current state means' I finally discovered that it means to use XOR mode for the graphics. I think it's best avoided.

Incremental mode is probably best avoided. I think it was only useful for hand coding of gerber data.

Note that the Format Statement can specify the number of digits used by M, D, G, and N codes. Since all of these codes will be terminate by a non digit (either the next code or a *) then I can't see it would be a problem for any modern software. Some software that creates gerber files specifies the code lengths, and some does not.

Technically, the maximum possible DCODE is 999, but all software these days seems to ignore this limitation.

I think it's safe to assume that any person or software that can read a gerber file can understand RS-274X, so don't generate pure RS-274D files unless you have to. If Absolute/Incremental and units should be specified using the 274X codes in the Format Statement and MOde command. If you've done this, don't bother with the G70/71 and G90/91 codes.

I don't think any software actually requires a G54 before an aperture selection D code. On the other hand, it shouldn't hurt to put on in.

Note that, as far as I can tell, polygon fills *can* have arcs defining some of the boundaries, but it might be safer not to do it.

Note that the L and T in the Format statement have the opposite meaning to LZ and TZ in an Excellon file. In a gerber file, L and Z refer to zero *suppression*. In an Excellon file, LZ and TZ refer to the presence of zeroes.

So, in 2.4 mode:-

Gerber %FSL... = Excellon TZ X10000
Gerber %FST... = Excellon LZ X01