Article: Andy Collinson
Email :
Quick Index
Drawing the Schematic
General Navigation
Edit Components
Operating Point Analysis,
Display Node Numbers,
Labelling Nodes,
Rounding Values,
DC Sweep
Using Measure,
Parameter Sweep,
Maximum Power
After selecting a component, you have the option to place another of the same type press Escape to cancel this. Components can be moved around by pressing F7. Wires are drawn by pressing F3 or from the edit menu.
Other components are found in the main component menu, by pressing F2, or the icon on the menu bar as shown above. Use the scroll bar and then click on voltage generator as shown above. The triangle symbol is the ground symbol or 0 Volt line in the circuit. Every schematic needs a ground as a reference and it is always labelled as node 0.
Edit Component ValuesAfter re-arranging components, press F7 and move the component, F5 deletes a wire or component and F3 draws a wire. the simple series circuit is drawn, as above. To edit the value of a component right click its symbol and enter a new resistance value. The designation can also be changed with a right click, e.g. right click over R1 to change the designation.
Operating Point Analysis* Z:\media\share\electronics\ltspice\basic_dc.asc
R1 N002 0 15k
R2 N001 N002 5k
V1 N001 0 20V
.op
.backanno
.end
The title line includes the PATH to where the circuit was loaded from, ending with the file id, basic_dc.asc Lines 2 and 3 contain resistor statements and line 4 is the voltage source V1. The ground terminal is always node 0 in any circuit. The next line contains the simulation command, followed by some options, the final line is an .end statement. More about spice netlists can be found in the Spice Primer article.
Displaying Node Numbers in the Status BarTo display the voltage across resistor R2, it is simply the difference between the node voltages. Hovering the mouse cursor near a wire the node will be displayed on the bottom left of the main LTspice window. As the topmost terminal is displayed as n002, and the lower connection is Vout then entering the expression: V(n002) - V(vout) as shown above will compute the voltage across R2.
An alternative method is to use comma separated node values as shown above. This is just V, for voltage then the node numbers separated by a comma and encased in parenthesis. Whichever method it is helpful to create a text marker, press "t" and enter "VR2" to remind you what is being displayed.
Decimal PlacesThis will display the voltage difference between nodes 1 & 2 to three decimal places. Replace 1 and 2 with the appropriate node number in your circuit. Change the value of the multiplier for other values of decimal places, e.g. for two decimal places multiply and divide by 100.
The example above is the same circuit with all of the above rounding techniques. Generally you would fix all values with the same number of places but the voltage across VR4 and current through R4 are set at 2dp (decimal places), the voltage across VR2 is rounded to dp and Vout has no rounding at all.
To enter the simulation you can use the menu or type "s" and enter the simulation command. Unless you have experience with spice based simulators, you will find it easier to go to the simulation menu and choose option, "edit simulation command" as shown below:
The options for the simulation command appear. Click on the DC sweep tab. The fields below are the id of the source (current or voltage ) to be swept and from our schematic this is V1. The next field is used to set a linear or logarithmic sweep, and then there is the start value, stop value and increment. If increment is left out, then the default value of 1 is used. The full simulation command is .dc V1 1 10 as shown below.
After running the circuit and clicking on Vout, the following result is displayed. As current through a resistor is proportional to voltage across it, then there's no surprise that the graph is a straight line. The horizonal (x-axis) displays the voltage source V1, while the vertical (y-axis) is a plot of Voltage at the resistor R1 and R2 junction, more conveniently labelled as Vout.
If my graph looks a little different to yours its because I "tweaked" the graphs axis. Right click at the left hand side (y-axis) you will see a dialog box like below, where you can change start, stop and increment values. Its the same for the x-axis as well.
Using Measure Commands
If you want to know the current or voltage at a particular node when some condition is reached
you can use a measure command. A measure command starts with a period followed by "measure" or
"meas" and uses the following syntax:
.MEAS[SURE] [AC|DC|OP|TRAN|TF|NOISE] <id>
+ [<FIND|DERIV|PARAM|MAX|MIN|AVG|PP|RMS|INTEG> <expr>]
+ [WHEN <expr> | AT=<expr>]]
+ [TD=<val1>] [<RISE|FALL|CROSS>=[<count1>|LAST]]
The syntax looks quite daunting, but let me offer some further explanation. Any statement or expression in square brackets "[ ]" is optional, and may be omitted. Any value in angle brackets "< >" is mandatory. The pipe "|" symbol means choose one OR other value and the plus "+" symbol is a continuation. So to begin type .meas or .measure to start your command. The first statement [AC|DC|OP|TRAN|TF|NOISE] is the applicable analysis. For circuits involving ac or transient or noise calculations in the time or frequency domain these values are relevant but may be omitted for simple DC circuits. Next follows a mandatory result id in angle brackets, followed by the measured quantity. The last two statements determine the condition(s) for the calculated result.
So, for example if you want to measure the current through R2 when the voltage V1 is at 6 Volts and the voltage across R2 when V1 is at 5 Volts. Press "s" to enter a simulation command and enter the two expressions shown below:Take note of the bottom left hand button. The "test" feature will evaluate your expression before you simulate the circuit.
Parameter Sweep
As well as simulating a circuit with variable input voltage, its often useful to know
how it will perform if one component or parameter is altered. Consider the simple voltage
divider circuit below. The power supply, V1 is fixed at 10V but this time the value of resistor
R2 is swept from 10 ohms up to 10 kohms. Instead of a fixed value, R2's resistor is placed inside
braces "{}", and given the value "R".
A new simulation command is entered, the step command, with the parameter to be swept "R" and followed by start, stop and incremental values. As before a step command editor exists by right clicking the .step statement. This is shown below:
Maximum Power
Once the circuit is run pressing "alt" + "control" on the keyboard, and then moving the mouse
to the center of R2 a thermoneter icon is displayed.
Keeping alt + control pressed and left clicking will now plot power through R2 (y-axis) against
resistance of R2 on the x-axis, see below:
Notice the y-axis is also labelled in mW and the graph is a curve. Pressing ctrl+L you can see the maximum power generated in R2 is when R1 = R2 or 1k or you may want to adjust the graph with a logarithmic x-axis as below:
DC Sweep with Non-Linear Component
Diode Characteristics
Finally I'll finish this article with a DC sweep through a non-linear component, the diode.
The diode can be accessed by pressing the shortcut 'd' when in the schematic editor. You can
right click its symbol to select a diode type.
In LTspice and other simulators, the diode is modelled with a list of parameters. These parameters are not the same as the small signal characteristics that you would find on the manufacturers datasheet, but some do have similar ids. The accuracy of the simulation depends upon the accuracy of the model. If the diode model in LTspice does not exist, then you have two choices when adding a new component, use the manufacturers spice model, (if one exists) or use a model from the internet. The circuit is below:
This time the DC voltage voltage V1, starts at -120Vdc and is swept through to +10Vdc in 1 volt increments. Unless you have access to a lab or test bench equipment this would be difficult to do. The characteristic of the diode are shown below:
The test voltage is measured directly across the anode and cathode of the diode, as the cathode is connected to the ground or 0volt, the anode is node 2 (n002) in this circuit. Breakdown occurs at -110Vdc and conduction in the forward region starts at around 0.5 Volt.
I'll zoom in on this region shortly but first an actual datasheet1 for the 1N4148 from Vishay Semiconductors is shown below:
The datasheet shows that at 1.6Vdc forward currents of almost 1000mA (1A) will flow. To simulate this in LTspice the value of R1 must be changed from 1k to 0.5 ohm. The simulation is rerun and axis zoomed to match the graph by Vishay semiconductor. The results are quite a good match.