Author Topic: ltspice - getting "Unknown subcircuit" when using a .model directive  (Read 8161 times)

0 Members and 1 Guest are viewing this topic.

Offline ledtesterTopic starter

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
I'm trying to use a .model directive in my schematic, but I'm getting an "Unknown subcircuit" error when I try to run the simulation.

I can get it to work if I use a .subckt directive instead. I've attached the ltspice file (it's a very simple circuit.)

What am I doing wrong?

Here is the complete .asc file:

Version 4
SHEET 1 1520 2404
WIRE -560 -32 -688 -32
WIRE -448 -32 -560 -32
WIRE -448 80 -448 48
WIRE -688 96 -688 -32
WIRE -560 160 -560 -32
WIRE -496 160 -560 160
WIRE -688 224 -688 176
WIRE -560 224 -688 224
WIRE -448 224 -448 176
WIRE -448 224 -560 224
WIRE -560 240 -560 224
FLAG -560 240 0
SYMBOL nmos -496 80 R0
SYMATTR InstName M1
SYMATTR Value 2N9999
SYMATTR Prefix X
SYMBOL voltage -688 80 R0
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR InstName V1
SYMATTR Value 5
SYMBOL res -464 -48 R0
SYMATTR InstName R1
SYMATTR Value 1k
TEXT -688 296 Left 2 !.tran 0 0.001 0 1u
TEXT -688 360 Left 2 !.model 2N9999 VDMOS(Rg=3 Vto=1.6 Rd=0 Rs=.75 Rb=.14 Kp=.17 mtriode=1.25 Cgdmax=80p Cgdmin=12p Cgs=50p Cjo=50p Is=.04p mfg=Fairchild Vds=60 Ron=2 Qg=1.5n)
« Last Edit: January 30, 2016, 06:25:03 am by ledtester »
 

Offline liquibyte

  • Frequent Contributor
  • **
  • Posts: 475
  • Country: us
Re: ltspice - getting "Unknown subcircuit" when using a .model directive
« Reply #1 on: January 31, 2016, 04:16:47 am »
I tried for awhile with no luck myself so I decided to look for the spice line itself.  Minus the 2N9999 part, the following line is exact and I found it here

Code: [Select]
.model 2N7002 VDMOS(Rg=3 Vto=1.6 Rd=0 Rs=.75 Rb=.14 Kp=.17 mtriode=1.25 Cgdmax=80p Cgdmin=12p Cgs=50p Cjo=50p Is=.04p mfg=Fairchild Vds=60 Ron=2 Qg=1.5n)
Seeing that, I added a 2N7002 to the simulation and it works though I don't understand what you're trying to achieve with it.

Edit: just for fun, here's the models from Fairchild.
« Last Edit: January 31, 2016, 04:20:46 am by liquibyte »
 

Offline bson

  • Supporter
  • ****
  • Posts: 2270
  • Country: us
Re: ltspice - getting "Unknown subcircuit" when using a .model directive
« Reply #2 on: February 01, 2016, 12:57:12 am »
Get rid of the "prefix x".
 

Offline eetech00

  • Regular Contributor
  • *
  • Posts: 64
Re: ltspice - getting "Unknown subcircuit" when using a .model directive
« Reply #3 on: February 01, 2016, 02:17:25 pm »

Delete the NMOS device then add it back in

If you change the prefix to "X", LTspice searches for a .subckt definition.
Since you are using a .model statement, do not change the prefix to "X".

 

Offline ledtesterTopic starter

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: ltspice - getting "Unknown subcircuit" when using a .model directive
« Reply #4 on: February 11, 2016, 05:16:40 pm »
Thanks everyone - blanking out the PREFIX for the device worked.

I've had a lot of trouble modifying the ltspice lib files to include the 2n7000 definition, so I wanted to figure out how to hard code a device definition into the schematic file using a .model directive.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf