Analog Computing, Ngspice (publ. 2025-03-07)

I finally was able to place that parts order. I've got some multipliers on the way, as well as enough parts to make some comparators and a reference voltage module. My wife donated a big cookie tin, and I was planning to mount some banana socket and potentiometers on that.

I'm doing envelope savings also toward purchasing an Analog Thing computer. But it may be several months yet before I have enough money saved up, with the system currently selling at about $500.

Meanwhile, I've been experimenting with ngspice. KiCAD can export a spice netlist, so you can lay out your schematic in KiCAD and then load up the netlist in ngspice. Actually, KiCAD has a built-in spice interface, but I have ran into some errors when trying to use it, so until I get that figured out I am running the simulations from directly within the ngspice interpreter.

As an early experiment, I set up an inverter circuit in KiCAD, using the LM358 simulation model from the KiCad-Spice-Library repository.

KiCAD screenshot with inverter circuit

Here is a screenshot of the results from an ngspice "tran" simulation, with a gnuplot showing the inverted signal:

screenshot of Emacs running ngspice, with a gnuplot showing the input signal and the inverted output signal

One quirk of this approach is that the KiCAD netlist did not have the op amp model parameters in the correct order, so I had adjust that manually. I think it is because the KiCAD symbol is for a dual op amp chip but the model is for one op amp. Not sure. Anyway, it worked after I made that adjustment.

The Guix ngspice package does not include Xspice, unfortunately, for graphical plots. But this does not prevent you from using the "gnuplot" command instead, to generate the plots with gnuplot.

KiCAD has something called "sheet hierarchies", which allow you to have subsheets in a schematic, that can be reproduced in the main schematic as many times as you want. So I guess that is the way forward on making this modular. But hierarchies only work within a project, not across projects, so maybe I need to figure out how to make new symbols (...?)

This work © 2025 by Christopher Howard is licensed under Attribution-ShareAlike 4.0 International.

CC BY-SA 4.0 Deed

Proxied content from gemini://gem.librehacker.com/gemlog/starlog/20250307-0.gmi

Gemini request details:

Original URL
gemini://gem.librehacker.com/gemlog/starlog/20250307-0.gmi
Status code
Success
Meta
text/gemini
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.