Thursday, 9 February 2017

importing Lt-Spice schematics into gEDA pcb-rnd for board layout

The gEDA PCB fork pcb-rnd has a very modular architecture, allowing import and export modules to be coded up quite quickly.

The latest development efforts have revolved around increasing the number of schematic layout tools that pcb-rnd can obtain netlists from.

The gEDA project's schematic editor, gschem, remains a powerful and flexible schematic editor, able to export netlists for a variety of PCB layout and design tools - but - some institutions and engineers do like their LT-Spice. It should also be remembered that LT-Spice works rather well under the wine windows emulator on Linux.

There is already the option of porting the LT-Spice schematic to a gschem schematic with a tool like translate2geda, which can then produce a netlist for pcb-rnd, but if no further modifications are needed to the schematic, then the option of importing the design directly into pcb-rnd remains attractive.

An LT-Spice import plugin was therefore created to import a pair of files:

an LT-Spice schematic (.asc), and

a netlist exported from LT-Spice in "Mentor" (.net) format.

The pair of files (.asc and .net) contain enough information to allow pcb-rnd to populate a new layout with their associated connection data.

The only difficulty with this process is that LT-Spice does not routinely allow a footprint attribute to be associated with a component.

One workaround for this is to abuse the "mfg=" manufacturer field in the parts libraries for the passive components, by inserting a footprint designator such as

".pcb-rnd-ACY(300)"

in a new component for use in the layout. The library with the new part is then saved, so that the part remains available subsequently.

The reason for the prepended period is to make sorting the list of components in the library by manufacturer simpler.

The "mfg=" field is saved for passive devices in the exported schematic (.asc) file, but the "mfg=" field is not explicitly saved in the schematic (.asc) file for non-passive devices.

One workaround is to make a new library part identical to the desired part, but append the footprint information to the library part name, i.e.

giving the following results in the (.asc) schematic file,

namely, 2N2222.pcb-rnd-TO92

Modifications to the default libraries may be the preferred approach in a computer lab or multi-user teaching environment.

These sorts of hacks would not be needed if LT-Spice allowed the addition of arbitrary attributes and had a netlist format or schematic format that preserved and printed the additional information.

For those who can't be bothered editing the inbuilt libraries, the schematic file can simply be modified manually with the addition of lines like

SYMATTR Footprint TO92

i.e.

after each SYMBOL declaration.

This is probably the simplest and quickest approach... but... these additional attributes will get scrubbed by LT-Spice if the schematic (.asc) file is opened and saved again by LT-Spice subsequently. So a new copy should be made and modified in this way to avoid losing the information if the original is re-opened in LT-Spice.

With pcb-rnd running, the LT-Spice netlist and schematic can be loaded; here it is being done via the command line interface, using the command

:LoadLtspiceFrom(/home/user/path/to/layout.asc)

The easier way is of course via the "File:Import:..." menu.

The layout editor, on finding valid .asc and .net files, will load the parts and the connection data into the new layout

The parts can be selected, and then dispersed via the menu

after which they can be appropriately arranged:

In this simple demonstration design, using a variety of footprints for the sake of example, connectors for the voltage sources were omitted, but can be added manually to the .asc file easily enough prior to loading by pcb-rnd with something like the following

SYMATTR Footprint HC49

directive, i.e.

With easily extended modular infrastructure now in place within pcb-rnd, additional import plugins are planned for other schematic layout tools as well.

This LT-Spice import is now available from the svn, and is expected to be in the next formal pcb-rnd release.

About Me

Licensed radio amateur - That doesn't mean I wait for floods and tornadoes with a battery and a radio, it means I like to pull stuff apart, put stuff together, and hack stuff generally, while avoiding electric shock, thermal burns, RF burns, fire, lightning and falls from heights.