Distortion measurements and Spice

LT spice, Curve Captor, PSUDII and whatever other sims you can think of.

Post Reply
sbench
Posts: 296
Joined: Fri Jan 28, 2005 3:45 pm

Distortion measurements and Spice

Post by sbench »

I'm still around and kicking. At least for a while. First, I'd just like to say hi to all. Although I'm not actively doing tube work, I use LTSpice all the time and have gleaned a few tricks over the years.

LTSpice provides two methods of obtaining distortion information about your pet circuit. (The .FOUR directive, and the FFT plot). Both have good usage, but it's always in the context of primarily the standard transient circuit analysis. However, we can build a circuit that can more or less universally give us this information directly, and plot distortion and other parameters. I was planning to discuss:

1. Easy subcircuit module creation.
2. Creating a "THD" module.
3. Expanding that to provide individual components.
4. Timing requirements.
5. Plotting things other than time on the horizontal axis.
6. Several worked examples.

Ultimately, we will be able to plot distortion or power output (Y axis) vs ut level or even load impedance.


Enjoy,
Stephie

Here's an example (Horizontal Axis is load impedance in kOhms from 2 to 5k in 100 ohm steps
Attachments
2a3dis.PNG
2a3dis.PNG (21.61 KiB) Viewed 1901 times
sbench
Posts: 296
Joined: Fri Jan 28, 2005 3:45 pm

Post by sbench »

To create a distortion measuring module is relatively easy in Spice. Let's assume a 1kHz driving source. What we need is a very sharp high pass filter just below 2kHz. It has to be sharp enough that 1kHz driving signal won't get thru. A 0.2dB chebychev filter at 1.995kHz, 11 pole is down a bit over 100dB at 1kHz. This would give us resolution to 0.001% distortion. Then, a couple behavioral sources to give us the original signal squared and then averaged produces a Reference. A second one just like it at the output of the filter gives us the residual distortion component. A third one taking the square root of the ratio of these numbers, multiplied by 100 gives us a "DC" signal whose magnitude in volts is the % distortion.

We can do this and create a module by building and testing our module like...
thd_sch.PNG

Once you have it debugged, remove the spice simulation directives and driving sources and whatnot, and save that schematic as a .asc file in the directory you use for your schematics. For example
THDmodule_asc.PNG

Now create a schematic symbol (create symbol in Spice), with pins for the nodes you wish to bring out. Note that the pin names need to match the pins you want going in and out of your module. It might look like this
THDmodule_asy.PNG

Save the symbol file WITH THE SAME NAME you gave the schematic file, except for .ASY file extension.

Now, when you add a component to any schematic file you create, and you go to near the top of the box where it says "top directory", and select the directory you saved that file in, you ought to find the symbol as a component. Presto, you have your THD module.


I have attached the .ASC and .ASY files for this module so you don't have to create and build it yourself.
Those files are
THDmoduleHR.ASC
THDmoduleHR.ASY

It should be noted that it does take some time for these circuits to "settle" to give you good results.
For this module, as you will see below, the results are only accurate after about 25ms of simulation time. Here's some curves.

First, the filter frequency response...
thd_2kHPF.PNG

Then, if you do a transient analysis, the response is...
settle.PNG
Note the transient, and note the distortion (orange) doesn't settle to below 0.001% until you have injected the sine wave for about 25ms or so.

Note well. Since you are trying to resolve distortion accurately, you need to set Spice's step size to 1e-7. This DOES slow things down a bit, but necessary for the accuracy we are looking for.


See, wasn't that easy?

Peace,
Stephie
Attachments
thd_2kHPF.PNG
thd_2kHPF.PNG (11.45 KiB) Viewed 1894 times
settle.PNG
settle.PNG (14.88 KiB) Viewed 1894 times
thd_sch.PNG
thd_sch.PNG (23.64 KiB) Viewed 1896 times
THDmodule_asc.PNG
THDmodule_asc.PNG (24.02 KiB) Viewed 1896 times
THDmodule_asy.PNG
THDmodule_asy.PNG (11.25 KiB) Viewed 1896 times
THDmoduleHR.asc
(3.74 KiB) Downloaded 67 times
THDmoduleHR.asy
(478 Bytes) Downloaded 71 times
Last edited by sbench on Tue Jun 23, 2020 12:01 am, edited 1 time in total.
sbench
Posts: 296
Joined: Fri Jan 28, 2005 3:45 pm

Post by sbench »

