Difference between revisions of "Most frequently asked questions for beginners"

From LTwiki-Wiki for LTspice
(Add DISQUS for comments)
(Why is the current going the wrong way in a resistor?)
(3 intermediate revisions by the same user not shown)
Line 21: Line 21:
  
 
It is not possible to use copy and paste in the symbol editor.  Symbol files are ascii text.  Merge the text as described in [http://tech.groups.yahoo.com/group/LTspice/message/7201?threaded=1&l=1 message 7201] in the LTspice Yahoo Group.
 
It is not possible to use copy and paste in the symbol editor.  Symbol files are ascii text.  Merge the text as described in [http://tech.groups.yahoo.com/group/LTspice/message/7201?threaded=1&l=1 message 7201] in the LTspice Yahoo Group.
 +
 +
==== Why is the current going the wrong way in a resistor? ====
 +
 +
LTspice has to pick a reference current direction, and it can only be one way.  Think of it like the current convention used in [http://en.wikipedia.org/wiki/Kirchhoff%27s_circuit_laws Kirchhoff's circuit laws].  Simply rotate your resistor 180 degrees in the schematic and the current will be to your liking.  '''Alternate:''' Download [[File:Res.asy]] and place in your /lib/sym folder.  This symbol has a small arrow indicating the defined way current flows.
  
 
==== How can I add intrinsic device models (BJTs, FETs, etc.) to LTspice? ====
 
==== How can I add intrinsic device models (BJTs, FETs, etc.) to LTspice? ====
Line 67: Line 71:
 
This section of the asy file gives the location and the same information as opening the .asy file in LTspice.  So it's your preference which approach you take.  
 
This section of the asy file gives the location and the same information as opening the .asy file in LTspice.  So it's your preference which approach you take.  
 
   
 
   
An excerpt from the subcircuit we want to use is listed below in its original form: [http://www.national.com/models/spice/LM/LMH6642.MOD Source of the SPICE model from National Semiconductor]
+
An excerpt from the subcircuit we want to use is listed below in its original form: [http://ltwiki.org/images/f/fa/LMH6642.MOD Source of the SPICE model from National Semiconductor]
 
<pre>
 
<pre>
 
* PINOUT ORDER -IN +IN VCC VEE OUT
 
* PINOUT ORDER -IN +IN VCC VEE OUT
Line 77: Line 81:
 
Saving the opamp2.asy file in LTspice as Opamp2(In+ In- reversed).asy, right-clicking the pins as indicated above, then reversing the pin orders on the input produces this file [[File:Opamp2(In+ In- reversed).asy]]  Note:  You have to close and reopen LTspice so that this symbol is available.
 
Saving the opamp2.asy file in LTspice as Opamp2(In+ In- reversed).asy, right-clicking the pins as indicated above, then reversing the pin orders on the input produces this file [[File:Opamp2(In+ In- reversed).asy]]  Note:  You have to close and reopen LTspice so that this symbol is available.
 
<br>
 
<br>
Finally, we can add our new opamp2 to a test circuit and try it.  We have to save the model [http://www.national.com/models/spice/LM/LMH6642.MOD Source of the SPICE model] to the same directory as our test file.  Next, we can place the component in our circuit, the new Opamp2(In+ In- reversed).  Right clicking on the modified opamp2 component, we put LMH6642 as the Value.  This name must ''exactly'' match the subcircuit name in LMH6642.MOD.  Then we add an include statement on the test file, .include LMH6642.mod.
+
Finally, we can add our new opamp2 to a test circuit and try it.  We have to save the model [http://ltwiki.org/images/f/fa/LMH6642.MOD Source of the SPICE model] to the same directory as our test file.  Next, we can place the component in our circuit, the new Opamp2(In+ In- reversed).  Right clicking on the modified opamp2 component, we put LMH6642 as the Value.  This name must ''exactly'' match the subcircuit name in LMH6642.MOD.  Then we add an include statement on the test file, .include LMH6642.mod.
 
The test circuit is here: [[File:LMH6642 test opamp2(+-).asc]]
 
The test circuit is here: [[File:LMH6642 test opamp2(+-).asc]]
  
You can also make this op-amp a permanent addition to your component selections. See  [[Components_Library#Opamps]]
+
You can also make this op-amp a permanent addition to your component selections. See  [[Components_Library#Opamps]]<br>
 +
Here is an external link as well - [http://jeastham.blogspot.com/2009/10/adding-lm741-op-amp-model-to-ltspice.html Adding a LM741 Op Amp Model to LTSpice ]
  
 
==== I have a pulse source in my schematic with zero transition times.&nbsp; LTspice only shows slow transition times of 2ns.&nbsp; What's going on here? ====
 
==== I have a pulse source in my schematic with zero transition times.&nbsp; LTspice only shows slow transition times of 2ns.&nbsp; What's going on here? ====

Revision as of 04:07, 20 January 2013



What are the different LTspice file types?

Schematic:     name.asc   the drawing with your circuit (a text file)
Symbol:        name.asy   symbols for the schematic (a text file)
Netlist:       name.net   unprocessed netlist (text file viewable from within LTspice 
                          & usable by other SPICE engines) 
Logfile:       name.log   info and results from .four, .measure, .op (text file viewable 
                          from within LTspice); may also contain the fully processed
                          and expanded netlist (a Control Panel setting)
Result:        name.raw   binary output data file (text format may be optionally specified)
Result:        name.fft   binary result of an FFT
Plot settings: name.plt   text file used to save and restore Waveform Viewer plot settings
Model file:     abc.xyz   text file containing model(s) - may be any valid file name
Circuit file:  name.cir   frequently used extension for an external netlist input file (text)

How do you copy and paste between schematics?

Click the Copy Icon in the tool bar or select Copy from the Edit drop down menu (or type ctrl-C).  Select (with the mouse) what you want to copy.  Make the target schematic active (click on it or its tab or type ctrl-Tab) and then click the Paste Icon in the tool bar or select Paste from the Edit drop down menu (or type ctrl-V).

How do I copy and paste between symbols in the symbol editor?

It is not possible to use copy and paste in the symbol editor.  Symbol files are ascii text.  Merge the text as described in message 7201 in the LTspice Yahoo Group.

Why is the current going the wrong way in a resistor?

LTspice has to pick a reference current direction, and it can only be one way. Think of it like the current convention used in Kirchhoff's circuit laws. Simply rotate your resistor 180 degrees in the schematic and the current will be to your liking. Alternate: Download File:Res.asy and place in your /lib/sym folder. This symbol has a small arrow indicating the defined way current flows.

How can I add intrinsic device models (BJTs, FETs, etc.) to LTspice?

Please take a look to the many examples in the files section of the LTspice Yahoo Group (Files => Lib).

How can I add subcircuits to LTspice?

You will find many answers when you search the LTspice Yahoo Group messages for words like "library", "symbol" or "FAQ".

Please read first the programs help:
Help -> Schematic Capture -> Editing Components -> Creating New Symbols
Help -> Help Topics ->FAQs -> Third party models
Help -> Help Topics ->FAQs -> Mosfet

You will find also help in the linked documents from our LTspice Yahoo Group.

Links
Links -> Spice Courseware And Tutorials

There is another document about symbols and models in our Files section.

Files -> Tut -> Symbol Types For Subcircuits

Example: Using the SPICE model LMH6642 from National Semiconductor and the opamp2 symbol

This example will aid the new user in familiarization with the .asy (symbol) and its use in using a subcircuit. The issue that prevents easy utilization of the SPICE model from National Semiconductor is that the pin order list of the SPICE model does not match the pin order list expected by the opamp2 symbol.

You can open the opamp2.asy either in LTspice or in a text editor (such as Notepad) to determine the assumed pin order of opamp2. Right clicking each pin (the blue square) in LTspice provides information about each pin including the label and netlist order. As a summary you can select 'View', 'Pin Table'. Opamp2.asy has a netlist order of In+, In-, V+, V- and OUT. Looking at the opamp2.asy in Notepad you see the following:

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

This section of the asy file gives the location and the same information as opening the .asy file in LTspice. So it's your preference which approach you take.

An excerpt from the subcircuit we want to use is listed below in its original form: Source of the SPICE model from National Semiconductor

* PINOUT ORDER -IN +IN VCC VEE OUT
* PINOUT ORDER  2   3   7   4   6
.SUBCKT LMH6642 2 3 7 4 6

So, we either have to modify the symbol or the subcircuit. Given the provisions of the model, that it cannot be modified (see Copyright) AND there would be other subcircuits that have the same netlist order, i.e. IN+ and IN- reversed, the choice is to make a new symbol and save it under 'Opamps', the same folder as opamp2.

Saving the opamp2.asy file in LTspice as Opamp2(In+ In- reversed).asy, right-clicking the pins as indicated above, then reversing the pin orders on the input produces this file File:Opamp2(In+ In- reversed).asy Note: You have to close and reopen LTspice so that this symbol is available.
Finally, we can add our new opamp2 to a test circuit and try it. We have to save the model Source of the SPICE model to the same directory as our test file. Next, we can place the component in our circuit, the new Opamp2(In+ In- reversed). Right clicking on the modified opamp2 component, we put LMH6642 as the Value. This name must exactly match the subcircuit name in LMH6642.MOD. Then we add an include statement on the test file, .include LMH6642.mod. The test circuit is here: File:LMH6642 test opamp2(+-).asc

You can also make this op-amp a permanent addition to your component selections. See Components_Library#Opamps
Here is an external link as well - Adding a LM741 Op Amp Model to LTSpice

I have a pulse source in my schematic with zero transition times.  LTspice only shows slow transition times of 2ns.  What's going on here?

PULSE(0 5 0 0 0 20n 100n)

LTspice automatically will use a default value for <trise> and <tfall> if these parameters are set to zero.  Default value: 10% of Ton or 10% of Tperiod-Ton whatever is smaller.  You must specify Trise and Tfall if you want a certain value.

PULSE(0 5 0 100p 100p 20n 100n)

Don't use steeper transitions than required by your application.

I have used a pure sine source in my schematic, but the output signal of my circuit looks slightly different from cycle to cycle.

LTspice has waveform compression enabled as the default setting.  This compression reduces the amount of saved data during the simulation.  It's a lossy compression and thus it can distort the saved signals.  You can switch it off with the following command line in your schematic.

.options plotwinsize=0

It could be switched off in the "Control Panel -> Compression" pane as well, but this setting will be lost upon closing the current session of LTspice.

How does one set the threshold and high/low voltages for LTspice's digital devices?

The default threshold is always (Vhigh+Vlow)/2 . Flipflops require either a Td or a Trise for correct operation under every condition.

Right-mouse-click on the device (instance) in the schematic.

  • SpiceLine: Vhigh=3V Ref=1.5
  • SpiceLine2: Td=5n Trise=3n

Schmitt devices have the threshold and hysteresis parameters Vt and Vh instead of Ref. Vup=Vt+Vh Vdn=Vt-Vh.

blog comments powered by Disqus