How to improve the KiCad - ngspice interface


#1

The current Eeschema - ngspice interface has been defined three years ago and has not seen any update since then.

In my view it is a good idea to start a new thread discussing user friendly improvements.

So once I (not being a PCB designer) had the view that one might add an additional layer in Eeschema that allows to encircle a portion of the complete schematic. And only this portion is to be simulated. The circle crossing any interconnect line would cut it. Then either an extra input to this line is to be set or the line allows a measurement, acting as output. This would (hopefully) make different schematics for PCB design and simulation obsolete.

I guess many other, better ideas might surface up, and your inputs are welcome. Solid ideas should then move to the KiCad bug tracker, that now will serve as our input for the developers.

There has already been a detailed entry at https://bugs.launchpad.net/kicad/+bug/1814188


#2

I still like the independent of running the ngspice simulation while work with eescheme. It not blocking the app, and it can be plot, and doing math under console. I only wish the piloting windows in ngspice improve it way for refreshing the draw to avoid long delay every time windows move, or change focus. Like doing a image buffer for draw graph instead or redraw every points all the times, and every mouse clicks.


#3

As far as the entry in launchpad (https://bugs.launchpad.net/kicad/+bug/1814188) is concerned, my thoughts are:
Multiple plots would be nice, especially if different scale to the axes are in order (a mV signal is lost if there is a V signal plotted at the same scale). Hiding a signal easily would be as well. I feel point 8, the legend, is very useful.

My own thoughts:
It would be nice to be able to set the path to the ngspice library somewhere in the gui. It would probably be handy to include that specific to a certain schematic with a global default. It would be good if the version of the ngspice libs was show somewhere, for instance as part of a first line in the simulation output at the bottom left.

As far as your suggestion for limiting the simulation to a part of the schematic, I would like to suggest to use a sub schematic for that as an interface. It is not ideal, but it is probably easier to implement and easier for the developer to discern which signals/connection are added specifically for the simulation and which belong to the schematic.

Hmmm. I will have to think about this one, I guess: It would be need if we could find a way to set up a schematic for simulation and PCB generation without the need to change in between. There currently is a “do not use for simulation” field in the properties of a part; perhaps we need a property “do not use in netlist for PCB” as well to prevent pcbnew from complaining about parts that are only there for the simulation.

Any thoughts?


#4

One other thought is the annoying need to fill in “alternate node sequence” on many of the real world parts. It would be neat if the alternate node sequence would be included in the parts definition, but I hesitate to mention it, as it requires a library change.
After the change from KiCAD4 to KiCAD5, which was a huge improvement by the way, but I think I prefer the libraries to be more or less stable… Perhaps it is better not to tinker the library definitions, again.


#5

Needless to say:
Any change in the gui, please do not break existing schematics. Some have been a lot of work to get working in the simulator (searching for lib’s, alternate node sequence, etc.etc.).


#6

Yeah, it sucks that the need for the alternate node sequence can’t be eliminated since there is a natural disconnect between SPICE netlist order and pin numbering on real parts. Simplest example I can think of is a SOT23 BJT. Almost always the pin order is 1-Base, 2-Emitter, 3-Collector. In SPICE, the netlist order is 1-Collector, 2-Base, 3-Emitter.

I do like your idea of putting the alternate node sequence in the part library. To avoid your concern of breaking existing schematics, the alternate node sequence on the schematic level (if existent) can simply override anything provided at the library level.

At the minimum, I think simply changing the way of entering alternate node sequences into the program can make things much easier for people. Instead of an cryptic ordered list of numbers, you can have some GUI method of presenting to the user “Hey, which pins are collector, base, and emitter?” after you tell the program that this device is a BJT. Maybe a dropdown or something for each terminal…I dunno??? Should be able to work for most other basic semiconductors and even opamp subcircuits. Numbered list should still remain for advanced users.


#7

I am talking from the point of view of a passionate, in my opinion some focus should be put on making a base library with transistor/mosftet (pnp and npn), zener, Schottky, optocoupler, etc.

Every time i simulate a circuit i put the symbol in the schematics then i lost half an hour to find a suitable model for that part. If kicad could manage this it would be a great improvement


#8

Providing models is not our job. (The kicad library is there to provide symbols/footprints for kicads core job which is creating a pcb. For that we need to ensure we are following industry standards which are in a lot of cases counter to what the spice side would require.)

We can not take models of third parties because of licensing and even patent concerns. It is not feasible to create our own models because we do not have the data required to make anything above the most basic models which are of no use for anything but teaching. (And these basic models are already part of ngspice.)

A simple small signal model is possible from values of the datasheet. Such models are supplied with ngspice (Or at least i assume they are.) and are easily filled with the parameters given in the datasheet. (read the ngspice documentation for details)

What is impossible without manufacturer support is a model outside the normal operation range (where linearization no longer works)


This means if you want a model of a part, talk to the manufacturer (They are the only ones with access to all the required documentation). In a lot of cases part model access will require you to sign a non disclosure agreement (For getting access to unencrypted models).


The only things we can feasibly provide are example symbols filled with example values like we did with voltage/current sources recently.


In general i feel it is not a good idea to just simulate the schematic used for creating the pcb. Creating a pcb requires a different set of information compared to simulation. (In a lot of cases you might want to simplify your circuit for simulation. And with the pcb definition side getting more powerful with v6 this need of simplification will grow further.)


#9

I understand.

Agree
Usually I do only digital simulation with not more then 5 components in a separete project. I will talk about what happened yesterday, but this is not a complain or a request of help, it is to show what kind of problems an enthusiastic face with kicad: I drove a simple schematics with a voltage source, transistor, a few resistors and a zener diode. I already had the transistor model, then i started the simulation, but there was something odd, after 30 minutes of various check i understood that the problem was with the zener diode (I assumed that it was like a resistor and i didn’t need a library/model for it), so after understanding my error i found a library online, i added it to the simulation and it worked

we do not have the data required to make anything above the most basic models which are of no use for anything but teaching

Now (and before) I am talking as a complete profane to ngspice, but in my humble opinion this won’t be so bad as a starting point.

Also coming back to the problem of licensing/patent, am i wrong or kicad is becoming better and better day by day, more and more people are using it, it is founded by the CERN, isn’t this enough to ask to some manufacter if they want to contribute with some open source model and release them with a license that is usable by you? They will get visibility and, more important, a pcb designer is more inclined to use their product because he knows that them worked in the schematics


#10

Most semiconductor manufacturers (Including the one i work at right now) are in the mindset that anything that is published can lead to them loosing an advantage over competitors. This at the least means they want to stay in control who gets what and that is exactly the opposite mindset to anything related to open source. (One of the reasons why pspice added support for encrypted models. The kicad devs categorically dismissed any support for something like this as it would violate the core idea behind open source.)

Take the license of ltspice as an example. It gives nearly everyone a pass to use it with one major exception. Anyone associated with a competitor of theirs.


Centralized repo for Spice libraries
#11

I am too far from this context to deeply understand all the motivation behind the manufacturers choice. (I just know that open source in same context improved the advantages over competitors)

Anyway I am not sure if my comments in this post are useful (if not, just say, it is not a problem), so I will try to add the last idea:

Would it be possible to collect a list of parts from open source libraries or anyway patented with a compatible license? For example I just found this http://espice.ugr.es/espice/src/modelos_subckt/spice_complete/ from the university of Granada which, if usable, is already quite a good starting point.

Once a kicad library will be created and shipped with the program when the user is in eeschema and try to add a component it would be perfect if an icon appear near it, meaning that that part is already present in the kicad-base-library (and so simulation-ready without any hustle of googling modules buried deep inside old forums). A concept of what I am talking about:

Then the Spice Model Editor should be already filled with all the needed things like file path to the library and model (and I don’t know if more is needed)

If at this point of history we are able to collect only 30-40 modules it is always a starting point, release after release more libraries will be added, more people (who knows how to use a ngspice) would contribute and finally the eeschema-ngspice integration would be stupid (like me) free

This is how I imagine kicad 6 (or even 5.x)

edit 20/04/2019: i created a centralized repo https://github.com/kicad-spice-library/KiCad-Spice-Library and wrote a post on the forum Centralized repo for Spice libraries