Tuesday, 7 March 2017

Converting Eagle (.brd) layouts to gEDA PCB / pcb-rnd (.pcb) format

Eagle has been a popular CAD program in some parts of the electronics community for many years, thanks to its multi-platform support and fairly integrated, "one stop shop" offering.

Accordingly, many open hardware designs and community contributed footprints and symbols now exist as a result.

The issue that naturally arises is how best to leverage and extend existing community contributed IP in the form of schematic symbols, footprints and layouts.

For some time (since the advent of the Eagle XML file format) gEDA users (and by extension, KiCad users able to import gEDA footprints into their pcbnew layout tool) have been able to extract schematic symbols and footprints from Eagle library (.lbr) and board layout (.brd) files by using translate2geda.

The current limitations of this conversion pathway via translate2geda are

1) polygonal pads (albeit rarely encountered) in Eagle are not supported in gEDA footprints

2) board layout conversion has not yet been implemented, due to Eagle's frequent use of rotated footprints within layouts, necessitating some refactoring to allow this to work smoothly.

3) following on from 2), to convert symbols and footprints in a layout file (.brd), you need to rename it to a .lbr file before running it through translate2geda

Issues 2) and 3) are simply a matter of finding time to write more code.

Issue 1) will require extensions to pad definitions within gEDA PCB and pcb-rnd in due course.

So, how best to get an Eagle layout into a format for use within the gEDA ecosystem?


Update!!!!! - May 2017:

pcb-rnd now has native Eagle XML import support

Update!!!!! - December 2017:

pcb-rnd now has native Eagle Binary (V3, v4, v5) import support, as well as Eagle XML and Eagle Binary library (.lib) support

... and now back to our previous programming:

A fairly imperfect method is to find gerber files generated by Eagle, and use translate2geda to convert the gerber files into footprints for use as a template within gEDA PCB, pcb-rnd, or KiCad. It's simple enough to do:



Here's a converted layer one (.L1) gerber from the SM1000 codec2 smart microphone designed by Rick Barnich KA8BMA and David Rowe VK5DGR:


Although the converted gerber-as-footprint is not without uses, the biggest problem with it is Eagle's tendency to paint any gerber features with a raster of lines which is not

1) a simple track,
2) a round pad, or,
3) a square pad

This can be seen in the following screenshot where a number of features have been highlighted


As the good people at UCAMCO hath doth verily spake unto us in their "open letter on standard gerber"

"Consider this happening not just once, but maybe hundreds of times, and in different sizes, across a densely populated PCB, and it quickly becomes obvious that painted features are every CAM engineer's nightmare"

As well as resulting in a bloated design description file (and gerbers), this will limit the usefulness of gerbers converted in this way when it come to snapping items to features in the footprint.

The other limitation is the difficulty translate2geda encounters in trying to identify what is a pad and what isn't during conversion; non square and non round flashed polygons aren't necessarily going to appear on the layout as a pad with heuristics currently implemented in translate2geda.

At present, a more workable pathway is to take advantage of the (FOSS) KiCad project's layout editor, pcbnew, which is able to import Eagle XML layouts.

Here's the same SM1000 layout being viewed in pcbnew:


And here is the file dialogue being used in pcbnew to save it in pcbnew's s-expression layout format (.kicad_pcb).



Once saved in a kicad format (.kicad_pcb), the layout can then be loaded into pcb-rnd, which can load these layouts natively:


pcb-rnd is a fork of the gEDA project's pcb layout tool, "PCB". From there, you can proceed with business as usual.

In addition to the open hardware SM1000 design, the workflow was tested and pcb-rnd's s-expression import module refined with another example, this time from Adafruit's git repo, namely, an
Adafruit-PiTFT-3.5-Plus-PCB touch screen PCB layout


Concluding remarks:

An effective method now exists for sharing open hardware designs and community contributed design elements in Eagle's XML format with the gEDA ecosystem.

gEDA toolchain users now have multiple options available for extracting design information from Eagle generated gerber files, Eagle board layout files, and Eagle library files with the techniques outlined.


Caveats / fine print:

These arise primarily from the non-surjective and non-injective mapping of features when translating from one EDA tool to another....

1) As previously discussed, polygonal pad features will not be converted into gEDA compatible footprint features

2) text size, kerning, justification and styles will be altered somewhat during translation through various EDA formats

3) KiCad has some peculiar interactions between polygonal zones and via/pin definitions/thermal properties, meaning that these features need to be checked carefully in a converted board.

4) KiCad tends to specify pullbacks from polygonal zones, which are not a feature of polygonal entities in gEDA.

5) KiCad doesn't necessarily translate an imported Eagle layout into a sensible location within the KiCad layout, so you need to select the layout and move it into the layout's bordered area before saving it in .kicad_pcb format. Here's the SM1000 layout before being moved in KiCad's layout window.



6) converted files are likely to have in excess of 16 layers, which will require a recent build of pcb-rnd, or a recompiled version of mainline PCB with support for an increased number of layers with modifications to the relevant header files.

Failing that, and probably the simplest layer limitation workaround for those disinclined to recompile, is to simply cut and paste the contents of each layer of interest with a text editor into the relevant layer sections of an existing empty layout (.pcb) file, along with the section defining the footprints prior to the layer definitions. If, after doing this, nothing appears in your layout, you need to resize your layout in the preference dialogue; the design is probably sitting outside of the board's defined area...


No comments:

Post a Comment