Atopile
Create a schematic with code!
Head over to atopile
atopile is a language and toolchain to describe electronic circuit boards with code. By replacing the point and click schematic interface with code, we introduce software development workflows like reuse, validation and automation to the world of electronics. Join us in this adventure!
And since a demonstration is probably the easiest way to understand it, here is some atopile code.
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
- it vaguely looks like JavaScript
- it creates two resistors that have a 0402 footprint and are 100 Kohm and 200 Kohm, both with a tolerance of 10%
- ~ connects things
That's interesting, right? Next, you use their toolchain and it will:
- Search JLC/LSCS for a matching part (you can also specify exactly what part you want there)
- download a footprint and convert it to KiCAD format
- turn that code into a KiCAD netlist file
- create a BOM
After you get your netlist, you open KiCAD, import it into the PCB Editor and lay out the board.
Why?
First, I would say why not? But really, there are some pros and cons to this approach
pros
- automates several steps like part searching, symbol creation isn't needed, and footprint import is done for you
- you can split up sections of the schematic into separate files
- you can create abstractions, like the voltage divider code above or an I2C bus
- it is code
cons
- there are some benefits to a visual approach: you can see all the pins
- it is a niche tool and you're not likely to see this in a company
- it is code
Making a small board
To really get an idea of how it works, I made a small board and tried to use most of the features. One thing to note is this is a very early-stage tool. The latest version is 0.2 and there are bugs. One notable bug is it doesn't work on Windows.
Installing it in Linux went fine, just a simple pip
install. I wanted to recreate
a carrier board for a Mod-EC . The
documentation describe how to create your own components, and use your own KiCAD footprints
and it all worked quite easily.
The equivalent of a schematic symbol is (in a way), called a component in atopile. It is where you let the compiler know what to call each of the pins, what footprint to use, and what to call it.
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
Now to use the new component import Microfire_Mod_EC from "Microfire_Mod-EC.ato
it into the main .ato file, and ec_sensor = new Microfire_Mod_EC
to make
an instance of it. I quickly did the same for
Mod-ISO and all the others.
I needed a few more components like an SMA connector and a block terminal. In KiCAD, I might
have just placed a generic `CONN` symbol, and then searched for a specific component to ensure
the footprint is correct. In atopile, you do it backwards: search JLCPCB Parts for the component you want, then enter ato install --jlcpcb Cxxxxxx
where
Cxxxxxx is the JLCPCB Part # from their parametric search page. atopile then downloads the footprint,
creates a component file for you and you're set to use it. When you open KiCAD, you'll find the
footprint ready to go. If you don't/can't use JLC for parts, you can use any KiCAD footprint, although
I think you'll need to make your own component file.
The end result looks like this:
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
I decided to use some more of the features of the language and tried making a component that provided I2C pullup resistors. It looks like this:
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
There are definite benefits to this approach I think. Aside from personal preference, it is quicker to create things. You don't need to spend any time at all creating schematic symbols for parts, aside from creating the component. This actually has a benefit as well though, because you can create extra information to the component, providing interfaces, primarily.
One thing I found to be a downside to schematics-as-code, is some information is more efficiently displayed visually. Looking at a schematic symbol lets me see all the pins and what they are connected to. You'll need to be familiar with the project file structure to get that same information, checking the component file, looking through the signals, etc.
Last thoughts
Overall, I would say the downsides aren't necessarily downsides. They feel like it, but that's only because I've spent years and years doing it one way, and moving to a code-only method is a blank slate. I don't know what the best practices might be or what ways might be easier, but lead to problems down the road. There's also the need to learn another language, although to be fair, it is quite simple at this point. The developers are talking about adding features to the langue and it is being quickly developed from the looks of it.