Professional Documents
Culture Documents
by Makerss
SPICE is short for “Simulation Program with models” that replicate the properties and nuances of
Integrated Circuit Emphasis”. In KiCad’s case, KiCad 5.0 their real-life counterparts, and then package these
and later comes pre-packaged with a SPICE program models as downloadable libraries, so that drawing a
called ngspice. Ngspice has its quirks, hiccups and circuit would be as simple as downloading the
limitations but will be the software we will focus on. required libraries and assigning model to our
Ngspice uses “Components” to model circuit components. But that’s all talk, let’s get our hand dirty
behaviour. This means that aside from drawing the and see how this actually works.
circuit schematics we also must annotate and “assign”
models to individual components. To solve the
problem of multiple models of the same components,
ngspice decided to let each company make “spice
• 1 LED
Ngspice doesn’t recognize “standard” voltage sources; reference name for the voltage source, VoltageMain
those used by KiCad. It provides a library speci cally for example, and then we click “Edit Spice Model.” As
for the voltage sources and grounds shown above
To access the library, rst, we have to pick the “Choose Then we choose a value of dc 9v, and that is about it.
symbol” tab, and search for “spice” As shown in ( gure 3)
*As seen in ( gure 1), we have the “pspice” library and the Th e Gro un d
“simulation_spice” one. For voltage sources, we want to
scroll down to the simulation_spice library and choose a For the ground, we search for “spice” again and the
dc voltage source rst result is the 0V reference potential as shown in.
( gure 4). Unlike normal schematics, spice software
Afterward, we have to set its values for the simulator needs the ground as it calculates its voltages based
to understand, in this circuit we want a 9v dc source. on the 0v reference.
We click “E” on the voltage source and the following
menu opens, shown in ( gure 2). We choose a
As we can see from the circuit picture, the transistor used is a very speci c model, the “BC547”. As a general case,
almost all manufactured components will be found on their respective manufacturer’s website. Under their tool or
support tab, there will be “simulation models” featuring the model number and a relative spice model. In our case I
searched for “bc547” online and found that it was manufactured by a company called “On semiconductors”. I
searched for their website “https://www.onsemi.com/” and found the model by doing as follows:
I opened their “Tools and support” tab, underneath I, found a design resources tab. ( gure 1)
Underneath design resources they asked for the type of document, I chose “Simulation Models”
( gure 2)
I searched for the part by name: “BC547”. We want the library, so we choose “BC547 Lib Model” and
downloaded it. ( gure 3)
After downloading it, I put the lib le in my project directory. Now my project directory is shown in
the original KiCad window I opened, as seen in ( gure 4) . I clicked my way to that directory, pasted
the library le as shown and returned to nd it shown alongside my project’s les
After all that has been said and done, let’s draw the transistor symbol. I clicked using the “place
symbol” menu, and just searched for the name. You nd that almost all components exist in the
symbol menu as in ( gure 5).
Now, what remains is assigning the model to the symbol. We click “E” as always on the symbol, and
click on “Edit spice model”.
As we can see, the only tabs available are model, passive, and source. Since transistors are neither
source nor passive, we choose the model and choose to plug-in a library to ll. The menu rst opens
to the project’s directory, which we lucky have already put the library into it. We click on the lib le.
Great!! Now ngspice has identi ed the transistor as “BC547” and is almost ready to
operate. There is one tiny detail to be sorted rst. We have to enable alternate node
sequence and type “3 2 1”. The reason we have to do this step is that ngspice names the
3 transistor terminals in a manner opposite to how KiCad shows them. So, it may have 3
assigned to the collector while KiCad shows 3 as the emitter. To avoid confusion, we
recon gure Spice’s naming order, as shown in ( gure 7)
Anddddd that is it! This process is almost identical for all
vendor-supplies models. Once you wrap your head around this tutorial part, you can
use any type of electronic model and component with only a little research.
Simulating a KiCad Circuit: Page 4
Simulating a KiCad Circuit: Page 5
Step 5: Modeling LEDs
LEDs are a bit trickier in the fact that modeling them requires some knowledge about their parameters and curve-
tting. So, to model them I just looked up “LED ngspice”. I found multiple people posting their “LED models” and I
decided to go with this “ * Typ RED Ga As L ED: Vf=1. 7 V Vr=4 V I f=40 mA t rr=3uS . MODEL LED1 D (IS=93.2P
RS=42M N=3.73 BV=4 IBV=10U + CJO=2.97P VJ=.75 M=.333 TT=4.32U)?”
We will pick “LED ” from the symbol menu and paste this code into the empty space below the
libraries in “Edit spice model ”. We’re also going to switch on alternate node sequence and write “2 1 ”,
as shown in gure 1
Step 6: Simulating
First, we open the simulator from the tools tab in the upper ribbon ( gure 1)
Then we go to the simulation tab in the upper ribbon and click settings, from there we can specify
what kind of simulation we want to run, and its parameters. ( gure 2)
We want to run a transient simulation. There’s also DC and AC sweep available as simulation options. Dc sweep increments
the value of the Dc current and reports the changes in the circles while AC monitors the frequency response.
However, transient analysis simulates a circuit in real-time. It has 3 parameters, of which we are
going to use two. Time step is how often will the simulator record results, and the nal time is after
how many seconds will the recording stop. We input 1 millisecond and 5 milliseconds and then ok,
Step 7: Wrapping Up
Since this circuit was supposed to be made with an LDR and a resistor, we can alter both of these components resistance
and then rerun the circuit to determine the resistance values we would like for this light-controlled LED using a common-
emitter npn transistor as a switch circuit.
A n d d d t h e re st is up t o yo u : 3