Linear Circuit Analysis


LTspice

LTspice is a powerful, fast, and free SPICE (Simulation Program with Integrated Circuit Emphasis) simulator software developed by Analog Devices. It is widely used by engineers for simulating analog circuits, mixed-signal circuits, and power electronics. LTspice provides a user-friendly graphical interface for designing circuits, running simulations, and analyzing results. It supports a wide range of components, including resistors, capacitors, inductors, diodes, transistors, and operational amplifiers. Additionally, LTspice allows users to create custom components and models, making it a versatile tool for circuit design and analysis. Feel free to download and install it on your computer LTspice from here.

Users can export circuit digrams from the CircuitsU website as a netlist file (*.net) that can be opened in LTspice for further analysis and simulation. This option is currently available only for DC and AC circuits.

Syntax

LTspice is using a modified nodal analysis technique to compute the voltages and currents in the circuit numerically. To simulate a circuit the user create a netlist file that contains a list of components and their connections. Below is a description of some of the basic components that can be inncluded in a netlist file.

  1. Independent voltage source
    Vname N+ N- [DC value] [AC value] [transient shape]
  2. Independent current source
    Iname N+ N- [DC value] [AC value] [transient shape]

    Both sources can be set can generate waveforms:

    • SIN(offset amplitude freq)
    • PULSE(V1 V2 Tdelay Trise Tfall Ton Tperiod)
    • EXP(...), PWL(...), etc.

  3. Resistor
    Rname N1 N2 value
  4. Capacitor
    Cname N1 N2 value [IC=initial_voltage]
  5. Inductor
    Lame N1 N2 value [IC=initial_current]
  6. Voltage-Controlled Voltage Source
    Ename N+ N- NC+ NC- gain
  7. Voltage-Controlled Current Source
    Gname N+ N- NC+ NC- transconductance
  8. Current-Controlled Voltage Source
    Hname N+ N- Vcontrol gain
  9. Current-Controlled Current Source
    Fname N+ N- Vcontrol gain

The ground node is denoted by 0. Since LTspice uses a modified nodal analysis technique to solve the circuit equations, it is important for the circuit to have a ground node. Otherwise, one can get errors such Node XXX is floating or singular matrix.

The following examples illustrate how to write the netlist file for a few simple circuits.

Example 1
+ V0 20 10 A 4 3 5 V v2 v3 v1
* Circuit with independent voltage and current sources
R1 v1 v2 20                   ; 20Ω resistor from node v1 to v2
I1 v3 v1 10                   ; 10A current source from node v3 to v1
R2 v1 v3 4                    ; 4Ω resistor from node v1 to v3
R3 v2 0 3                     ; 3Ω resistor from node v2 to 0
V1 v3 0 5                     ; 5V voltage source from node v3 to 0

.op                           ; Compute the DC bias point
.end
Example 2
Ix 1 V 3 I x + V0 3 A 1 2 v2 v1 v3
* Circuit with a current-controlled voltage source
V1 v2 v1_ 1                   ; 1V voltage source from node v2 to v1_
VIx v1_ v1 DC 0               ; add dummy voltage source with 0V
H3Ix v1 0 VIx 3               ; Voltage-controlled voltage source from node v1 to 0
I1 v1 0 3                     ; 3A current source from node v1 to 0
R1 v2 v3 1                    ; 1Ω resistor from node v2 to v3
R2 0 v3 2                     ; 2Ω resistor from node 0 to v3

.op                           ; Compute the DC bias point
.end
Example 3
6 V 3 V x 2 20 + Vx 5 8 V 10 9 10 v1 v2 v3 v4 v5
* Circuit with voltage-controlled current source
V1 0 v1 6                     ; 6V voltage source from node 0 to v1
G3Vx 0 v2 N2 N3 3             ; Voltage-controlled current source from node 0 to v2
R1 v1 v3 2                    ; 2Ω resistor from node v1 to v3
R2 0 v2 20                    ; 20Ω resistor from node 0 to v2
R3 0 v2 5                     ; 5Ω resistor from node 0 to v2
V2 v2 v3 8                    ; 8V voltage source from node v2 to v3
R4 v3 v4 10                   ; 10Ω resistor from node v3 to v4
R5 v2 v5 9                    ; 9Ω resistor from node v2 to v5
R6 v4 v5 10                   ; 10Ω resistor from node v4 to v5

.op                           ; Compute the DC bias point
.end
Example 4

Consider that the current of the independent source is $$I_1(t)=9 \class{mjunit}A \cdot \cos(\omega t + 45^\circ)$$

3 + Vx I1 ( t ) 2 V x 20 µH 20 + V0 30 µH I0 3 µF v1 v2 v3 v4
* AC circuit simulation
R1 0 v1  3                    ; 3Ω resistor from node 0 to v1
I1 v2 v1 AC 9 45              ; 9A current source from node v2 to v1
E2Vx 0 v3 v2 v1 2             ; voltage-controlled voltage source from node 0 to v3
L1 0 v4  2E-05                ; 2E-05H inductor from node 0 to v4
R2 v1 v2  20                  ; 20Ω resistor from node v1 to v2
L2 v3 v4  3E-05               ; 3E-05H inductor from node v3 to v4
C1 v4 v2_C1  3E-06            ; 3E-06F capacitor from node v4 to v2_C1
VI0 v2_C1 v2  0               ; add dummy voltage source with 0 V so LTspice can compute the current going through the wire

.ac lin 100 1k 10k            ; Compute the small-signal response from 1 KH to 20 kHz
.end
Read more

First SPICE program
LTspice
Analog devices