Valve models - different syntaxes and getting them running in LTspice


 

Hi all,
 
I need some guidance regarding different models of Valves which are readily available from this and other Web sites.  As an example, I have added 3  12AX7 models below.  I am trying to get them to run in a very simple triode circuit by pasting them directly into a schematic as Spice directives.  ... and then to understand why they are different, in syntax structure and in operation.
 
I have changed the Triode symbol Attributes to .... Attribute is Value,  Prefix is X,   InstName is U1  and  SpiceModel is 12AX7 ... other fields are blank.
 
The first .SUBCKT below runs okay, but I do not understand the syntax eg BGG  GG 0 etc.. I'm okay with the maths. 
 
I cannot find this info anywhere in the LTspice Help, or in my many searches of the Web.  Maybe I'm searching the wrong terminology .... any advice please??
 
Why does the first .SUBCKT model run, but the second one does not.  I get an Error message "Undefined subcircuit triodenh"??
 
Also, why is the syntax vastly different?  eg +PARAMS etc??
 
Thanks, Ian
 
.SUBCKT 12AX7 A G K
BGG   GG   0 V=V(G,K)+0.59836683
BM1   M1   0 V=(0.0017172334*(URAMP(V(A,K))+1e-10))**-0.2685074
BM2   M2   0 V=(0.84817287*(URAMP(V(GG)+URAMP(V(A,K))/88.413802)+1e-10))**1.7685074
BP    P    0 V=0.001130216*(URAMP(V(GG)+URAMP(V(A,K))/104.24031)+1e-10)**1.5
BIK   IK   0 V=U(V(GG))*V(P)+(1-U(V(GG)))*0.00071211506*V(M1)*V(M2)
BIG   IG   0 V=0.000565108*URAMP(V(G,K))**1.5*(URAMP(V(G,K))/(URAMP(V(A,K))+URAMP(V(G,K)))*1.2+0.4)
BIAK  A    K I=URAMP(V(IK,IG)-URAMP(V(IK,IG)-(0.00058141055*URAMP(V(A,K))**1.5)))+1e-10*V(A,K)
BIGK  G    K I=V(IG)
* CAPS
CGA   G    A 1.7p
CGK   G    K 1.6p
CAK   A    K 0.5p
.ENDS
*Ayumi Generic  tube.lib.txt file
 
.SUBCKT 12AX7 A G K
XV1 A G K TRIODENH
+PARAMS: LIP= 1.5 LIF= 0.000016 RAF= 0.076498 RAS= 1 CDO=-0.53056 
+ RAP= 0.18 ERP= 1.5 
+ MU0= 87.302 MUR=-0.013621 EMC= 0.00000111 
+ GCO=-0.2 GCF= 0.00001 
+ CGA=3.90E-12 CGK=2.40E-12 CAK=7.00E-13
.ENDS
*Duncan Munroe Generic  ENHtube.lib file
 
.SUBCKT 12AX7 1 2 3 ; A G C
E1  7 0 VALUE={V(1,3)/KP*LOG(1+EXP(KP*(1/MU+(V(2,3)+VCT)/SQRT(KVB+V(1,3)*V(1,3)))))}
RE1 7 0 1G
G1  1 3 VALUE={(PWR(V(7,0),EX)+PWRS(V(7,0),EX))/KG1}
RCP 1 3 1G    ; TO AVOID FLOATING NODES IN MU-FOLLOWER
C1  2 3 {CCG}  ; CATHODE-GRID
C2  2 1 {CPG1}  ; GRID-PLATE
C3  1 3 {CCP}  ; CATHODE-PLATE
D3  5 3 DX     ; FOR GRID CURRENT
R1  2 5 {RGI}  ; FOR GRID CURRENT
.ENDS           TRIODE
*duncan Munro ???????
 


 

I think that the second subcircuit is only a set of parameters to apply to a generic triode model TRIODENH, which you have not got.  Generally, you do not need to know much about the syntax of the netlist of a subcircuit. As it happens, BGG is a B source connected between nodes GG and 0. Others are far more difficult to explain.


On 2024-12-09 05:51, tinkera123 via groups.io wrote:
Hi all,
 
