# Trouble attaching new model with built-in symbol

#### bmbouter

Joined May 29, 2021
55
I'm attempting to use the attached DMG1012T.lib (from manufacturer site) to a generic nmos symbol lib\sym\nmos.asy. I've opened the symbol and it clearly shows 3 pins with the netlist labels 'D', 'G', and 'S'. Also the lib file also shows 3 symbols with the line .SUBCKT DMG1012T D=10 G=20 S=30.

When I run it, I get the error saying Port(pin) count mismatch between the definition of subcircuit "dmg1012t" and instance "xm2" The instance has more connection terminals than the definition. But they both show 3 terminals?

Any idea what I'm doing wrong? This is the first time I've connected a model to a symbol....

#### Attachments

• 565 bytes Views: 2

#### eetech00

Joined Jun 8, 2013
3,418
Hi

Changed the first two lines.

try the attached.

#### Attachments

• 559 bytes Views: 2

#### bmbouter

Joined May 29, 2021
55
Thanks! Your model does work nicely. Is the primary change that the D=30 style syntax doesn't work, so the line needs to be: ".SUBCKT DMG1012T 10 20 30" ?

Also how does the symbol know 10, 20, and 30? The symbol has netlist labels D, G, and S with numbers 1, 2, and 3? I'm trying to learn how to fix these sorts of things too. Thank you!

#### crutschow

Joined Mar 14, 2008
30,766
how does the symbol know 10, 20, and 30?
The symbol goes by the sequential position of the numbers following the .SUBCKT DMG1012T.
Thus 10 20 30 correspond to node names in the subckt, which, in turn, are connected to the node numbers 1 2 3 in the symbol.

10 20 30 could be any sequence of node numbers (such as 3 5 7- depending upon the particular subckt net list), and they would still refer to numbers 1 2 3 in the symbol.

Make sense?

#### eetech00

Joined Jun 8, 2013
3,418
Thanks! Your model does work nicely. Is the primary change that the D=30` style syntax doesn't work, so the line needs to be: ".SUBCKT DMG1012T 10 20 30" ?
Yes. Spice has a specific syntax, however, many spice vendors modify the syntax to there own liking, making it unique to their simulator. LTspice is (mostly) compatible with PSpice.

Also how does the symbol know 10, 20, and 30? The symbol has netlist labels D, G, and S with numbers 1, 2, and 3? I'm trying to learn how to fix these sorts of things too. Thank you!
The .SUBCKT line defines the name of the subcircuit and is followed by the pin names. The order of the pin names (left to right) on the line is significant. Each pin name is given a "netname" that is later used as "I/O" for providing both external and internal connectivity for the subcircuit. Netname's are the glue that connects the internal device primitives together, like diodes and resistors, and forms the internal component model.

The order of the subcircuit pin names is significant and should be followed, respectively, by the symbol:

For the subcircuit we are discussing:
subcircuit pin number: 1 2 3 <--- this is the pin order, left to right
subcircuit pin name: 10 20 30 <---each of these is a "netname"

Each symbol in LTspice also has a definable pin order and problems occur when a user does not define the symbol pin order in the same sequence as the subckt definition. The symbols pin order can be viewed while in the symbol editor by choosing "view->pin table". The names do not need to match those in the subcircuit, only the order is significant.

See below.
The "SpiceOrder" column is the significant order of the symbols pins. The "Name" can be just about anything and doesn't have to match those named in the subckt definition. The symbol sequence number is supposed to be insignificant, but I have seen errors many times when there are gaps in the pin numbers. So I don't allow gaps and make them contiguous starting with "1".

So, based on the above discussion, I think you can see that if I define my .subckt pins, thus:

.SUBCKT MYNMOS D G S

but then set the pin order in the LTspice symbol:
S 1
D 2
G 3

There is obviously going to be a malfunction of the component model due to incorrect pin mapping.
The symbol "S" will map to subckt "D", "D" will map to subckt "G", and "G" will map to subckt "S" causing a malfunction of what may be a perfectly good model.

Hope that helps....