modeling tube circuits with altium designer

17
Modeling tube circuits with Altium - The Art of the (Broken) Models By: Andrus Aaslaid March, 2010 I have been working on tube amplifiers for little over ten years. Choosing Altium as a tool for design and simulation has not been so much about the particular suitability, but being an electronics engineer by profession, the tools selection is often driven by customers. As it happens so that many of my clients have chosen Altium instead of Orcad/Cadence, I have to use it on a daily basis,so it is quite obvious to use the same for my tube designs as well. De Palma once sayd, that “in order to sound good, an amplifier design has to follow the laws of physics as well as those for musical instruments”. This is a good guideline for creating good sounding designs in every aspect, and while there can be designs which are calculated the right way but do not sound exactly too good, there are rarely any designs what sound good and do not follow the basic calculations. Mathematics always has to be sound (no pun!) in a first place, and only then we can talk about selection of components, topology and such for a good sounding amplifier. One of the best ways to check out the schematics is to run it through simulation and save lot of time on prototyping. Although one can have all the calculations right the first time, it always helps to run it through simulation first, to see if everything really looks as it is supposed to. Altium, having its modeling based on XSpice by the Georgia Tech Research Institute (GTRI) (what itself is based on some version of Berkeley SPICE3) has extensive simulation support for its standard library components including common vacuum tubes, so it should make things blazing. Or then again… The following is a result of trying to simulate phono stage design, which prototype was supposed to work correctly, but did not really. Simulating it through with Altium proved the calculations being correct “Spicewise”, but still, the prototyped design was flaky. But let’s start from the beginning. The tube models world has done a great leap forward in last years, with the replacement of electrical models with ‘phenomenological’. The latter allows much precise results and most of the tube enthusiasts have been opting in with models by Norman Koren. I will not go in-deep about the models itself as Koren has described his work more than adequately himself [1]. Let it be said, that these models together with curve tracking software ([2], [3]) gives one a possibility to build its own models interactively with no mathematics involved, tracing the lines over the tube curves from datasheet, resulting the model which is as close to actual electronic device as it probably gets.

Upload: andrus-aaslaid

Post on 09-Mar-2015

1.355 views

Category:

Documents


14 download

TRANSCRIPT

Page 1: Modeling Tube Circuits With Altium Designer

Modeling tube circuits with Altium - The Art of the (Broken) Models

By: Andrus Aaslaid

March, 2010

I have been working on tube amplifiers for little over ten years. Choosing Altium as a tool for design and

simulation has not been so much about the particular suitability, but being an electronics engineer by

profession, the tools selection is often driven by customers. As it happens so that many of my clients

have chosen Altium instead of Orcad/Cadence, I have to use it on a daily basis,so it is quite obvious to

use the same for my tube designs as well.

De Palma once sayd, that “in order to sound good, an amplifier design has to follow the laws of physics

as well as those for musical instruments”. This is a good guideline for creating good sounding designs in

every aspect, and while there can be designs which are calculated the right way but do not sound

exactly too good, there are rarely any designs what sound good and do not follow the basic calculations.

Mathematics always has to be sound (no pun!) in a first place, and only then we can talk about selection

of components, topology and such for a good sounding amplifier.

One of the best ways to check out the schematics is to run it through simulation and save lot of time on

prototyping. Although one can have all the calculations right the first time, it always helps to run it

through simulation first, to see if everything really looks as it is supposed to. Altium, having its modeling

based on XSpice by the Georgia Tech Research Institute (GTRI) (what itself is based on some version of

Berkeley SPICE3) has extensive simulation support for its standard library components including

common vacuum tubes, so it should make things blazing.

Or then again…

The following is a result of trying to simulate phono stage design, which prototype was supposed to

work correctly, but did not really. Simulating it through with Altium proved the calculations being

correct “Spicewise”, but still, the prototyped design was flaky.

But let’s start from the beginning.

The tube models world has done a great leap forward in last years, with the replacement of electrical

models with ‘phenomenological’. The latter allows much precise results and most of the tube

enthusiasts have been opting in with models by Norman Koren. I will not go in-deep about the models

itself as Koren has described his work more than adequately himself [1]. Let it be said, that these models

