NGspice simulation of Wave File

For doing simulations only (meaning, not going to make a PCB), I prefer LTspice.

But, if intending to build an actual PCB/real-circuit, I prefer doing schematics/pcb’s in Kicad.

I ran into a problem with NGspice/kicad when wanting to simulate an Audio Amp using a WAV file as the input source.
WAV file works great in LTspice (zero problems) but, NGspice does not appear to like WAV files (or renamed to .TXT…etc).

I discovered a simple way to use the circuit in Kicad: generate the Netlist file but select ‘Spice’ as the file type and it generates a xxx.CIR

Then, simply open the .CIR in LTspice. Thus, no need to make the circuit in LTspice.

2 Likes

Cool. If you are doing this repeatedly, you can fill in the location of the LTSpice EXE file and launch the simulation straight from KiCad. A similar thing is shown at this timestamped video:
https://www.youtube.com/watch?v=90Z6ffxzDz8&t=21m57s

2 Likes

Thank you! It worked :grinning:

1 Like

There is now an experimental ngspice (pre-compiled for MS Windows) that reads and writes wave audio files.

Please check http://ngspice.sourceforge.net/download.html#wav for downloading. For now this is discrete ngspice only. A example is given in post 230 at https://www.diyaudio.com/forums/software-tools/331656-installing-using-ngspice-opensource-simulator-23.html as https://www.diyaudio.com/forums/attachments/software-tools/865262d1596379259-installing-using-ngspice-opensource-simulator-passlabf6-diyaudio-5-zip how to use it in conjunction with KiCad.

A short intro to the input and output formats is found in http://gareus.org/oss/spicesound/start

1 Like