Simulation examples for KiCad/Eeschema/ngspice

I have made some updates (for the Amp section for now):
Added circuit diagram pictures, added the compatibility flag ‘LTSPICE and PSPICE’, where appropriate.

1 Like

This is an incredible help for me as a total noob to simulation.

I have some basic questions:
1: you seem to be using both the “pspice” and the “Simulation_SPICE” libraries. Is that right?
2: how do you set the components up for simulation? Until now, my only solution was to build local libraries and add supplier models manually. Is there a smarter way?

Thanks.

To 1) That’s right.

To 2) No, there is currently no other way. It is being discussed among the developers to improve it. You will find a basic set, very complete lists and external links of models and model parameters here: Spice models and model parameters for ngspice circuit simulator

Thanks, that link was great.

Another question: is there any difference in using “pspice” vs. “Simulation_SPICE”? Anything to look out for?

That’s a matter of taste. I prefer the Simulation_Spice lib.

There is a new example on Monte Carlo simulation in this thread.

2 Likes

I believe that for the DIODE symbol, it’s best to avoid them both, if you want to create a PCB later (they are fine if you want to stay compatible with e.g. LTspice). Use a regular symbol from Diode library and specify alternate node sequence 2 1, or use some symbol installed with the content manager that has it specified already (like in Elektuur Style or Generic Symbol Library).

i love your work. Could you do a bit of explanation on it? It might be helpful. Thanks.

I have added some missing links to the origin of the circuits, containing also much more detailed explanations.

If there are questions concerning the circuits, please consult the links given. If there are questions on setting of one of the projects displayed here, please just post them here.

2 Likes

I have added a simple TRIAC circuit and a quartz crystal oscillator.

3 Likes

These are great. Thank you so much!

I am really pleased that this thread exists. Simulation examples are far harder to find for KiCad than for its PCBs

2 Likes

I am new to KiCad and I am very happy to find out these examples in this forum.

I tried the first one - LM3886-simple. I could open it smoothly in KiCad 6.0.4 (Linux). But when I simulated it, Vout stayed at -91.97V which I think was abnormal.

I also tried LM3886. The simulation result was similar with Vout stayed at an unrealistically high voltage.

Is there anything I just overlooked?

What is your ngspice version?

What’s the easiest way to check in Linux? Can you type something in the terminal to spit it out? Or does it say somewhere explicitly in the GUI? I only know how to check using version within a .control / .endc block, and wondering if there’s an easier way Linux users may be able to do it.

It should say in Help → About KiCad → Version on all operating systems, although maybe that’s only be true for relatively recent versions of ngspice?

1 Like

Below is the KiCad version info for your reference.

Application: KiCad Schematic Editor

Version: 6.0.4-6f826c9f35~116~ubuntu20.04.1, release build

Libraries:
wxWidgets 3.0.4
libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3

Platform: Linux 5.13.0-39-generic x86_64, 64 bit, Little endian, wxGTK, pantheon, x11

Build Info:
Date: Mar 21 2022 17:21:29
wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
Boost: 1.71.0
OCC: 7.5.2
Curl: 7.81.0
ngspice: 31
Compiler: GCC 9.4.0 with C++ ABI 1013

Build settings:
KICAD_USE_OCC=ON
KICAD_SPICE=ON

But somehow, I tweaked for a while and finally got LM3886 as well as the next example (Nelson Pass F5) working. Below is what I have done.

  1. I just notice that my ngspice is of version 3.1. It is the latest version available from Ubuntu packages. With this version, I cannot get the Nelson Pass F5 example to work because ngspice 3.1 does not recognize the VDMOS thermal model.

  2. So I follow the user manual of ngspice to compile ngspice 3.6. It took me some time to sort out all development libraries required because I did not specify to install development environments in my ElementaryOS. But finally, I can make it compiled.

  3. Furthermore in KiCad I have to choose compatibility with PSpice and LTSpice in order to make the LM3886 and PassF5 examples work.

Conclusion: Versions of KiCad and ngspice are important.

I will continue to try the other examples in the forum.

1 Like

Type /usr/local/bin/ngspice. It will show the version info as below.


** ngspice-36 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Copyright 2001-2020, The ngspice team.
** Please get your ngspice manual from Ngspice, the open source Spice circuit simulator - Documentation: manual and control flow
** Please file your bug-reports at Ngspice circuit simulator - Reporting Bugs
** Creation Date: Sat Apr 16 05:46:43 UTC 2022


1 Like

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.