Gerber Text File Editing Fun

Relax in southern comfort on the east bank of the Mississippi. You're just around the corner from Beale Street and Sun Records. Watch the ducks, throw back a few and tell us what's on your mind.
Post Reply
User avatar
mediatechnology
Posts: 5486
Joined: Sat Aug 11, 2007 2:34 pm
Location: Oak Cliff, Texas
Contact:

Gerber Text File Editing Fun

Post by mediatechnology »

I just sent off a revised layout to ExpressPCB that I had "stretched" 0.2 inches to add some additional compensation caps.

The previous layout worked fine when reasonable op amps were used but peaky 4558-class op amps such as the NJM2068, LM833, MC33078 and NJM45XX-series were problematic. The peaked out-of-band response of these parts is another story but suffice it to say for now that somewhere between 750 kHz and 1.2 MHz there will be, in a unity gain inverting configuration, a resonant peak between 1.5 and 2.5 dB. Cascade four stages with this peak and things get wild. I decided some 22 pF compensation caps needed to be sprinkled in.

I haven't built the new boards but the stretch appeared fine with the exception that one connector did not line up, by 25 mils, with the others. It's purely a cosmetic thing.

Rather than fix it in ExpressPCB (which I did) and send the layout back for an updated Gerber I decided to edit the Gerbers by hand using its txt files. My job was to move six pads and the silkscreen 25 mils West. Let the fun begin...

The top layer was relatively easy using the X and Y value coordinates in the Gerber viewer to locate the objects' text.
Gerber files seem to place the origin at the lower left-hand corner.
ExpressPCB's software places the origin at the upper left-hand corner. If you use their app to locate your object you'll get lost fast because the Y-values are wrong.

The bottom layer was equally easy for five pads. The sixth, a thermal pad, was hell. I finally got it.

The silkscreen required a square box and three alpha characters, +, - and G to be moved.
The box was relatively easy except that it didn't quite render the same as the other connector where a keep-out region obscured parts of a line near the pads.
It took a couple of hours off and on to find the hidden object. As it turns out pads have a negative polarity object on the silkscreen I couldn't see until I accidentally highlighted it and looked at its properties in the Gerber viewer. Makes sense now. I moved those "hidden" keep out area objects 25 mils west and the line rendered normally.

Moving the + and - characters was relatively easy.
I haven't started working on moving the "G" symbol as it is quite complex in its vector representation. There are a lot of coordinates to write down and find in the .slk text file.

Everything except the "G" is now rendering correctly in the viewer. Though I could have spent money on boards to get updated Gerbers and come out ahead the time spent learning how to edit Gerbers made it worth it.

Image

The left output Phoenix connector got moved 25 mils to the west. The "G" character is eight lines. Being able to grab and object in the layout editor and drag it into place seems like magic now.
flyboy71
Posts: 76
Joined: Thu Nov 21, 2019 6:56 am

Re: Gerber Editing Fun

Post by flyboy71 »

You're a brave soul. I haven't edited gerbers since I worked at a local PCB shop back in the 90s. In those days we used GC-Prevue to verify a customers files and GC-CAM to prep them for manufacture because "back then" before RS-274X they sent a gerber file and an aperture file and sometimes the aperture file wasnt right so the features were hosed up if it tried to flash the wrong feature. Sometimes it was subtle and we sent the boards out and found out they were wrong but had no way of knowing if the engineer failed to review and approve the checkplots we physically mailed to them.

Just as a general note: A gerber file uses a list of apertures (round pads, squares, traces, etc) and moves to an XY coordinate, turns on the light source (flashes the aperture) and either keeps it on and moves to another XY to form a trace or turns off to move elsewhere. If you want a 0.030" trace it uses a 0.030" dot and just drags it around to make a trace. The idea of "flashing the aperature" was when the apertures were on an actual physical wheel in the early plotters. I suspect the "G" is a drawn polygon which might explain why it shows up as a bunch of XY coordinates. Its pretty much like an etch-a-sketch when it comes to those features.

I have an old copy of GC-Prevue when it was free to use but it may only run on XP anymore.

https://www.graphicode.com/products
My projects site: https://ornerscorner.neocities.org/

"Things are more like they are now then they ever were before" - Dwight
User avatar
mediatechnology
Posts: 5486
Joined: Sat Aug 11, 2007 2:34 pm
Location: Oak Cliff, Texas
Contact:

Re: Gerber Editing Fun

Post by mediatechnology »

Thanks! Not sure I'm brave or just crazy.

I've been using Gerbv: https://sourceforge.net/projects/gerbv/ and GerberLogix: https://easylogix.de/products_detail.php?prog_id=1

Every layer, except the .oln outline layer, requires modification. Top and bottom copper, top and bottom silkscreen, top and bottom solder mask and the drill file.

I've also found Notepad++ to be a invaluable tool for text and general file editing: https://notepad-plus-plus.org/

What I should have done earlier was to deconstruct the thermal pad in ExpressPCB or a Gerber viewer to see how it was built. What threw me is that the thermal relief area in the corners was four square polygons of ground plane keep-out with two thin traces from the ground plane crossing over the pad to the other side in a "+" pattern.

When I feel like doing something incredibly tedious I'll move the "G" symbol. Being able to click on an object with either of the Gerber viewers and see its attributes and coordinates is helpful. The hashed object on bottom copper, a square pad, is highlighted with its properties shown.

Image
flyboy71
Posts: 76
Joined: Thu Nov 21, 2019 6:56 am

Re: Gerber Editing Fun

Post by flyboy71 »

So in the upper part of the gerber file that thermal pad D21 should be defined. Its either a pre-defined aperture or a list of XY coordinates to make the feature.


This is good reading if you're really digging in. https://www.ucamco.com/files/downloads/ ... -02_en.pdf
My projects site: https://ornerscorner.neocities.org/

"Things are more like they are now then they ever were before" - Dwight
User avatar
mediatechnology
Posts: 5486
Joined: Sat Aug 11, 2007 2:34 pm
Location: Oak Cliff, Texas
Contact:

Re: Gerber Editing Fun

Post by mediatechnology »

I've used the Ucamco viewer and file checker. They're a great resource.

Code for D21 defines a 0.065 x 0.065 pad:
%ADD21R,0.065X0.065*%
The entire thermal pad, bottom layer, is 5 objects total.

Square pad of 0.065X0.065
And four identical square polygons of 36x37 mils of negative polarity keep-out.

I was mistaken about the two traces forming a "plus."
User avatar
mediatechnology
Posts: 5486
Joined: Sat Aug 11, 2007 2:34 pm
Location: Oak Cliff, Texas
Contact:

Re: Gerber Editing Fun

Post by mediatechnology »

I set aside this editing project for a couple of weeks while I soldered boards and dealt with the usual yard, household and auto entropy.

The remaining Gerber Fun task was to move the Left channel "G" character 25 mils west. (Actually 24 mills to match the Right.)
As you can see I got it done.
With the coordinates obtained from the viewer finding the X-Y values in the .slk file, as plain text, isn't that difficult.

Just for fun I loaded it into Ucamco's online viewer and checked the syntax.
Ucamco always complains about line 1 not being a command but that's in just about every Gerber I have.
Otherwise Ucamco's syntax checker didn't have issues with any of the layers.

Original:
Image

Left Channel Moved:
Image

In the meantime I've got one of the pre-production boards with the shifted connector to build.
Post Reply