Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need help adding components to LTspice

Status
Not open for further replies.

carbonzit

Active Member
So over in another thread I asked about getting a model for the CD4011 (quad NAND chip), which was gracioiusly answered (here) by RonV. So now I can add this part (and all of the CD4xxx series) to my schematics.

But here's the problem: when I try to run a simulation using this part, I get this error message:

**broken link removed**

I think the problem is that the .lib file that contains the subcircuit or model descriptions for these parts isn't being found by the program, even though I put it where I though it should go ( .../lib/sub).

So here's what I'd like, if possible: to find out how to set up LTspice so that I don't have to add any include directives or whatever to my simulations in order to find all the definitions needed for these parts. It should be as easy to add a CD4011B as it is to plop down a NPN or "polecap" or resistor or whatever. I really don't want to have to add these directives in order to use these parts.

So where do I put the various pieces to make this work? The .asy files are already where they belong, and I can access them. I think everything that LTspice needs is in the CD4000.lib file. Can I just put this file in the appropriate folder? or do I need to extract the .subckt definitions from here and put them somewhere else? I don't mind editing a few files, if it's just a one-time setup thing.

+++++++++++++++++++++++++++++++++++++

So I tried copying this .subckt to a new file (CD4011B.sub) that I put in my ../lib/sub folder, but no joy:

Code:
*
*
* 2-input NAND gate
* tpd 125n
* tr 100n
.SUBCKT CD4011B  A B Y  VDD VGND  vdd1={vdd} speed1={speed} tripdt1={tripdt}
.param td1=1e-9*(125-40-10)*5/{vdd1}*{speed1}
*
XIN1  A Ai  VDD VGND  CD40_IN_1  vdd2={vdd1}  speed2={speed1}  tripdt2={tripdt1} 
XIN2  B Bi  VDD VGND  CD40_IN_1  vdd2={vdd1}  speed2={speed1}  tripdt2={tripdt1} 
*
A1  Ai Bi 0 0 0  Yi 0 0  AND  tripdt={tripdt1}  td={td1}  
*
XOUT  Yi Y  VDD VGND  CD40_OUT_1X  vdd2={vdd1} speed2={speed1}  tripdt2={tripdt1}
.ends
 
Last edited:
hi cz,
If you post your LTS .asc file, its far easier for us to try locate the problem.
 
hi cz,
If you post your LTS .asc file, its far easier for us to try locate the problem.

OK, here it is. Pretty simple.

By the way, I got the files from your post here.

=======================================

