2

I am trying to use mosfet model, and passing the voltage threshold, how ever, I am getting error

 unknown parameter (vto) 

I've read in NGSpice manual, that mosfet level 1 has the param VTO,

the netlist is:

vV1 0 3 5v
vV2 0 1 3.5v
mMosfet1 3 1 2 NMOSFET VTO=1.5
VrMeter1 4 proxynode dc 0 
rMeter1 4 2 1e-8 $ 
Rproxy proxynode 0 0.0000001
.dc vV1 5 5 1
.dc vV2 3.5 3.5 1
.control
set units=degrees
.endc
.print dc i(VrMeter1) 
RGRND1 3 proxynode 1000000 
RGRND2 1 proxynode 1000000 
.model NMOSFET NMOS level=1

.end

ngspice stopped due to error, no simulation run!

ERROR: fatal error in ngspice, exit(1)


Error on line 4 :
  mmosfet1 3 1 2 nmosfet vto=1.5
 unknown parameter (vto) 
Process 3935010 dead!
Process 3935010 detected

Any idea?

simo
  • 273
  • 1
  • 12
  • 1
    You need to set `Vto` inside the `.MODEL` definition. What does work in the same line as the MOSFET is the width (`w`), height (`h`), and areas. Maybe also `m` (the multiplier), but I'm not sure in ng-spice (and the manual is far away from me now). – a concerned citizen Mar 04 '22 at 15:05
  • Thanks, kindly check here http://ngspice.sourceforge.net/docs/ngspice-html-manual/manual.xhtml at `21.3 MOSFET Characterization` there is an example as you said, but how can I pass the value rather than having it constant at the model? – simo Mar 04 '22 at 15:25
  • Thanks to @SteKulov's comment below: it's not `w/h`, but `w/l`. The message remains, though (also updated the answer). – a concerned citizen Mar 07 '22 at 10:30

1 Answers1

1

You need to use the .param statements and then assign the values within curly braces. e.g. (case insensitive):

.param x=1.618
M1 3 1 2 NM
.model nm nmos Vto={x}

All .param statements are evaluated prior to simulation start, and the curly braces tell the engine to evaluate whatever there is enclosed. Since x is a .param, it's evaluated before the simulation starts, so the curly braces replace {x} with its defined value, 1.618.

As a minor addition, in the comments I mentioned that the MOSFET line can have parameters: width, height, areas. Usually, the areas are calculated from w and l, so the line could look like this:

.param y=0.618
M1 3 1 2 NM w=1 l={y}

As it is, w is predefined and unchanged, while l can be defined and used with a .step to see how varying it changes the response. For this particular MOSFET you'll need a hefty workbench.


Thanks, but that leads to use the model only for one mosfet. What if I want to have two mosfets in the circuit each with different VOT, using the same model?

You should have specified this in your OP -- actually, please do so.

You will need to use as many .MODEL definitions as you have MOSFETs that use that particular change, but there is a shortcut: the ako (a kind of) keyword. If you already have the .MODEL defined in the database, then all you need is to rename each MOSFET that needs a change, preferably in an intuitive manner, and then add (assuming you're "impersonating" the 2N7000, for example):

.model N_3.14 ako:2N7000 vto=3.14
.model N_2.718 ako:2n7000 vto=2.718
...

Then having a MOSFET named N_3.14 will make it behave like a 2N7000 with a 3.14 V threshold; similarly for an N_2.718. And, just like in the original answer, you can use .PARAM statements to assign to Vto.


[edit] Thanks to Ste Kulov's comment, you need to enable either PSpice, or LTspice compatibility for ako to work [/edit]

a concerned citizen
  • 21,167
  • 1
  • 20
  • 40
  • Thanks, but that leads to use the model only for one mosfet. What if I want to have two mosfets in the circuit each with different VOT, using the same model? – simo Mar 05 '22 at 08:28
  • @simo I've updated my answer, but this comment needs to be included in your OP -- you have no mention about this. – a concerned citizen Mar 05 '22 at 08:50
  • 1
    Just a heads up that `ako` only works when PSpice compatibility mode [`set ngbehavior=ps`] or PSpice/LTspice joint compatibility mode [`set ngbehavior=ltps`] is enabled within ngspice. See Section 16.14.5 and/or 16.14.7 of the manual. – Ste Kulov Mar 07 '22 at 02:55
  • 1
    Oh wait. Another thing. Just realized it's `W` and `L`, not `W` and `H`. There is no `H` unless there's some goofy 3D model I don't know about yet. – Ste Kulov Mar 07 '22 at 06:20
  • 1
    @SteKulov Your friends must call you Hawkeye. Thank you for spotting those, and for the flags (they were further down the page when I wrote these, but that was one page too far in the viewer...). – a concerned citizen Mar 07 '22 at 10:29
  • 1
    WARNING: Spotting minor things too frequently may result in not having any friends left! – Ste Kulov Mar 07 '22 at 19:44