There is a problem with the latest KiCAD 5.99 export spice netlist

Edit:

2021.7.9 - After reconfirmation, this is not a bug, but each sub-component must be manually set to the same spice configuration, because kicad will not automatically process them into the same configuration.

— Previous description —

There is a problem with the latest KiCAD 5.99 export spice netlist. including the version downloaded yesterday.

I uploaded an example. In this example, KiCAD cannot always generate the correct netlist. It discards the external model file (missing .include) and ignores the spice setting for LMV358.

But it doesn’t always make mistakes, and an occasional edit will produce the correct results, but you have to try your luck.

=============================
Windows 10 64bit 21H1 (Professional)

FilesTestLMV358_PspiceModel.zip (135.0 KB) encoding is UTF-8.

Edit:

Note that the model file name forgot to restore, please modify it manually.

Hi All,

I am sure I found a bug.

For some reason, in the spice setting of the component, the model file cannot be loaded, causing all the spice information related to it to be discarded.

If this model file is clearly pointed out in a text (although it has been set in spice in the component settings, it is invalid), it will not go wrong.

Edit: Sorry, this measure is no longer valid after some changes have been made.

In your zip file the model is located in
models/LMV358.lib
but not in
models/LMV358.cir
as your posted picture suggests

Hi holger,

Thanks Reply.

Sorry, i changed the file name (including various manual modifications) in various tests to find the cause of the bug, and forgot to restore it. But the bug is real, and the cause has been found.

Another remark:

When you put the command
set ngbehavior=kips
into the .control section, it will not become effective. It has to be put into the user definied initialization file .spiceinit (or spice.rc, as an alternative name).

Reason is that this command has to be set before the circuit is loaded and parsed. The PSPICE compatibility checks and modifications are done during circuit loading. The .control section will become active only later, when the circuit is already loaded.

I will have a look at your project later, because now I do not have access to KiCad 5.99.

Edit:
I see the same problem: even when I load the spice model, it is not recognized in the spice netlist.

Please provide a bug report at https://gitlab.com/kicad/code/kicad/-/issues, where the dev are listening.

No bug here: the schematic is just incorrect:
the op amp has 2 units (of 3) in schematic.
One has the spice model set (unit A), and the other has no model (unit C), that is a kind of model.
Moreover, one unit is missing (unit B). It can be needed depending on the kind of simulation.

One cannot have 2 different info: one for a unit one other for unit C, therefore 2 different models.
Kicad cannot know what is the right info.

Simulation is not an approximative thing.

I tried the .spiceinit file and it made ngspice.exe work very well.

But after I removed the set ngbehavior=kips in KiCAD, no matter how I changed the content (including restoring it), I couldn’t export the correct spice netlist. :confounded:

I don’t know why KiCAD can output the results correctly sometimes. I don’t know what conditions are triggered to make this happen.

The model file has stated that there is only one unit, as long as the pin assignment is correct, it can work, it has been verified, and there is no abnormality when you are lucky.

After testing more than a hundred times, I guessed that KiCAD did not get a correct confirmation from the dynamic library of ngspice, so it discarded the part that was considered wrong.

But ngspice’s connection library can occasionally return a signal indicating OK, so KiCAD will correctly generate a spice netlist. I just don’t understand why this happens.

The bug has been reported

https://gitlab.com/kicad/code/kicad/-/issues/8758

A similar issue has been discussed in https://gitlab.com/kicad/code/kicad/-/issues/8518.

For now it is safe only to add the spice model to all three units. It does work also when I added it to unit U1C in addition to unit U1A.

@holger @jp-charras

After I replaced the ordinary op amp symbol with the op amp symbol of the simulation library, there was no error anymore.

So, do circuit diagrams and simulation diagrams have to be drawn separately? I think that as long as the model file is correct, the ordinary symbol library can be handled correctly as a spice component.

Because the op amp pins of the simulation library are different from the real LMV358, it will be very troublesome if KiCAD cannot handle this conversion.

KiCAD is foremost a tool to design PCBs. Therefore the symbols and footprints of the LVM358 contain the full IC in 3 units: 2 OpAmp- and 1 Power-Unit.

The typical vendor Spice model contains a single OpAmp only.

To bridge this gap, some user action is required. Please see http://ngspice.sourceforge.net/ngspice-eeschema.html#multi how to handle this issue.

You should either place all three units into your circuit, as you do when soldering the device onto the PCB, even if one OpAmp remanes unconnected (One should ask themselves, if this is allowed), and then (at least for now) add the spice model to all three units, or select a generic OpAmp, if Eeschema is mainly used as schematic entry for ngspice.

1 Like

This is new knowledge for me. I will try it tomorrow and hope to succeed. thank you very much!

@holger @jp-charras

Hi all,

I re-verified that the same model file should be used for the separate parts of the component and it will not cause an error. Because KiCAD does not automatically associate the relationship between the separated parts of the component and the spice model file, each sub-component needs to be manually configured to the same settings, including the model file.

This is really not a bug, I’ll report it again.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.