together with curve tracking software ([2], [3]) gives one a possibility to build its own models

interactively with no mathematics involved, tracing the lines over the tube curves from datasheet,

resulting the model which is as close to actual electronic device as it probably gets.

Page 2: Modeling Tube Circuits With Altium Designer

I have preferred a tool from [2], which is easy to use and has its Java source code included, so this is as

good as it gets in my world.

However, this was not what I started from. As I mentioned before, the Altium has its built-in tube

models as well, so for quick and dirty check-up of my design, I have been using what was closest to my

selected tubes (which in this case was ½ of the 12AX7) .

The design simulated allright with no visible shortcomings. Needless to say that the gizmo on a

testbench did not feel a tad better from this fact and still had its bias points screwed up in every aspect.

This was the moment I started to have a doubts about the modeling accuracy. One of designs had to be

fundamentally different from what it appears, and I was pretty sure that my scope, nor multimeter, are

lying to me, so it had to be a simulation!

To check, how far I actually was with my approximated tube model, I built a small virtual tube tester

with Altium:

This is a fairly straightforward design, with only obscurity of having R1 in place, but this is needed to get

the proper net available for us to print a graph for (see below).

To make it a real “tube tester”, we have to sweep the schematic both, the B+’wise and gridwise, so you

have to give your simulation a parameters like that:

GND

GND

+200

VCCB

VSRC

0

VCCG

VSRC

GND

B

G

0.01

R1

12

3 4 56

7

89

V1

Tube 12AX7

12

VCCH

VSRC

GND

Page 3: Modeling Tube Circuits With Altium Designer

(For the B+ sweep)

(For the Grid sweep)

Running a simulation now, plotting out the I for R1 (this is why we need it ☺), one gets the simulation

result as following:

Page 4: Modeling Tube Circuits With Altium Designer

Nice set of curves … if you are ready to ignore the fact, that it does not at all resemble the tube I was

trying to simulate. Neither does it resemble 12AX7 in any way except that it’s a triode!

0.000 100.0 200.0 300.0 400.0 500.0

Plate Voltage (V)

Pla

te C

urr

en

t (A

)

-0.500m

0.000m

0.500m

1.000m

1.500m

2.000m

2.500m

3.000m

3.500m

vccg[dc] =-2.500 (sw eep 6 of 11)

r1[i]_p01

r1[i]_p02

r1[i]_p03

r1[i]_p04

r1[i]_p05

r1[i]_p06

r1[i]_p07

r1[i]_p08

r1[i]_p09

r1[i]_p10

r1[i]_p11

Page 5: Modeling Tube Circuits With Altium Designer

After tweaking with every possible parameter in simulation and getting the same result over and over

again, I finally decided, that it should be the model. I was planning to give a try for Koren models for

quite some time already, so this did look like a perfect moment.

Tracing in the latter 12AX7 curves page with the tool gave me the nice set of curves like this:

Note, that I was spending about 10 minutes on it, including making a cup of coffee, so be assured that

one can make even closer match with spending more time on it. However, for my testing purposes it

was close enough.

The following spice model was spit out by the tool, which is exactly the Koren model with appropriate

variables chosen by the tool:

*********************************************************************

* Created on Sat Feb 27 18:41:18 EET 2010 using tube.model.finder.PaintKIT

.SUBCKT TRIODE_12AX7_WITHPOWER 1 2 3 ; P G K ;

+ PARAMS: CCG=3P CGP=1.4P CCP=1.9P RGI=2000

+ MU=102.14399999999999 EX=1.3159999999999998 KG1=1485.0 KP=900.0 KVB=216.0 VCT=

0.446 ; Vp_MAX=500.0 Ip_MAX=0.0040 Vg_step=0.5

E1 7 0 VALUE={V(1,3)/KP*LOG(1+EXP(KP*(1/MU+V(2,3)/SQRT(KVB+V(1,3)*V(1,3)))))}

RE1 7 0 1G

G1 1 3 VALUE={(PWR(V(7),EX)+PWRS(V(7),EX))/KG1}

RCP 1 3 1G ; TO AVOID FLOATING NODES IN MU-FOLLOWER

