For when the path is a loop

1. Variables in LTspice

  • Curly braces { } denote places to substitute variables. Before LTspice can simulate, the contents of the { } must resolve to a number, though the substitutions can be several layers deep.

  • .param name=foo statements teach LTspice how to resolve the symbolic names to values.

  • .param other=name*2 is also valid! See the Help for the functions available also.

  • .param foo=7, then the resistor value {other} will resolve to 14 by the start of the simulation.

From LTspice’s main window, Help  Help topics F1 opens the locally-installed documentation in a web browser:

ltspice help param
Figure 1. LTspice’s Help is very useful

1.1. .param sweep the base resistance

ltspice vdivider
Figure 2. Voltage divider

First, learn to do a parameter sweep by varying the base resistor RB's value.

Read the documentation for the .step dot command.

Types of things can be stepped:

Ways the step values can be selected:

The definitions of the specifiers lin / oct / dec / list for linear, octave, decade, and list steps are found in the first mention of them — in the .AC dot command.

Go there and read about it!

beta test jig1
Figure 3. Beta test jig in LTspice

What does Figure 3 do?

What value of RB makes V(c) == 5 V?

  • Figure this out by doing a .param sweep

RB =

What happens to this “best” value when the transistor’s \(\beta\) or \(h_{FE}\) changes?

1.2. .param a model value

There are two ways to sweep a model’s parameter value. Which is best depends on your goals.

1.2.1. Direct .step syntax

Straight from the documentation:

.step NPN 2N3904(BF) 100 300 10

1.2.2. Custom model with parameter substitutions

ltspice user library
Figure 4. LTspice library files in %LOCALAPPDATA%

See the effect of different β values on the Lab 2: Fig. 2. BJT beta test jig.

This requires changing a parameter inside a model, and then running a sweep simulation to step that value over a range.

Find the models which show up in the menu at C:\Users\<username>\AppData\Local\LTspice\lib\cmp\standard.bjt

What else is in the lib\ folder?

Open standard.bjt and find the .model statement for the 2N3904 transistor that we’ve been using.

Copy the definition, then add it directly to your schematic as a SPICE Directive (the black .t icon).

ltspice spice directive

Change the name to make it unique (e.g. to 2N3904x) so you don’t need to worry about name clashes and trying to figure out which model the simulator will actually use for the simulation.

What does happen when there are two .models with the same type and name?

.param beta=132

.model 2N3904x npn( ...
+ more
+ Bf={beta}  $ <--- see the parameter substitution
+ lots more
+ )

.step param beta 15 450 1