# How to enter .subckt model in Ltspice?

This is a LTSpice model I created for a single electron transistor macro model:

.subckt SET 1 2 3

+pi=3.1415926535897932846
+CF1=40 ; 2CG/e
+CI2=0.2e-9
+CR2=100e+6
+CVp= 0.02
V2 5 3 DC CVp
V3 7 3 DC ‘-CVp’
D4 2 8 DIODE
D5 3 8 DIODE
RR1 1 3 R= ‘CR1+CR2*cos(CF1*pi*V(2,3))’
RR2 1 4 R= ‘CVp/(CI2-2*CVp/(CR1+CR2*cos(CF1*pi*V(2,3))))’
RR3 1 6 R= ‘CVp/(CI2-2*CVp/(CR1+CR2*cos(CF1*pi*V(2,3))))’
D2 4 5 DIODE
D3 7 6 DIODE
.MODEL DIODE D(N=0.01)
.ends


I got error message that symbols RR1, RR2, and RR3 are undefined. What does that error mean and why did I get it?

• Hello Haider, welcome to EE.SX. Please see the help center for information on how to ask good questions. There are a dozen or more SPICE packages all of which are slightly different and use slightly different syntaxes. I assume from .param you are using LTspice, but this should be stated explicitly. Use the "edit" button below your question to make changes. How are you entering this into LTspice? As a separate file? And the text is missing some linefeeds. – rdtsc May 15 '16 at 21:17

For most simulators the first line in any spice file should be an asterisk *, and is always a comment line.

I do not think you should put the R= part in the resistor definition lines. The lines should work fine like this:

R<rname> <node1> <node2> <r_value>


For example:

RR1 1 3 'CR1+CR2*cos(CF1*pi*V(2,3))'


If this does not work, try defining the expression as a parameter first:

.PARAM R1VALUE='CR1+CR2*cos(CF1*pi*V(2,3))'


then define resistor values like:

RR1 1 3 R1VALUE


Also, it looks like in LTspice the .ends should have the subcircuit name afterwards, i.e.:

.ends SET


For particular nuances of each simulator check the documentation.

• Thanks jbord39 for answer , That suggestion still error saying that cant't solve .PARAM R1VALUE='CR1+CR2*cos(CF1*pi*V(2,3))' – Haider May 23 '16 at 18:15
• I think ltspce doesn't like that expression of resistance voltage dependent R1VALUE='CR1+CR2*cos(CF1*pi*V(2,3))' – Haider May 23 '16 at 18:17
• Yes that sounds reasonable, I would expect the proper way to handle this to vary between simulators. I guess check the documentation and see if any examples are given for voltage dependent parameters. – jbord39 May 23 '16 at 23:48