HackerTrans
TopNewTrendsCommentsPastAskShowJobs

liu3hao

105 karmajoined vor 15 Jahren
electronics designer and software developer mail_hn at weihao.dev

comments

liu3hao
·vor 15 Stunden·discuss
Hi HN, still making progress on Circuitscript, a Python-inspired language for describing electronic schematics: https://circuitscript.net/. You can try it in the browser via the Bench IDE: https://bench.circuitscript.net/

The biggest addition in the past month is initial support for ngspice netlist export — you can now take a Circuitscript design and export it to a SPICE netlist for ngspice simulation. This is a step toward closing the loop between describing a circuit and verifying its behavior, all from the same source file.

I have also added bus support, which makes wide parallel connections like data/interface (I2C, SPI, etc.) lines much less tedious to connect up.

Recently I produced and tested a 161-LED charlieplexed array in Circuitscript, using nested for-loops to generate the array instead of copy-pasting every LED and connection by hand. I plan to write a blog post soon to document this design.

As always, the motivation is to describe schematics as code rather than by clicking around graphical CAD tools (KiCad, Allegro, Altium, etc.). I want to spend time on the design itself, with code expressing the intentions clearly and reviewable in text.

Feedback welcome, especially from anyone frustrated with graphical schematic tools! If you have a KiCad design you'd like to convert to Circuitscript, please reach out to me. I'm looking to test the limits of the language and happy to help with the conversion.
liu3hao
·vor 27 Tagen·discuss
Hi! Thank you for taking a look at circuitscript! Before creating circuitscript, I did consider using the SKiDL package as a circuit design tool, however even though I am familiar with python, the syntax for things like connecting pins was very strange (using the += operator). Moreover many of the existing code to schematics, including SKiDL, forces the designer to give up the actual layout of the schematic itself. As a electronics designer in my day job, a well organized schematic is very important to understand the overall design. It does not only show connections, but is also a map of the system. A poorly drawn map complicates system understanding and troubleshooting.

I'm not sure how an object oriented approach would make things easier for schematic generation. The objects (components) themselves do not undergo much data interactions/manipulations. Maybe if you have some examples, this would be helpful for me to understand. As much as possible I am leaning towards a more functional approach, where inputs, data transformations and outputs are more defined.

With a new language, I could decide features that I wanted and more importantly, include more circuit specific features (branch/join/parallel statements). Of course, a python library would be able to produce the same data representation that circuitscript ultimately generates, but one aim of circuitscript is to make it much easier to do so.

The standard lib provides led, supply, res and cap as component functions (basically normal functions that return a component). For LED and supply, they take strings as parameters, this defines the led color and the name of the supply net respectively. Res and cap take a number parameter like 1k, 1u, 100n, etc. Such number expressions are very common in schematics and CAD packages, so this is a important feature to support (python equivalent of using 1e3, 1e-6, etc.).
liu3hao
·vor 29 Tagen·discuss
Hi HN, I am making progress working on Circuitscript, a language based on python to describe electronic schematics: https://circuitscript.net/. A basic IDE (called the Bench) to try Circuitscript is available online: https://bench.circuitscript.net/

In the last month, I have added support for more ERC rules (pin type compatibility checks), added initial support for net classes and also cleaned up the language a little (backslash line continuation, similar to python).

Recently, I just completed a 161-LED charlieplexed array design that uses nested for-loops to simplify the array design. It is currently in production and I plan to write a blog post soon to document this design.

As always, the motivation for creating Circuitscript is to describe schematics in terms of code rather than graphical UIs after using different CAD packages extensively (Allegro, Altium, KiCad) for work in the past. I wanted to spend more time thinking about the design itself rather than fiddling around with GUIs. With code, the design intentions become explicit and reviewable.

Feedback welcome, especially from anyone else frustrated with graphical schematic tools! If you have a KiCad design that you would like to convert to Circuitscript, please reach out to me as well and I will help you to do so as I am trying to challenge/test the limits of Circuitscript.
liu3hao
·vor 2 Monaten·discuss
Having some progress on CircuitScript, a python like language for describing electronic schematics as code: https://circuitscript.net. Try the language through the online IDE at https://bench.circuitscript.net

In the past 2 months, I have added support for exporting to the .kicad_sch format. Multi-sheet designs are exported as separate .kicad_sch files, one per sheet. The pin types has been updated to be similar to KiCad's and to better support ERC rules. Setting the GND symbol pin as a type of power_input was a real headache for me, eventually, I decided to define a new pin type, power_reference.

The motivation for creating Circuitscript is to describe schematics in terms of code rather than graphical UIs after using different CAD packages extensively (Allegro, Altium, KiCAD) for work in the past. I wanted to spend more time thinking about the schematic design itself rather than fiddling around with GUIs. With code, the design intentions become explicit and reviewable.

