File name or pin updates, fatal bug, KiCad and/or ngspice

@holger Herr Holger, I keep running into some bugs that indicates something is very wrong either with the file name or with some kind of automatic updates of the SPICE fields in the symbols. I hope you are aware of some of these issues or you can understand where is the problem, and maybe you can point me in the right direction.

I attached here two examples. Everything is identical between them, except for the name of the ngspice file model: one is named X1-DIG_FLIPD_SN74LVC2G74DCUR.sp, the other one X1_DIG_FLIPD_SN74LVC2G74DCUR.sp (a “minus” character was replaced by an underline character).

For reasons I cannot understand, the project using the minus character in the file name automatically messed-up the pin mapping in the symbol Sim.Pins = 1=2 2=1 3=7 4=6 5=5 6=3 7=4 8=8 instead of Sim.Pins = 1=1 2=2 3=3 4=4 5=5 6=6 7=7 8=8

What is even worse, the ngspice model clearly has the pins mapped one to one without any compromise. Even assuming there is some kind or automatic re-annotation that I am not aware of, still I cannot explain why the pin order is messed-up, not keeping the normal one-to-one matching annotation.

* PINSEQ:               1               = NULL FORBIDDEN, VECTOR NO, digital, input clk
*                       | 2             = NULL FORBIDDEN, VECTOR NO, digital, input data
*                       | | 3           = NULL FORBIDDEN, VECTOR NO, digital, output inverted data
*                       | | | 4         = NULL FORBIDDEN, VECTOR NO, analog, local floating V- reference
*                       | | | | 5       = NULL FORBIDDEN, VECTOR NO, digital, output data
*                       | | | | | 6     = NULL FORBIDDEN, VECTOR NO, digital, input asynch. reset
*                       | | | | | | 7   = NULL FORBIDDEN, VECTOR NO, digital, input asynch. set
*                       | | | | | | | 8 = NULL FORBIDDEN, VECTOR NO, analog, local floating V+ reference
*                       | | | | | | | |
.SUBCKT SN74LVC2G74DCUR 1 2 3 4 5 6 7 8 PARAMS:

The circuit works as expected when the mapping is not changed, but when the pins are scrambled I get an error message Fatal error: instance b.x2.b_qn is a shorted ASRC

I have no idea how is possible to end up with the pins scrambled automatically in this order:

And finally, my pulse source V4 is defined y1=0 y2=8 td=1u tr=29u tf=29u tw=1u per=60u but for some very weird reason I will end up with y1=0 y2=1 td=2n tr=2n tf=2n tw=50n per=100n, my ngspice definition is replaced automatically! I an not quite sure why, I suspect that when I use the schematic menu Tools > Update Symbols from Library the custom paramer values are automatically replaced by some hidded default values.

NOTE: any automatic changes in the ngspice-specific fields executed by by the schematic or symbol editor must be treated as a fatal bug! Any SPICE-specific stuff must be understood as something absolutely different from symbol graphical stuff (pins, lines, positions and colors).

If a field that is called Sim.Something is automatically messed-up by the schematic or the symbol editor, there will be zero chance to ever run simulations in KiCad.
1_Logic_Driver.7z (1.2 MB)
2_Logic_Driver.7z (1.2 MB)

EDIT:
I figured out KiCad is not really providing a self-contained archive of a project, and a demo circuit can end up with missing files, especially model files. I updated here the test files with some missing models. Unfortunately, even so, one must edit the declared location of the model file that is embedded in the symbols. KiCad is not smart enough to look first in the project directory for the needed model files. This is the best I can do under these circumstances. Also note, this is the demo from Linux, the path in the models must be converted accordingly for your operating system.
test_002.tar.gz (1.3 MB)

Somehow this sentence in bold is nonsense, as you might see in Simulation examples for KiCad/Eeschema/ngspice or Simulation examples for KiCad8/KiCad9/Eeschema/ngspice .

I have taken your example test_002.tar.gz. You have forced me to re-attach all models, as the paths have been incompatible. I have done this by
Double Click on symbol to open ‘Symbol Properties’ window → Simulation model → Spice model from file → select file → OK -->OK.
This has to be done for each symbol (device) with model attached.

Then select tran ‘Edit analysis tab’ and set time step not to 10u but 10n, and run the simulation, with a result like your plot above (with better time step resolution).

So what might be your problem right now? I cannot reproduce it.

I agree with you, I cannot provide a self-contained project. We need to make all kind of adjustments for the project to work, and that is not very helpful. Other simulators are automatically searching the project directory for missing stuff, no need to mess around. It is quite trivial to provide a self-contained project.

I am afraid you misunderstood. See this pin order Sim.Pins 1=1 2=2 3=3 4=4 5=5 6=6 7=7 8=8?

Later on, the same part X2, the same symbol, the same SPICE model showed me a new pin order Sim.Pins 1=1 2=2 3=3 4=4 5=5 6=6 7=7 8=8.

I have no idea how the pin declaration got messed up. How I detected this issue? My test program worked without problems for a while. When I got back to this test, it stopped working.

At one point I suspected some bugs with “-” in the file name and/or model name. I do not recall this issue popping up with the model where I removed “-” and replaced it with “_” all over.

Another suspicion is that changes to the symbols and model are updated “live” between KiCad and the ngspice simulator, but not always the right way. I kept working with the schematic and I made changes that I used to validate through simulation. Aafter saving my project files and closing the project something was not quite updated on the disk (bad file names?).

I encountered the same issues with Linux and with Windows. Here is a bug from Windows: when I searched for some file name with only “underline” in name, it returned a result with a “minus” in name, something unheard of (until now)!

There is nothing else I can suspect. Maybe there are bigger issues at play, with bugs affecting not only KiCad, but also the operating systems.

Of course you can provide a self-contained project for having somebody else reproducing your project issues.

I do not misunderstand anything: you have provided a project, after I modified it to get it up and running there has been no issue.

Your pin declaration is probably messed up due to some action on your side. If you cannot reproduce that and describe it here, how should one offer any support?

Same with the pulse source data. You have done something to change its parameters (from your data to default) by some action you have not described here (delete the symbol and put it again for example).

I have never experienced such a search bug in Windows 10, even with your data - and _ will be treated correctly during a search.

If you want to have the search for files being improved, please think about a short specification and put it to the wishlist at Issues · KiCad / KiCad Source Code / kicad · GitLab .