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
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.
Information on your setup and on your simulation command is missing.
My guess:
Put set ngbehavior=ltpsa
into .spiceinit.
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.
I get an error though.
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.
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.