2020 LTSpice Command Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ECE 2280 LTSpice Commands

ECE 2280
LTSpice Commands

Shortcuts:

[1]
ECE 2280 LTSpice Commands

Spice Simulation Commands: (spice directives)

To do an AC Sweep to obtain the Bode Plots:


.AC [LIN][OCT][DEC] {points} {start} {end}
Examples:
.AC LIN 101 10Hz 200Hz
.AC DEC 20 1MEG 100MEG

To do an transient or time analysis:


.TRAN {print step value} {final time} [{no print time}]
Examples:
.tran 10m
.tran 0.1m 70m 7m *this means that the simulation will have 0.1m steps, go until 70ms, skips first 7ms

To include files such as models:


.include <filename>
(Note: make sure the file is located in the same directory as your saved schematic)

To have measurements in the spice log:


.MEAS [AC|DC|OP|TRAN|TF|NOISE] <name>
+ [<AVG|MAX|MIN|PP|RMS|INTEG> <expr>]
+ [TRIG <lhs1> [[VAL]=]<rhs1>] [TD=<val1>]
+ [<RISE|FALL|CROSS>=<count1>]
+ [TARG <lhs2> [[VAL]=]<rhs2>] [TD=<val2>]
+ [<RISE|FALL|CROSS>=<count2>]

Keyword Operation perform over interval


AVG Compute the average of <expr>
MAX Find the maximum value of <expr>
MIN Find the minimum value of <expr>
PP Find the peak-to-peak of <expr>
RMS Compute the root mean square of <expr>
INTEG Integrate <expr>

Examples:
.MEAS TRAN res7 AVG V(NS01)
+ TRIG V(NS05) VAL=1.5 TD=1.1u FALL=1
+ TARG V(NS03) VAL=1.5 TD=1.1u FALL=1
Print the value of average value of V(NS01) from the 1st fall of V(NS05) to 1.5V after 1.1us and the 1st fall of
V(NS03) to 1.5V after 1.1us. This will be labeled res7.

.MEAS AC rel8 when V(out)=1/sqrt(2) (The result rel8 is the frequency that the magnitude of V(out) is equal to
0.7071067811865475.)

.MEAS AC tmp max mag(V(out)) (the 3dB bandwidth is computed)

.MEAS AC BW trig mag(V(out))=tmp/sqrt(2) rise=1


+ targ mag(V(out))=tmp/sqrt(2) fall=last

[2]
ECE 2280 LTSpice Commands

Print the difference in frequency between the two points 3dB down from peak response. NOTE: The data from a
.AC analysis is complex and so are the .measurement statements results. However, the equality refers only to the
real part of the complex number, that is, "mag(V(out))=tmp/sqrt(2)" is equivalent to
Re(mag(V(out)))=Re(tmp/sqrt(2)).

.meas tran output_pos AVG V(regulator_output_pos)


.meas tran peaktopeakpos PP V(regulator_output_pos)
.meas tran output_neg AVG V(regulator_output_neg)
.meas tran peaktopeakneg PP V(regulator_output_neg)

Others:
.op (operating bias points)
.dc VCC 3.3 5 (DC Sweep)
.DC [LIN] {varname} {start} {end} {incr}
.DC [OCT][DEC] {varname} {start} {end} {points}
Examples:
.DC VIN -.25 .25 .05
.DC LIN I2 5mA -2mA 0.1mA VCE 10V 15V 1V

.IC - Initial Transient Conditions.


.IC { {vnode} = {value} }
Examples:
.IC V(2)=3.4 V(102)=0

(Additional options for the measure command)


.MEAS[SURE] [AC|DC|OP|TRAN|TF|NOISE] <name>
+ [<FIND|DERIV|PARAM> <expr>]
+ [WHEN <expr> | AT=<expr>]]
+ [TD=<val1>] [<RISE|FALL|CROSS>=[<count1>|LAST]]
Examples:
.MEAS TRAN res1 FIND V(out) AT=5m
Print the value of V(out) at t=5ms labeled as res1.

.MEAS TRAN res2 FIND V(out)*I(Vout) WHEN V(x)=3*V(y)


Print the value of the expression V(out)*I(Vout) the first time the condition V(x)=3*V(y) is met. This will be labeled
res2.

.MEAS TRAN res3 FIND V(out) WHEN V(x)=3*V(y) cross=3


Print the value of V(out) the third time the condition V(x)=3*V(y) is met. This will be labeled res3.

.MEAS TRAN res4 FIND V(out) WHEN V(x)=3*V(y) rise=last


Print the value of V(out) the last time the condition V(x)=3*V(y) is met when approached as V(x) increasing wrt
3*V(y). This will be labeled res4.

.MEAS TRAN res5 FIND V(out) WHEN V(x)=3*V(y) cross=3 TD=1m


Print the value of V(out) the third time the condition
V(x)=3*V(y) is met, but don't start counting until the time as elapsed to 1ms. This will be labeled res5.

.MEAS TRAN res6 PARAM 3*res1/res2


Print the value of 3*res1/res2. This form is useful for printing expressions of other .meas statement results. It's not
intended that expressions based on direct simulation data, such as V(3), are present in the expression to be
evaluated, but if they are, the data is taken from the last simulated point. The result will be labeled res6.
[3]
ECE 2280 LTSpice Commands

.MEAS TRAN res6 WHEN V(x)=3*V(y)


Print the first time the condition V(x)=3*V(y) is met. This will be labeled res6.

Note that a “*” is for a comment

Sinusoidal input format:


SINE (Voffset Vamp Freq Td Theta Phi Ncycles)

To perform a parametric sweep which means that a variable in the circuit can be
changed. Follow these steps:
1. Define the component parameter with a variable by editing the component
attribute (Ctrl–right-click on the component) and entering “{X}” for the Value,
where “X” is a user defined variable name. The addition of the curly braces
around the variable is important as it tells LTspice IV that “X” is a parameter.
2. Add a .step command via a SPICE directive that specifies the steps for the
parameter by a linear, logarithmic or list of values.
Example A: “.step param X list .1u .2u .3u” steps the parameter X through each
value listed.
Example B: “.step param X .1u .3u .1u” steps the parameter X from 0.1u to 0.3u
in 0.1u increments.

Example:

[4]

You might also like