Simulation examples for KiCad/Eeschema/ngspice

I have already requested and ask for adding ngspice-36 to the Ubuntu PPA KiCad distribution. The maintainer has agreed. So hopefully the next release (KiCad 6.0.5), due by end of April, will contain ngspice-36.

1 Like

Great news! Thanks, holger.

I have added another demo, a 200 V, 20 A full bridge.

Several oscillators are available now in the example section on the top of this thread:

  • Using dual LM555 for switching the frequency
  • Ring oscillators (either with 7404 inverters, CMOS inverters or inverters made from switches.
  • Wien bridge oscillator (with device parameter variations for Monte-Carlo simulation)
  • Simple phase shift oscillator with bipolar amplifier
  • Phase shift oscillator with OpAmp and frequency measurement
  • Quartz crystal oscillator
2 Likes

We have two more oscillators, an astable multivibrator and a comparator oscillator.

2 Likes

I have followed the Sallen-Key-Bandpass Filter example. It demonstrates the use of a Dual OpAmps chip. Details are provided here.

What I would like to do: develop a board (with simulation and PCB design) that contains several MCP6002 chips (again, dual op amp).

On a side note : I was able to adapt the Sallen-Key-Bandpass Filter example for the MCP6001 model, with a few adjustments detailed here.

The problem that I face is when I want a second Dual OpAmp chip on the scheme. Simulation gives me:

Too few parameters for subcircuit type “tl072c” (instance: xxu2)

It may have to do with the syntax of the TL072c: “XU1A …”. I tried to write a new model that just substitutes “XU1” for “XU2” (U2 being the reference of the second chip), with no success.

Any idea ?

How may I set a NGSPICE compatibility mode when using “external” simulation ?

Create a file .spiceinit (see ngspice manual chapter 16.6 for further info on its location) and add the line
set ngbehavior=ltpsa
into the file.

Attach the model to all three units of U2 (A, B, and C): Doubl Click on unit U2A → Spice Model… → Select file → TL072-dual.lib, TL072c, Subcircuit.
This has to be done for all three units of U2.

Create a file .spiceinit (see ngspice manual chapter 16.6 for further info on its location) and add the line
set ngbehavior=ltpsa
into the file.

@holger Thanks. I unsuccessfully tried this method with the .spiceinit located in the directory of my Kicad project. With .spiceinit located at the root of the user directory, it works (running Linux here).

Attach the model to all three units of U2 (A, B, and C): Doubl Click on unit U2A → Spice Model… → Select file → TL072-dual.lib, TL072c, Subcircuit.
This has to be done for all three units of U2.

Fantastic! Apparently, the issue was related to the fact that UnitB was missing. Thanks a lot @holger

2 posts were split to a new topic: KiCad and electromagnetic simulation

There is now available an example for digital simulation with 74xx gates. It has been done with KiCad 6.0.11 and ngspice-39. It is a sort of preview, as ngspice-39 is out just today and not yet available with the KiCad distributions (but may be installed on top of 6.0.11).

As I am not a circuit designer, I have “borrowed” this example from Quadrature Rotary encoder - Page 1. ngspice uses an event based purely digital simulation, the simulation time for this example is a mere 42 ms.

1 Like

An error occurs in QEI_public of Digital Simulation.

Information on your setup and on your simulation command is missing.

My guess:
Put set ngbehavior=ltpsa into .spiceinit.

How to solve the error?

Put

set ngbehavior=ltpsa

into .spiceinit.

Read about .spiceinit in the ngspice manual (see https://ngspice.sourceforge.io/docs/ngspice-39-manual.pdf), chapter 16.6.

I get an error though.
4
5

6
I get an error though.

9


11