Coffee Space


Listen:

PCB Design Tools

Preview Image

TL;DR: I use Kicad, skidl and freerouting to aid in my PCB design process.

Disclaimer: I don’t claim to be an expert. I’m just a programmer that found a process that works for me.

The functionality offered is (beyond Kicad’s normal functionality):

Introduction

In reply to a post on HackerNews titled “The tooling ecosystem that adds joy to KiCad”, I commented regarding my own setup:

The best thing to happen to KiCad was skidl [1] paired with freerouting [2]. You can spin a board in so little time it’s insane. In the future I will be looking to automate even the parts placement too.

P.S. If there is interest I will look to document my workflow.

[1] https://github.com/devbisme/skidl

[2] https://github.com/freerouting/freerouting

At the time of writing this, there were 16 upvotes and some requests to discuss in more detail the process I use in this setup. The intention of this article is to address this and previous requests regarding this.

Makefile

The heart of the process is a Makefile. I’m a Linux user and quite like using a Makefile for basic stuff, if nothing else it provides autocompletion.

Without further delay, here it is:

0001 ROOT = $(shell eval pwd)
0002 
0003 .PHONY: all
0004 
0005 all: clean
0006 
0007 # -- Installing --
0008 
0009 setup:
0010     # Build circuit programmatically
0011     python3 -m pip install skidl
0012     # PCB layout
0013     sudo apt install --no-install-recommends kicad kicad-footprints kicad-libraries kicad-symbols kicad-templates
0014     # Auto-route the PCB
0015     curl -fsSL https://github.com/freerouting/freerouting/releases/download/v1.4.4/freerouting-1.4.4-linux-x64.zip -o bin/freerouting.zip
0016     unzip -d bin/ bin/freerouting.zip
0017 
0018 # -- PCB --
0019 
0020 pcb_circuit:
0021     ( \
0022       export KICAD_SYMBOL_DIR="/usr/share/kicad/symbols"; \
0023       export KICAD_TEMPLATE_DIR="/usr/share/kicad/template"; \
0024       export KISYSMOD="/usr/share/kicad/footprints"; \
0025       cd pcb; python3 board.py; \
0026     )
0027 
0028 pcb_layout:
0029     ( \
0030       export KICAD_SYMBOL_DIR="/usr/share/kicad/symbols"; \
0031       export KICAD_TEMPLATE_DIR="/usr/share/kicad/template"; \
0032       export KISYSMOD="/usr/share/kicad/footprints"; \
0033       cd pcb; pcbnew board.kicad_pcb; \
0034     )
0035 
0036 pcb_route:
0037     java -jar bin/freerouting-1.4.4-linux-x64/lib/app/freerouting-executable.jar -de pcb/board.dsn -do pcb/board.ses -mp 1000
0038 
0039 pcb_gerber:
0040     # TODO: Should version the ZIP file.
0041     zip -r pcb/board-gerbers.zip pcb/*.gbr pcb/*.drl
0042     rm pcb/*.gbr pcb/*.drl
0043 
0044 # -- Tools --
0045 
0046 skidl:
0047     ( \
0048       export KICAD_SYMBOL_DIR="/usr/share/kicad/symbols"; \
0049       export KICAD_TEMPLATE_DIR="/usr/share/kicad/template"; \
0050       export KISYSMOD="/usr/share/kicad/footprints"; \
0051       cd pcb; python3 -i load.py; \
0052     )

The commands do the following:

Documentation

The following is my internal documentation on how to perform this process:

PCB Description

The PCB is designed in skidl, a programmatically defined schematic tool. Our controller can be located at pcb/control.py. Documentation for skidl can found online1. Additionally there is a great introduction video explaining the benefits of using the library2.

Note that it is useful to have named nets as these can be set to have different trace properties. For example, you could have a thicker trace for a power circuit.

Once you have modified the controller, you can check it and generate a netlist by running make pcb_circuit. Errors produced by the ERC process need to be fixed and warnings should be ideally avoided.

Kicad Basic PCB

We now want to utilize pcbnew to do the basic board layout, which can be run using make pcb_layout.

To import our netlist, go to File > Import > Netlist… (this may take a while depending on your machine). We want to load our netlist, so we open the file pcb/board.net. Then select Update PCB to add the parts. NOTE: It likes to add the parts off the screen sometimes.

Now we can draw a PCB outline (graphic line tool on the “Edge.Cuts” layer) and place the components inside - but don’t bother with the routing process.

We now want to delete all existing traces by doing Edit > Global Deletions… an then select “Tracks & vias”. This then allows the autoroute to fully solve all tracks automatically. Lastly we can export Specctra DSN by going to File > Export > Specctra DSN…. Save this as pcb/control.dsn.

Before performing the DSN, it is good to delete the existing routes, otherwise the auto-router will work around these.

Autoroute

To do the auto-routing, we simply run make pcb_route. A GUI will appear and you can watch it solve all of your problems.

Check

Now we can go back to pcbnew and go to File > Import > Specctra Session… and open pcb/control.ses. You should now see the traces applied to the PCB.

To get a rough idea of what the finished PCB will look like, use View > 3D Viewer.

As you can see, I’ve also interspersed a few additional details that are useful to know.

Discussion

I believe the real power here is circuit re-use. Imagine for example importing the skidl description for a controller and just being able to re-use it in lots of circuits, knowing it is well tested.

Of course, auto-routing is insanely cool too. With the right rules, there is no reason why any design couldn’t be generated.

Critique:

If there is interest in this process, I can look towards doing a step-by-step example, perhaps even as a video.


  1. https://xess.com/skidl/docs/_site/index.html↩︎

  2. https://youtube.com/watch/?v=WErQYI2A36M↩︎