Kicad 6.0 & ngspice 31

Hello :slight_smile:

I’m under the impression that Kicad-6.0 should come with ngspice-35; mine comes with 31. Is this correct?

I ask due to ngspice simulation problems regarding component models (sub-circuit etc). I have exhausted my ability; questions must be asked.

I have listed my system information below.

Kicad-6.0 -

Circuit: KiCad schematic
******
** ngspice-31 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Sun Oct 27 09:07:06 UTC 2019
******

NAME=“Ubuntu”
VERSION=“20.04.4 LTS (Focal Fossa)”

KiCad 6.0.2 for Windows is bundled with ngspice-36.

ngspice-31 has been the standard in Ubuntu 20.04.

Did you try recent ppa (https://launchpad.net/~kicad/+archive/ubuntu/kicad-6.0-releases)?

Perhaps the packager for KiCad PPA on Ubuntu (J.-S. Reynaud) does not create his own new ngspice, but does use the existing one.

You may compile ngspice (its shared library) yourself.

3 Likes

Hi again Holger,

I tried the ppa from your last message, and my spice version remains at 31. If this is not restricting my simulations, then it is not a problem.

May you help me with a simulation error please? I am using a TI spice model THS4631. With previous help from you Holger, I have managed to get a similar model working from TI (THS3001). So, I believe my simulation is set up properly for Pspice models. I have attached the simulation error below, and my circuit’s netlist.

##############################
ERROR:
##############################

Circuit: KiCad schematic
Warning: Model issue on line 0 :
.model xu1.x_esd_in:aesd_sw aswitch(r_on=50 r_off=1e12 cntl_on=500e-3 cn ...
Unknown model type aswitch - ignored
Error on line 0 :
a.xu1.x_esd_in.as1 %vd xu1.esdn 10v %gd 10v xu1.esdn xu1.x_esd_in:aesd_sw
MIF-ERROR - unable to find definition of model xu1.x_esd_in:aesd_sw
Error on line 0 :
a.xu1.x_esd_in.as2 %vd xu1.esdp 10v %gd 10v xu1.esdp xu1.x_esd_in:aesd_sw
MIF-ERROR - unable to find definition of model xu1.x_esd_in:aesd_sw
Error on line 0 :
a.xu1.x_esd_in.as3 %vd 0 xu1.esdn %gd xu1.esdn 0 xu1.x_esd_in:aesd_sw
MIF-ERROR - unable to find definition of model xu1.x_esd_in:aesd_sw
Error on line 0 :
a.xu1.x_esd_in.as4 %vd 0 xu1.esdp %gd xu1.esdp 0 xu1.x_esd_in:aesd_sw
MIF-ERROR - unable to find definition of model xu1.x_esd_in:aesd_sw
Warning: Model issue on line 0 :
.model xu1.x_esd_out:aesd_sw aswitch(r_on=50 r_off=1e12 cntl_on=500e-3 c ...
Unknown model type aswitch - ignored
Error on line 0 :
a.xu1.x_esd_out.as1 %vd net-_r4-pad2_ 10v %gd 10v net-_r4-pad2_ xu1.x_esd_out:aesd_sw
MIF-ERROR - unable to find definition of model xu1.x_esd_out:aesd_sw
Error on line 0 :
a.xu1.x_esd_out.as2 %vd 0 net-_r4-pad2_ %gd net-_r4-pad2_ 0 xu1.x_esd_out:aesd_sw
MIF-ERROR - unable to find definition of model xu1.x_esd_out:aesd_sw
Warning: Model issue on line 0 :
.model xu1.x_sw_ol:aol_sw aswitch(r_on=1e-3 r_off=1e9 cntl_on=900e-3 cnt ...
Unknown model type aswitch - ignored
Error on line 0 :
a.xu1.x_sw_ol.as1 %vd xu1.sw_ol_ths4631 xu1.mid %gd xu1.n1475893 xu1.n1475923 xu1.x_sw_ol:aol_sw
MIF-ERROR - unable to find definition of model xu1.x_sw_ol:aol_sw
Warning: Model issue on line 0 :
.model xu1.x_sw_or:aor_sw aswitch(r_on=10e-3 r_off=1e9 cntl_on=10e-3 cnt ...
Unknown model type aswitch - ignored
Error on line 0 :
a.xu1.x_sw_or.as1 %vd xu1.clamp xu1.n166817 %gd xu1.n166817 xu1.clamp xu1.x_sw_or:aor_sw
MIF-ERROR - unable to find definition of model xu1.x_sw_or:aor_sw
Error on line 0 :
a.xu1.x_sw_or.as2 %vd xu1.n166377 xu1.clamp %gd xu1.clamp xu1.n166377 xu1.x_sw_or:aor_sw
MIF-ERROR - unable to find definition of model xu1.x_sw_or:aor_sw
Reducing trtol to 1 for xspice 'A' devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Note: Starting dynamic gmin stepping
Trying gmin =   1.0000E-03 Note: One successful gmin step
Trying gmin =   1.0000E-04 Note: One successful gmin step
Trying gmin =   1.0000E-05 Note: One successful gmin step
Trying gmin =   1.0000E-06 Note: One successful gmin step
Trying gmin =   1.0000E-07 Note: One successful gmin step
Trying gmin =   1.0000E-08 Note: One successful gmin step
Trying gmin =   1.0000E-09 Note: One successful gmin step
Trying gmin =   1.0000E-10 Note: One successful gmin step
Trying gmin =   1.0000E-11 Note: One successful gmin step
Trying gmin =   1.0000E-12 Note: One successful gmin step
Trying gmin =   1.0000E-12 Note: One successful gmin step
Note: Dynamic gmin stepping completed
Initial Transient Solution
--------------------------
Node                                   Voltage
----                                   -------
net-_r1-pad1_                                2
net-_r2-pad2_                                2
net-_r3-pad2_                          2.00027
net-_r4-pad2_                          6.00079
xu1.mid                                     10
xu1.clamp                              6.52903
xu1.n42834                                  10
xu1.n44757                                  10
xu1.n45892                                  10
xu1.n45974                                  10
xu1.n56659                                  10
xu1.n56721                                  10
xu1.n61579                             6.52903
xu1.n68747                                  10
xu1.n68594                                  10
xu1.sw_ol_ths4631                           10
xu1.n1475893                           58.0176
xu1.n1475923                           13.8053
xu1.n1468953                            14.446
xu1.psrp                               10.0002
xu1.n1464296                           9.66128
xu1.n1464326                           9.99985
xu1.n1466445                          -5.33998
xu1.n706294                            9.99994
xu1.n406634                                 20
xu1.n317950                                 10
xu1.n406794                         1.0018e-05
xu1.n1475549                           58.0235
xu1.n1471231                           6.52903
xu1.n31014                             2.00001
xu1.n35813                                18.5
xu1.n38096                             1.50001
xu1.esdn                               2.00027
xu1.esdp                                     2
xu1.vclp                               6.52903
xu1.vimon                              14.6006
xu1.vout_s                             6.00079
xu1.n91498                             6.52903
xu1.cl_clamp                           6.52903
xu1.n112292                            6.00079
xu1.n1475637                           6.00079
xu1.n73852                             -17.671
xu1.n55875                             -17.671
xu1.n55050                              30.729
xu1.n56119                              30.729
xu1.vsense                             6.52903
xu1.claw_clamp                         6.52903
xu1.n886969                            6.52903
xu1.cmrr_2                             1.99977
xu1.n10561                             1.99991
xu1.vcc_b                                   20
10v                                         20
xu1.vee_b                           1.0008e-05
xu1.n25816                                   2
xu1.n11984                             1.99977
xu1.vcc_clp                               18.5
xu1.vee_clp                            1.50002
xu1.n1475563                           58.0235
xu1.n1471245                           6.52903
xu1.n06456                                   2
xu1.n11991                             2.00027
xu1.n28602                             2.00001
xu1.n30136                                  17
xu1.n30913                             2.00001
xu1.n35669                                18.5
xu1.n38050                             1.50001
xu1.n42663                                  10
xu1.n44799                                  10
xu1.n50645                                 108
xu1.n45856                                  10
xu1.n45986                                  10
xu1.n48550                                 -85
xu1.n56919                                  65
xu1.n1475627                           58.0209
xu1.n56635                                  10
xu1.n56733                                  10
xu1.n56891                                 -45
xu1.oln                                     10
xu1.olp                                     10
xu1.n69264                                  10
xu1.n1475555                           58.0235
xu1.aolnet                             9.97428
xu1.n110431                            14.6006
xu1.x_aol_1.g1_int1               -2.57108e-08
xu1.x_aol_2.g1_int1               -3.47096e-06
xu1.x_clawn.g1_int1                     0.0015
xu1.x_clawp.g1_int1                     0.0015
xu1.x_claw_amp.gvo+_int1                     0
xu1.x_claw_amp.gvo-_int1                     0
xu1.x_claw_src.g1_int1            -5.77316e-13
xu1.x_cl_amp.gvo+_int1                       0
xu1.x_cl_amp.gvo-_int1                       0
xu1.x_cl_src.g1_int1                         0
xu1.x_e_n.7                           0.833786
xu1.x_e_n.8                           0.833786
xu1.x_e_n.3                                  0
xu1.x_e_n.6                                  0
xu1.x_e_n.4                                  0
xu1.x_e_n.5                                  0
xu1.x_gr_amp.gvo+_int1                       0
xu1.x_gr_amp.gvo-_int1                       0
xu1.x_gr_src.g1_int1                         0
xu1.n166377                            -17.671
xu1.n166817                             30.729
xu1.x_iq_n.g1_int1                           0
xu1.x_iq_p.g1_int1                  0.00460061
xu1.x_i_nn.3                                 0
xu1.x_i_nn.5                                 0
xu1.x_i_np.3                                 0
xu1.x_i_np.5                                 0
xu1.x_ol_sense.gsw+_int1                     0
xu1.x_vcm_clamp.g1_int1               -7.99998
xu1.x_vos_drift.e1_int1              -9.11e-05
xu1.x_zo_src.g1_int1                   48.0235
10v_neg                                      0
b.xu1.x_zo_src.bg1#branch                    0
b.xu1.x_vos_drift.be1#branch                 0
b.xu1.x_vcm_clamp.bg1#branch                 0
b.xu1.x_ol_sense.bgsw+#branch                0
b.xu1.x_iq_p.bg1#branch                      0
b.xu1.x_iq_n.bg1#branch                      0
b.xu1.x_gr_src.bg1#branch                    0
b.xu1.x_gr_amp.bgvo-#branch                  0
b.xu1.x_gr_amp.bgvo+#branch                  0
b.xu1.x_cl_src.bg1#branch                    0
b.xu1.x_cl_amp.bgvo-#branch                  0
b.xu1.x_cl_amp.bgvo+#branch                  0
b.xu1.x_claw_src.bg1#branch                  0
b.xu1.x_claw_amp.bgvo-#branch                0
b.xu1.x_claw_amp.bgvo+#branch                0
b.xu1.x_clawp.bg1#branch                     0
b.xu1.x_clawn.bg1#branch                     0
b.xu1.x_aol_2.bg1#branch                     0
b.xu1.x_aol_1.bg1#branch                     0
h.xu1.x_h3.h_h3#branch            -4.60061e-09
v.xu1.x_h3.vh_h3#branch            -0.00460061
h.xu1.x_h2.h_h2#branch                       0
v.xu1.x_h2.vh_h2#branch                      0
h.xu1.x_h1.h_h1#branch                       0
v.xu1.x_h1.vh_h1#branch                      0
e.xu1.x_vos_drift.e1#branch        2.75373e-13
e.xu1.x_i_np.e1#branch                       0
e.xu1.x_i_nn.e1#branch                       0
e.xu1.x_e_n.e3#branch              4.97246e-11
e.xu1.x_e_n.e2#branch                        0
e.xu1.x_e_n.e1#branch                        0
e.xu1.e_e6#branch                 -1.69216e-08
e.xu1.e_e3#branch                   3.9992e-09
e.xu1.e_e2#branch                            0
v1#branch                           -0.0161006
v2#branch                                    0
v3#branch                         -0.000199992
v.xu1.v_v_orp#branch                         0
v.xu1.v_v_orn#branch                         0
v.xu1.v_v_iscp#branch                 -9.8e-08
v.xu1.v_v_iscn#branch                  9.5e-08
v.xu1.v_v_grp#branch                  -5.5e-08
v.xu1.v_v_grn#branch                   5.5e-08
v.xu1.v_vcm_min#branch             7.99998e-09
v.xu1.v_vcm_max#branch            -6.99999e-09
 Reference value :  0.00000e+00
 Reference value :  2.80030e-04
 Reference value :  6.19616e-04
 Reference value :  9.70071e-04
No. of Data Rows : 5968

##########################################
NETLIST:
##########################################

.title KiCad schematic
.include "/home/tyler/Electronics/models/opamp/ths4631/ths4631_b.lib"
R2 Net-_R1-Pad1_ Net-_R2-Pad2_ 500
R1 Net-_R1-Pad1_ GND 10k
R4 Net-_R3-Pad2_ Net-_R4-Pad2_ 1k
XU1 Net-_R2-Pad2_ Net-_R3-Pad2_ 10v GND Net-_R4-Pad2_ THS4631
R5 Net-_R4-Pad2_ GND 10k
R3 GND Net-_R3-Pad2_ 500
V3 Net-_R1-Pad1_ GND dc 5 ac 1 sin(2 0.5 100k)
V2 GND 10v_neg dc 0
V1 10v GND dc 20
.end

Please fire away with feedback regarding how I construct my question; this is fairly verbose.

Thanks again in advance; seriously appreciate the help!

Cheers,
Tyler

Did you set
Inspect → Simulator → Sim Parameters → Compatibility Mode PSPICE and LTSPICE
?

The simulation is o.k. with ngspice-36.

Hello,

My settings were not originally as you have specified, however, the error did not change after I had adjusted them to mode “PSPICE & LTSPICE”.

I’m having similar spice problems with other models as well. I guess compiling ngspice myself will no longer allow me to use kicad as a GUI interface?

Is it possible that kicad/ngspice is not installed properly? Is there a way of verifying this?

Thanks again!

It seems that ngspice is not installed properly. The XSPICE code models are missing.

Are you familiar with files and folders in a Linux system? If yes, search for libngspice0 (the simulator) and analog.cm (one of the *.cm code models) and post their paths here.

Unfortunately it is a little tricky to do remote maintenance on a Linux system (for me).

It is no problem to compile and use shared ngspice for the Eeschma GUI. The only requirement is that after compiling libngspice0 (the simulator) and analog.cm (and the other code model files *.cm) are at their right locations in the file system.

Good morning,

I have done some file hunting :smiley: . This is indeed difficult to do via forums.

##########################################################
METHOD 1)
PACKAGE INSTALLER: APT
Search apt packages: “sudo apt search ngspice”
output:
Sorting… Done
Full Text Search… Done
chiark-scripts/focal,focal 6.1.2 all
chiark system administration scripts

gwave/focal 20190116-2 amd64
  waveform viewer eg for spice simulators

libngspice0/focal,now 31.3-2 amd64 [installed,automatic]
  Spice circuit simulator - library

libngspice0-dev/focal 31.3-2 amd64
  Spice circuit simulator - development files for libngspice

ngspice/focal 31.3-2 amd64
  Spice circuit simulator

ngspice-dev/focal 31.3-2 amd64
  Spice circuit simulator - development files for ngspice and tclspice

ngspice-doc/focal,focal 31.3-2 all
  Documentation for the NGspice circuit simulator

tclspice/focal 31.3-2 amd64
  NGSpice library for Tcl

##########################################################
METHOD 2)
PACKAGE LOW LEVEL TOOL: DPKG
libngspice0
Command: “dpkg -L libngspice0”
Output:
/usr/share/doc/libngspice0
/usr/share/doc/libngspice0/changelog.Debian.gz
/usr/share/doc/libngspice0/copyright
/usr/lib/x86_64-linux-gnu/libngspice.so.0

##########################################################
METHOD 3)
SEARCH SYSTEM FOR FILE:
analog.cm
Command: “`sudo find / -iname *.cm”
Output:
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied

“The system could not find anything”

##########################################################
##########################################################
INSTALLING NGSPICE:
I have also installed ngspice (sudo apt installl ngspice). I did this in an attempt to fix the kicad simulator error; which it may or may not have done. The error is now, however, gone.

##########################################################
REPEATING METHOD 3)
analog.cm:
I searched my machine using “sudo find / -iname *.cm” , and received the following output.
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
/usr/lib/x86_64-linux-gnu/ngspice/table.cm
/usr/lib/x86_64-linux-gnu/ngspice/digital.cm
/usr/lib/x86_64-linux-gnu/ngspice/spice2poly.cm
/usr/lib/x86_64-linux-gnu/ngspice/xtraevt.cm
/usr/lib/x86_64-linux-gnu/ngspice/xtradev.cm
/usr/lib/x86_64-linux-gnu/ngspice/analog.cm

However, after running “sudo apt-get remove --auto-remove ngspice” I receive the output,
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied

So, I believe my external installation of ngspice provided the analog.cm files, that were otherwise not installed via kicad? Where this fixed the simulator or mearly suppressed the error, I don’t know.

I could install ngspice manually to work with Eeschma GUI with clear instructions.

Thank you for your help! :slight_smile:

Concerning ngspice update in Ubuntu 20.04 (Focal Fossa):

There is a ppa maintained by Nico Onorata ( https://launchpad.net/~nicola-onorata/+archive/ubuntu/desktop/+index?batch=75&memo=75&start=75 ), which offers ngspice-36 for 20.04.

I do not know anything about its quality, there is a warning that using the ppa may break your system. Maybe some Ubuntu user can offer a better judgement.

1 Like

Thank you for the alternative, however, I wish to avoid manually changing how kicad works with ngspice if it can be avoided; I’m currently writing my masters thesis :smiley: .

Now I think my main enemy is distinguishing the difference between errors caused by the simulator, and by my own doing. May I send another error :smiley: .

IR2125.lib

#############################################################
Simulator Error:

Error: bad syntax in line 225
g_err_up err_vcc err   cur={ table(v(err_set_del,com),0,0,10m,1)*100u*table(v(err_vcc,err),0,0,100m,1)}
Error: ngspice.dll cannot recover and awaits to be detached
******
** ngspice-31 shared library
** Creation Date: Sun Oct 27 09:07:06 UTC 2019
******
Error: there aren't any circuits loaded.
Error: vector time not found!
Error: vector time not found!
Error: vector time not found!
Error: vector time not found!

#############################################################
Netlist:

.title KiCad schematic
.include "/home/tyler/Electronics/models/diode/byg22d/BYG22D.LIB"
.include "/home/tyler/Electronics/models/icDriver/Model/IR2125.lib"
.include "/home/tyler/Electronics/models/mosfet/irf540n/irf540n.lib"
XU1 Net-_R3-Pad2_ GND INPUT VCC_DRIVER Net-_C1-Pad1_ Net-_C1-Pad2_ Net-_R2-Pad2_ Net-_R1-Pad1_ IR2125
V3 INPUT GND dc 5 ac 1 pulse(0 5 0.0 0.000000001 0.000000001 10m 20m)
V2 VCC_DRIVER GND dc 12
V1 VCC GND dc 35
R1 Net-_R1-Pad1_ GND 10k
XQ1 VCC Net-_Q1-Pad2_ Net-_C1-Pad2_ irf540n
R3 Net-_Q1-Pad2_ Net-_R3-Pad2_ 5
DU2 Net-_C1-Pad1_ VCC_DRIVER byg22d
R4 Net-_C1-Pad2_ GND 10k
R2 GND Net-_R2-Pad2_ 10k
C1 Net-_C1-Pad1_ Net-_C1-Pad2_ 0.1u
.end

#############################################################
Comment:

From what I understand myself, the model is connected correctly. I have made the schematic symbol myself, so could there be problems with how I have defined the pins that causes this error? Or is this related to my ngspice version?

Again,
Thank you for your patience, and effort!

Unfortunately the Infineon Website does not allow me to download the model.

Another issue: When you publish a script, source code or the text output of any software here, you will need to mark it as ‘preformatted text’ (Ctrl + Shift + C). Otherwise the web page editor mangles the text, some extra characters become unreadable. Could you please edit your previous post?

Oh,
I see the same problem. I have attached the zipped file for the component; not sure if this is allowed or not.

Cheers for the feedback; it all of a sudden looks so much nicer :smiley: .

ir2125.zip (6.6 KB)

The Infineon model of the IR2125 uses constructs that are not compatible with ngspice (and some other popular simulators). Even ngspice-36 will not do.

Unfortunately there is no immediate simple solution for this issue.

I will start looking into this, but no warranty for fast feedback.

2 Likes

Oh ok, that is not a problem; I guess they loose a customer then :smiley: .

Thank you for the help! Saved me a good deal of time!

Best of luck!

1 Like

I’m confused. The Infineon website with the broken link claims it’s a Pspice model, but the .LIB you posted says it’s a SIMetrix model. Did you get the model from the Infineon website before the link went dead or did you find this model elsewhere?

Hello,
I’m sure that I downloaded it from the now broken link; I’m very certain that it was atleast from the official Infineon website. I will check ASAP, and then edit this message if I thought wrong.

Thank you for your effort! I’m really enjoying kicad! :grin:

It’s possible the ZIP file includes several model types. Is there anyway you can post the original ZIP file that you downloaded from their site? It says it’s called this:
Infineon-IR2125-PSpice-SimulationModels-v01_01-EN.zip

By the way, I talked with Infineon Live Chat Support and all they did was redirect me here:
https://www.infineon.com/cms/en/about-infineon/company/contacts/product-support-form/

Good morning Ste,

I found the original download; perks of having a messy PC :wink: . Would love to help out in any other way :slight_smile: .

Infineon-IR2125-PSpice-SimulationModels-v01_01-EN.zip (1.2 MB)

Thanks for that. However, I think it’s a dead end. Sorry. It seems like the readme.txt confirms that this model was only tested on SIMetrix. You can try downloading the free version of that software and run Infineon’s demo circuit also found in the same ZIP file. SIMetrix/SIMPLIS Elements | SIMPLIS

Other options are waiting for Holger to maybe figure out a patch for the VALUE={TABLE ...} construct, choosing a different part/manufacturer which provides a compatible model, or reaching out to Infineon support to ask if they can provide a different model for a specific simulator.

Attached you will find a patch model of the IR2125 for ngspice.

There are now no errors and only a few warnings (to be ignored).

I do not have a circuit available, so cannot test the model.

IR2125_ng.zip (6.8 KB)

3 Likes

3 posts were split to a new topic: Install ngspuce on Fedora