Get the top HN stories in your inbox every day.
Neywiny
Wish I could comment on the routing like others but the render is stuck at 96.2% for me. Nothing else on the page shows it on my phone so I assume that's the problem. (And of course nothing in the log of error tabs).
I think just looking at the first code example you can already see the problem. A lot of duplication and hand written or auto generated code. I thought the point was to define it in the code. Put an array of pin functions. For loop the footprint. That kinda thing. This looks like a mess to get started with and even worse is at higher point count parts it looks like it'll balloon in maintainability. Altium has very solid footprint generators with a nice menu. This looks like it's missing an overarching API for creating these long lists of parameters. Doesn't feel like the juice is worth the squeeze on this one. If it's a simple schematic, just do it by hand. If it's complicated, this feels harder to wrangle.
Another example of weird code is the previousLedName. Like like really that variable isn't used and the first term of the && should be that indeed check. But even more so, it should be an if statement not rely on remembering short circuiting (lazy evaluation) tricks. Because that's what you mean. You mean if it's not the first one, connect to the previous one. So, the code should say that. I find it hard to believe such a high level language would prevent it.
I think the pin label lists don't make sense. They're maps where the value is an array where the first element is the key? Why is this not just a list of pin numbers to names or a map of they're not contiguous whole numbers?
And then the icing on the cake: you still have to define where in XY everything is.
So really, in thinking about this, this looks more like a file format than a tool. And maybe that's fine. But I'll stick to the native formats of the tools.
Neywiny
Looking back on this, lots of typos. I must've been really tired. I hope the point still came across.
zjorzzzey
Interesting, reminds me of a project my colleague has just been working on: using KiCad + python to auto-place LEDs at specific coordinates on a PCB. Instead of positioning them as a regular matrix, the LED locations are derived from the shape of a racing circuit: https://ledsrace.at/zandvoort (routing and non-LED part of the layout was still done manually)
I don't think 100% auto-placement/routing will be able to take over manual layout, but there is definitely lots of potential for further automation!
joshvm
This is a really good use case, though I'd be surprised if there aren't macros to do simple grid layout already in Altium or KiCad. It's the sort of thing you'd find in a badly documented Eagle userscript. I recently made a smaller PCB with 30 LEDs in a specific colour arrangement and even that was a pain by hand.
fxtentacle
Jlcpcb, the manufacturer mentioned in the article, has a graphical editor with grid functionality and they even have a JS API if you want to automate PCB changes like arranging LEDs or renaming components.
joshvm
Yeah I'm not surprised this is a feature in other EDA packages, it's something I'd like to explore more, in combination with OpenSCAD. I've been pretty happy with the few things I've tried from JL, though I'm a longtime supporter of OSHPark and I think their finish/price ratio is still excellent.
convolvatron
i scaned the article but didn't see this. declarative netlist is probably ultimately the right thing. but one place where I got alot of leverage was writing generators for footprints. its so much nicer to say 'this pad is 0.8 x 0.3" and i'd like two rows of them separated by 4mm with a 1mm pitch than to draw little rectangles with the mouse and getting them all to line up. i dont know if more professional tools do this, but integrating that into kicad made me much happier about the whole process.
crote
Honestly? I want a footprint editor with constraint-based modeling.
The datasheets often show measurements like the horizontal distance between the leftmost side of the left-row pads and the rightmost side of the right-most pad, and the distance between the rightmost side of the left-row pads and the leftmost side of the right-row pads.
Converting that into the stuff you need to enter in the editor (width of pad, distance between center of pad and center of footprint) isn't hard, but it is cumbersome and error-prone. Being able to directly enter it as constraints[0] would make it literally an order of magnitude easier to input, and it would allow for a simple 1:1 comparison with the datasheet for verification.
[0]: Something like https://wiki.freecad.org/images/thumb/7/71/FC_ConstrainedSke...
seveibar
tscircuit maintainer here, we actually do support constraint-based modeling for footprints, although we don't use it often because we also support "short string" footprints which are often faster
mschuster91
What I'm missing is something like <pinheader>, just for generic connectors - say, <connector variant="[microusb,miniusb,usba-female,usba-male,vga-male,vga-female]">.
Also, for resistors, is there a chance for PTCs and NTCs? And <diode> would benefit IMHO from a variant="[zener, schottky, photo]" plus associated parameters for them.
whartung
I took a stab at something like this. My intent was that you’d be sitting at a Common Lisp REPL, and start entering commands.
As you did this, a graphical window would show your components and traces. I considered similar to a legacy AutoCAD, way back before pointing devices were commonplace.
I had a whole simple dialect to easily identify traces, which you would continuously split with points, then nudge them around or anchor next to other points.
I honestly felt, especially for the small board project I was working on that writing this from scratch would have been faster than fighting KiCAD or any of the similar tools.
But I was stymied with finding a good way to get graphics out of CL on my Mac. I even considered doing it all in SVG with some kind of auto reloading file, and just rewriting it each time.
Obviously I did not put a lot of effort into it, had enough friction to move on to something else.
MomsAVoxell
You could use AI to build this, I believe, in a few days. Especially having thought about it, oneself, for a few years ..
mschuster91
If I understand this correctly, in the end, JS/TS is being used only as a template language (similar to React, Lit, ...) to render out XML that is then picked up by a router and rendered out into something a PCB fab shop can use?
Nice idea.
synapsomorphy
Atopile is another thing in the circuits-as-code space: https://github.com/atopile/atopile
As a half EE/half SWE I think there are significant benefits to circuits as code but I'm not impressed with this one. Atopile has a narrower focus (autorouters are really really hard) and doesn't use as many buzzwords. Like why on earth does a "web first approach" matter at all for hardware development?
But also, GUI tools are getting better, Kicad 9 had a lot of changes that made templating / reusing blocks easier. And it works fine if not great with version control.
I don't see circuit-as-code taking off with humans anytime soon, it's much better but not enough better to convince EEs many of which don't code much or at all. But I can see it becoming much more common as LLMs get better at complex circuits.
mystified5016
I don't know why anyone wants to shove big heavy applications into browsers. Are they imagining you'd use your phone for this?
Are we not teaching kids how to publish desktop applications these days or what?
imrishabh18
It's just not that we are imagining that people will be using phone to build PCB's, we also have a cli which perform better than the browser playground!
saidinesh5
My guess is the cross platform story.
For cross platform development we barely have any decent, free development tools. It's a lot easier to find JavaScript developers in most places than c++/c# developers.
kev009
It's probably a simple economics thing. You can hire out a contract PCB design for a reasonable cost and the long poll is getting back physical prototypes. Contrast to HDLs displacing schematic based designs for ASICs and programmable logic, where simulation allows for rapid development.
fxtentacle
I'd say it's significantly different because you can get a physical PCB prototype in days for a few dollars while an ASIC prototype takes months and millions.
kev009
I'm not sure if you missed the point. HDL design work is done by simulation for countless iterations before ever making it to a physical prototype. ASIC prototypes come very late in the cycle and are usually a low digit number of revs. So the point is simulation carries you through most of the design feedback cycle, and a significant economic and technical effort went into industry automatic place and route, DRC/LVS, etc. I am also ignoring the human heavy side of layout especially around analog and RF which is more like PCB design still.
A PCB can be reworked by hand on site. And those revs can be incorporated cheaply as you say. So the need to do all this programmatically is lowered below the economic threshold to make it all plausible in most cases. This presupposes that modern PCB tooling is itself semi-automated and includes simulation capabilities, but an expert operator is doing a lot of the decision making.
bb88
> I don't see circuit-as-code taking off with humans anytime soon
I don't agree with this. Circuits aren't really anything more complex than anything else humanity has had to figure out. Most knowledge in this area seems solvable.
Maxwell's equations have been known for a century.
For whatever reason, Software Engineering and Hardware Engineering even though they rely upon the same fundamental physics, are so very different? And apparently can't be reconciled? No. I don't believe it.
cactacea
PCB layout is as much art and black magic as it is science. I'm not sure why you dismiss the complexity so easily, this definitely is not just a matter of applying Maxwell's equations.
0_____0
Layout is a puzzle, especially with particularly high density layouts, but some of this is ameliorated by high layer count and fine trace/space boards becoming cheaper. Definitely not black magic. RF layout is black magic, let's not steal their thunder here.
bogantech
> For whatever reason, Software Engineering and Hardware Engineering even though they rely upon the same fundamental physics
Software engineering isn't a thing besides being an ego title.
Software is "ship now, patch later"
Hardware is engineered, it must be correctly designed from the beginning and cannot be easily modified in the field
donkey_brains
[dead]
crote
> For whatever reason, Software Engineering and Hardware Engineering even though they rely upon the same fundamental physics
They are completely different. Software is pure mathematics: you know exactly what goes in, you know exactly what operations it is going to do, and you know exactly what will come out. There are no surprises here, it's just a mechanical translation. If you want to, you can even prove that your code is doing the right thing.
Hardware is physical. Your components don't neatly follow mathematical models - the model is just a rough approximation. Everything interacts with everything else: a signal in one trace will impact a signal in the next trace over - or even on the other side of the board. Your PCB will behave differently if you hold your hand above it - without even touching it. Worst of all, most of your components are black boxes, and you don't have accurate models describing them! What good are Maxwell's equations if there's no way you're ever going to solve them?
You can make a reasonable estimate of how a PCB is going to behave, and you can occasionally do a reasonably-close simulation of some part of your circuit-to-be in isolation. But you need to physically manufacture it to find out whether it behaves the same in practice, and it takes weeks of time and thousands of dollars to manufacture a single prototype. You can't "move fast and break things". You can't afford to do the usual "hit a bug, change tiny thing, recompile, check" cycle you're used to from software programming, and some fancy tooling isn't going to change that reality.
mystified5016
Slightly tangential, but what's the state of the art in auto routing and placement these days? I haven't tried any since I used EAGLE a few years ago.
I know routing is one of those really hard problems, and for a long time they were all pretty bad at even moderately complex or constrained designs. Have things gotten better recently with the rise of machine learning? (Specifically not 'AI')
alnwlsn
Most routers (including humans) haven't even figured out that you can run traces in more than just 8 directions :) I quite like autorouted boards in TopoR for this reason, but it's hardly cutting edge; been around for decades.
I hear Altium has some pretty decent autorouting. The problem here is that by the time you've set up all the grouping, constraints and settings to get an auto route that works well, you probably could have just routed the board yourself. So I've never used it once. There's still no magic button you can click once to make a full routed board. As far as I know, autorouting for all the big players is still based on tried and true algorithms like A-star. They might be getting a little better year over year, but not so much so that anyone noticed.
I have seen quite a few improvements in manual routing though. It seems like the manual routing tool has gotten better at pushing traces out of the way, and if you move a routed component you might not need to redraw all the traces going to it anymore.
krasin
> Slightly tangential, but what's the state of the art in auto routing and placement these days?
I always recommend quilter.ai: https://www.quilter.ai/ - they "eat" Kicad or Altium files, and produce autorouting and/or autoplacement. I tried them about 9 months ago and made a couple of boards that worked well.
cibomahto
I've been working on CircuitPainter, a Python-based system for generating PCBs. Some examples are here: https://circuitpainter.blinkinlabs.com/examples.html .
It uses KiCad as a backend, so you are able to take advantage of the design rule checker and other niceties that come from the traditional CAD world. We've been using it successfully to automate very repetitive design jobs at our studio.
crote
I'm genuinely surprised by how awful the resulting PCB is. A trivial LED matrix like this is pretty much the best-case scenario for tooling like this. Not being able to handle this is a pretty damning - although a decent bunch of the blame should probably be placed on whatever third-party autorouter they are calling out to.
Even with better results, the big issue with tools like these is that they simply don't match with the kind of development style that's needed for the problems at hand. You see the same issue with those drag-and-drop visual programming languages, or scripted modeling like OpenSCAD: they end up making fairly trivial details slightly easier, while significantly complicating the meat-and-potatoes. Nobody cares about a neat little part placement for-loop if it generates a living hell of autorouted spaghetti you can't possibly interpret and fix manually.
In reality the low-hanging fruit has already been covered by existing tooling. Automatically generating symbols and footprints from textual descriptions is routine practice, and software like KiCad already has a reasonably usable scripting API and a well-documented file format. A lack of code-based code-based EDA hasn't stopped projects like Ergogen[0] from popping up. The main limitation for additional automation is a lack of reliable input data, and user-side tooling can't fix that.
seveibar
(tscircuit maintainer here) It might be easier to think of tscircuit as an electronics CAD kernel. We're MIT licensed and web-compatible, so we would make a great foundation for people building new EDA tools or people who would like to generate electronics (think domain-specific tools, e.g. a website that allows you to quickly build a custom keyboard)
FWIW In this case I think this board called out to freerouting for the routing. Companies have reached out to us with autorouting APIs, so we'll support different vendors and hopefully allow enough constraint-specification for people to get good results. Autorouting is important for reusability, even if it's routing between manually-routed sections (e.g. fanouts)
boznz
I guess it kind of works, but why would you? I find it quite therapeutic designing PCCB's. My last try at getting AI to draw a circuit diagram was actually quite hilarious: https://rodyne.com/?attachment_id=1753
undefined
sgnelson
SVG PCB is a similiar concept. The nice thing is that it allows both code and gui manipulation of the design.
apexedison
Thanks for the shout-out.
Get the top HN stories in your inbox every day.
I built a WiFi-controlled RGB LED matrix using tscircuit, a library that lets you design PCBs with JavaScript instead of traditional CAD tools.