But wait! There's more... If you call within the next 3 minutes....

No, no, no. Where did that come from?

More seriously. Since we have a THD module, we could add a bank of very sharp, narrow bandpass filters, and get not only a measure of THD, but individual distortion components as well. It's just a few more filters. It would look like this...

Distortion_module_asc.PNG.

The associated assembly file is...
Distortion_module_asy.png

Because of the additional filters, you need to allow for more settling time when using this module. It takes about 60ms for these to settle.

Yes, I've built up and tested this module as well. The .ASC and .ASY files are attached as...

Distortion_module.ASC
Distortion_module.ASY

In the next installment, I'll give examples of their use, and how to set up Spice to plot your distortion curves.

Enjoy,
Stephie
Attachments
distortion_module_asc.PNG
distortion_module_asc.PNG (83.1 KiB) Viewed 1895 times
distortion_module_asy.PNG
distortion_module_asy.PNG (11.4 KiB) Viewed 1895 times
Distortion_module.asc
(20.88 KiB) Downloaded 73 times
Distortion_module.asy
(917 Bytes) Downloaded 75 times
sbench
Posts: 296
Joined: Fri Jan 28, 2005 3:45 pm

Post by sbench »

Continuing on, let's consider an example. For this first example, let's set up a simple 2A3 single ended output stage. Nothing fancy (yet - we'll talk about that in later examples. But in this example, I simply want to show a nice vanilla output stage. 255 volts (well, 250V behind the resistance of the output transformer) on the plate, so bias will be -45v. With the "classic" load of 2.5k on the plate, should produce 3.5W at about 5% distortion.

NOTE: It often helps to use GEAR spice analysis when using tube models. Set this up in the spice setting in tools.

See example1_schematic attachment and the test2A3_1.asc files below.

I've loaded distortion module onto the schematic as I detailed in the previous post.

The first thing I want to show is the settling time in the real live circuit, so I've first set the transient simulation display for 0 to 100ms, and I've plotted the distortion products. See the example1_settlingtime attachment.

Note that initially, nothing makes sense, since we are not looking at steady state conditions. But notice that by 60ms, things have settled down quite nicely.

for all below, I will set the transient command to display after 60ms, and display 1ms. (61ms total time, display data after 60ms). I also set the max time step to 1e-7.

The first trick is to display something other than time on the horizontal axis, So lets plot distortion vs power output. Note that in the schematic, I have a small function (Behavioral source B1) that automatically calculates and averages the power output.

So, click the horizontal axis in the waveform display. See where it says quantity displayed "time"? Simply change that "time" to "V(PO)". Then choose logarithmic display.

Now, to set it up, do a step param amp command, so that we step thru 1 to 45 volts in a logarithmic manner. (That's shown on the schematic). Now plot your run by plotting v(THD), V(2nd) etc to plot all the individual harmonics. This is shown in the example1_distVSpo attachment.

Log display of distortion works nicely. Notice that the 2A3 produces primarily 2nd harmonic and some 3rd harmonic, but the higher orders are very low. Nice display, huh?

But, we can do much, much more. Let's now set up a parameter to step through output transformer load impedances of 2 to 5 kohms, and plot against this. First, we set up a voltage source to mimic the impedance. That is the purpose of V1, labeled horiz. Now if you run a step of inductance values to step you thru 2 to 5k in 100 ohm steps, using the step param command, you can plot against V(horiz) and get that nice display. In addition, I also had the simulation step thru 12 and 45 volts of drive signal, just to get 2 different signal levels, so you can see any changes at lower signal levels as well. The result is shown in example1_distVSload.

I find it very interesting that we have also verified the "common wisdom" that higher losd impedances on a triode result in lower maximum power, but cleaner output. (lower distortion). Note that at higher impedances, the available power drops, but the 3rd harmonic gets a lot lower too.

Next, we will add a driver stage, and watch what happens!

Enjoy,
Stephie
Attachments
test2a3_1.asc
(5.45 KiB) Downloaded 63 times
example1_distVSloadAT4wand200mw.PNG
example1_distVSloadAT4wand200mw.PNG (17.45 KiB) Viewed 1887 times
example1_distVSpo.PNG
example1_distVSpo.PNG (25.04 KiB) Viewed 1887 times
example1_settling time.PNG
example1_settling time.PNG (15.58 KiB) Viewed 1887 times
example1_sch.PNG
example1_sch.PNG (20.97 KiB) Viewed 1887 times
Post Reply