Electrical – How to enter .subckt model in Ltspice

ltspicesubcircuit

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?

Best Answer

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.