LTSpice - DC Analysis

Article: Andy Collinson
Email :


Please Note: All the information presented here is my own work and not from Linear Technology. This advice does not replace the information given by Linear Technology, the LTWiki or the Yahoo LTspice User group. Please also read my sites general disclaimer.

Quick Index
Drawing the Schematic  General Navigation  Edit Components  Operating Point Analysis
Display Node NumbersLabelling NodesRounding ValuesDC Sweep  Using MeasureParameter SweepMaximum Power

DC Analysis
Drawing the schematic
Start LTspice and select New Schematic from the File Menu. Components can be selected in two ways. Either from the edit menu, or by pressing F2. The F2 key will give access to all the components in LTspice, frequently used parts like the resistor,capacitor, inductor and ground symbol can be selected from the top menu line.
General Navigation
Also shown on the edit menu are general navigation keys. For example, key F3 draws a wire, F4 allows you to label a net, F5 will delete a wire or symbol, F6 copies a component and F7 allows you to move a component. To perform the same action on a group of components, first select the action e.g. F5 for delete, then hold down the left mouse button and drag a rectangle around the components to be edited. Once mouse button is released, the action will be performed. If you make a mistake, F9 will undo previous action.

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 Values

After 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
An operating point analysis (.op) will provide a DC analysis of the circuit and results will appear in a dialog box. There are three ways to add the .op analysis to your circuit; from the simulation menu or by pressing "s" or "t" on the keyboard. If you press "t", then change the radio button to SPICE directive and add the text .op as shown below. Note that pressing "s" automatically selects a spice directive: Running the Simulation
To run the simulation click on the running man icon or press the appropriate hotkey if you remapped this function. The DC operating point is calculated with all capacitances open circuited and all inductances short circuited. The results will appear in a dialog box, as shown below: Conventional Current
You may be surprised to see that the current from the power supply has a negative value. This is because LTspice assumes conventional current flows from positive to negative terminal; but actual electron flow is from negative to positive terminal. This is why the minus "-" sign is used.

Ltspice Netlist
Every circuit contains a netlist. The netlist is an ASCII text file describing the circuit. The first line is always the title, and the other lines will contain node numbers and circuit descriptors for each component. The netlist can be displayed from the View Menu, SPICE netlist. The netlist for the simple dc circuit is shown below:

* 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 Bar
After an .op simulation has been run, when you move your mouse cursor over a wire, the voltage at that node will appear on the status bar. This is shown on the screenshot below. If you move your mouse pointer over a component the current and power dissipated in that component will also be displayed. For example, hovering over R1 will show the current is 1mA and power dissipation in R2 is 15mW. Spice error Log
After each simulation, or if something went wrong a spice error log is created. This is available from the view menu or by shortcut keys Ctrl+L.

Operating Point Data Labels
Each connection in a circuit is given a node number. Sometimes it is useful to display the numeric dc value of a node. To label a node, after the simulation has run, double click the desired wire segment as shown below, the operating point voltage of the node will be displayed: Voltage and Current Labelling
By default the voltage of a node will be displayed. However you can display current through the node or use a numeric expression. Right click over the current label and you will see a screen like below:
The default expression is the dollar character, "$" which will display voltage at that node. However, the expression may be edited to any equation, including currents, powers or even the voltage of a specific node. Once placed, these data labels may be moved or copied to other nodes in the circuit.
To display, say current through R1, delete the $ and click on the I(R1) as shown above. Click on OK and current through R1 will be displayed. You can even double click the vertical wire segment, which will show voltage of the node. The screenshot below shows the modified circuit, now displaying both voltage and current at node 2. Values between Nodes and Decimal Values
So far, the examples have been easy and all answers were integers. Now consider the circuit below: When run you will have a table of results, click the close button and the results will be displayed on the schematic, see below: As before clicking on wire segments allow you to enter an expression. For the node Vout this is simply $. Now look at the junction called VR2. Right click to edit the expression. A dialogue box similar to below will be displayed:

To 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 Places
LTspice has many math functions and the "round" function may be used to truncate the number of digits displayed. To limit a particular voltage node to just 3 decimal places, use the following expression: round($*1k)/1k Similarly, if you want to round the displayed value of a current use the following expression: round(I(R1)*1k)/1k Replace R1 with the node you want to display. To round a value between two nodes, use the following expression: round(V(1,2)*1k)/1k

This 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.


DC Sweep
Starting again with a basic voltage divider with two resistors is an easy way to introduce the DC sweep. So far all results, have been static, steady state values. If you want to see how a circuit results when the DC voltage is increased, you use a simulation command called .DC All simulation commands are prefixed with a period "." The circuit is shown below:

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: Once the simulation has been run the results are available in the View Menu under "Spice Error Log" or the shortcut "ctrl + L". The output is shown below: The expressions are evaluated in the order they are placed on the schematic and shown at the top of the spice error log. The measure command is extremely powerful, fortunately a measure command editor exists. Its not available directly from the menu though, but can be invoked this way. Press "s" and create a blank ".meas" statement. Place this somewhere on your schematic and right click, the measure command editor will then appear as 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:

The increment can be linear, octave, decade or a list of values. In addition, another example of the measure command is used, this time to calculate maximum power through R2.

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.

Top of Page

References
LTwiki web site: http://www.ltwiki.org
Measure Commands
11N4148 datasheet
Return to LTspice