Model Paint Tools: Trace Tube Parameters over Plate Curves, Interactively

Author: Dmitry Nizhegorodov ( My other projects and articles

1.   Intro

The Java tool described in [1] needs a text file containing rows of data representing dots on plate curves. Do not have such data for a particular tube? So am I, except for tubes in [2], [3]. However, we have access to lots of pdf, gif or jpg images displaying plate curves - thanks to maintainers of such great datasheet banks as [6], [7] and many smaller repositories. What to do to derive SPICE models from that? One solution is [4], an Excel macro package incorporating a calibrator and point-and-click converter of curve points into excel table format, used as input to tube model parameter optimizer. A different approach is presented here. It is a tool that displays an image with load curves and allows to PAINT the model curves over it. The model used in the tool is Koren Improved Triode [5]. You have slider controls, each corresponding to a tube parameter such as MU, KG1, KP, etc., to change the model curves, until you fit the parameters to your liking, and generated a complete SPICE model definition. With a bit of training the process becomes natural, frequently entertaining, occasionally captivating and almost never boring. The results easily surpass those obtained with automatic optimizers.

2.   Downloading the Tool

Download java jar file paint_kit.jar by right-clicking on the link, and save it somewhere on the disk. A directory where you'll be collecting tube curve inages is a convenient place for that. No unpacking is needed if you just want to run the tool without modding its code.

  • Note: the screenshots shown on this page are for older version v1 of this tool. The link above is for version v2 featuring many new improvements and extensions, still in beta. Ale Moglia of Bartola Valves is an enthusiastic user of paint_kit and motivated me to work on the new version, providing countless suggestions and serving as my tireless alpha- and beta- tester. Thanks, Ale!

3.   Running the Tool

Make sure you can run java version 1.3 or later on your computer. Then you can start the tool from a command line (MSDOX box, shell) this way:

java -jar paint_kit.jar <plate-curves-image>
Here, <plate-curves-image> is a GIF or JPG image containing tube plate curves. There is plenty of images available on the web. For starters, Audiomatica contains a good selection of most popular audio triode curves. For example, we'd like a model for 6sn7 matching Audiomatica's curves. First, download 2a3crv.gif and do

java -jar paint_kit.jar 2a3crv.gif
we-300b-1997-with-model-small.gif Here is a typical session. The horisontal bars are the sliders. The sliders are high-precision and automatically readjust: when you hit a left margin of any bar, the slider scales 1/2, if you hit the right margin, it switches to a 2x scale. After a good match found, you can press the [Model] key to print out a working model definition, or press [Exit] to print out the final model definition and exit. Button [Color] changes the color of the model curves.

12B4A-with-model-curves.gif Here is another session - 12B4A.

paint_kit_26small.gif RCA-published curves for the 26 triode are difficult to match well, yet a good fit is found.

4.   Detailed step by step instructions

After the application starts, you should see a window displaying the image. On the left you'll see 3 buttons, [Color], [Report], [Exit], a text input window with "600 200 12" displayed in it and several horizontal slider controls that look like scrollbars. You may want to adjust the window size for better layout of the image and controls.

Painted over the image, you should see a small red gridbox with tube curves in it. This is the model. Moving the sliders will affect the curves in the small red box in realtime.

Your next task is to align the red box and the axis of the plot. You can do that using the mouse, by "rubber-bending" the red box. First, position the mouse precisely over the 0,0 point on the plate plot and press mouse without releasing it. The small red box disappears. Then drag the mouse (move it with the button still pressed) in the direction of the Imax, Vmax point on the image. You'll see that the small red box appears again, growing in size in real time as you drag its max, max point with the mouse. position the mouse at the diagonal point where you wan the plots aligned an release the button. The plot coordinates are geometrically aligned now. Repeat the whole click-drag-drop procedure if the alignment is not precise.

After you've aligned the planes, do not click the mouse when it is hovering over the image, it will shrink the box again.

if the color of the model lines (default red) collides with the image, use button [Color]. Pressing it iterates over a selection of various colors (red, yellow, black, etc).

Now you need to calibrate the model plane. type the values of the Vmax, Imax and grid voltage step in the text box area. For the 6sn7 image from Audiomatica, you need to enter 500, 20, 2. Of course, if you did not drag the model box all the way to 500v,20ma marks, you'll have to enter different values. Note that there is no need to enter a negative sign for grid voltage. Press return when in the box, you'll see that the model re-scales. It is not calibrated in sync with the image plot.

With little practice, the above steps take just a couple of seconds of time. Now you are ready to start finding tube parameters. At this point, chances are that the image and the model lines are a complete mismatch.

Now you can pay closer attention to the sliders. The sliders are "smart": they rescale "infinitevely". Each slider re-scales when you move the control all the way left or right. . For example, initially the MU slider covers the range from ~ .5 to 10, but after you move it to the left corner, it will re-scale to cover ~ 1 .. 20 range, and if you bump it twice again it will readjust to 4 .. 80 range. Each slider does that in a similar way. This allows to always maintain a good precision yet does not lock a slider in a particular range. Try moving the sliders. Watch the shape of curves changing.

Now you are ready to start fitting parameters. Finding the best parameter fit is a hard task at the beginning, but will be easy after little practice. It is absolutely critical to develop a feel of each parameter. Knowing what each parameter does helps to shape the curves very quickly. Below is a little cheat-sheet explaining the impact of each slider.

MU slider
This is the first to start adjusting. It affects space between grid lines and, as side-effect, the steepness. Hence most often you need to adjust KG1 after changing MU. The best way to adjust MU is to find a spot on the plot between the 2nd and the 3rd grid lines where the distance can be easily seen, and match that with the spacing on the model curves. For example, on the 26 triode curves above, at 6mA the distance between the 2nd and 3rd curves is about 2 cells. Adjust MU until the spacing at 5ma between the corresponding lines is about the same. Then adjust KG1.

KG1 slider
affects only the angle, "steepness" of all the curves. Hence, adjust this after touching any other control that affects steepness.

EX slider
affects "curving" of the lines, that is how fast each of the curves transition from horizontal to "diagonal" shape. Affects least the 0-grid voltage lines and max-grid voltage lines. Most usable range - 1.3 ... 1.8. If in doubts, try 1.4...1.5 first.

KP slider
affects density increase (shrinkage of distance) between curves in high Vp region and when Vg magnitude increases. This is one of the best features of Koren improved model, as it approximates imperfection in distribution of electrical fields in the tube and in construction - those factors that make tubes less linear then what is computed with simple models. Together with EX, determines tube's 2nd harmonic distortion. Higher value of KP means less shrinkage and less distortion. Also, this elevates the slope of high-Vg curves, hence try changing KP and EX to get the right shape. Has no very little. influence on small-Vg lines. Do not "fix" a too big MU with too little KP.

VCT slider
corresponds to contact potential between grid and cathode. In mathematical terms, this is simply an "offset" on grid voltage: realVg = VCT + Vg. Remember that Vg goes from 0 down in negative territory, thus VCT "subtracts" from Vg voltage. For example, a curve for Vg=-1 becomes a curve for Vg=0 when VCT=1. Useful for high-mu/small-signal tubes.

KVB slider
Affects the shape in the 0, region for curves with positive VCT+Vg. Also, this affect the lines with negative VCT+Vg, as they shift horizontally alone X. Sometimes useful for high-mu, low-Vg, low-current, low-plate voltage curves.

Read Norman Koren's articles [5] to learn more about these parameters and the formulas of the model.

4.1   Recommendations for finding best fit

The key is to do incremental adjustments.

First, find the best MU (distance alone X between first 2-3 curves) then adjust KG1 to get the idea about the curves. Adjust EX to get the best "curving" of most lines, adjust KG1 and MU again. Then try KP. after that, you may want to try KVB and VCT. Remember that the way how you iterate affects the shape of the curves, and that be developing a feel of how the parameters affect the shape you can beat the results of automatic optimizers.

5.   Viewing SPICE model output

SPICE model matching current set of "painted" curves can be generated at any time.

When you think you found a good interim curve fit result, press the [Model] button. A separate textual pop-up window will appear, displaying the SPICE model text matching you current parameter values.

You can simply observer the text and kill the window and continue.

You can keep around as many separate model text windows as you want

You can copy&paste the model text and add it to your SPICE tube library: highlight the text with the mouse (drag button1), copy the highlighted selection using the button3 on the mouse or keyboard shortcut C-v, and paste the model into your SPICE tube library.

The windows can be used as save-points in your work: you can read the model back into the painting tool from any of currently opened model windows at any time, To do that, press "Update PARAMS" button on a model window you wish to return to. The slider and the curves will change according to the parameters in the text.

You can edit the text, entering the values by hand and then press "Update PARAMS".

You can import models from your SPICE model lib file via a model window: Paste the model text you've copied from you SPICE library into any model window and then press "Update PARAMS". This is very useful to see how your existing models match particular set of curves.

The [Exit] button pops up am exit confirmation dialog. If you pressed "Yes", the tool quits. If you forgot to copy/save the model, you can still capture it after exiting if you have access to your standard output window (a gnu/mks shell window, a DOS Command Box). The text for the model is printed into the log window.

An example of the tool's output:

** 12AX7 ************************************************************
* Created on Wed Nov 21 16:22:57 PST 2007 using tube.model.finder.PaintKIT
* URL: "
* Tube Curves URL:
.SUBCKT TRIODE_12AX7CRV 1 2 3 ; Plate Grid Cathode
+ PARAMS: CCG=3P  CGP=1.4P CCP=1.9P RGI=2000
+ MU=92.064 EX=1.3719 KG1=1770.0 
+ KP=1176.0 KVB=1.9687 VCT=0.392 ; Vp_MAX=405.0 Ip_MAX=0.0080 Vg_step=0.6
E1 7 0 VALUE={V(1,3)/KP*LOG(1+EXP(KP*(1/MU+(VCT+V(2,3))/SQRT(KVB+V(1,3)*V(1,3)))))} 
G1 1 3 VALUE={(PWR(V(7),EX)+PWRS(V(7),EX))/KG1} 
C2 2 1 {CGP} ; GRID=PLATE 
there, I provided the values for the inter-electrode capacitance and the URL with the curves.

6.   My own Models

A small yet growing repository of "good matches" can be found in [8].

7.   Tips and Solutions

Frequently you want to set the parameters to values corresponding to some existing model - to check how it fits a plot, for example - or to continue from a save-point data. Earlier we described how model windows can be used for that and how the text box localed just under the label "Max Vp (V), Max Ip, Vg step (V):" can be used to calibrate the model grid with 3 space-separated values Vp_MAX, Ip_MAX, Vg_step. Same text box can be used to set the value of MU, KGP, etc. The format is the same that ise used in your SPICE models, so that you can simply cut&paste the name=value pairs from SPICE lib files. etc to the values matching the TRIODE_12B4A model:

If you look closely, you'll see that the model definitions contain SPICE-syntax comments similar to this:

; Vp_MAX=500.0 Ip_MAX=0.07 Vg_step=10.0

this is another way to set the 3 calibration parameters. For example,

MU=7.518 EX=1.344 KG1=390.0 KP=45.0 KVB=930.0 VCT=0.328 Vp_MAX=500.0 Ip_MAX=0.07 Vg_step=10.0

sets the sliders and calibrates the model plane. These are saved in model text so that the toll can be instantly restored to any save-point.

8.   Inverse Koren Improved Triode equation

The latest update of my paint_kit.jar contains feature dynamically displaying Vp, Ip, Vg, Mu, Gm and Ra for the position on the plot mouse hovers over. Computing this on fly required knowing the inverse of Koren Improved model. What is the inverse? The Koren Improved equation takes Vp and Vg and returns Ip. The inverse takes Vp and Ip and returns Vg. the following sheet demonstrates derivation.


9.   Possible future extensions

image dialog
with minimal coding, a dialog loading specific image file can be added to the tool

model data input
a nice extension in functionality seems the following: to check, when loading an image file with name <name> a file, say <name>.txt, which will contain tube parameters for <name>.

pdf, djvu images, images that need scaling or rotation
what if tube curves are in pdf or djvu document such as on Frank's tube site? The best solution is to render the image on the screen and use any screen capturing tool to grab it. I use lvpro, for example, to capture or rotate. Scaling is only meaningful if done with pdf or djvu, and is very ugly for load curves if tried with jpg or gif files.

gif file attributes
these can be used to store tube params, but I have not explored this possibility

reading params directly from and into SPICE .lib files.
doable but I have not done that.

images that are tilted or misaligned
some tube data pages are scanned tilted. I'm considering adding a slider that allows to tilt the model plot, but this is not currently done.

10.   Code source

The Java source of the tool,, is included in paint_kit.jar. It is just a single file which helps understanding and modding the code. Please send me patches if you come up with improvements and enhancements, and I'll incorporate the code into the tool!

Go here to learn how it works.

11.   Other interactive tools

We provide several other tools, very similar to Koren Improved Triode finder but featuring different tube models. Here is the list of currently available parameter finders.

paint_kip.jar Koren Improved Pentode Model, version V2 supports loadlines, PP mode and various advanced controls. The old version V1 is still available, here,

paint_ppt.jar Stefano Perugini Polynomial Ex(Ep) Triode model

paint_pexgt.jar Polynomial Ex(Eg) Triode model

12.   links

[1] tubeparams, a text-input parameter-finding tool

[2] NextTube data page

[3] Klausmobile T-files

[4] Teodoro Marinucci Excel image-to-table tool, Also see

[5] Norman Koren tube parameters

[6] Duncan Amp's tube data

[7] Frank's Tube Pages

[8] Not finished yet. models-gallery.htm A collection of good matches done with my Paint* java tools, screenshots as well as model text ready to be copied into your SPICE .lib files are provided. Please send me your findings for inclusion.

Author: Dmitry Nizhegorodov ( My other projects and articles