C1 2 3 {CCG} ; CATHODE-GRID

C2 2 1 {CGP} ; GRID=PLATE

C3 1 3 {CCP} ; CATHODE-PLATE

D3 5 3 DX ; FOR GRID CURRENT

Page 6: Modeling Tube Circuits With Altium Designer

R1 2 5 {RGI} ; FOR GRID CURRENT

.MODEL DX D(IS=1N RS=1 CJO=10PF TT=1N)

.ENDS

*$

Feeding it into Altium takes a little tinkering. The semicolons are not treated as comment lines, so we

have to clean it up. Also, let’s use the .SUBCKT definition from the built-in library as a wrapper.

The modified model for simulation looks like this:

---- CUT HERE ----

*Vacuum Tube Dual Triode (Audio freq.) .SUBCKT 12AX7 a1 g1 c1 a2 g2 c2 h1 h2 hc X1 a1 g1 c1 12AX7s X2 a2 g2 c2 12AX7s RH1 h1 hc 100 RH2 h2 hc 100 .ENDS 12AX7 *********************************************************************

* Created on Sat Feb 27 18:41:18 EET 2010 using tube.model.finder.PaintKIT

*

.SUBCKT 12AX7s 1 2 3

+ PARAMS: CCG=3P CGP=1.4P CCP=1.9P RGI=2000

+ MU=102.14399999999999 EX=1.3159999999999998 KG1=1485.0 KP=900.0 KVB=216.0

+ VCT= 0.446

* Vp_MAX=500.0 Ip_MAX=0.0040 Vg_step=0.5

E1 7 0 VALUE={V(1,3)/KP*LOG(1+EXP(KP*(1/MU+V(2,3)/SQRT(KVB+V(1,3)*V(1,3)))))}

RE1 7 0 1G

G1 1 3 VALUE={(PWR(V(7),EX)+PWRS(V(7),EX))/KG1}

* TO AVOID FLOATING NODES IN MU-FOLLOWER

RCP 1 3 1G

* CATHODE-GRID

C1 2 3 {CCG}

* GRID=PLATE

C2 2 1 {CGP}

* CATHODE-PLATE

C3 1 3 {CCP}

* FOR GRID CURRENT

D3 5 3 DX

* FOR GRID CURRENT

R1 2 5 {RGI}

.MODEL DX D(IS=1N RS=1 CJO=10PF TT=1N)

.ENDS

*$

---- CUT HERE ----

Note the spice controversy what sometimes creates lots of confusion for newbies – the parameters on

.SUBCKT line are numbers in most cases. However, these numbers are barely the variable names and

represent nothing else! The number itself has no meaning. Also, inside the .SUBCKT definition you will

see, that other numbers, not present at definition line, are used. They are just an variables as well,

created on a fly.

If you are new to spice modeling, the best tutorial I have been able to find is at [4].

Anyway. Save the model file as my12AX7.ckt for example and set it up like this:

Page 7: Modeling Tube Circuits With Altium Designer

Word of wisdom – although sometimes Altium (erratically) allows using the spice models while model

sub-kind is set to “Generic Editor”, this shall NOT be done. You will be having a different netlist mapping,

as well as it is almost impossible to match pins between model and schematic, as you will see only the

numbers in Port Map dialog and no labels. This is true for at least Summer 09 edition, but the simulation

component seems to be quite the same from version to version, so beware.

Also you have to check always your port mapping:

Page 8: Modeling Tube Circuits With Altium Designer

Now, you can imagine my sheer horror, if the above gave me the simulation results as following:

0.000 100.0 200.0 300.0 400.0 500.0

Plate Voltage (V)

Pla

te C

urr

ent

(A)

-0.500m

0.000m

0.500m

1.000m

1.500m

2.000m

2.500m

3.000m

3.500mr1[i]_p01

r1[i]_p02

r1[i]_p03

r1[i]_p04

r1[i]_p05

r1[i]_p06

r1[i]_p07

r1[i]_p08

r1[i]_p09

r1[i]_p10

r1[i]_p11

Page 9: Modeling Tube Circuits With Altium Designer

Note the same X and Y axis scaling as before.