I need some guidance regarding different models of Valves which are readily available from this and other Web sites.  As an example, I have added 3  12AX7 models below.  I am trying to get them to run in a very simple triode circuit by pasting them directly into a schematic as Spice directives.  ... and then to understand why they are different, in syntax structure and in operation.
 
I have changed the Triode symbol Attributes to .... Attribute is Value,  Prefix is X,   InstName is U1  and  SpiceModel is 12AX7 ... other fields are blank.
 
The first .SUBCKT below runs okay, but I do not understand the syntax eg BGG  GG 0 etc.. I'm okay with the maths. 
 
I cannot find this info anywhere in the LTspice Help, or in my many searches of the Web.  Maybe I'm searching the wrong terminology .... any advice please??
 
Why does the first .SUBCKT model run, but the second one does not.  I get an Error message "Undefined subcircuit triodenh"??
 
Also, why is the syntax vastly different?  eg +PARAMS etc??
 
Thanks, Ian
 
.SUBCKT 12AX7 A G K
BGG   GG   0 V=V(G,K)+0.59836683
BM1   M1   0 V=(0.0017172334*(URAMP(V(A,K))+1e-10))**-0.2685074
BM2   M2   0 V=(0.84817287*(URAMP(V(GG)+URAMP(V(A,K))/88.413802)+1e-10))**1.7685074
BP    P    0 V=0.001130216*(URAMP(V(GG)+URAMP(V(A,K))/104.24031)+1e-10)**1.5
BIK   IK   0 V=U(V(GG))*V(P)+(1-U(V(GG)))*0.00071211506*V(M1)*V(M2)
BIG   IG   0 V=0.000565108*URAMP(V(G,K))**1.5*(URAMP(V(G,K))/(URAMP(V(A,K))+URAMP(V(G,K)))*1.2+0.4)
BIAK  A    K I=URAMP(V(IK,IG)-URAMP(V(IK,IG)-(0.00058141055*URAMP(V(A,K))**1.5)))+1e-10*V(A,K)
BIGK  G    K I=V(IG)
* CAPS
CGA   G    A 1.7p
CGK   G    K 1.6p
CAK   A    K 0.5p
.ENDS
*Ayumi Generic  tube.lib.txt file
 
.SUBCKT 12AX7 A G K
XV1 A G K TRIODENH
+PARAMS: LIP= 1.5 LIF= 0.000016 RAF= 0.076498 RAS= 1 CDO=-0.53056 
+ RAP= 0.18 ERP= 1.5 
+ MU0= 87.302 MUR=-0.013621 EMC= 0.00000111 
+ GCO=-0.2 GCF= 0.00001 
+ CGA=3.90E-12 CGK=2.40E-12 CAK=7.00E-13
.ENDS
*Duncan Munroe Generic  ENHtube.lib file
 
.SUBCKT 12AX7 1 2 3 ; A G C
E1  7 0 VALUE={V(1,3)/KP*LOG(1+EXP(KP*(1/MU+(V(2,3)+VCT)/SQRT(KVB+V(1,3)*V(1,3)))))}
RE1 7 0 1G
G1  1 3 VALUE={(PWR(V(7,0),EX)+PWRS(V(7,0),EX))/KG1}
RCP 1 3 1G    ; TO AVOID FLOATING NODES IN MU-FOLLOWER
C1  2 3 {CCG}  ; CATHODE-GRID
C2  2 1 {CPG1}  ; GRID-PLATE
C3  1 3 {CCP}  ; CATHODE-PLATE
D3  5 3 DX     ; FOR GRID CURRENT
R1  2 5 {RGI}  ; FOR GRID CURRENT
.ENDS           TRIODE
*duncan Munro ???????
 
-- 
OOO - Own Opinions Only
Best Wishes
John Woodgate
Keep trying

Virus-free.www.avg.com


 

On 09/12/2024 06:51, tinkera123 via groups.io wrote:
I need some guidance regarding different models of Valves which are readily available from this and other Web sites.  As an example, I have added 3  12AX7 models below.  I am trying to get them to run in a very simple triode circuit by pasting them directly into a schematic as Spice directives.  ... and then to understand why they are different, in syntax structure and in operation.
 
I have changed the Triode symbol Attributes to .... Attribute is Value,  Prefix is X,   InstName is U1  and  SpiceModel is 12AX7 ... other fields are blank.
 
