Hacker News new | ask | show | jobs
by kragen 852 days ago
i've been doing a lot of small circuit simulations in paul falstad's circuit.js lately

i've learned a lot of interesting things:

- it's free software under the gnu gpl

- you can download the repo and run the javascript locally when you're offline. for this purpose the 'export as text' file menu option is useful; it gives you a textual representation of the circuit you can copy and paste, so you aren't dependent on tinyurl.com to get your circuit back. like spice, it ignores leading whitespace, which is super convenient if you keep your notes in markdown

- you can set the background to white (under options)

- the list of available devices isn't extensive but it does include a tl431

- the svg export (file menu) is great for including in a web page, but it only includes 'undocked' scopes, and the data that's plotted in them may not be the same as what you see

- the simulations are generally in good agreement with the ngspice simulations i've done, but you have to use a smaller timestep than spice usually chooses (i guess because of the lower order of integration), and unless it's much smaller, it can still have some numerical stability problems

- they run slower than spice, but often the faster feedback loop for interactivity makes up for it

- you can simulate an avr in it at the instruction level with avr8js: https://hackaday.com/2021/06/11/circuit-vr-arduino-virtually... which i don't know how to do in ngspice or any other spice

— ⁂ —

i have some questions, maybe someone knows the answers:

- is there a way to convert spice netlists into circuit.js designs? because that would be pretty useful, especially if i could, say, import a spice model of a 7805 as a subcircuit

- is there a way to convert circuit.js designs into spice netlists? because i feel like the schematic view is a lot clearer than the textual netlist

- is there a way to import and/or export to kicad?

- is there a way to do monte carlo simulation in circuit.js? or at least sensitivity analysis?

— ⁂ —

here are some circuits i've put together in circuit.js this week: http://tinyurl.com/27m6usjw http://tinyurl.com/23u2y4w8 http://tinyurl.com/2cf5kgxc http://tinyurl.com/23qvuylw http://tinyurl.com/27agyg4q http://tinyurl.com/2bssxwjq and last week: http://tinyurl.com/2889h6o8 http://tinyurl.com/2a8by2mq (happy to explain any of these if anyone is curious)

1 comments

It has apparently been longer since I was a TA for an electronics class in college than I realized. I appear to have lost most of that knowledge. I would love a one-sentence explanation of what each of these circuits you put together are meant to demonstrate, if you're up for it.
in many cases i wasn't trying to demonstrate things but trying to find things out

http://tinyurl.com/27m6usjw rc-filtering a (badly simulated) rc-filtered gpio pin to observe the v-i curve of a diode over the relevant range to measure its temperature

http://tinyurl.com/23u2y4w8 checking an input-protection design sketch for a 500kbps open-drain communications bus to make sure it doesn't degrade the signal too much

http://tinyurl.com/2cf5kgxc adaptor for probing a logic circuit with your cellphone's headphone jack without risk of blowing up your phone or loading down the circuit (though probably just a resistor would be fine for this actually)

http://tinyurl.com/23qvuylw simple linear circuit to supply 5 volts at up to 100 milliamps that won't burn up or drag your power rail down to ground if you short-circuit it, or if you accidentally connect a conflicting voltage source to it

http://tinyurl.com/27agyg4q placing a diode-connected transistor used as a temperature probe in between two rc-filtered gpio pins in order to be able to measure its v-i curve repeatedly at different voltage levels to cancel out possible nonlinearity in the adc you're using to measure it

http://tinyurl.com/2bssxwjq 5-volt linear voltage regulator limited to 150 milliamps with only three transistors and four resistors, eliminating the requirement in the original circuit (from the tektronix 576 curve tracer) for a precisely regulated -12.5 volt rail, but sacrificing some output impedance

http://tinyurl.com/2889h6o8 running several individually switchable devices, including one using a high-precision tl431-based 5-volt regulator, from a 100-milliamp linear regulated current supply over a high-resistance wire, whose unknown temperature-varying voltage drop doesn't affect the current regulator at all, unlike the conventional constant-voltage type of power supply

http://tinyurl.com/2a8by2mq walt jung's gled431, an ultra-low-noise non-temperature-compensated 2.5-volt voltage reference circuit using the forward drop of a lite-on green led as the reference voltage

you could maybe complain a bit that these are a little repetitive, since three of them center around variations on the same standard linear current-source circuit, but it wasn't at all obvious to me how to adapt it to those three cases

overwhelmingly more details in log.md in

    git clone http://canonical.org/~kragen/sw/leatherdrink.git