I will now skip several weeks of head-scratching, hair-pulling, keyboard-banging etc., including the

peeking at the PaintKIT source code, hoping to find a math error there somewhere. Unsurprisingly

everything looked OK, except of course the simulation result.

To make matters worse, it appeared that my original design did not even complete the simulation with

the new model, running into some sort of convergence errors.

The latter I was able overcome by help of using the Koren model modified by diyaudio member

runeight [5]:

*

* ECC99 Dual Triode

*

* Created: 2003

* Author Alex Cavalli

*

* Based on triode model equations by Norman Koren

*

* Grid current is modeled with a diode and resistor

*

* please note that this model is provided "as is" and

* no warranty is provided in respect of its suitability

* for any application.

*

* this model is provided for educational and non-profit use.

*

.subckt ECC99 A G K

be0 3 0 v=500*(1/22+v(g,k)/sqrt(300+v(a,k)*v(a,k)))

be1 7 0 v=v(a,k)/500*ln(1+exp(-uramp(-v(3))+uramp(v(3))-uramp(v(3)-700)))

bg1 a k i=2*((uramp(v(7))-uramp(v(7)-700))^1.3)/362

rcp a k 1g

c1 g k 5.8p

c2 g a 5.1p

c3 a k 0.91p

d3 5 k dx

r1 g 5 2000

.model dx d(is=1n rs=1 cjo=0 tt=1n)

.ends

The thread at diyaudio also revealed one very important detail – namely that Koren models are based

on natural logarithm. And indeed, XSpice is using the LN() function instead of LOG() for natural

logarithms, so this is something we definitely have to replace.

The new set of curves with log() replaced with ln() did look slightly better, but still no good:

Page 10: Modeling Tube Circuits With Altium Designer

As there seems to be nothing else wrong, it appears that XSpace is having an exponent problems of a

sort, so I decided to switch over to ‘runeight’ model, reverse-engineering it for fitting in the parameters

at the correct places.

This is what the runeight has to say in forum:

Here is my B2Spice model. I love my B2Spice simulator, but it does have convergence

problems and in order to get around those, I've had to adjust the model. Most of this has to

do with exponents that get too large. The simulator should handle this, but it doesn't so you

have to build these limits into the model.

The resulting simulation model with necessary modifications for Altium looks following:

---- CUT HERE ----

*Vacuum Tube Dual Triode (Audio freq.) *Connections: * Plate 1 * | Grid 1 * | | Cathode 1 * | | | Plate 2 * | | | | Grid 2 * | | | | | Cathode 2 * | | | | | | H H HM * | | | | | | | | | .SUBCKT 12AX7 1 2 3 6 7 8 4 5 9 X1 1 2 3 12AX7s X2 6 7 8 12AX7s RH1 4 9 100 RH2 5 9 100 .ENDS 12AX7 * Created: 2003 * Author Alex Cavalli * * Based on triode model equations by Norman Koren *

0.000 100.0 200.0 300.0 400.0 500.0

Plate Voltage (V)

Pla

te C

urr

ent

(A)

-0.500m

0.000m

0.500m

1.000m

1.500m

2.000m

2.500m

3.000m

3.500mr1[i]_p01

r1[i]_p02

r1[i]_p03

r1[i]_p04

r1[i]_p05

r1[i]_p06

r1[i]_p07

r1[i]_p08

r1[i]_p09

r1[i]_p10

r1[i]_p11

Page 11: Modeling Tube Circuits With Altium Designer

* Grid current is modeled with a diode and resistor * * please note that this model is provided "as is" and * no warranty is provided in respect of its suitability * for any application. * * this model is provided for educational and non-profit use. * .subckt 12AX7s a g k + PARAMS: CCG=3P CGP=1.4P CCP=1.9P RGI=2000 + MU=102.14399999999999 EX=1.3159999999999998 KG1=1485.0 KP=900.0 KVB=216.0 + VCT=0.446 * e0 3 0 VALUE={KP*(1/MU+(v(g,k)+VCT)/sqrt(KVB+v(a,k)*v(a,k)))} e1 7 0 VALUE={v(a,k)/KP*ln(1+exp(-uramp(-v(3))+uramp(v(3))-uramp(v(3)-700)))} re1 7 0 1g * g1 a k VALUE={(2*(PWR(limit(v(7),0.0001,700),EX)/KG1)*STP(v(7)))+1p} g1 a k VALUE={(PWR(V(7),EX)+PWRS(V(7),EX))/KG1} rcp a k 1g c1 g k {CCG} c2 g a {CGP} c3 a k {CCP} d3 5 k dx r1 g 5 {RGI} .model dx d(is=1n rs=1 cjo=0 tt=1n) .ends ---- CUT HERE ----

