KiCad 5.1.5 / ngspice Noob question

Okay,

I am absolutely new to KiCad at all (first fault ^^), finally managed a fine tutorial eeschema -> pcbnew, and another project created from scratch (yay).

Now, I want to play with the KiCad -> ngspice interface (second fault?). What I want to simulate is a simple OpAmp-based oscillator. Nothing too wild, just a simple Wien. In my small world, I just need two DC power sources (like +/- 9V=), a GND (or 0V), the parts, the KiCad requirements (like power sources), the wires, a place to put the probe, like a label, and hit run. Well, of course not. :frowning:

What I believe to have found out so far is that I need an OpAmp that ngspice can deal with. Perhaps you can point me to one (doesn’t need to be the most amazing opamp ever invented, just one that will work). I just want to get familiar with the KiCad -> ngspice thing, am far away from being able to create my own part descriptions.

It’s the usual problem with cool software created by cool brains: the tutorials run like a top model on the catwalk, but if you want to make the next step, it’s like ‘‘use Google!’’, and if you do so, you’ll find yourself in a nutshell drowning in the Pacific, without even a bottle of water.

So: SOS! :slight_smile:

Still a tutorial on this: http://ngspice.sourceforge.net/ngspice-eeschema.html

You just should work through the examples. And if you have questions, ask them here in this thread.

Because the simple, but not very helpful answer to your question would be: ngspice can deal with all OpAmps. The tutorial names a LF356, more by chance than by reasoning.

1 Like

Well, Holger, I guess now I know what the Corona lockdown could be good for… Honestly, I was afraid of this kind of answer, like I tend to tell my tuition students: ''if you want to unterstand maths, you have to know maths…" Still, thank you, that tut looks like its learning curve is managable.

PS: Is there an easy way to find out wether a part within KiCad’s libraries is ready for simulation?

Again the answer to this question is simple: Beyond R, C, and L you always have to deal with finding a suitable device model externally (in the web, at the manufacturers’ site etc.). These are not delivered with ngspice nor with KiCAD. But you have to do it only once (per device). People have refrained from making collections of these data and offering them publicly due to restrictions in licensing and maybe other reasons.

For me (with some experience) it takes a few minutes to find a suitable model. And why not just start with the tutorial example?

1 Like

Hey, man. Maybe give the Universal Level 2 a shot? Sounds like it fits your use-case well.

We should ask the library maintainers to do us (simulators) a favour:

For a very basic (beginners) simulation library set we need:

R, L, C: this is already included, the user just needs to add the value

Bipolar, MOS, JFET, Diode: Add a simple model description to the symbol lib using the default model parameters coming with ngspice. For the diode this for example would be just a “.model SimDiode D”, for the npn a “.model SimNPN NPN” etc…Have the correct (alternative) pin sequence compatible with ngspice in the symbol. The user just has to choose the diode symbol or the right symbol for pnp, npn, or p-channel, n-channel.

OpAmp: Use your (Ste) universal OpAmp model, already integrated into the OpAmp symbol.

This library set is then not meant to support creating a PCB (no footprints etc.), but serves as a starter set for people entering simulation. Probably this might be an extension of the already existing “Spice_Simulation” library, clearly stating that these are generic symbols for generic simulation.

1 Like

I think this is a great idea, if it’s possible to do. Do KiCad symbols have a field that can add custom SPICE statements to the netlist? I thought they could only reference external text files…maybe I’m wrong?

The default models work decent for D and BJT. However, I know MOS default sucks and never gets you anywhere close to your expected result. Maybe that might require a few model params added, or maybe make it a VDMOS (with a 2V-ish threshold) since that’s what most people use for discrete parts anyway??? I have near-zero experience with JFETs, so I don’t know if those have the same problem.

Maybe you are right. Then let’s place all models into a single file and ask the user to download it and place it into ?? (his project folder, the folder where *.sch resides?). We then would have a little more freedom to offer suitable model parameters eg. for MOS, VDMOS and the others.

I would like to see a (small) library of “spice compatible models” in KiCad that work out of the box and are especially targeted at beginners, and the components they use.

For transistors, that is without doubt the BC547 and BC557 for European users, I think the 2n2222 is the “usual starter” transistor for North Americans.
NE555
Opamps: The usual suspects:
LM741, LM324, TL071

The most important thing is that it’s included in KiCad itself, and guaranteed to work without twiddling. (A separate package which is easily installable is also acceptable)

The problem for beginners is always the chicken and Egg problem. Is there some problem with the models, or does the circuit itself not work at all?

Licensing of spice models is a problematic issue.

The opamp in the sallen key demo:
/usr/share/kicad/demos/simulation/sallen_key/
has a link for a license but that link is dead.

Lots of models on the 'net do not have any licensing info at all.
Others simply have a completely ridiculous:

  • Copyright © Linear Technology Corp. 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008. All rights reserved.

and if you take that literally you are violating the copyright if you read that text.

I have been browsing through random spice models in search of licencing information, but Edsel is hitting hard today.
I have seen licencing info, especially in very old models which state something along the lines of:

This model is free to use and distribute as long as you do not sell it.

For me, the added complexity for searching for spice models, not really understanding what’s in them and uncertainty about whether they work is such a big hurdle that I’m more inclined to go back to a breadboard than to spend more time in trying to understand the spice thing.

Seems like we’re hijacking this thread, so I made a new thread for further discussion on supplying SPICE models with KiCad.