Kicad 7 not saving simulation model and crashing

Model Name: Mac mini
Model Identifier: Macmini8,1
Processor Name: 6-Core Intel Core i7
Processor Speed: 3.2 GHz
Number of Processors: 1
Total Number of Cores: 6
L2 Cache (per Core): 256 KB
L3 Cache: 12 MB
Hyper-Threading Technology: Enabled
Memory: 16 GB
System Firmware Version: 1715. (iBridge: 19.16.10744.0.0,0)
OS Loader Version: 540.80.2~11

macOS Monterey 12.2.1

Steps to recreate:

Create custom symbol in user-defined library from Q-NJFET-DGS and save as LSK170.

New symbol is first to be added to schematic.

We have a spice model file called LSK170.lib, containing models derived from an LTSpice installation.

The spice file has three ‘.model’ definitions for LSK170A, LSK170B and LSK170C.

Edit symbol with E and hit the ‘Simulation Model…’ button.

Select radio button for SPICE model from file. Browse to file with folder button, the three models appear in the dropdown and I select LSK170B then click OK, and then OK out of the symbol editor.

If I then attempt to edit the symbol again, KiCad crashes immediately. If I save the schematic and exit out gracefully, restart KiCad and edit the symbol, my Spice file setting has not been saved, it’s completely blank again. The same happens if I try to associate the Spice model with the corresponding symbol in the library, it simply crashes out or fails to save the spice model.

I tried a different file path for the spice file that wasn’t on iCloud drive and didn’t contain spaces, but that made no difference.

Frustrated that I cannot seem to make this work at all, I had hoped to be able to dispense with LTSpice and spare myself from having to manually copy the schematic to KiCad after modelling.

EDIT - this also happens on a Macbook Pro running Ventura with the same files.

The SPICE model file may be corrupted or incompatible with KiCad. You could try creating a new SPICE model file for the LSK170B model and see if that resolves the issue.

Two potential problem sources:

  • Create custom symbol in user-defined library from Q-NJFET-DGS and save as LSK170.
  • LSK170.lib

With the subcircuit model below I do not have any problems (using Q-NJFET-DGS, no personal library, MS Windows).

*   2SK170 SPICE MODEL MARCH 2007 Toshiba
*   J2SK170: 1, Drain,  2,Gate,  3,Source
.SUBCKT 2SK170 1 2 3
  Ld  1 4   1.1nH
  Ls  3 6   1.25nH
  Lg  2 5   0.78nH
  Rg  5 7   0.535Ohm
  Cds 1 3   0.0001pF
  Cgs 2 3   1.05pF
  Cgd 1 2   0.201pF
  Co  4 6   0.35092pF
  J1  4 7 6 2SK170

.model 2sk170 NJF(
+ Beta=59.86m Rs=4.151 Rd=4.151 Betatce=-.5 Lambda=1.923m
+ Vto=-.5024 Vtotc=-2.5m Cgd=20p M=.3805 Pb=.4746 Fc=.5
+ Cgs=25.48p Isr=84.77p Nr=2 Is=8.477p N=1 Xti=3 Alpha=10u Vk=100
+ Kf=111.3E-18 Af=1)
.ENDS 2SK170


Please post your LSK170.lib, if possible also your project here (as a zip file)

Aha! Thank you @holger - that one worked, well, it didn’t crash KiCad in any case, and it saved successfully.

I think I see the problem, this was the content of LSK170.lib:

* Copyright � 2000 Linear Technology Corporation.   All rights reserved.
* Mike Engelhardt
.model LSK170A NJF(Beta=37.86m Betatce=-0.5 Vto=-0.40 Vtotc=-2.5m Lambda=4.78m Is=35.58f N=1 Rd=11 Rs=7 Cgd=39.9p Cgs=40.7p Fc=0.5 M=790m Pb=0.98 Kf=0 Af=1 Mfg=Linear_Systems)
.model LSK170B NJF(Beta=35.07m Betatce=-0.5 Vto=-0.54 Vtotc=-2.5m Lambda=4.95m Is=27.62f N=1 Rd=8 Rs=7 Cgd=43.6p Cgs=43.6p Fc=0.5 M=890m Pb=1.2 Kf=0 Af=1 Mfg=Linear_Systems)
.model LSK170C NJF(Beta=27.85m Betatce=-0.5 Vto=0.80 Vtotc=-2.5m Lambda=12.24m Is=24.52f N=1 Rd=12 Rs=6 Cgd=42.2p Cgs=42.3p Fc=0.5 M=610m Pb=0.92 Kf=0 Af=1 Mfg=Linear_Systems)

so there was no SUBCKT included, only the .model that I picked out of one of the LTSpice files. I’ve never been able to quite fathom out the myriad model data structure standards in LTSpice and how they relate to the drop down menus etc - I could not find a SUBCKT for LSK170 defined anywhere yet somehow it still works, it must handle it internally somehow whereas KiCad doesn’t. LTSpice had a big file under a ‘cmp’ folder called Standard.jft where I got the model defs from.

At least if KiCad is consistent about what is needed in a model file, I know where I stand!

It doesn’t help when all you get from Linear Systems is the .model definition - so how am I meant to use that without the subckt def?

The offending parameter is


Just remove it, it is unnecessary, a LTSPICE trick to confuse others.

Still eeschema should not crash. There has been some discussion and issue report about this, I will check it.

This bug has been reported as fixed in KiCAD crashes when loading a spice library for simulation (#12425) · Issues · KiCad / KiCad Source Code / kicad · GitLab.

However I have re-opened the issue.

Sadly that didn’t help - it still crashed out even when I removed that parameter. There may be another ‘non-standard’ parameter there.

I ended up down the rabbit hole this afternoon educating myself about ‘models’ and ‘subcircuits’ - models being the original parameters for the fixed number of spice elements such as resistors, transistors that spice used to be limited to - and as such it sounds like I should be using the Built In element feature, manually setting what parameters I can using the dialog rather than trying to feed it a .model definition?

It’s not clear from the KiCad documentation whether .model defs are supported outside of the ‘built in’ option - maybe they are and I need to identify and remove what parameters are not being recognised. Some experimentation is in order.

Of course .model lines have to be supported.

There is something broken in KiCad, when trying to add a .model for JFETs.

Yes, I just tried it again reducing it down to one parameter (Beta) which surely should be known to ngspice for a jfet. Same result, it didn’t save and crashed out.

Editing title to remove ‘solved’ :slight_smile:

It is not ngspice, but KiCad/Eeschema.