In general, it would be really, really helpful to some of us LTspice newbies if someone could explain, clearly and succinctly, how to add components: which files (.asy, .sub, .lib, etc.) go in which folders, etc. I know the whole process isn't all that complicated, but I just don't know all the details. (Ronv posted a guide to this earlier, which I successfully used to add an op-amp model, but it didn't help me here.)
 

Attachments

  • CD4011 test.asc
    513 bytes · Views: 380
Last edited:
The file required the .include CD4000.lib

If you want to keep the LTS files structure. you just place the files with a particular ext into the existing LTS folder with same files extensions.

For the asy files I create my own folder in LTS main folder, I called mine MyWork and in this folder I have sub folders called for example OPA, Comparator, 555 etc.

C:\Program Files\LTC\LTspiceIV\lib

C:\Program Files\LTC\LTspiceIV\lib\sub\*.sub

C:\Program Files\LTC\LTspiceIV\lib\sym\ all the symbol files

C:\Program Files\LTC\LTspiceIV\lib\sym\CDlogic\*.asy

C:\Program Files\LTC\LTspiceIV\MyWork
 

Attachments

  • CD4011 test.asc
    539 bytes · Views: 376
The file required the .include CD4000.lib

But that's just the thing: as I said earlier, I don't want to have to mess with .include statements. That's the whole point.

Isn't there a way to incorporate the definitions of these parts into LTspice's file structure so that they become intrinsically known, like other parts (for example, all those LTxxxx parts)?

Another question: I guess I don't have to provide Vdd & Vss to this part? does LTspice just assume that they're connected? but how would that work? shouldn't it have to know what the voltages are?
 
Last edited:
But that's just the thing: as I said earlier, I don't want to have to mess with .include statements. That's the whole point.

Isn't there a way to incorporate the definitions of these parts into LTspice's file structure so that they become intrinsically known, like other parts (for example, all those LTxxxx parts)?

Another question: I guess I don't have to provide Vdd & Vss to this part? does LTspice just assume that they're connected? but how would that work? shouldn't it have to know what the voltages are?
I don't think it can be done. In the .asy file, the SYMATTR SpiceModel is normally followed by the name of the file where the model or subcircuit is found.
Here is my LM393.asy file:
Version 4
SymbolType CELL
LINE Normal -32 32 32 64
LINE Normal -32 96 32 64
LINE Normal -32 32 -32 96
LINE Normal -28 48 -20 48
LINE Normal -28 80 -20 80
LINE Normal -24 84 -24 76
LINE Normal 0 32 0 48
LINE Normal 0 96 0 80
LINE Normal 4 44 12 44
LINE Normal 8 40 8 48
LINE Normal 4 84 12 84
WINDOW 0 16 32 Left 0
WINDOW 3 16 96 Left 0
SYMATTR Value LM393
SYMATTR Prefix X
SYMATTR Description Dual comparator w/open collector outputs
SYMATTR SpiceModel LM393.sub
SYMATTR Value2 LM393
PIN -32 80 NONE 0
PINATTR PinName In+
PINATTR SpiceOrder 1
PIN -32 48 NONE 0
PINATTR PinName In-
PINATTR SpiceOrder 2
PIN 0 32 NONE 0
PINATTR PinName V+
PINATTR SpiceOrder 3
PIN 0 96 NONE 0
PINATTR PinName V-
PINATTR SpiceOrder 4
PIN 32 64 NONE 0
PINATTR PinName OUT
PINATTR SpiceOrder 5
In the CD4000 library .asy files, SYMATTR SpiceModel is followed by VDD 0. Here is the CD4011B.asy file:
Version 4
SymbolType CELL
LINE Normal -16 96 -16 32
LINE Normal 64 64 32 64
LINE Normal -16 48 -48 48
LINE Normal -16 80 -48 80
CIRCLE Normal 32 72 16 56
ARC Normal -48 96 16 32 -16 96 -16 32
WINDOW 0 -16 16 Left 0
WINDOW 3 -32 113 Left 0
SYMATTR Value CD4011B
SYMATTR Description 2-input NAND gate
SYMATTR SpiceLine VDD=5 SPEED=1.0 TRIPDT=5e-9
SYMATTR Prefix X
SYMATTR SpiceModel VDD 0
PIN -48 48 NONE 0
PINATTR PinName A
PINATTR SpiceOrder 1
PIN -48 80 NONE 0
PINATTR PinName B
PINATTR SpiceOrder 2
PIN 64 64 NONE 0
PINATTR PinName Y
PINATTR SpiceOrder 3
Apparently, LTSpice is using this attribute for another purpose.
Look at it this way: With one .include statement (I use .lib, which works just as well), you get access to the whole CD4000 library (as far as it goes). I personally don't have a problem with it.
I know - you do.

Default VDD is 5V. If you want to change it, you have to edit the supply voltage (ctrl-right click on the part, then edit the value of VDD). If you want to play with various values of supply voltages, and you have lots of CD4XXX parts in your schematic, parameterize the value of VDD. If you have lots of identical gates, parameterize one, then copy and paste the rest of them to save time. You will learn lots of these little tricks the hard way, just like I did.:D
 
Last edited:
Thanks! Maybe not the answer I was looking for, but a very helpful one nonetheless.

I like the idea of parameterizing stuff. Don't know how to do it yet w/LTspice, but will educate myself.

Hmm; after re-reading your post, couldn't I add the line

SYMATTR SpiceModel CD4011.sub

to the .asy file (as well as creating CD4011.sub)? Might work?
 
Last edited:
Thanks! Maybe not the answer I was looking for, but a very helpful one nonetheless.

I like the idea of parameterizing stuff. Don't know how to do it yet w/LTspice, but will educate myself.

Hmm; after re-reading your post, couldn't I add the line



to the .asy file (as well as creating CD4011.sub)? Might work?
As I said, SYMATTR SpiceModel is already used. I don't think you can use it twice. You can try it. It's only software. You probably won't break anything.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top