2. Sub-circuit Body
< component name > < node1 > < node 2 > < node 3 > ... : < value >where the elements are:component name the reference of primitive component such as R2nodes the nodes within the sub-circuit to which it is connectedvalue which may contain temperature coefficient and other qualifiers or the name ofa parameter in curly brackets whose value can be set externally
代码例2:
. C2 5 0 10u
Lseries 0 3 {Lx}
D1 2 3 MyDiode 直接从库中调用;
Rout 4 2 100 tc1=0.0002
代码2解析:
This will set the value of C2 at 10u, and that cannot be changed.
Lseries is declaredas a parameter, and a value must be supplied. 电感感抗是参数控制;
Rout also is fixed at 100 Ω and so is itslinear temperature coefficient of 0.0002.设置电阻阻值和温度系数;
3.Models and Other Sub-circuits
.model < model name >
< model type > < model parameters >
.model that of an existing SPICE model, usually a semiconductor devicemodel name as found in the model database and which has been invoked previouslyin the list such as ‘MyDiode’ above although it is not an error to add a model thatis not actually used – it just bloats the sub-circuit.
model type used to specify what sort of model SPICE will use 模型类型
model parameters enclosed in brackets to change them from the default modelvalues,模型参数,可以更改默认模型值;
代码例3:
.model MyDiode D (Is=1.2e-12)
4. Ends
The sub-circuit is concluded with .ends<name>although LTspice does not insist onthe name. 作者: 888888 时间: 2021-7-9 09:29 5.Exclusions
A sub-circuit may not contain SPICE directives (dot commands), so it cannot specifya type of analysis such as transient, nor measure statements.
Example – Opto-Isolator Sub-circuitThe sub-circuit of the 4N25 optoisolator is: 光电耦合器4N25代码参数如下:
This shows that it has a 2 Ω resistor between nodes N003 and 2;
a diode D1 oftype LD which is defined by the model call where LD is declared to be a standarddiode D with two parameters changed from the default.
It also includes a voltage dependent current source G1 whose value is 0.876 m, a small capacitor of 18 pF anda transistor Q1 which has a model NP defined as an NPN transistor followed by a listof parameters.
We should also note that all the components have at least one nodeconnected to an external pin, although that is not often the case.