Feedback welcome, especially from anyone else frustrated with graphical schematic tools!
liu3hao
·vor 4 Monaten·discuss
Thank you for taking a look at my project! But from what I can read in the JITx documentation, there are quite a few differences when compared to circuitscript. Firstly, they aim to provide a higher level design language compared to circuitscript, which targets only the schematic level at the moment. JITx goes beyond the schematic, and also does physical design as well as analysis. Secondly, JITx circuits are written in python, which honestly is clunky for defining the circuits as well as laying them out in a graphic schematic.
liu3hao
·vor 4 Monaten·discuss
Hi HN, I am still working on Circuitscript, a language based on python to describe electronic schematics: https://circuitscript.net/. A basic IDE (called the Bench) to try Circuitscript is available online: https://bench.circuitscript.net/

In the past month, as suggested by the previous user, I have added support for kicad schematic libraries. The kicad schematic libraries files are converted into circuitscript format and can be directly imported into circuitscript code. To support the large number of components in the kicad libraries, I had to improve the import functionality and also implement some caching to speed up the imports. With the kicad schematic libraries available now, it provides a larger library of components that can be used in circuitscript projects. The converted libraries can be found here: https://gitlab.com/circuitscript/kicad-libraries

The motivation for creating Circuitscript is to describe schematics in terms of code rather than graphical UIs after using different CAD packages extensively (Allegro, Altium, KiCAD) for work in the past. I wanted to spend more time thinking about the schematic design itself rather than fiddling around with GUIs.

Please check it out and I look forward to your feedback, especially if you are also exploring alternative ways to create schematics. Thanks!
liu3hao
·vor 5 Monaten·discuss
Thank you! I haven't tried circuitscript with LLMs yet, but I do plan to do so in the future. As the language is similar to python, hopefully it is able to work well syntactically. But of course, the correctness and accuracy of the circuit would be more challenging to get right. Your work at https://www.mikeayles.com/#tokn is very cool! This will be very useful when I try LLMs!

I have seen both atopile and tscircuit too and they are really complete it terms of the entire PCB design flow compared to circuitscript, which is just focused on the schematic part.

The ato language works well for specifying parts and parameters, but is very basic for defining connectivity. This means that the designer will have minimal control of how the final schematics will turn out. Of course, atopile focuses on the complete design flow, so having nice schematics could be a want rather than a need. For myself, especially in my professional job, clear and well-organized schematics are important not just for understanding and creation, but also troubleshooting the design and eventually improving the design.

I did try some automatic layout features for the schematic that balances giving the user some control over the overall schematic, but this was really hard to get right. In the end, I went with the logo/turtle approach and give full layout control to the user.

For tscircuit, I like typescript as a programming language and circuitscript itself is created in typescript. But typescript is really clunky to use for schematic design. Coupled with react, there is a lot of extra noise/symbols when looking at the code and for complex designs, it will be challenging to understand and troubleshoot. Moreover, I believe that typescript/javascript is less common among electronics engineers compared to python (which circuitscript is based on). The simplicity of python is one of the reasons it is popular and that is what I believe might help to lower the learning curve for circuitscript.
liu3hao
·vor 5 Monaten·discuss
Thanks! For laying out and connecting the schematic components, I found that a turtle/logo inspired flow does do the job well for relative placement. I guess you can imagine it as creating paths for the electrons to flow!

I do like the ease of visually drawing schematics, however for some parts of circuit design, it gets repetitive and the GUI (used Altium, Allegro and Kicad professionally) gets in the way. For more complex circuit changes, it can be much easier to diff text rather than graphics, since text can capture intent better.
liu3hao
·vor 5 Monaten·discuss
Please reach out to my email listed in my profile. I will be glad to chat about how circuitscript can be useful for your work!
liu3hao
·vor 5 Monaten·discuss
Hi HN, I am working on Circuitscript, a language based on python to describe electronic schematics: https://circuitscript.net/. A basic IDE (called the Bench) to try Circuitscript is available online: https://bench.circuitscript.net/

I have created a usb-uart converter board with the CH340 chip. The complete schematic was coded with Circuitscript and then imported as a netlist into kicad pcbnew to do the pcb layout. The design was produced with JLCPCB and after receiving the boards I tested them and they do work! The design files are here https://github.com/liu3hao/usb-uart-bridge. The circuitscript code file is here https://raw.githubusercontent.com/liu3hao/usb-uart-bridge/re... and the generated pdf from the circuitscript code is here: https://github.com/liu3hao/usb-uart-bridge/blob/main/usb_uar...

The motivation for creating Circuitscript is to describe schematics in terms of code rather than graphical UIs after using different CAD packages extensively (Allegro, Altium, KiCAD) for work in the past. I wanted to spend more time thinking about the schematic design itself rather than fiddling around with GUIs.