The first .SUBCKT below runs okay, but I do not understand the syntax eg BGG  GG 0 etc.. I'm okay with the maths. 
 
I cannot find this info anywhere in the LTspice Help, or in my many searches of the Web.  Maybe I'm searching the wrong terminology .... any advice please??
 
Why does the first .SUBCKT model run, but the second one does not.  I get an Error message "Undefined subcircuit triodenh"??
 
Also, why is the syntax vastly different?  eg +PARAMS etc??
 
Thanks, Ian
 
.SUBCKT 12AX7 A G K
BGG   GG   0 V=V(G,K)+V=V(G,K)+0.59836683
BM1   M1   0 V=(0.0017172334*(URAMP(V(A,K))+1e-10))**-0.2685074
BM2   M2   0 V=(0.84817287*(URAMP(V(GG)+URAMP(V(A,K))/88.413802)+1e-10))**1.7685074
BP    P    0 V=0.001130216*(URAMP(V(GG)+URAMP(V(A,K))/104.24031)+1e-10)**1.5
BIK   IK   0 V=U(V(GG))*V(P)+(1-U(V(GG)))*0.00071211506*V(M1)*V(M2)
BIG   IG   0 V=0.000565108*URAMP(V(G,K))**1.5*(URAMP(V(G,K))/(URAMP(V(A,K))+URAMP(V(G,K)))*1.2+0.4)
BIAK  A    K I=URAMP(V(IK,IG)-URAMP(V(IK,IG)-(0.00058141055*URAMP(V(A,K))**1.5)))+1e-10*V(A,K)
BIGK  G    K I=V(IG)
* CAPS
CGA   G    A 1.7p
CGK   G    K 1.6p
CAK   A    K 0.5p
.ENDS
*Ayumi Generic  tube.lib.txt file
 
.SUBCKT 12AX7 A G K
XV1 A G K TRIODENH
+PARAMS: LIP= 1.5 LIF= 0.000016 RAF= 0.076498 RAS= 1 CDO=-0.53056 
+ RAP= 0.18 ERP= 1.5 
+ MU0= 87.302 MUR=-0.013621 EMC= 0.00000111 
+ GCO=-0.2 GCF= 0.00001 
+ CGA=3.90E-12 CGK=2.40E-12 CAK=7.00E-13
.ENDS
*Duncan Munroe Generic  ENHtube.lib file
 
.SUBCKT 12AX7 1 2 3 ; A G C
E1  7 0 VALUE={V(1,3)/KP*LOG(1+EXP(KP*(1/MU+(V(2,3)+VCT)/SQRT(KVB+V(1,3)*V(1,3)))))}
RE1 7 0 1G
G1  1 3 VALUE={(PWR(V(7,0),EX)+PWRS(V(7,0),EX))/KG1}
RCP 1 3 1G    ; TO AVOID FLOATING NODES IN MU-FOLLOWER
C1  2 3 {CCG}  ; CATHODE-GRID
C2  2 1 {CPG1}  ; GRID-PLATE
C3  1 3 {CCP}  ; CATHODE-PLATE
D3  5 3 DX     ; FOR GRID CURRENT
R1  2 5 {RGI}  ; FOR GRID CURRENT
.ENDS           TRIODE
*duncan Munro ???????
There's no one way to make valve model, so models written by different people are likely to end up different. The test for any model is: how close does it come to predicting the actual behaviour of the real device. That's where you should be directing your curiosity. Models may have varying levels of complexity depending on the accuracy desired by their creators.

As far as syntax... You clearly didn't read the Help thoroughly enough. The syntax: eg BGG  GG 0 etc. is listed in netlist form for each element. So, for example, a B-source - see:

Help > LTspice > LTspice® > Circuit Elements > B. Arbitrary Behavioral Voltage or Current Sources

Syntax: Bnnn n001 n002 V=<expression> ..., where:
"Bnnn" is the instance name. It is the unique reference of that particular element. The first letter of the instance name defines what kind of element definition follows. All B-source names must start with "B". The rest of a name is arbitrary, so long as it is unique. So, "BGG" is the name of the B-source definition that follows.

"n001" is the net name that pin 1 is connected to; "n002" being the net name that pin 2 is connected. So, "GG   0" means pin 1 is connected to net name "GG" and pin 2 is connected to ground, which is universally called "0" in SPICE.

