Post by ***@yahoo.com [kicad-users]Hello All,
I've decided to move to KiCad from CircuitMaker 2000 (after 17 years!)
and would dearly love to import my current PCB layouts into KiCad/Pcbnew.
Does anyone know if this has been done or can be done?
CircuitMaker 2000/Traxmaker will also export in Protel Advanced PCB 2.8 format and dxf.
Thanks.
Some years ago I wrote a series of postscript programs (scripts) that
can take an ExpressPCB project and convert both ways to KiCad.
While the tool works and did the job I needed it to. I had a number of
issues with the stability of the schematic converter. Mostly due to the
design notation that KiCad does not save the schematic elements locally
in the file. Some are saved in a separate local cache. The problem
was most acute with the symbols, Power, ground, netnames etc. Where
the paths to the library had to be exact. While is works for archival
storage. Editing the schematic could cause things to break down. The
component rotation matrixes (calculated by postscript) Would rotate
symbols against the source orientation. Postscript had no way of
knowing the north pole so to speak of a given component. I sort of
made a guess that pin 1 orientates to the upper left. I think the
schematic program rotates arround pin 1. KiCad rotate around the center
of mass. In the schematic, the pin can have a separate rotation, and
the pins text additional rotations. While postscript could handle all
of this, it would break apart on edit.
The PCB converter was much more effective. I still use it occasionally
to go from KiCad to expressPCB (which uses a proprietary ordering
system.) There is still a bit that needs automating, which is the
creation of the fill zones. The main issue is this currently that some
of the net list has to be hand edited.
The result also was that the conversion tool was turning into an "AI"
driven expert system. The expressPCB internal components had a naming
system which related to DigiKey part numbers. The stock file names
sort of have a parsable way of determining what a component is such as a
chip, passive, symbol connector etc. This breaks down as for custom
components the file name can be anything. While the postscript tool can
learn to match, it takes time an a large data set to train it.
Somewhere I do have some OrCad and Pads projects. These also are
proprietary formats, however I have not found any documentation of the
internal proprietary file structure. I have found viewers which can
create a PDF printout of the project from PostScript print driver. As
most modern print drivers can print to file.
The above postcript KiCad conversion tool actually evolved from a
postscript Gerber Viewer I once wrote. That tool was closely related to
a DXF viewer I also wrote. This was part of a system for milling PCBs
using a CNC mill. Depending on the print driver, If the driver wrote
vector postscript from which to distill the PDF, then some of the
structure could be recovered. Again this project is turning into an
Expert system, and has been on the back burner for a decade or more.
Recently I was working on another project and re-reading some of my
image processing textbooks from the 1990s. I sort of had the
realization (I would not consider it an epiphany.) That much of the
vision code is what is leading the self driving car answer what is
looking for a solution.
Applying this same machine vision code to recovery of a netlist from a
gerber or image of a board one could do the following image processing
steps.
PCB layout and auto routing are based on the same first year computer
science project, known as the Traveling salesman problem. This is
usually the second or third program a CS student or coding school
student will write. It is intended to teach statistical cost analysis.
It also teaches how to plot a path on a map.
In image processing it leads to region analysis. Region analysis leads
to rasterization. This is how PCB milling and Gerber Plotting work.
The easy direction is Gerber or dxf plotting. Such is a simple robot
that has a shutter which exposes film. If the source traces are
vectors, then it is a simple traveling salesmen result plot. A simple
move to x,y draw marker, draw line to next x,y.
Region mapping (how a lot of print drivers work) restricts the pen to
only be able to draw horizontal lines. A bit more complex but still
the same problem. Typically the map is banded into a raster buffer.
This buffer needs only be one pixel in height, the width is the width of
the plotting device. The entire path the traveling salesman is plotted
into this windowed buffer. The resulting buffer can then be run length
encoded. The result will then give the start and stop plot lines for
the fill region.
There is however a problem with this solution (and it affects self
driving cars too.) which is where the salesman crosses his path. Or
creates two unconnected paths through the third dimension. (multi layer
boards.) This is called the winding number rule. It can be even or
odd. In typography this is created by the letter O where one way the
center of the O is filled the other way it is plotted as a ring. The
other test for this rule is the 5 pointed pentagram star. Fortunately
for most things there is standardization to this rule when making maps.
Where things do get interesting is the recovery of nets and zones from
postscript created plots of Gerber files. This is called skelitinzation
and region growing. It can be done by hand in Photoshop or automated.
Again this is probably (I hope) being used in the vision system of self
driving cars. It closely relates as to how the Boffins think we see
things. By detecting the edges of objects. Edge detectors are easy to
code through what is called template matching or convolution. This is
what Photoshop filters do. Region growing maps these into areas what
look like the topographical lines on a geological map.
Back in the days of the Apple][ game designers found if they mapped the
edge of the object that they wanted to animate which was called a
sprite, they could store just the edge outline. The other quantity
1980s game designers wanted was the center of the mass of this outline
so the sprite could be rotated. My guess is that EDA designers
leveraged on this to create the packages we know and love. A symbol or
pad could be considered a sprite. The outline is a chain code, the
position of the object the center of area mass. In games Sprites are
connected by rubber band
which are analogous to moving a wire in an EDA package.
Anyway in this day and age it is easy to detect regions and
boundaries. When we return to our traveling salesman we now give him
or her the Quantum property that she now travels all the possible paths
at the same time. Fortunately for us this is a bounded infinity. The
result if this infinity is the net list we seek. The result cycle of
this bounded infinity is the edge detector on the Gerber or even a high
contrast photograph of the board. This result is typically the
insulated non copper parts. The other bounded infinite region is is the
copper.
Limiting our quantum salesperson to only travel this path once. we have
the problem of where she starts. This is a well known quantity called
phase. By using the sprite model we can create one cycle where she
visits each point in a copper region only once. This is actually our
net. We can learn a lot about this net from the sprite properties. By
skelitinizing it which is a process where we make it one pixel thick we
can determine the width of our trace by how much was removed to find the
backbone of the region. A further quantatization of the sprite will
break it down into lines. A corner detector will give us the corners
from this we now have the xy and move to coordinates to plot this net.
There is a bit more work to be done on the zones although the
skelitization will leave a branch at the center of the mass. There is
also work to do find out the phase (where on the net) the start is. The
net will also have branches.
Where the Expert system part gets a workout is identifying these edges.
Edges can link to a pad with a high cost to keep or a corner with a low
cost as it has no real value in recovering the schematic from the Gerber.
Edges which are close together or follow patterns can be estimated into
groups which could be considered footprints. Further Quantazation can
locate the center of these pads. Winding number type rules can be used
to number the pad edges. These edge clouds of pins can then be matched
against database of known likely component footprints.
This is of course a simple 2 dimensional way of recovering nets and
footprints from Gerbers or photographs of boards. A full stack will
exist in 3 dimensions and the regions will be solid objects in order to
include the vias.
I have not done anything with these ideas for a decade or so. I think
they do have potential and if others want to build on it so much the better.