Please check it out and I look forward to your feedback, especially from electronics designers/hobbyists. Thanks!
liu3hao
·vor 6 Monaten·discuss
Thank you very much! That's a good point and I will look into this to help drive some momentum!
liu3hao
·vor 6 Monaten·discuss
Hi HN, I am working on Circuitscript, a language based on python to describe electronic schematics: https://circuitscript.net/. A basic IDE (called the Bench) to try Circuitscript is available online: https://bench.circuitscript.net/

During the December break, I have implemented some new features: automatic stable refdes annotations, parameter assignment rules for easy part number assignment and some ERC rules. These are also important parts of the design workflow to help turn a schematic into a usable BOM and layout.

I have created a usb-uart converter board with the CH340 chip. The complete schematic was coded with Circuitscript and then imported as a netlist into kicad pcbnew to do the pcb layout. The design was produced with JLCPCB and after receiving the boards I tested them and they do work! The design files are here https://github.com/liu3hao/usb-uart-bridge. The circuitscript code file is here https://github.com/liu3hao/usb-uart-bridge/blob/main/usb_uar... and the generated pdf from the circuitscript code is here: https://raw.githubusercontent.com/liu3hao/usb-uart-bridge/re...

The motivation for creating Circuitscript is to describe schematics in terms of code rather than graphical UIs after using different CAD packages extensively (Allegro, Altium, KiCAD) for work in the past. I wanted to spend more time thinking about the schematic design itself rather than fiddling around with GUIs.

Please check it out and I look forward to your feedback, especially from electronics designers/hobbyists. Thanks!
liu3hao
·vor 9 Monaten·discuss
Hi HN, I am working on Circuitscript, a language based on python to describe electronic schematics: https://circuitscript.net/. A basic IDE (called the Bench) to try Circuitscript is available online: https://bench.circuitscript.net/

Since the last month, I have created a complete schematic with Circuitscript, exported the netlist to pcbnew and designed the PCB. The boards have been produced and currently waiting for them to be delivered to verify that it works. Quite excited since this will be the first design ever produced with Circuitscript as the schematic capture tool!

The motivation for creating Circuitscript is to describe schematics in terms of code rather than graphical UIs after using different CAD packages extensively (Allegro, Altium, KiCAD) in the past. I wanted to spend more time thinking about the schematic design itself rather than fiddling around with GUIs.

The main language goals are to be easy to write and reason, generated graphical schematics should be displayed according to how the designer wishes so (because this is also part of the design process) and to encourage code reuse.

Please check it out and I look forward to your feedback, especially from electronics designers/hobbyists. Thanks!
liu3hao
·vor 9 Monaten·discuss
Yes, that's true, right now you have to manually press on the Save button. I will update the online editor to auto-save after some time and probably also prompt the user to save before navigating as well too. Thank you very much for your feedback!
liu3hao
·vor 10 Monaten·discuss
You can actually skip all the wire commands and still generate a valid netlist, however the schematic might be a bit hard to decipher if there are many components!

I did explore automated layout algorithms for components in the schematics, however the readability and flow of the schematics might not be ideal, depending on what the algorithm prioritizes.

In the end, I realized that the actual layout and arrangement of the schematic itself was critical in the overall understanding. That was when I decided to add the "wire" command and give more control back to the schematic designer.

In the future, I do plan to add some automated way to generate these "wire" commands for automated layout. If the designer ever chooses to edit this automated schematic layout, he would be able to edit the wire commands for finer control.

In the end, I do believe that the visual part of the schematic plays an important role in understanding it. I, too, have spent hours puzzling/being misled by poorly drawn/disorganized schematics. Especially during troubleshooting or creating an updated revision, having a good understanding of the schematic saves time.

One of the aims of Circuitscript is to make the visual part easier, so at least more time can be spent thinking and organizing the schematic itself.
liu3hao
·vor 10 Monaten·discuss
Sure, let's talk! Please contact me at my email in my profile. Thanks!
liu3hao
·vor 10 Monaten·discuss
Thank you very much!
liu3hao
·vor 10 Monaten·discuss
Hi HN, I am working on Circuitscript, a language based on python to describe electronic schematics/circuits: https://circuitscript.net/

Recently, I have released a simple IDE (called the Bench) to try Circuitscript online: https://bench.circuitscript.net/

The next steps are to create more schematics with Circuitscript as examples to test the limitations of the language and to generate PCB designs with KiCAD. The Circuitscript tool (currently only the desktop cli tool) is able to generate KiCAD netlists and this can be imported into PCBnew.

The motivation for creating Circuitscript is to describe schematics in terms of code rather than graphical UIs after using different CAD packages extensively (Allegro, Altium, KiCAD) in the past. I wanted to spend more time thinking about the schematic design itself rather than fiddling around with GUIs.

The main language goals are to be easy to write and reason, generated graphical schematics should be displayed according to how the designer wishes so (because this is also part of the design process) and to encourage code reuse.

Please check it out and I look forward to your feedback, especially from electronics designers/hobbyists. Thanks!