Note, that we are using the G1 value without the built-in safety. The commented-out G1 equation is

working according to Koren formulas, however, it is somewhat slower than the other, so I opted in to

the non-failsafe one. Some simulations do not like the zero current result, so adding 1pA to the result

may cure things when you run into GMIN stepping failures with your model.

The resulting simulation looks much more like a 12AX7 we are supposed to be simulating:

Superimposing it to 12AX7 datasheet reveals, that it is exactly as close to the datasheet curves as we

were tracing with PaintKIT!:

0.000 50.00 100.0 150.0 200.0 250.0 300.0 350.0 400.0 450.0 500.0

vccb (V)

(A

)

-0.500m

0.000m

0.500m

1.000m

1.500m

2.000m

2.500m

3.000m

3.500m

12AX7

r1[i]_p01

r1[i]_p02

r1[i]_p03

r1[i]_p04

r1[i]_p05

r1[i]_p06

r1[i]_p07

r1[i]_p08

r1[i]_p09

r1[i]_p10

r1[i]_p11

Page 12: Modeling Tube Circuits With Altium Designer

Mission accomplished! This is probably closer than individual tubes get to their datasheet curves

anyway, so let’s leave it there.

The comment, has to be made about the VCT parameter, not normally found in Koren models. This is

something what PaintKIT developer has invented, and is a pretty good feature. It is useful for the tubes

like 12AX7, as they have their 0-volt grid line somewhat shifted left on a graph, like you would print the

positive grid voltages with Koren model. VCT variable allows the correction of the grid voltage, so the

curves will look and be labeled right by basically “shifting” the entire picture VCT voltages worth.

Basically: If the tube has its Vg=0 curve with the shape as would be normally seen for the Vg=+0.7 by

Koren model, you will enter the correction value VCT=0.7 and everything is back to normal.

So, finally, what did we learn?

First, Koren models are much more useful than the built-in ones for Altium, and together with PaintKIT

or other tracing tools offer unprecedented possibility to model just any tube one has plate curves

available for.

Second, the XSpice, and Altium Designer for that sake, has its serious drawbacks about the exponential

calculations. I have no intention digging into this problem, as I hope someone from Altium will pay

attention to that some day and do whatever has to be done. The LOG() vs. LN() natural logarithm

Page 13: Modeling Tube Circuits With Altium Designer

problem is an obscurity one has to live with, although I can only imagine the cumulative work-hours

spent annually around the globe debugging the resulting misbehavior of simulation models.

The heater current model is simplistic, as there are very limited information available about plate curves

for reduced heater voltage anyway, thus heater becomes sort of irrelevant from simulation point of

view. There is, however, a comprehensive heater model available from Intusoft, created by EXCEM [6],

[7].

I haven’t tried it, neither do I know if it works correctly (or even compiles) for Altium, but I am quoting it

here as a reference, so you might understand how sophisticated the heater modeling really could be:

*******************

*SRC=HEATER;HEAT1;Tubes;Generic;Heater model

*SYM=HEAT1

.SUBCKT HEAT1 F F' ISAT {INOM=??? VNOM=??? LAMBDA=??? RCOOL=??? TCTE=??? TNOM=??? INIT=???

W=??? ISAT=???}

*

* COPYRIGHT EXCEM, 1993

*

* This model for the heater gives a voltage ISAT

* that is an analog for the saturation current of the cathode.

*

*

* THE HEATER'S 9 PARAMETERS ARE:

*

* INOM the nominal heater current, at nominal voltage.

* VNOM the nominal heater voltage (causing nominal temperature)

* LAMBDA temperature coefficient of the heater resistance.

