Kicad ngspice github repository

I was wondering if there is an official Kicad Spice Library - github repository containing SPICE models for different electronics components.

Something like https://github.com/KiCad/kicad-footprints/

I only found this outdated repo https://github.com/ryansturmer/kicad-spice-library

In case there is some issue with licensing, I would suggest that the spice library contains a hyperlink to the manufacturer file, and in the GUI a button to autodownload to your project. Just to ease the integration.

1 Like

i follow, it would be useful

Just found this:


Still, I would find it useful to have an ‘unofficial’ repository where people can start adding their contributions, and later find out how to do a thorough review of them to embed it in the official KiCAD.

I have some too :slight_smile:

I think that making a a library for general purpose use (not for production or any other use outside the hobbyist field) would make eeschema+ngspice far away more usable

This library IMHO should contain just a general approximation of these components:
LED
Rectifier diode
Schotty diode
N bjt
P bjt
N mos
P mos
Opamp
Voltage comparator
Optoisolator
Meccanichal switch

Voltage/current sources, Resistor and capacitor are already perfectly implemented, what about inductors?

Do you think that other components should go inside this library?

1 Like

I would add

  • monostable multivibrator
  • delay block

Some of the symbols you mention are already here:


and here:
https://kicad-info.s3-us-west-2.amazonaws.com/original/2X/c/c5ac29f02150a0dc0ffff5282a15d53402831be8.lib

Should we fork the github repo and merge both files as a start?

Before i would rather to hear why it hasn t been done before from a more experienced member, maybe there is a reason.
If not i am in, maybe just for a better maintenance the repo could be linked to an organization page and not to a personal profile

The reason is here:

Disclaimer: I have not really looked into simulation yet. I plan to do that around Christmas.


Another big reason are concerns regarding licenses and patents. There is a reason why there is a huge cost difference between simulation tools with and without model libraries. (There is also a reason why a lot of the manufacturer models are encrypted.)

Especially models that model more than the simple stuff will be quite hard to come by under any reasonable license.
My assumption is that ngspice already comes with such simple models. (If this is true than we might want to point probable contributors to their contribution site. Adding models there will be even more useful than adding them to kicad alone as this will profit everyone using ngspice with whatever frontend used.)

I am talking from the point of view of an enthusiastic, you seem to be a professionist, isn t it?

From my perspective the professionist already have his own spice library (or at least he knows what spice is and how to make a model)

In the other hand day by day the hobbyist are increasing and, trust me because i discovered spice 3 days ago, they doesn t have any idea what the hell is spice.

I am not talking to implement inside kicad the model of a complex/esotic IC I am just talking about a few easy models like the few i listed on post #5 (so without ANY licensing problems)

Yesterday i lost 30minutes because in my schematics there was a led and the simulation wasn t able to use it. Then i googled a model (it was just one line found on stack exchange) and magic!

About adding these models directly to (ng) spice i disagree because in my opinion these tools are made for professionist and they wouldn t like to have around “general purpose models”

As i said i am new here so i may be wrong

The library I provide from the other topic earlier are mine creation (no need any licences/MIT) that capture ngspice model “directly” and do have most of the things you mentioned except LED (which Diode can be use), Optoisolator (which can be as simple as Current Control Current Source)


Most of those model are been use many times from couple designs. So I’m pretty sure they are all work.

When I need more precise simulation, I start to rename my symbol value to the “manufacturer” model that I obtain from them. Usually my symbol pins are compatible with most of the manufacturer models. So I do not need to use any special feature from 5.x version. In fact they were works for any kicad 4.x versions.

There is a project that downloads publicly available models instead of hosting them in a repository. The script is now outdated, but perhaps that is the way to go.

2 Likes

Perhaps the most extensive collection of SPICE models, or links pointing to SPICE models, is in the Yahoo " LTSpice User’s Group ". That is also a place to learn about SPICE simulation in general.

Dale

1 Like

I would like to point out that there can be several spice models for the same part, depending on what one is trying to simulate.

Example:
Simulating an opamp to verify ones schematic makes sense, checking functionality etc., requires a model that can be relatively simple. In many cases such a spice model van be downloaded from the manufacturer for free.
Simulating that same opamp to verify its behaviour in the schematic as part of an estimation for noise, or high temperatures or some other difficult special case at the limits, requires a different and much more sophisticated spice model.

