Electrical – How to simulate a mosfet from a datasheet in ngspice

datasheetmosfetngspicesimulation

First of all, I'm pretty new to the simulation side of engineering. I'm using gschem to draw simple circuits and I'm using ngspice from the commandline to run the simulation and plot the results.

So far I've succesfully done a simulation with a simple voltage source, and resistor. Just to get used to the basic workflow.

Now the next thing I would like to accomplish, is to use a Mosfet in my simulation.

enter image description here

This generates the following netlist:

* gnetlist -g spice-sdb -o sim1.ckt sim1.sch
*********************************************************
* Spice file generated by gnetlist                      *
* spice-sdb version 4.28.2007 by SDB --                 *
* provides advanced spice netlisting capability.        *
* Documentation at http://www.brorson.com/gEDA/SPICE/   *
*********************************************************
*==============  Begin SPICE netlist of main design ============
M1 drain 1 0 unconnected_pin-1 STN2NF10 
V1 Vcc 0 DC 12V
R1 drain Vcc 250  
.tran 1ms 100ms
V2 1 0 pulse(0 5 0s 2ns 2ns 1ms 10ms)
.end

Now when I try to run this I get the following error:

Error on line 9 : m1 drain 1 0 unconnected_pin-1 stn2nf10
  Unable to find definition of model stn2nf10 - default assumed 

Which is not realy a supprise, after all, how should ngspice know the characterics of all components in the digikey catalogue.

So I understand that I have to specify the charcteristics of this mosfet. This is where I get stuck. I've read the part of the ngspice manual (p. 127, sorry not enough reputation to post 2 links: ngspice.sourceforge.net/docs/ngspice-manual.pdf) about mosfets, it says the general form to define a mosfet is as follows:

MXXXXXXX nd ng ns nb mname <m=val> <l=val> <w=val>
+ <ad=val> <as=val> <pd=val> <ps=val> <nrd=val>
+ <nrs=val> <off> <ic=vds,vgs,vbs> <temp=t>

The 'm' parameter is for multiplicity, I understeand this one.
Now the 'l' and 'w' parameters, these are the length and width of the channel. How on earth should I be able to know these? They are not in the datasheet for sure. Same for the 'ad' and 'as' parameters these are the drain and source 'diffusions'.

Why can't we just enter the characteristics as meantioned in the datasheet: STN2NF10. Vdss, Idss, Igss, Vgs, Rds, etc.

I believe there is a good reason why it's the way it is, I'm probably just missing or misunderstanding something.

The question:

How do I simulate a circuit containing a Mosfet, and transform the values in the datasheet of the mosfet into ngspice.

PS. The same question is of course applicable to other parts then mosfets, I would just like to keep to the mosfets for now, in order to keep thins simple and practicle.

Best Answer

How do I simulate a circuit containing a Mosfet, and transform the values in the datasheet of the mosfet into ngspice.

First of all pick a MOSFET from within your sim that is already present and supported. Try this out to make sure everything seems to work.

Second, double-click (or whatever mechanism is needed) to open that MOSFET part so you can inspect the parameters. Can you edit them - you should be able to do this.

Thirdly, forget about trying to convert data sheet values to spice parameters - just go look for the model of the device you want to use and change the values by editing them. Sometimes models are written down in data sheets but, more often than not you have to dig around.

Some sims will allow you to paste the whole ascii model text into a special area and this will overwrite the model parameters contained in the device you chose. I don't use ngspice so I can only guess at this bit and what facilities it has.

The spice model for the STN2NF10 is found on this page: -

*****************************************************
*     Model Generated by STmicroelectronics         *
*             All Rights Reserved               *
*      Commercial Use or Resale Restricted          *
*****************************************************
* CREATION DATES: 21-04-2006                        *
*                                                   *
* POWER MOSFET Model (level 3)                      *
*                                                   *
* EXTERNAL PINS DESCRIPTION:                        *
*                                                   *
* PIN 1 -> Drain                                    *
* PIN 2 -> Gate                                     *
* PIN 3 -> Source                                   *
*                                                   *
*                    ****C****                      *
*            **********************                 *
*     ***************************************       *
*  PARAMETER MODELS EXTRACTED FROM MEASURED DATA    *
*              <<<<<<<<<<<>>>>>>>>>>>               *
*     ***************************************       *
*   THIS MODEL CAN BE USED AT TEMPERATURE: 25 °C    *
*                                                   *
*****************************************************

* MODELLING FOR STN2NF10

.SUBCKT STN2NF10 1 2 3
LG 2 4  7.5E-09
LS 12 3 7.5E-09
LD 6 1  4.5E-09
RG 4 5  4.001
RS 9 12 0.325E-02
RD 7 6  0.142
RJ 8 7  0.445E-03
CGS 5 9   0.419E-09
CGD 7 10  0.467E-09
CK  11 7  0.307E-10
DGD 11 7 DGD
DBS 12 6 DBS
DBD  9 7 DBD
MOS  13 5 9 9 MOS L=1u W=1u
E1  10 5 101 0 1
E2  11 5 102 0 1
E3  8 13 POLY(2) 6 8 6 12 0 0 0 0  0.321
G1  0 100 7 5 1u
D1  100 101  DID
D2  102 100  DID
R1  101 0  1MEG
R2  102 0  1MEG
.ENDS STN2NF10

.MODEL MOS NMOS
+ LEVEL = 3
+ VTO   = 4.184
+ PHI   = 0.827
+ IS    = 0.1E-12
+ JS    = 0
+ THETA = 0.995
+ KP    = 15.084
+ ETA   = 0.199E-02

.MODEL DGD D
+ IS    = 0.1E-12
+ CJO   = 0.171E-10
+ VJ    = 0.754
+ M     = 0.367
.MODEL DBD D
+ IS    = 0.1E-12
+ CJO   = 0.202E-10
+ VJ    = 0.755
+ M     = 0.335
.MODEL DBS D
+ IS    = 0.1E-12
+ BV    = 117
+ N     = 1
+ TT    = 0.699E-07
+ RS    = 0.505E-02
.MODEL DID D
+ IS    = 0.01E-12
+ RS    = 0
+ BV    = 127

* END OF MODELLING