Seems to me that in the simulator included in Kicad (ngspice) the passive components (resistors, capacitors and inductors) have an ideal model and can not be modeled using an equivalent series/paralle circuit giving the possibility to change the values of the parasitic R, L and C values.
This possibility is very important designing switching power supplies and other circuits where they are part of switching circuits. Am I wrong? Any way to solve the problem?
I would like to have my personal library fitted also with the fields needed by the simulator so I am checking/investigating how everything works. It would be great if the library fields may be OK also to export a netlist to LTSpice.
Every answer and suggestion will be very appreciate.
Massimo.
Double click onto the resistor symbol.
–> Edit Spice model --> Model --> Select File
Select the file res_mod.lib
–> Type --> Subcircuit --> ok --> ok
–> Tools --> Simulator --> Run simulation
Massimo, generic spice simulators like ngspice have always used ideal components. Mike Englehardt with LTspice did build in a more complicated capacitor model that allows series and parallel L’s and R’s in the model to simulate switchers a little more easily. (He also did significant work on the simulation engine to make switcher analysis more robust.) This isn’t a very satisfying answer, but you can achieve the same by building a subcircuit for the capacitor. Feel free to add this to the bug list as a wishlist.
I am a user and fan of LTSpice also if I don’tu se it very very often. At the moment I am thinking how to organiza a set of Kicad linked libraries taking care of schamtic, simulator, and pcb fabrication needs to see if it is possible to use Kicad for my production needs.
Thanks for the answers, I made a trial and it is ok for me, it works. There are still a couple of points for which I did not find an answer so any help will be apprecaited.
Is there a way to pass a parameter from Kicad GUI to the .subckt. For instance tha Value of the resistor may be passed to .subckt trough a variable/place holder or anything else?
Not using the .subckt strategy, Kicad paases the Value field to the Value field in Edit Spice Model/Passive/Value that is a good idea but in eeschema the Value field is linked to the Symbol Name so for instance if you organiza your library to have a symbol for each passive component (I mainly mean resitors, capacitors and inductors) you have to manually adjust the Value on the Spice tab. Is there a way to unlink the eeschema symbol Value from the symbol name? IT should be very useful.
Mmmm… I have some limited experience using PSpice and more using LTSpice, in both cases the syntax of passive components is quite more complex, at least they provide 2 temperature coefficients for the resistors and a lot more for capacitors. For general uses the provided “optional” parameters are not very useful (at least they are set with default values under the hood) but working with switching power suplies and switching circuits require them especially for capacitors and inductors.
Hi Massimo, I’ve been thinking about my use of PCB layout and simulation, and I’ve come to several conclusions. One is that the schematic I use for PCB layout is unsuited for simulation. For example: what level of behavioral abstraction do you use for opamps? Ideal?. Ideal with slew-rate? Ideal with slew-rate and output clamping? Detailed transistor-level? In reality I want to switch between all of them and trade off accuracy vs simulation time depending on what I am simulating. It feels like I want a switch or some sort of selector in the schematic symbol to change between model levels / complexity.
An open conversation about schematics and spice would be interesting to get perspectives.
Why not select an OpAmp and use the model offered by the device manufacturer (PSPICE- or TINA-compatible will do)? These are not transistor-level models, but sort of lumped-element models, and often the model description tells you what is modelled and what not.
If you do for example a transient simulation, you may have in the eeschema circuit editor window a line .tran 1u 10m
or similar in a text box. You may edit this text box by double clicking into it.
Try adding a line R1 n1 n2 'val'
to the subcircuit and add a line .param val=1k
to the text box mentioned above.
Hi Holger, asked from the perspective of an old analog guy that wrote my own spice3/xspice c-code models 30+ years ago, what happens when things don’t converge? Do the manufacturers provide support? Or do you have to figure it out for yourself?
That is a reasonable attitude. In practice, I suspect that most design engineers use opamp models based on the “macromodel” concept published by Boyle, Graeme, Cohn et al in 1974 (and subsequently enhanced circa 1990 by engineers at several of the prominent analog IC manufacturers of that era). The IC manufacturers typically publish this type of model for their products; individuals and other organizations may also publish opamp macromodels. A search engine will often uncover several different models for a particular opamp type. I have created quite useful SPICE models using a Datasheet and Analog Devices’ AN-138.
In all cases (including manufacturer-provided models), “Caveat Emptor” applies. A typical opamp datasheet lists dozens of characteristics; each one has a tolerance band, each one has some dependency on temperature and supply voltage, and a particular model may, or may not, even attempt to model a particular characteristic. The majority of these characteristics and their dependencies probably aren’t significant in your particular application, but this varies from one design to another.
Transistor-level models are not generally available for IC opamps designed after about 1970. The other options you mentioned are useful for crude first-cut investigations when more complete models are simply not available. In some cases they are actually “too ideal” for SPICE and will create convergence problems or extend computation time.
I haven’t gone very far down that road. I think you get a (usually proprietary) “mixed-signal simulation program”, or study up on the SPICE “extensions” available on some of the no-charge SPICE simulators (including, if I recall correctly, NGSPICE).
Dale, Holger, or Massimo, if you were at KiCon, my apologies for not meeting you. I was one of the people behind the bar serving breakfast/lunch and servicing the drink cooler.
Unfortunately, I was NOT at KiCON. I certainly wanted to be there, not only to support Chris’ initiative and express some appreciation for all of his work, but also to attach some faces and voices to ID’s here on this Forum. But even though Chicago is an easy train ride from St Louis, KiCON didn’t fit into the budget for the Working Poor.
Dale
P.S. - I’d like to say, “I’ll be there next year”, but my wife’s medical situation will probably keep me on a pretty short leash for the next few years.