In the simplest models, only the intended functionality is modelled, but the unwanted limitations of the part are not.

Who would have thought a TL082 opamp, under unfavourable conditions, can get stuck at one of the rails, for instance? This kind of (usually unwanted) behaviour is seldom modelled by free models.

There is usefulness in both types of models, because the simple model requires less calculations and hence can be simulated faster. In many cases, there is no need to simulate correct real life behaviour at the limits, but sometimes there is.

Imagine the maintenance on sophisticated spice models as the manufacturer, in time, goes through several versions of the same part. Imagine modelling the temperature behaviour of parts the are available in several different packages.

Do not not get me wrong: I would love to have easily accessible reliable spice models. I would absolutely love it! Even the simple versions of spice models for many parts would be very nice.
However, the complexity of the subject and the licence issues will make the effort quite hard to get completed. If only we would live in an ideal world where manufacturers could openly “publish” the limitations of their parts in spice models for all the world to know. I do not think we will see this any time soon. It is much to difficult to admit limitations of parts.

4 Likes

I think we would need to limit ourself to basic models, due to licencing issues. (which means creating the models ourself). Personally, For the start I would like to have all basic R/L/C symbols including R-networks modeled (which are the easiest parts), all in the standard lib (no separate pspice library). Later Transistors, FET’s, Diodes,
 could be modelled in a trivial fashion (using the datasheet values). But I’m not an expert in those things.

For IC’s we likely need to say the user has to add them on demand, due to licence issues. But we can at least improve the users live by providing most of the models.

I’m heavily in favour of embedding the models directly in the symbol, not linking them. Which likely needs the new symbol format first.

1 Like

I agree with your perspective. I think that making the workflow easier (i.e. default standard spice models embedded) is very important for doing first designs and checking most basic stuff. Ideally, it should take the user no more than 2 min to run the simulation with basic elements, instead of looking around on forums and doing repetitive linking task and so on.

For more demanding applications, the user can spend more time looking for the proper package model version from the manufacturer. I would still consider it helpful to add the html link to the more complicated spice model, or to do a conversion platform like https://github.com/werner2101/spicelib/.

ngspice simulator has built in models (device equations of current versus terminal voltages) for the most common generic devices like diodes, bipolar transistors, JFETs, MESFETs, and MOSFETs. These models require model parameter sets (the .model cards), for specific devices generally offered by the semiconductor manufacturers.

For each of these device types ngspice offers a default parameter set. This typically does not resemble a manufacturer’s specific device model. However it should be generic enough that one can do a first test of her circuit, before a dedicated device model parameter set is searched for.

Of course this is somehow like you need a bipolar transistor in your circuit, and you solder in a device found somewhere on the shelf.

How to invoke these parameters?

You have to add a .model card to your device symbol, as described in http://ngspice.sourceforge.net/ngspice-eeschema.html#BipAmp or in the wiki. However, there is no need to search for such a parameter set on the internet. For the bipolar transistor you may simply use
.model modname npn
or
.model modname pnp
modname is the model name selected by the user. A diode may be invoked by
.model modname d
A MOS transistor may get this model (simple MOS1 model)
.model modname nmos(level=1)
.model modname pmos(level=1)
or
.model modname NMOS level=8 version=3.3.0
for a more sophisticated model used for IC work (BSIM3). JFETs are then
.model modname njf level=1
.model modname pjf level=1
Many more details of these models (the equations and their default parameters) are given in the ngspice manual in chapts. 7 - 11.

Amplifiers and other ICs are not available with ngspice, because they are not generic devices (they are made out of the generic devices described above). R, L, and C in their most simple usage don’t need specific model parameters, you just have to give the resistance value etc.

The MOSFETs and JFETs thus added to your circuit will deliver only a very small current (”A). ngspice does not know your intentions. So it will be necessary to add a parameter that can control the current. Here we should use W and L. So the .model cards will become
.model modname nmos(level=1 W=50u L=5u)
.model modname pmos(level=1 W=50u L=5u)
.model modname NMOS level=8 version=3.3.0 W=50u L=5u
.model modname njf level=1 W=50u L=5u
.model modname pjf level=1 W=50u L=5u
Change W if more current is required, don’t touch L. 5u is 5”m. Unfortunately this will not do with ngspice-26 (W and L are no model parameters), but only with ngspice-28 and newer.

Life is not easy 


4 Likes