Show HN: React for Circuits
197 points| seveibar | 1 year ago |github.com
I've wanted to program circuits for a long time- I started experimenting with the concept of creating circuits in React almost 8 years ago and have spent many weekends since to prove the concept. Over the past 2 months, I've decided to start working on tscircuit full-time.
[+] [-] looneysquash|1 year ago|reply
I'm not sure I'd really want to design an electronics project in jsx though. That's just xml, but also JavaScript. And I guess I think of it more as data than as code.
I was thinking a simple language would be nice, something alternative to a GUI and mouse.
But I was thinking more along the lines of LT Spice's netlist. Or plantuml. Or markdown
Also, I was thinking of html and css. But not so much the syntax as the separation of structure and styling.
You could even have two "stylesheets", one for the schematic and one for the board
[+] [-] seveibar|1 year ago|reply
[+] [-] kennywinker|1 year ago|reply
https://atopile.io/
https://google.github.io/pcbdl/doc/_build/html/readme.html
[+] [-] philsnow|1 year ago|reply
What about OpenSCAD? I haven't looked into tscircuit very much and I barely remember any of the vhdl I did in college, and maybe it's more useful/relevant to make parameterized 2d/3d shapes rather than parameterized circuit components, but I have always been more comfortable with typey-compiley rather than pointy-clicky.
[+] [-] Flux159|1 year ago|reply
Do you see the future of this project being something like a library of tscircuit components that you can compose together writing code rather than having to use Eagle or other pcb design software? Or I guess somehow autogenerating tscircuit components based on specsheets?
Looking at the code, I see that there's a reconciler here https://github.com/tscircuit/react-fiber/blob/main/src/lib/r..., but that seems to just be a thin wrapper to https://github.com/tscircuit/builder which is doing the heavy lifting of getting to a serializable format. One thing I'm wondering is why is there a need for separate repos since I feel like the tsx portion, reconciler, and builder are kinda needed together?
[+] [-] seveibar|1 year ago|reply
Yes I see the registry/central library being kind of like npm with a lot of React/tscircuit components that can be dropped into or used as a foundation for large designs, think <Arduino />, <MotorController /> or <Atmega /> etc. I also hope to make part substitution super easy, so equivalent subcircuits can be swapped based on part availability.
Separating into multiple repos makes some things really difficult but creates some nice boundaries. React Fiber is something that a lot of people don't understand (it's also not really officially documented as you may know!) so I wanted to separate it from "pure typescript" and the builder pattern which I think is a bit easier to grok if you're just fixing a bug etc. The codebases are a mess and I'm very eager to do some basic project hygiene- a lot of cruft accumulates over years of weekend development haha.
Thanks a ton for checking it out!!
[+] [-] vbezhenar|1 year ago|reply
[+] [-] UberKryos|1 year ago|reply
[+] [-] seveibar|1 year ago|reply
Going from schematic back to JSX is a major goal, I'm building an LLM that can do this as well as read datasheets- this is in part to bootstrap the registry with components that come pre-loaded with the recommended decoupling capacitors.
[+] [-] imtringued|1 year ago|reply
[+] [-] seveibar|1 year ago|reply
I'm introducing "trace baking" soon that will let you use stuff like the freerouting autorouter (or other autorouters) asynchronously, e.g. you just surround your circuit with <autoroute router="freerouting" cache_id="..."> and it'll use a remote or local server to handle autorouting.
[+] [-] CodeMaven|1 year ago|reply
[+] [-] tmitchel2|1 year ago|reply
The only minor complaint is that the wires / nets / traces are also components themselves. JSX can only build tree structures but wires turn circuits into graphs, so for those I would have used plain js classes or hooks like useWire and then pass the + and - into the components. That gives you the added benefit of warning when you haven't wired up a component fully. Also allows for required and optional wire inputs on components.
[+] [-] seveibar|1 year ago|reply
[+] [-] gedy|1 year ago|reply
[+] [-] seveibar|1 year ago|reply
It's wayy easier to collaborate in tscircuit, people can make submodules for eachother! So I could even just take your BOM and try to put something on the registry to make it easier to build out your first design :) good luck!
[+] [-] WaxProlix|1 year ago|reply
Kudos, I'll check it out this weekend (or next... :)
[+] [-] seveibar|1 year ago|reply
[+] [-] shepherdjerred|1 year ago|reply
I've got a breadboard concept but I have no idea how to polish it up. All of the software GUIs look so intimidating, but I'm very familiar with TS/React!
[+] [-] seveibar|1 year ago|reply
[+] [-] meta-level|1 year ago|reply
[+] [-] seveibar|1 year ago|reply
[+] [-] franky47|1 year ago|reply
[+] [-] nixpulvis|1 year ago|reply
[+] [-] seveibar|1 year ago|reply
[+] [-] iyifr|1 year ago|reply
[+] [-] throwaway11460|1 year ago|reply
Also could be used to build an interactive simulator pretty easily.
[+] [-] cjk2|1 year ago|reply
I mean it's a good experiment and learning exercise but I don't see a practical case for it.
[+] [-] frognumber|1 year ago|reply
The core thing code allows is code, constraints, and subcomponents. I can see writing:
<oscillator555 frequency="10kHz">
And having this have a premade parametrized component with layout, as well as knowing about things like power supplies.
I can also see this integrating more with GUI tools.
There are many steps going forward, not specific to this, which would need to be in place, such as:
- Allowing React XML without JSX (e.g. in data files)
- Exporting to the above
- CSS-style templates and state management
... and similar. Those would potentially permit both code-based tools and GUI tools to interact meaningfully, and that's where the real power would come in.
You get there with prototypes like this one, and increments.
Ideally, where this would end up is almost:
<EPSHome> <ESP8266/> <Sensor/> <Sensor/> <Sensor/> </ESPHome>
And a crude-but-working layout comes out, which gets made for $10, populated with ESPHome, and monitors whatever I want to monitor at home. Not much more than STEMMA, but with a nice PCB instead of a dozen cables .
[+] [-] junon|1 year ago|reply
[+] [-] amelius|1 year ago|reply