* (normalized to the nominal temperature);

* RCOOL resistance of the cold heater.

* TCTE the time constant for the heater temperature.

* TNOM the nominal heater temperature in K.

* INIT initial heater temperature in % of TNOM.

* W work function of the heater, in eV.

* ISAT the saturation current at nominal heater voltage.

*

V1 F 4 0

R1 5 4 0.01

* Above the Debye temperature, the resistivity is nearly linear

* with respect to temperature, see Ashcroft & Mermin p. 525 and p 461.

B1 5 F' V = V(7) > 0 ? I(V1) * ({VNOM / INOM - RCOOL} * (1 + {LAMBDA} * (V(7) - 1)) + {RCOOL})

+ : I(V1) * {VNOM / INOM}

* B1 delivers the power recieved by the heater

B2 6 0 V = (V(F) - V(F')) * I(V1) > 0 ? (V(F) - V(F')) * I(V1) / {VNOM * INOM} : 1

R2 6 7 1

C1 7 0 {TCTE} IC = {INIT/100}

* Only conductive dissipation is considered. Therfore, V(7) is a normalized temperature.

* B4 contains the Richardson-Duschman law, with an exponential containing

* B = W/k, the Bolzmann's constant is 0.8617e-4 eV/K

* for Tungsten (see Ashcroft & Mermin p. 364) and W = 4.5 eV. It may

* be 2.2 times lower for an oxide-coated cathode (see Terman p. 173).

* B3 delivers the saturation current.

E1 13 0 7 0 {TNOM}

B3 ISAT 0 V = V(13) > 0 ?

+ {ISAT} * V(7)^2 * EXPL(({W/0.8417E-4} * (1 / {TNOM} - 1 / (V(13) + 1))),5) : {ISAT}

* The 1 Kelvin added to V(13) avoids convergence problems.

.ENDS

And the example usage for this heater model from Intusoft example library:

.SUBCKT 12AU7A 1 2 3 4 5

Page 14: Modeling Tube Circuits With Altium Designer

* Anode Grid Cathode F F'

* COPYRIGHT EXCEM, 1993

*

...

X2 4 5 10 HEAT1 {INOM=0.15 VNOM=6.3 LAMBDA=1 RCOOL=3 TCTE=10 TNOM=1150 INIT=100

+ W=2.045 ISAT=0.099}

...

.ENDS

Finally, some cleaned-up code what I am using for my own work. Nothing special, but it makes library

easier to use. All the curves are traced with PaintKIT, but there are several libraries available in the net

with Koren model parameters for variety of tubes, so if you do not fancy tracing your own curves, you

can just use the values you can find from the net. If the particular model does not use VCT value then set

VCT=0 and the rest of the values should work just fine.

---- CUT HERE ----

*

* 6N6P one half without heater

*

.SUBCKT 6N6P a g c

X1 a g c TRIODE

+ PARAMS: CCG=3P CGP=1.4P CCP=1.9P RGI=2000

+ MU=17.556 EX=1.848 KG1=1395.0 KP=102.0 KVB=7.5 VCT=0.224

.ENDS 6N6P

*

* 6S17K

*

.SUBCKT 6S17K a g ch1 h2

X1 a g ch1 TRIODE

+ PARAMS: CCG=3P CGP=1.4P CCP=0.015P RGI=2000

+ MU=182.784 EX=1.176 KG1=93.75 KP=408.0 KVB=1248.0 VCT=0

* Vp_MAX=190.0 Ip_MAX=0.013 Vg_step=0.2

RH1 ch1 h2 100

.ENDS 6S17K

*

* 12AX7 as of Altium Misc. Devices Library component

*

.SUBCKT 12AX7 a1 g1 c1 a2 g2 c2 h1 h2 hc

X1 a1 g1 c1 TRIODE

+ PARAMS: CCG=3P CGP=1.4P CCP=1.9P RGI=2000

+ MU=102.144 EX=1.316 KG1=1485.0 KP=900.0 KVB=216.0 VCT=0.446

* Vp_MAX=500.0 Ip_MAX=0.0040 Vg_step=0.5

X2 a2 g2 c2 TRIODE

