How to set spice transistor parameters

Running Kicad 5.0 RC2.

I am trying to use spice and simulate a very simple schematic , see appended file.

My problem is the transistors Q1 and Q2. How do I set a spice model to them ???

Probably the answer is “obvious”, but I have spent many hours googling around, without getting any answer that can help me.pulse.pdf (37.8 KB)

You need to talk to @PKTKS, he’ll be able to help you out.

Not so obvious as you MUST have the models
available in your system

Two ways - same procedure:

  • If you have a proper model you should use
  • IF NOT use the standard default SPICE3 model

Open the EDIT component and select SPICE MODEL
On the SPICE MODEL you put the required model

* STANDARD SPICE3 definition
.model npn npn
.model pnp pnp
.model nmos nmos
.model pmos pmos

That should do the trick for now



A very good question. I have spent some time looking into this, it’s been a struggle since

Anyway, here’s what I found:

For transistors and MOSFETs, even for the symbols in pspice.lib, you need to supply some additional info. If you don’t supply the info, you get an error like this:

UX Note: The error message scrolls out the window, so it is easy to miss. It just looks like it “didnt work” for no reason.

The extra info can be supplied in several ways:

  • specify an ngspice model corresponding to the symbol value in a text comment. e.g. if the value is “qnpn”, you need to specify .model qnpn npn

Here is an example using symbols from pspice.lib after example #1 in the ngspice manual (Chapter 21. Example Circuits)

You can also specify more complex models using the same method (provided the model is compatible with ngspice), e.g.

Putting ngspice directives in the schematic had the advantage of being self-contained, but can bloat the schematic.

An alternative is to create a spice “library file”, containing the corresponding directives. For example, put the following lines into a plain text file using a text editor (not a word processor) and save it somewhere:

* Generic models for ngspice

.model qnpn npn
.model qpnp pnp

.model npn npn
.model pnp pnp

.model nmos nmos
.model pmos pmos

*ZETEX BC108 Spice model     Last Revision  23/3/00
*                          (C)  1991 ZETEX PLC
*   The copyright in this model  and  the design embodied belong to
*   Zetex PLC ("Zetex"). It is supplied free of charge by Zetex for
*   the purpose  of research  and design  and may be used or copied
*   intact (including this notice) for that purpose only. All other
*   rights  are  reserved.  The model  is believed  accurate but no
*   condition or warranty as to its  merchantability or fitness for
*   purpose  is  given  and  no liability  in respect of any use is
*   accepted by Zetex PLC, its distributors or agent.
*   Zetex PLC, Fields New Road, Chadderton, Oldham  OL9 8NP
.MODEL BC108 NPN IS =1.8E-14 ISE=5.0E-14 NF =.9955 NE =1.46 BF =400
+            BR =35.5 IKF=.14 IKR=.03 ISC=1.72E-13 NC =1.27 NR =1.005
+            RB =.56 RE =.6 RC =.25 VAF=80 VAR=12.5
+            CJE=13E-12 CJC=4E-12 VJC=.54 MJC=.33
+            TF =.64E-9 TR =50.72E-9

The Zetex model is reproduced according to license.

Now you have more options. You can include the library file directly in the schematic:


OR edit the symbol and associate the model to the symbol.

  1. Place the symbols like so (all from pspice.lib):
  2. click “Edit Properties” for Q1 then “Edit Spice Model”
  3. Click “Select file” and browse to the “library file” you created earlier:
  4. Select the model from dropdown. (You don’t have to use the same model as the symbol value)
  5. The symbol Q1 properties should now look like this. Note: the spice properties now override the “Value” field. For transistors, “Spice_Primitive” must be “Q”.

Over time, you will likely build up your own collection of ngspice models in your spice library file.

Note: examples tested with kicad Version: (5.0.0-rc2-dev-266-gbad462a22), debug build KICAD_SPICE=ON

Finally, here is a sample project as complete and simple as I can make it: (1.7 KB)

@Rene_Poschl @Joan_Sparky is this FAQ-worthy? :slight_smile:


Added a link to this post to the index thread.


There is a chapter regarding the Spice simulation with eeschema. It is not available in the stable branch docs you pointed to, as the simulator is not present in v4. Still, I see you have given even better explanation of Spice directives, I am sure the users will find it useful. Perhaps some of your examples could be added to the Spice directives chapter of the manual

1 Like

Thanks for heads up!

I think the simulation with ngspice is a really nice and powerful extension, so kudos to both KiCad and ngspice devs for bringing it :+1:

Thanks all for pointing me in the correct directions.
Now everything is working and Spice is running nicely :slight_smile:

Just a small problem, it is not working as I had expected :smile:

I think the problem is the connection between my schematic and the 556 spice model.

This picture (from eeschema manual )

shows “Alternate node sequence”

Can this be used to map signals to correct positions, if so, how. Cant find anything in the manual about it.

The node order for transistor (Q) models is C B E. So if pin 1 is E, pin 2 is B, and pin 3 is C you’d use node order 3 2 1. But the BC556 is C B E, which matches the spice default and should be fine as is. (This is for parameter style .model models, not subckt models… those can have any order and you need to check the model source to see what it needs.)

What model are you using for the 556?

I found two different models, one from Linear Technology and one from Texas.
I’ve used the first one in my simulations that gives crazy results.
The model from Texas I just downloaded. The Texas model have understandable port names so I have been able to compare names in the Texas model with the names in my schematic. This tells me that the 555 model not are correctly instantiated.
That why I am looking for ways to remap the the connections.
Current model of 555 NE555.sub (1.1 KB)

(( lets hope anyone can understand me, because my english is not the best ))

You can change the Spice node to eeschema pin mapping using the “Alternate node sequence field” you have mentioned. It is explained in the manual, let me know if it is not clear.

Sorry, I didn’t read through the whole thread and thought 556 referred to a transistor. An NE555 is obviously going to be a subcircuit. It’s customary to document the nodes on subcircuits, and that .sub you have is lacking that part. What I’d do is load up LTspice (since this is an LT model) and see how its NE555 definition ends up mapping pins to the model. (My gut guess would be 1:1, but it sounds like you already tried that.)

Thanks all for the help.

I’ve have been able to simulate my circuit using your help.

(Hermit deleted expletives)
I’ve tried to use kicad+ngspice. The pin order is x, the models are missing, the documentation is one of the worst I’ve seen. I’ve lost a lot of time reading lots of documents, all kind of x, some usefull, most of them not usefull and not solving my problem. This approach (gspice + kicad) is simply not good enough.
Man, who the x will have enough time to create a library file for each type of component he uses? This will take a lot of time, will be prone to errors and is simply not the way to go.

You are allowed to be as unhappy as you wish but do so respectfully. This is a 2 year old thread and nothing in your post warrants reopening it as opposed to starting a new one to address you specific needs. Please keep in mind that people of all ages and walks of life are welcome here so please be mindful of other peoples sensitivities.