"V=<expression>" is the transfer function of the B-source. So "V=V(G,K)+0.59836683" means that the voltage between "GG" and ground is defined to be V=V(G,K)+0.59836683V greater than the voltage between nets "G" and "K". So "V(x,y)" defines a differential voltage between nets "x" and "y" without any reference to ground.

"<expression>" may contain any function listed in the table that follows on the B-source Help page.
Why does the first .SUBCKT model run, but the second one does not.  I get an Error message "Undefined subcircuit triodenh"??
The error message tells you why the second .SUBCKT failed. It references a separate .SUBCKT called "TRIODENH", but that model is (presumably) not defined anywhere in your netlist. It won't work without it.

Also, why is the syntax vastly different?  eg +PARAMS etc??
The line beginning "+PARAMS:" signifies that everything that follows, down to the "ENDS", is a parameter of the model "TRIODENH" (which is missing). The "+" at the start of each line is a continuation character that means that whatever follows should be netlisted on the same line as the line that preceded it.

--
Regards,
Tony


 

On 09/12/2024 10:38, Tony Casey wrote:
"V=<expression>" is the transfer function of the B-source. So "V=V(G,K)+0.59836683" means that the voltage between "GG" and ground is defined to be V=V(G,K)+0.59836683V greater than the voltage between nets "G" and "K". So "V(x,y)" defines a differential voltage between nets "x" and "y" without any reference to ground.
..should be:

"V=<expression>" is the transfer function of the B-source. So "V=V(G,K)+0.59836683" means that the voltage between "GG" and ground is defined to be 0.59836683V greater than the voltage between nets "G" and "K". So "V(x,y)" defines a differential voltage between nets "x" and "y" without any reference to ground.

--
Regards,
Tony


 
Змінено

Ian,
 
There is no reason why different SPICE models (even for the same part) should be structurally similar.  All valve models mimic the behavior of a valve, by constructing various arrangements of voltage- or current-controlled-sources.  In that respect, they are alike.  But the details can vary, as they do here.
 
The first model uses several B-sources (look them up in LTspice's Help) where most of them generate voltages with math formulas, but the last two  B-sources generate currents.  The third model uses a smaller number of E- and G- controlled sources (look them up in LTspice's Help).  It is up to the model creator how they made it.  That is why the syntax can be so different.  There are many ways to do a similar thing.
 
The second model is incomplete.  Apparently you used cut-and-paste from another file, and you didn't notice that one of the models calls another subcircuit (the line beginning with X), which was probably located elsewhere in the same file.  Nested subcircuit calls are not uncommon.  Also it's not unusual to have one generic subcircuit (for all triodes), which then is called (used) by several part-number-specific subcircuits, with different parameters for each valve type.
 
By the way, the correct way to use the Triode symbol is to change the Value (not SpiceModel) attribute from "Triode" to "12AX7".  In general, don't change the InstName attribute, but let LTspice assign that itself.
 
By the looks of the subcircuits, they might behave differently, although the differences might or might not be subtle.  I think the first one includes grid current but I think the third one does not.  That's mostly OK for class-A, AB, and B amps where grid current is essentially zero, so the third model's model-creator may have decided to ignore grid current in his model.  (I suspect most people won't use a 12AX7 as a class-C RF amp.)
 
Andy
 


 

Hi John, Tony and AndyI,
 
Many thanks for the responses ... very enlightening for me ... I realize now that I have been looking at this issue from the wrong perspective.  Whilst most of the issues I raised are now much clearer, I still have a loooooong way to go.  I have managed to get a couple of 12AX7 models to run in the same circuit and can see differences in outputs.  I also have a few other valve models working in LTspice ... so I need to play around with these.  I don't intend to take a deep dive into modelling components, but I like to understand the basics.  I have downloaded a couple of articles that are regularly referenced to give me a bit more depth in understanding.
 
Andy - your comments about amps was timely ... a circuit that I wish to model is in an audio amplifier with feedback to a 12AX7 to shift its operating point between Class A and A/B ... acccording to the Amp manual.
 
Thank you again for your time and advice.  It is great to get expert help when things do not make sense.
 
Cheers,
Ian