4 ms·
Unless I'm missing something, this is not circuits-as-code, it's just circuits-as-text. It's basically a non-standard way to represent a netlist, and to hang me
by addaon 3y ago
Unless I'm missing something, this is not circuits-as-code, it's just circuits-as-text. It's basically a non-standard way to represent a netlist, and to hang metadata off that netlist -- which is, to be fair, quite cool and useful.
But take the example from [0] of a voltage divider. I agree that that is a textual description of a voltage divider that can be compiled to a netlist, a BOM, etc. But what is the actual division properties? What's the combined tolerance stackup? What I /want/ to be able to do is define a module generator function that takes a ratio, a desired output tolerance, and a maximum output current and generates the divider module with resistors chosen (both resistance and tolerance) that will meet those properties. And while I'm wishing, given that (for low output currents) this is an underdefined problem, I'd also like a way to lean towards components already in the BOM, either by just manually using preferred values (yuck), or by outputting multiple possibilities and having a selector downstream that does BOM line count optimization.
Besides taking much, much more of the drudge work out of this, it also makes these circuit-as-code text files reviewable, in much the same way code is. Consider an input pin for an ADC on a microcontroller. On the signal path, I might have at a minimum a voltage divider to get things in range, a low pass filter to get rid of aliasing, and a buffer to satisfy the input pin impedance requirements. If this is three different modules, each with two or five components... reviewing this is equivalent to designing it, I need to check each bit. If, instead, this is generate_divider(1/3, 0.1%); generate_lowpass(200 Hz); module my_standard_opamp_bufer -- then I only need to review those implementations once, and can trust the use of them (for, potentially, dozens of ADC pins).
[0] https://atopile.io/getting-started/ https://atopile.io/getting-started/
- napowderly 3y agoFor sure, we found that to start with something useful from day 0 we needed to be able to completely represent any possible circuit. Starting by just providing a cleaner way to write out a netlist is just the beginning. We are working to add an equations solver to our compiler over the next few weeks, which will allow you to do things like set the ratio of a divider and total resistance, then have the solver pick optimal values based on availability, cost etc. I think that gets really exciting when you start to be able to link these together, its trivial from there to directly set the output voltage of a power supply in volts, which will internally configure the feedback resistor divider. Also verified designs will be super important. Its a little crazy that the status quo is you will almost inevitably make a silly mistake on your first spin. I am imagining designers will go off, make a new circuit, build and test it then make a PR to merge it into main.
- addaon 3y agoGet even a basic equation solver in there and I'll be a user! Have it handle units properly and I'll be a happy user. Have it be able to handle both worst-case and RSS tolerance stackups and I'll be in love.
- napowderly 3y agoExcited to hear it! Our language already captures tolerances and the solver we are building does proper tolerances stackups. You specify the desired output with a tolerance, eg my_regulator.power_out.voltage = 4.75V to 5.25V and we will solve the stack up to get you there. Hang tight, its coming soon!
- bboygravity 3y agoWill it take into account temperature ranges and other parameters as well?
- mawildoer 3y agoIf we can build the equation solver our hearts are set on, you should be able to account for as many factors as your design requires - albeit with some performance limitations at some point. That is, assuming temperature can be factored into equations in the same manner as any other parameter or attribute
- mawildoer 3y agoWe're also super stoked about getting topology and equations together in the same file (and even code-base!) The equation solver is soon on our roadmap: https://atopile.io/roadmap/#language-features https://atopile.io/roadmap/#language-features
- phkahler 3y agoSolvespace has a nonlinear algebraic equation solver: https://solvespace.com/index.pl https://solvespace.com/index.pl It's what underlies the geometric constraint solver which you don't need for what you're doing. It's probably worth a look under the hood. You might also read this post from Michael-F-Bryan implementing something similar in Rust: https://users.rust-lang.org/t/geometric-constraint-solvers-part-1-algebraic-expressions/45818 https://users.rust-lang.org/t/geometric-constraint-solvers-p... He based his work on what he learned from Solvespace.
- Timot05 3y agoHad a play here for equations: https://github.com/atopile/atopile/blob/tim/equations/sandbox/equations.ipynb https://github.com/atopile/atopile/blob/tim/equations/sandbo...
- addaon 3y agoThis is great. The pragmatic bit that makes it a bit more challenging (or, perhaps, a bit more of a search optimization problem than analytical) is that most of the cost functions are step functions. Once you need better than 10% tolerance on a resistor, you might as well step down to 1% -- available tolerances are discrete, and 5% and 2% tolerance parts are rarely cheaper than 1%. Similarly going to 0.1%. So once it's clear that preferred_tolerance_N is not going to solve, you can assume preferred_tolerance_N+1, and then push that through -- and hopefully push a few marginal parts up a bucket. There's also a similar step-function cost for adding a new BOM line, especially for hobby-scale projects; this is a project-global optimization, where I might change a 10 kΩ / 2.2 kΩ resistor ladder to 6.8 kΩ / 1.5 kΩ if I already have 1.5 kΩ, 6.8 kΩ, and 10 kΩ in my BOM but would otherwise need to add 2.2 kΩ (assuming everything else still solves, of course; more likely than not, since we usually don't care much about the total resistance of a ladder, as long as it's stiff enough, and doesn't leak too much).
- Timot05 3y agoHadn't thought about the BOM line one but that definitely makes sense. The implementation I linked is definitely math heavy but might actually not be the best idea. As you say, the cost functions has steps. For less than a given amount of components, random search might be suited. Past that point, we might use maths to constrain the problem and then search within that range. We have equations at the top of our todo list and hope to get there soon :) Matt setup a roadmap here with things we want to work on: https://atopile.io/roadmap/ https://atopile.io/roadmap/
- Joker_vD 3y ago> it's just circuits-as-text. atopile (1) — convert ASCII to pile of electronic components
- napowderly 3y agolove it