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.

Help! w/LTspice

Status
Not open for further replies.

carbonzit

Active Member
I would've tried to find answers that have already been given, but since the search facility here is, let's say, less than optimal, I'm asking here.

So I've got a circuit I want to simulate in LTspice, all set up and ready to go. I can run it, but I'm not getting the waveform I should be seeing (triangle wave).

I think there may be a problem with the op-amp model I'm using. I copied National Semi's model for the LM358, but I may have screwed it up: the symbol I inserted was a generic op amp ("opamp2"), and I gave LM358/NS (Nat'l.) as the value. Is this right?

It ran and gave me a flat waveform at the output until I connected U2 to power. Now it runs a bunch of iterations, very much slower, then gives an error message ("Singular matrix: check node u2:6 Iteration No. 1").

Isn't there some way to indicate that these 2 op-amps are in the same package, and only one of them needs power connections?

Lots more questions to follow ...
 

Attachments

  • Spicecap1.gif
    Spicecap1.gif
    31.5 KB · Views: 864
I was actually able to run this, stop it (with <Esc>) and see what looked like a believable waveform. If I let it run to completion, I get the error message indicated above.

If anyone wants to help, here's my LTspice project. You need to include potentiometer.sub:

Code:
* This is the potentiometer
*      _____
*  1--|_____|--2
*        |
*        3
*
.SUBCKT potentiometer 1 2 3
.param w=limit(wiper,1m,.999)
R0 1 3 {Rtot*(1-w)}
R1 3 2 {Rtot*(w)}
.ENDS

and LM38.mod (from National Semicircular):

Code:
*//////////////////////////////////////////////////////////////////////
* (C) National Semiconductor, Inc.
* Models developed and under copyright by:
* National Semiconductor, Inc.  

*/////////////////////////////////////////////////////////////////////
* Legal Notice: This material is intended for free software support.
* The file may be copied, and distributed; however, reselling the 
*  material is illegal

*////////////////////////////////////////////////////////////////////
* For ordering or technical information on these models, contact:
* National Semiconductor's Customer Response Center
*                 7:00 A.M.--7:00 P.M.  U.S. Central Time
*                                (800) 272-9959
* For Applications support, contact the Internet address:
*  amps-apps@galaxy.nsc.com

*//////////////////////////////////////////////////////////
*LM358 DUAL OPERATIONAL AMPLIFIER MACRO-MODEL
*//////////////////////////////////////////////////////////
*
* connections:      non-inverting input
*                   |   inverting input
*                   |   |   positive power supply
*                   |   |   |   negative power supply
*                   |   |   |   |   output
*                   |   |   |   |   |
*                   |   |   |   |   |
.SUBCKT LM358/NS    1   2  99  50  28
*
*Features:
*Eliminates need for dual supplies
*Large DC voltage gain =             100dB
*High bandwidth =                     1MHz
*Low input offset voltage =            2mV
*Wide supply range =       +-1.5V to +-16V
*
*NOTE: Model is for single device only and simulated
*      supply current is 1/2 of total device current.
*      Output crossover distortion with dual supplies
*      is not modeled.
*
****************INPUT STAGE**************
*
IOS 2 1 5N
*^Input offset current
R1 1 3 500K
R2 3 2 500K
I1 99 4 100U
R3 5 50 517
R4 6 50 517
Q1 5 2 4 QX
Q2 6 7 4 QX
*Fp2=1.2 MHz
C4 5 6 128.27P
*
***********COMMON MODE EFFECT***********
*
I2 99 50 75U
*^Quiescent supply current
EOS 7 1 POLY(1) 16 49 2E-3 1
*Input offset voltage.^
R8 99 49 60K
R9 49 50 60K
*
*********OUTPUT VOLTAGE LIMITING********
V2 99 8 1.63
D1 9 8 DX
D2 10 9 DX
V3 10 50 .635
*
**************SECOND STAGE**************
*
EH 99 98 99 49 1
G1 98 9 POLY(1) 5 6 0 9.8772E-4 0 .3459
*Fp1=7.86 Hz
R5 98 9 101.2433MEG
C3 98 9 200P
*
***************POLE STAGE***************
*
*Fp=2 MHz
G3 98 15 9 49 1E-6
R12 98 15 1MEG
C5 98 15 7.9577E-14
*
*********COMMON-MODE ZERO STAGE*********
*
*Fpcm=10 KHz
G4 98 16 3 49 5.6234E-8               
L2 98 17 15.9M
R13 17 16 1K
*
**************OUTPUT STAGE**************
*
F6 50 99 POLY(1) V6 300U 1
E1 99 23 99 15 1
R16 24 23 17.5
D5 26 24 DX
V6 26 22 .63V
R17 23 25 17.5
D6 25 27 DX
V7 22 27 .63V
V5 22 21 0.27V
D4 21 15 DX
V4 20 22 0.27V
D3 15 20 DX
L3 22 28 500P
RL3 22 28 100K
*
***************MODELS USED**************
*
.MODEL DX D(IS=1E-15)
.MODEL QX PNP(BF=1.111E3)
*
.ENDS
*$
 

Attachments

  • LED throbber.asc
    2.9 KB · Views: 377
Last edited:
hi cz,
I would suggest when you post a LTS query that you post the asc file.

To have a dual LM358 model for LTS, which IMHO is a waste of time, you have to create a 'hierarchical' circuit...
 
hi cz,
Your asc file runs OK for me.

BTW, if you want to cut down the simulation time click the box as shown in image #1
Skip initial op point.


EDIT:
The include potentiometer.sub command used the 'regular' sub from my hard drive.
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    9.8 KB · Views: 486
  • AAesp02.gif
    AAesp02.gif
    31.8 KB · Views: 513
Last edited:
hi cz,
If you want your circuit to be less cluttered with connecting lines, use F4 key to assign a label to Nodes.
Example image.
 

Attachments

  • AAesp03.gif
    AAesp03.gif
    13.5 KB · Views: 607
Thanks!

Thanks much, Eric. I'm leaping over the barriers to learning this package with your help.

Here's a small puzzle: I made the following change to my circuit, adding a collector resistor to the Q (R8). As a result, the simulation slows down to a crawl and never completes. Is this a bug in the program? some topological situation it can't deal with? have I created a "forbidden" condition? Not a huge deal, just curious.

Anyhow, I'm now pretty much at the point where I can happily plug in components and change values, and instantly see the results. This is definitely a great tool, whatever its shortcomings may be.

Something else I'm going to want to know is where I can download symbol libraries and models (like for unsupported transistors). Anywhere besides that Yahoo! group that gets mentioned everywhere, which seems to be defunct.
 

Attachments

  • LED throbber.asc
    3.4 KB · Views: 290
carbonzit, the lack of search ability of hte forum is known, and there's an easy solution, simply use Google's advanced search and limit the results to this domain, then you have all the power of Google search on everything here, this site is actively indexed on Google.
 
carbonzit, the lack of search ability of hte forum is known, and there's an easy solution, simply use Google's advanced search and limit the results to this domain, then you have all the power of Google search on everything here, this site is actively indexed on Google.

Actually, if you read ElectroMaster's reply to my query about this, you'd know that they added Boolean search operators (AND, OR and NOT) to the search facility here. So there is something to be said for being an irritant and asking inconvenient questions. Sometimes the squeaky wheel does get the grease ...
 
There would be something to be said for it if I hadn't already brought the same topic up twice and nothing was done =)
 
There would be something to be said for it if I hadn't already brought the same topic up twice and nothing was done =)

Just think of me as the straw that broke the camel's back.

BTW, did you get a chance to look at the circuit in post #6 above? I'm still curious why this seems to "break" LTspice.
 
It doesn't break LTspice it's just stretching a specific problem point of the math, all spice compilers would do the same thing, add more real world parameter like parasitic's, they'll tend to solve themselves.
 
hi cz,
Basically there isnt a 'sane' solution for the circuit, consider how you have the output transistor configured.!

Do this.
Go to Menu...........Tools/Control Panel/Spice..... change Normal to Alternate... ok
While you have the Spice window showing the Normal/Alternate options, change the 'tritol
[*]' from 1 to 7, this reduces tight tolerance on the calculatins, it will speed things up a bit.

Lets know you go.

Rerun your Sim, note the 'weird' waveform on the 2N2222 collector.
 
Last edited:
Thanks, Eric: that was quite educational, not to mention amusing!

So without asking you to spoon-feed me basic transistor/circuit theory, why that decidedly weird waveform? (in 20 words or less?)

And in general, why is this not a "sane" configuration?

Be assured that I'm doing my homework on my end and reading my textbooks. At this point, what you had me do to tweak Spice is a little over my head.

Recommend a good Spice manual (keeping in mind my other comments about the quality of documentation)?

Thanks again!
 
Thanks, Eric: that was quite educational, not to mention amusing!

So without asking you to spoon-feed me basic transistor/circuit theory, why that decidedly weird waveform? (in 20 words or less?)

And in general, why is this not a "sane" configuration?

Be assured that I'm doing my homework on my end and reading my textbooks. At this point, what you had me do to tweak Spice is a little over my head.

Recommend a good Spice manual (keeping in mind my other comments about the quality of documentation)?

Thanks again!

hi,
Twenty words less....mmmmmmmmmm

I will ponder an explanation, hopefully and get back to you.

I guess you know that I really think you should bite the bullet and join that Forum, the forum has FAQ's which answer most of the problems we run into with LTS.

BTW: these thoughts are not to be included in my 20 word allocation
 
hi,
Look at this marked up image.
The LM358 output is high and has low impedance, so its forward biassing the transistor.
Allowing for a Vbe drop of 0.7V, means the emitter is at 5V, so with that 5K emitter resistor, means it passing 1mA.

The collector is connected to +12V via a 10K, so if 1mA did flow in the 10K, the collector voltage would be 2V, which it cannot be as the emitter is at 5v.
So LTS is trying an impossible calculation, you try it with pencil and paper, lets know what you get...

Thats not a bad explanation for only 20 words.!:rolleyes:
 

Attachments

  • AAesp11.gif
    AAesp11.gif
    9.8 KB · Views: 435
I guess you know that I really think you should bite the bullet and join that Forum, the forum has FAQ's which answer most of the problems we run into with LTS.

Well, if worse comes to worst I'll join it, but it's not my preference. Having participated here on Electro Tech has really spoiled me, I guess. So many advantages to this type of forum over Yahoo!'s text-only medium. (I guess you can post HTML-formatted emails there.)

Are there any other forums that deal with LTspice, or with any other flavors of spice?

BTW: these thoughts are not to be included in my 20 word allocation

I wouldn't dream of penalizing you after that great answer you gave!
 
The LTSpice user group contains more information about LTSpice specifically and Spice in general than you will need outside of a professional environment.
There is no one source for knowledge and information, don't cripple yourself by thinking there is. This website is just one method of communication to somewhat like minded individuals. Start with the Yahoo LTSpice forum, and work your way up from there. Spice is pretty standard for a reason, if you're trying to learn a new flavor of spice it's probably bad because it was designed to be a standard, it brooks almost no room for improvement outside of the SPICE compiler itself. Some leeway has been given for arbitrary behavioral systems (straight logic gates not simulated ones) but that's a whole different ballgame.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top