First we need to build something that has an amplification factor of 1, and the output is equal to the input. In the LTspice help, as shown in Figure 1. Select LTspice Simulator
Figure 1: LTspice help
Figure 2: LTspice Simulator
Select Circuit Elements in Figure 2, and it will show you some basic components. These are basically common to SPICE, but some may not be common. It is recommended to see which beginnings the standard SPICE supports. Here we select voltage dependent voltage, and its description is shown below.
E. Voltage Dependent Voltage Source
Symbol Names: E, E2
There are three types of voltage-dependent voltage-source circuit elements.
Syntax: Exxx n+ n- nc+ nc- <gain>
This circuit element asserts an output voltage between the nodes n+ and n- that depends on the input voltage between nodes nc+ and nc-. This is a linearly dependent source specified solely by a constant gain.
Syntax: Exxx n+ n- nc+ nc- table=(<value pair>, <value pair>, ...)
A look-up table is used to specify the transfer function. The table is a list of pairs of numbers. The second value of the pair is the output voltage when the control voltage is equal to the first value of that pair. The output is linearly interpolated when the control voltage is between specified points. If the control voltage is beyond the range of the look-up table, the output voltage is extrapolated as a constant voltage of the last point of the look-up table.
Syntax: Exxx n+ n- nc+ nc- Laplace=<func(s)>
+ [window=<time>] [nfft=<number>] [mtol=<number>]
The transfer function of this circuit element is specified by its Laplace transform. The Laplace transform must be a function of s. The frequency response at frequency f is found by substituting s with sqrt(-1)*2*pi*f. The time domain behavior is found from the impulse response found from the Fourier transform of the frequency domain response. LTspice must guess an appropriate frequency range and resolution. The response must drop at high frequencies or an error is reported. It is recommended that LTspice first be allowed to make a guess at this and then check the accuracy by reducing reltol or explicitly setting nfft and the window. The reciprocal of the value of the window is the frequency resolution. The value of nfft times this resolution is the highest frequency considered. The Boolean XOR operator, "^" is understood to mean exponentiation "**" when used in a Laplace expression.
Syntax: Exxx n+ n- value={<expression>}
This is an alternative syntax of the behavioral source, arbitrary behavioral voltage source, B.
Syntax: Exxx n+ n- POLY(<N>) <(node1+,node1-) (node2+,node2-)+ ... (nodeN+,nodeN-)> <c0 c1 c2 c3 c4 ...>
This is an archaic means of arbitrary behavioral modeling with a polynomial. It is useful for running legacy opamp models.
Note: It is better to use a G source shunted with a resistance to approximate an E source than to use an E source. A voltage controlled current source shunted with a resistance will compute faster and cause fewer convergence problems than a voltage controlled voltage source. Also, the resultant nonzero output impedance is more representative of a practical circuit. |
The output of n+ and n- comes from the input voltage of nc+ and nc-. After selecting the components, you can use subckt to build a subcircuit module. In LTspice, he gave an example as shown below
.SUBCKT -- Define a Subcircuit
As an aid to defining a circuit, repetitive circuitry can be enclosed in a subcircuit definition and used as multiple instances in the same circuit. Before the simulation runs, the circuit is expanded to a flat netlist by replacing each invocation of a subcircuit with the circuit elements in the subcircuit definition. There is no limit on the size or complexity of subcircuits.
The end of a subcircuit definition must be a .ends directive.
Here is an example using a subcircuit:
*
* This is the circuit definition
X1 a b 0 divider
V1 a 0 pulse(0 1 0 .5μ .5μ 0 1μ)
* this is the definition of the subcircuit
.subckt divider n1 n2 n3
r1 n1 n2 1k
r2 n2 n3 1k
.ends
.tran 3
.end
Which runs after expanding to
* Expand X1 into two resistor network
r:1:1 a b 1k
r:1:2 b 0 1k
*
v1 a 0 pulse(0 1 0 .5μ .5μ 0 1μ)
.tran 3μ
.end
Note that unique names based on the subcircuit name and the subcircuit definition element names are made for the circuit elements inserted by subcircuit expansion. |
The general meaning is that * is a comment, the divider following .subckt is the name of the module, and n1 n2 n3 are the names of the derived network nodes. Based on the above information, we can build a subcircuit module with gain=1.
Example 1: Sub circuit with amplification factor = 1
*this is IND901 spice model
* Device name
* | OPA IN-
* | | OPA IN+
* | | | OPA OUT
* | | | |
.subckt IND901 IN- IN+ OUT REF+ REF-
E1 REF+ OUT IN+ IN- 1
.ends |
Figure 3: Simulation results of Example 1
Very basic function , let's add Gain Error to it. Here we can directly use the param command to define a Gain Error
Example 2: Op amp with Gain Error
*this is circuit define
.param GainError=0.2/100
.param Gain=1*(1+GainError)
*this is IND901 spice model
* Device name
* | OPA IN-
* | | OPA IN+
* | | | OPA OUT
* | | | |
.subckt IND901 IN- IN+ OUT REF+ REF-
E1 REF+ OUT IN+ IN- {Gain}
.ends |
Figure 4: Simulation results of Example 2
Next we can add a little offset, which can be done using an independent voltage source.
Example 3: Op amp with offset
*this is circuit define
.param GainError=0.2/100
.param Gain=1*(1+GainError)
.param Vos=0.03
*this is IND901 spice model
* Device name
* | OPA IN-
* | | OPA IN+
* | | | OPA OUT
* | | | |
.subckt IND901 IN- IN+ OUT REF+ REF-
E1 IN_REF+ IN_OUT IN+ IN- {Gain}
E2 OUT REF+ Value={V(IN_OUT,IN_REF+)+Vos}
.ends |
Figure 5: Simulation results of Example 3
Simulation model, not perfect
List of LTspice simulation tutorials
https://en.eeworld.com/bbs/thread-1211610-1-1.html
That’s all for today, bye~