Because I do. Look at following pinout diagrams. Which one do you like more?
I don’t know about you, but I prefer the first one. It is easier to read and nicer to look at. RobotikaBrno is about to launch a new dev board and we want to make a proper documentation for the board. We agreed it would be nice to have a good pinout diagram. How to make? Personally I wanted something as cool looking as the first pinout diagram. There many pinout diagrams like that online, but no tool to generate them – as I found out all of them are hand draw! Disappointed with the findings I opened Inkscape start drawing our own pinout diagram. It turned out well and was really nice. But then I realised – when we make a new release of the board, I have to redraw it. That was terrifying, because Inkscape GUI is a hell.
PcbDraw – Awesome Looking Drawings
I opened KiCAD scripting guide, talked to few guys on KiCAD IRC and started to write tool to automate process of creating awesome looking drawings of my boards. It took me two afternoons, but it is done. I call my tool PcbDraw and you can find it on GitHub. I am satisfied with the results – the output produced by it looks amazing in my opinion. A guide on usage can be found on the GitHub page.
How It Works?
To draw boards I use KiCAD Python API to exctract board layers as SVG and to get a list of components. Then I supply module library – SVG drawings of footprints and glue everything together using a Python script. There are several notes from the development:
- It was hard to find a way to draw the board. KiCAD Python API is poorly documented and even when I found out how to plot, the output was hard to process because of the mismatch in units.
- I was even so desperate, that I wrote a parser for KiCAD PCB format and generated the SVG directly from my script. The only thing I was missing was support for the texts. After Googling for a while, looking into KiCAD source I gave up. Is too much work and it will be easier to leverage the API and figure out the units and positioning.
- By the way – you can write basic the parser of KiCAD format in 15 lines of Python code.
- The units are decimils converted to micrometers.
- There is no decent Python library for SVG manipulation. Either they can draw nicely and cannot load existing drawings or they can load drawing but they cannot modify them. I ended up with manipulating XML directly. Next time I might try node.js… maybe it has better libraries.
- XML seem as a nice file format, but when you dig into details and advanced features you find out it is unnecessarily complicated format…
- Because of using KiCAD API I have currently gave up support for EAGLE – maybe I will reconsider it in the future
- KiCAD does not preserve any linkage between elements of board outline. So I had to implement heuristics for connecting it into a polygon to get a proper board shape.
- Inkscape does crazy things with SVG! It doesn’t respect SVG coordinate system, ignores units… Therefore I had to figure out how to position the modules (footprints) correctly.
- Is there a decent Linux alternative to Photoshop and Illustrator? Because GIMP and Inkscape aren’t alternatives.
And What About The Library?
To make everything work, you need the library of components. And this might be the toughest thing to realise as there so many components. This is a potential blocker for usage of PcbDraw in practice. I decided to go with the Haskell-like approach – being lazy. When I need a component I draw it and put into the library. And I hope there will be enough people in the world, who would like to also create a nice looking drawings of their boards and they will be willing to contribute to the library.
PcbDraw is only a half step towards nice pinout diagrams. You also need pin labels. I don’t want to draw them manually. But when I generate them, it shouldn’t be hard to make them interactive and attach pieces of information from e.g. datasheet to the pins…