+ PARAMS: CCG=3P CGP=1.4P CCP=1.9P RGI=2000

+ MU=102.144 EX=1.316 KG1=1485.0 KP=900.0 KVB=216.0 VCT=0.446

RH1 h1 hc 100

RH2 h2 hc 100

.ENDS 12AX7

*---------------------------------------------------------

*

* Equations by Norman L. Koren, "Koren new model"

*

* Original Spice implementation by Alex Cavalli, 2003

*

* Exponent overflow workarounds by DIYAudio member runeight

*

Page 15: Modeling Tube Circuits With Altium Designer

* Modifications for Altium Designer by Andrus Aaslaid, 2010

*

* Grid current is modeled with a diode and resistor

*

* please note that this model is provided "as is" and

* no warranty is provided in respect of its suitability

* for any application.

*

* this model is provided for educational and non-profit use.

*

*---------------------------------------------------------

.subckt TRIODE a g k

+ PARAMS: CCG=0 CGP=0 CCP=0 RGI=0 MU=0 EX=0 KG1=0 KP=0 KVB=0 VCT=0

*

e0 3 0 VALUE={KP*(1/MU+(v(g,k)+VCT)/sqrt(KVB+v(a,k)*v(a,k)))}

e1 7 0 VALUE={v(a,k)/KP*ln(1+exp(-uramp(-v(3))+uramp(v(3))-uramp(v(3)-700)))}

re1 7 0 1g

*g1 a k VALUE={(2*(PWR(limit(v(7),1p,700),EX)/KG1)*STP(v(7)))+1p}

g1 a k VALUE={(PWR(V(7),EX)+PWRS(V(7),EX))/KG1}

rcp a k 1g

c1 g k {CCG}

c2 g a {CGP}

c3 a k {CCP}

d3 5 k dx

r1 g 5 {RGI}

.model dx d(is=1n rs=1 cjo=0 tt=1n)

.ends

---- CUT HERE ----

NOTE! This model does not seem to like simulating an Aikido types of push-pull designs, especially if

there are several directly coupled stages following each-other. The reasons are quite understandable, as

directly coupled designs take quite some calculations to figure out the operating point, and if you start

from everything but the power being zero, it IS a massive task to figure out where it all is going to

stabilize. To help the simulator out, one has to play around and use Node Set (NS simulation

component) function for most of the nets on a design to avoid singular matrix errors and iteration limit

exceeding errors.

I am quoting a part of the Altium Wiki here

