Simulation examples for KiCad/Eeschema/ngspice

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

set ngbehavior=ltpsa
into file spinit is o.k.

But now: remove set ngbehavior=ltpsa from the Eeschma window, remove it from the file with .subckt.

Best: delete the project QEI_public. Download it again and open it in KiCad/Eeschema.


Thank you.

Does anyone have issues with the examples and KiCad 7.0.1 ? I tried the Montecarlo (MC3) examples and i can’t click run. When i go into settings to load from schematics it is empty. But the commands can be seen in the netlist. If i force it to run using the transient tab with same settings as in schematic i get the error:

Background thread stopped with timeout = 0
Note: Compatibility modes selected: ps lt a
Circuit: KiCad schematic
Error on line 20 or its substitute:
v2 /rand2 0 trrandom( )
parameter value out of range or the wrong type
Error: circuit not parsed.

Is it just me?

Disclaimer: I am pretty new to KiCad. I have made a schematic and simulated a diplexer and want to test component variation.

The examples have not yet been tested with KiCad 7. I will wait for KiCad 7.0.2 to do so.

Your error message indicates that there is a bug in Eeschema, as it does not transfer a correct trrandom to ngspice. There should be some parameters inside of the brackets.

Unfortunately i get the same errors in 7.0.2 with MC3.

Is there any script to analyze Montecarlo simulations?

If not i am thinking of making an eye-diagram analyzer for the MC3.

This is a bug in V7 of KiCad. I will provide a bug report. The automatic transfer from V6 to V7 is buggy.

I needed to change 2 things in V7:
On the Eeschama canvas: Change the text window, sim command into the first row, .include path as absolute path. For me it is:

.TRAN 0.02m 'ttime'
.param ttime = 1200m
.param varia=100
.include D:/Spice_general/KiCad-700/examples/MC3/script5.txt

Edit the models for V1, V2 (the trrandom voltage sources): Double click onto the symbol of V1, → Simulation Model… → Built-in Spice model: type Random normal, mean 0, stddev 0.05, dt ‘ttime/varia’, td 0 → OK → OK. Do the same with V2.

Then the simulation will run, internally, but also with external ngspice.

1 Like

I have added another switch power supply, a hybrid switched capacitor converter, multiplying 28 V to 700 V. It uses a modern GaN transitor and SiC Schottky diodes. Its idea stems from Design and Evaluation of Hybrid Switched Capacitor Converters for High Voltage High Power Density Applications. (Conference) | OSTI.GOV.

The circuit is still made with KiCad 6.0.11.

2 Likes

Added a Schmitt trigger relaxation oscillator with 40106.
The circuit is made with KiCad 6.0.11.

Potentiometer / potmeter example made by Holger.
This simulation has the setpoints in it, and that is a new feature of KiCad V7.99.
Recently, on Friday the 13th of October 2023, Holger stated a new thread for simulations in the new KiCad version.

https://forum.kicad.info/uploads/short-url/g4LdFEdtGQYqCCe0uziOp1CZBNO.7z

https://forum.kicad.info/uploads/short-url/jEl4zfMijZdNZp3UtngBw3o4h3n.7z

First posted in this topic:

Any reason CMOS555_3.7z doesn’t work the same as shown with KiCAD 7 or the netlist into DuSpice using ngspice 42plus?

What is the error message of the failing simulation?