So I got my hands on some older Gerbers for a board I want to document…
(snipped attachment)
Most of the files open up to complete gibberish, but two will open up properly (after GerbView gripes about unexpected characters)
Seems those two are duplicates of two other files in that archive, after they were run through a commercial program (and I cannot see paying the license fee they want for what will be a one-time use).
What I want is to be able to convert or reformat the files to open properly in GerbView, so I can then open up EEschema and crank out a fresh copy of the schematic. The board is approximately 4" x 6" and 100% through-hole.
The files appear to be RS-274D, (Geda’s GerbV suggested that). And this old format (obsoleted in 2014) needs an extra file with settings. That file should have definitions of the D codes, and other initialization.
Also, Gerber files are readable ascii. you can load them in a text editor. I opened the “coupler-C.GBR” file in a text editor and inserted a “G91*” code on the second line. This switches from (whatever the default was (apparently absolute)) to relative coordinates. And then I re-loaded it in KiCad’s Gerbview, and now this layer does make sense:
After also adding G91 to the other files they look usable. The scale is wrong, and different files have different offsets (Relative coordinates, but wrong starting point?) but you have the most important information:
PCB outline.
Locations of footprints (need at least one pad per footprint).
Locations of tracks (Width is lost in the missing D-codes but cold be reconstructed).
The offset is relatively easy to guess in KiCad. The scaling would be more difficult. KiCad does not have usable scaling facilities for vectors. You can attempt:
Add those G91 codes.
Use GerbView to convert to KiCad layers.
Export to .SVG or .DXF.
Scale (and offset) correction in some external program.
Re-import in KiCad.
But it’s a fairly simple PCB. It looks like 6 relays (in two sizes) and some transistors to drive them. The “coupler.gbs” file is one of the files readable by KiCad, and it has no scaling issues. It can be used to reconstruct the outline and footprint locations. For the other files, you can create a bitmap (even a screenshot is good enough) and then use PCB Editor / Place / Add Reference Image to load them. Such images can be used with opacity and the can be easily panned and scaled in KiCad. So you can use them as a guide to reconstruct the tracks.
Do you have a schematic too?
It’s easier if you can enter the schematic manually. If you have no schematic, it can be reverse-engineered from the PCB tracks, but this takes more time. When the schematic is entered independently, then you can also make use of DRC at the end to check for errors (also explained in the FAQ link posted earlier).
KiCad is not the best tool for a job like this. There are Gerber editors in existence, and those can probably help you with re-creating the aperture table and other settings to generate better output. But it still leaves the conversion to a KiCad project, adding real footprints from the pad locations, cleanup and other stuff. Because the PCB itself is so simple, it probably does not matter very much which approach you take. As a guess, i’d say it would take between 2 and 4 hours to make a “representable” (not necessarily accurate) KiCad project from this. After that a verification step is of course still needed.
paulvdh: No, I don’t have the schematic and which I would prefer to have in the first place! Since this board is relatively straightforward (mainly the same stage repeated three times), it really shouldn’t take me long to recreate the schematic.
Adding G91 definitely helped. I have renamed the silk / drill / copper layers to the extensions used by GerbView, and they now open properly (some complaints aside).
If I can flip the bottom copper layer, then I have what I need. Is there an attribute that can be entered into the file?
You can’t do much in GerbView. It’s just a viewer. In the PCB Editor you have much more options. Consider this:
Add some extra internal copper layers in the Board Setup.
Use f to Flip a layer to the “other side”. (You can set flip to be either horizontal or vertical, but it does not matter much).
Then select everything on the new layer again, and set the properties of all track segments to the final layer you want it. You can also use m to move and r to rotate while stuff is attached to the mouse cursor.
You can also use PCB Editor / Edit / Edit Track and Graphic Properties to set it to the final layer. But Flipping to get the mirror image is probaby the most (only?) important step.
KiCad should open old Gerber files, provided that they are valid, wherever they came from.
Adding extra G91 codes looks like they are flawed, but is this an optional setting where KiCad makes the wrong default?
Manually adding G91 (for relative coordinates) is a hack indeed. The reason for doing so is that the file set is not complete. The aperture file is missing, and apart from the apertures, it apparently should contain more information too.
These Gerbers were generated on 1995-04-06 (According to data embedded in the files) and back then there were a whole lot (maybe even 100+) different dialects for Gerber files. In that era PCB design programs tended to have a lot of different drivers for gerber plotters, just like the old DOS programs had a lot of printer drivers, and the gerber files were tuned to fit with a particular brand of gerber plotter.
I know that KiCad has no intention of creating a gerber editor (at the moment), but a handful of relatively simple functions to help with interpreting such old Gerber files could help a lot. Things that come to mind are:
Aperture definitions. No complete set, just the ability to list which apertures a Gerber file attempts to use, and the ability to set a round diameter is enough to reconstruct most of the PCB. Pads are not important, as it’s necessary to replace those with real footprints after the conversion to a KiCad project anyway.
Scaling. The most common issues are Metric ↔ Inch conversion, and misinterpretations in the number of digits (which would result in a 10x scale factor)
Relative / Absolute coordinates (as is clearly the error in this file set).
Offset correction / shifting of layers. (This is already implemented. You can right click on a layer name and then click on Layer Display Parameters in the context menu.
Mirroring. These days, “top view” is standardized, but back then there were mirrored files (Also applies for this file set).
Reading of those old aperture files. Is KiCad able to do anything with such a file at the moment?
I got the top / bottom / silk imported into PCB Editor. Although the imported data is at a ridiculously small size and I can’t get the layers to register ‘just so’, I have them at least close enough that I can zoom in and use that as a starting point for drawing the schematic.
I don’t anticipate having to do this often, but I at least know how to approach this next time. Thanks all!
In “coupler.gbs” I measured 114.3mm width for the PCB, and in “coupler-D.GBR” I measured 11.43mm with, so that is pretty close to a scale factor of 10. This is common, because those old files don’t have a decimal dot in the coordinates, and KiCad “guesses” something.
In the PCB Editor, you can use the “Positioning Tools / Move with Reference” or another of the positioning tools for accurate offset. But it’s not very important, especially if you’re only looking for a functional recreation instead of an exact one.
You sent me a PM with your success. I assume you did it that way because this thread got closed in between.
You wrote me it was fairly easy after you found the right functions for your workflow. It’s always nice to see a project in KiCad succeed. Can you do a short write up of specific problems you encountered and how you solved them? The main audience for such a write up are other people searching for answers on this forum. Having some more details about further problems and how you solved them to get your project into KiCad are the most interesting parts.
How did you solve the scaling and alignment?
Was my “Reverse engineering” FAQ article of use? Any ideas for additions to improve that article?
I actually never addressed the scaling issue, as I merely needed to see how the traces got from point A to point B and what stops they made along the way.
Getting the file from Gerbview into PCBnew was a matter of creating a blank project in PCBnew first, then exporting the layers one by one into that project.
Cleaning out the extra text and lines once in PCBnew was a matter of a few quick mouse drags and keystrokes. In the end, I only needed the top / bottom copper and the silkscreen.
The fact that these gerbers just happened to have alignment targets helped, but I realize not all older gerber files will include these. Here’s how I aligned the layers:
First, I drew a reference target on the existing grid (User Drawings layer)
Under display settings, I turned ‘snap to grid’ settings to ‘when grid shown’, then turned the grid off.
I then clicked the ‘eye’ symbols in the layer list to mute all but one layer.
I then selected the objects on the layer and aligned the layer target with the reference target, then repeated the process with the other layers.
The one layer that was backwards, I did the additional step of mirroring the objects before aligning it.
From there, it was fairly straightforward for me to build a node list for drawing the schematic (which is what I do when reverse engineering a board).
When I get a bit of time, I’ll re-read and pass along any feedback on the FAQ you linked. Appreciate the help!
A counter proposal: I will do this, and do some experimentation about how this can be further refined, and add that to the FAQ article too. I assume I can use your gerber files for this, because you already posted them open and wide on this forum.