(http://wiki.altium.com/display/ADOH/Simulation+Models+and+Analyses+Reference) just for a

reference, as this might come handy for other problems as well:

----

Notes

In general, you should not have to change any of the advanced SPICE parameters in this page of the dialog for

accurate simulation. Only change these options if you have a good understanding of SPICE simulation parameters.

When troubleshooting Transient analysis failure, try setting:

• ABSTOL=RELTOL * (lowest current magnitude in the circuit)

• VNTOL= RELTOL * (lowest voltage magnitude in the circuit)

Raising the value of GMIN may help with convergence, but decreases accuracy.

ITL1 may need to be raised as high as 500 for many circuits.

ITL2 may need to be raised as high as 200 for some circuits.

ITL3 is not implemented in SPICE3. It is provided for compatibility in creating SPICE2 netlists.

Page 16: Modeling Tube Circuits With Altium Designer

Raising ITL4 to 100 or more may help to eliminate "timestep too small" errors improving both convergence and

speed.

ITL5 is not implemented in SPICE3. It is provided for compatibility in creating SPICE2 netlists.

Enabling the KEEPOPINFO option is useful if the circuit is large and you do not want to run a redundant Operating

Point Analysis.

In the numerical pivoting algorithm, the allowed min pivot is determined by:

EPSREL=AMAX1(PIVREL * MAXVAL, PIVTOL)

where MAXVAL is the max element in the column where a pivot is sought (partial pivoting).

With respect to the RELTOL option, larger values mean faster simulation time, but less accuracy.

General simulation convergence troubleshooting

When a simulation analysis fails, the most common problem is failure of the circuit to converge to a sensible

operating point. Use the following techniques to solve convergence problems.

Convergence trouble-shooting steps • When you have a convergence problem, first turn off all the analyses except the Operating Point analysis.

• Consult the Messages panel for any errors/warnings relating to simulation.

• Make sure the circuit is wired correctly. Dangling nodes and stray parts are not allowed.

• Ensure that the circuit has a ground node, and that every node in the circuit has a DC path to this ground.

Components that can isolate a node include transformers and capacitors. Voltage sources are considered a DC short

circuit, current sources are considered a DC open circuit.

• Ensure that zeros have not been confused with the letter O when entering simulation parameters.

• Ensure that proper SPICE multipliers have been specified (MEG instead of M for 1E+6) for any component values or

simulation parameters. Multipliers are not case sensitive. Also, spaces between values and multipliers are not

allowed. For example it should be 1.0uF, not 1.0 uF.

• Make sure all devices and sources are set to their proper values.

• Make sure the gain of any dependent source is correctly set.

• Temporarily eliminate series capacitors or current sources and re-run the simulation.

• Temporarily eliminate parallel inductors or voltage sources and re-run the simulation.

• On the SPICE Options page of the Analyses Setup dialog (from the schematic select Design » Simulate » Mixed Sim,

then click the Advanced Options entry in the Analyses/Options list), increase the value of the ITL1 parameter to 300.

This will allow the Operating Point analysis to go through more iterations before giving up.

• Add .NS (Nodeset) devices to define the node voltages. If the initial guess of a node voltage is way off, the .NS

device can be used to predefine a starting voltage that is used for a preliminary pass of the operating point analysis.

• If the Nodeset device does not assist in convergence, try defining the initial conditions by placing .IC devices. In this

case the node voltages are held at the specified values during the Operating Point analysis, then released during the

Transient analysis.

• Enable the Use Initial Conditions option on the Transient/Fourier Analysis Setup page of the Analyses Setup dialog

(from the schematic, select Design » Simulate » Mixed Sim, then click the Transient/Fourier Analysis entry in the

Analyses/Options list). This option works in conjunction with the .IC devices (or the IC parameter of the components).

By setting this option, the Operating Point analysis is not performed and the specified voltages are used as the initial

conditions for the Transient analysis.

• Specify the series resistance parameters of your models and increase the GMIN option (SPICE Options page of the

Analyses Setup dialog) by a factor of 10. Specify the initial condition of semiconductor devices, especially diodes, as

OFF.

Page 17: Modeling Tube Circuits With Altium Designer

----

And this as much as I can say about using the Koren models for Altium Designer.

Happy Simulating!, I now have to get back debugging my phono design now myself as well! ☺

Obvious gratitude goes to Norman Koren for doing such a good work on creating the models

(http://www.normankoren.com/Audio/Tubemodspice_article.html) , as well as for Dmitry

Nizhegorodov ([email protected]) for making them easy to use with his tools

(http://www.dmitrynizh.com/tubeparams_image.htm).

And finally, thaks to the Diyaudio user runeight, I would not been able to debunk the issue

of exponents with XSpice without. Thank you!!!!

Andrus.

1. Improved vacuum tube models for SPICE simulations; Norman L. Koren

(http://www.normankoren.com/Audio/Tubemodspice_article.html)

2. Model Paint Tools: Trace Tube Parameters over Plate Curves, Interactively; Dmitry

Nizhegorodov (http://www.dmitrynizh.com/tubeparams_image.htm)

3. PSPICE Calc V1.2 Triode Calculator; James E. Lanier, K4BPM

(http://www.chemroc.com/PSPICE.html)

4. CREATING A SPICE SUBCIRCUIT ; Richard P. Andersen (http://www.5spice.com/Subckts.htm)

5. JJ Tesla ECC99 spice model; (http://www.diyaudio.com/forums/tubes-valves/45287-jj-tesla-

ecc99-spice-model-2.html)

6. Simulation of circuits containing vacuum tubes "Vacuum Tube Modeling Package vol.1"

(http://www.eurexcem.com/cluba/tubery-a.htm)

7. Simulation of circuits containing vacuum tubes Broydé & Clavelier approach

(http://www.eurexcem.com/cluba/tubebr-a.htm)