Electr, a language for electronic formulas(github.com)
github.com
Electr, a language for electronic formulas
https://github.com/lkdjiin/electr
8 comments
Thanks, I should check GNU Units… (and the calculation is now fixed on Github)
As a student, I've found the TI-Nspire CAS software to work pretty well with units, but of course it's not free.
https://education.ti.com/en/us/products/computer_software/ti...
https://education.ti.com/en/us/products/computer_software/ti...
Sorry for the accidental downvote, I actually wanted to upvote :(
That has probably a lot of overlap with Frink https://futureboy.us/frinkdocs/, though after a quick try the output could be nicer, e.g. like described in this document.
That was my first thought as well; Frink, if it doesn't have this stuff, probably could.
Not command line (or open source), but we've built most of this capability and more into CircuitLab https://www.circuitlab.com/ (disclosure: I'm one of the developers) -- we have to manage units, metric prefixes, all sorts of arbitrary expressions https://www.circuitlab.com/docs/expressions/ , real and frequency domain, etc. We also have schematic-wide parameters, the ability to define functions of those parameters to set component values, and/or to set real-time arbitrary behavioral voltages and currents within the circuit graph, etc. On top of that, iteratively solved non-linear feedback systems, Laplace-domain filter notation.... It gets complicated fast!
One of the cool things about understanding circuits and simulation is that you can use the same concepts and tools to model non-electronics-domain problems: thermal systems, mechanical systems, etc. You can combine these, too: for a simple non-confidential example, we recently did modeling of the fusing of tin whiskers, which involves solving the electrical and thermodynamic properties at the same time.
One of the cool things about understanding circuits and simulation is that you can use the same concepts and tools to model non-electronics-domain problems: thermal systems, mechanical systems, etc. You can combine these, too: for a simple non-confidential example, we recently did modeling of the fusing of tin whiskers, which involves solving the electrical and thermodynamic properties at the same time.
I was going to mention you guys, its a pretty straight forward system.
There has been some other work on notational representation of electronics as part of the SPICE work that Berkley did. Also AT&T did some work there, the BLADES papers (http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=31523&...) and others have that. Hardward description languages (HDL's) often include an internal way of expressing various things as well.
From a purely hobby based approach building something which was a calculator with a resistor, capacitor, and inductor key might be useful. All though if you add two resistors and an inductor what you really want is the frequency response of the RL circuit not the parasitic resistance of the coil added to the resistors.
There has been some other work on notational representation of electronics as part of the SPICE work that Berkley did. Also AT&T did some work there, the BLADES papers (http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=31523&...) and others have that. Hardward description languages (HDL's) often include an internal way of expressing various things as well.
From a purely hobby based approach building something which was a calculator with a resistor, capacitor, and inductor key might be useful. All though if you add two resistors and an inductor what you really want is the frequency response of the RL circuit not the parasitic resistance of the coil added to the resistors.
(not-related) I'm happy that you show my twitter post on your homepage. I do love using circuitlab.
Awesome -- thanks so much for that! It always makes it a happy day in the office when we hear from happy users :)
TI used to distribute an script written in Lua that did essentially this - the original software company has long since gone out of business and I am not sure if TI has persisted with it (this was 2012)
NB: This was a separate product from the Inspire software
NB: This was a separate product from the Inspire software
Why can't Electr detect unit K form "10K + 200"? It's the only unit present in the equation.
Why kilo-ohms are denoted with "K" while milliamperes are using the proper SI unit "mA"? Why not to use "Ω" and "kΩ"? We have that symbol in high ASCII.
Probably just my ignorance of programming language design speaking but I really have to ask.
Why kilo-ohms are denoted with "K" while milliamperes are using the proper SI unit "mA"? Why not to use "Ω" and "kΩ"? We have that symbol in high ASCII.
Probably just my ignorance of programming language design speaking but I really have to ask.
In practical engineering (on circuit diagrams, bills of
materials, etc), you almost never see the "Ω" symbol. "K" is used for kΩ, "M" for MΩ, and "R" for Ω (as in 330R is a 330Ω resistor).
It's nothing to do with programming language design.
It's nothing to do with programming language design.
Like said before it has nothing to do with language design.
That said, I like the idea of having Ω, √, etc. But I'm afraid that our keyboards/editors/terminals are still not good to type that kind of characters quickly. But maybe I could use R or Ω, K or KΩ, why not…
And yes I think you're right, I could infer that 10K + 200 is 10.2K, like 3V times 2 is 6V, etc
That said, I like the idea of having Ω, √, etc. But I'm afraid that our keyboards/editors/terminals are still not good to type that kind of characters quickly. But maybe I could use R or Ω, K or KΩ, why not…
And yes I think you're right, I could infer that 10K + 200 is 10.2K, like 3V times 2 is 6V, etc
Nice idea. Unit handling can be hard though, there are several problems that you can bump into:
- It's not always evident what unit you want show after a calculation. (As/Vm or C/Vm, kV/m or V/mm)
- You should handle fractional power of units (like V/sqrt(Hz))
I recently discovered orpie and that one has unit handling. It has electrical (and all sort of physical) units and handles both of this problems fairly well. For the calculation result's unit it uses the one that comes evidently from the source terms (1kV* 0.5mA=0.5kV* mA), then the user can convert it to other equivalent units or to SI base units. It's an RPN calculator so one has to get the hang of it.
Edit:
Oh, electric engineers like to think of "rad" as a unit (like in rad/s and Hz). I think it's impossible to handle it well.
- It's not always evident what unit you want show after a calculation. (As/Vm or C/Vm, kV/m or V/mm)
- You should handle fractional power of units (like V/sqrt(Hz))
I recently discovered orpie and that one has unit handling. It has electrical (and all sort of physical) units and handles both of this problems fairly well. For the calculation result's unit it uses the one that comes evidently from the source terms (1kV* 0.5mA=0.5kV* mA), then the user can convert it to other equivalent units or to SI base units. It's an RPN calculator so one has to get the hang of it.
Edit:
Oh, electric engineers like to think of "rad" as a unit (like in rad/s and Hz). I think it's impossible to handle it well.
Thanks for the advices ;)
Very strange that nobody mentioned relative mainstream language that has the same feature: F#
http://fsharpforfunandprofit.com/posts/units-of-measure/
http://fsharpforfunandprofit.com/posts/units-of-measure/
I wonder why Frink isn't more popular:
https://futureboy.us/frinkdocs/
... and why in general programmers like to think about bare numbers and love to differentiate them into floats and ints of various length (like it's the 90-ies) but don't care if they are volts or meters.
https://futureboy.us/frinkdocs/
... and why in general programmers like to think about bare numbers and love to differentiate them into floats and ints of various length (like it's the 90-ies) but don't care if they are volts or meters.
https://en.wikipedia.org/wiki/GNU_Units
Calculations aren't quite as short as "1mA 3K", but pretty close to it.
It has long and short SI prefixes, scientific notation, implicit multiplication, and a history dating back to Unix itself.
By the way, one of the example calculations (calculation of 205 Hz) is too high by a factor 10.