Douglas Self, Jim Williams, and a sunny Saturday morning

Writing this, I was inspired by an article by Jim Williams called “Max Wien, Bill Hewlett and a rainy Sunday afternoon”, which documents his investigation of the Wien bridge oscillator and how to lower its distortion.

1. I’m a fan of Jim Williams, and his crazy cartoons and application notes with names like “Switching Regulators for Poets”.

2. My prototype Blameless power amp was getting good enough that I needed a really low distortion oscillator to test it. Surprisingly, even my 24-bit home studio gear wasn’t good enough: sigma-delta converters generate a lot of ultrasonic noise that inflates the THD figure. And my Twintrak Pro mainly generates smoke.

3. I could not find a Tektronix SG505 or SG5010 for sale at a reasonable price.

4. Neither could I be bothered building the oscillator section of Bob Cordell’s DIY THD analyzer.

5. A search of my kitchen junk cupboard yielded a RA53 thermistor.

6. A Google search of the part number revealed that it’s the magic ingredient for making a really good Wien bridge oscillator. So, using the RA53 and a NE5532 op-amp, it only took about an hour to make an oscillator that ran off a couple of 9v batteries, and measured about 0.007% THD at 10kHz on my analyser. (The remaining THD is probably a combination of ignoring Williams’ Law, thermal modulation in the thermistor, and the dirty mains in our lab.)

7. So, this morning I tested the Blameless using my new low-distortion oscillator. It was clean enough that I could see the “gm-doubling” distortion described by Self when the amp was biased too hot: the first time this effect has ever been reproduced at Conner Labs. 🙂 Optimal bias seemed to be about 8-9mV per side, though it wasn’t clear whether this was just cancelling the oscillator distortion, and the true minimum might be at a higher idle current.

8. The results were really good. The 10kHz, 100W, 4 ohm THD came out around 0.01%. I used the 80kHz low-pass filter, but from inspection of the residual, it wasn’t filtering much: mostly the 200kHz switching noise that our mains is ridden with. At 10kHz, 2W, it was about 0.007%.

9. I cranked it up to 140W and let it get really hot. This only caused about 1mV change in bias, and checking again at 2W, the THD reading and residual looked pretty much the same. Then I rigged up a fan to cool it down again, and that didn’t make much difference either. Yay for those ThermalTrak transistors, then.

10. Renting an Audio Precision test set costs about £600/month for the entry-level one. So, I decided to call it quits at this point. The Blameless is now complete, and it just needs another channel, DC offset protection, and a box. I shall publish the schematics soon.

11. When Jim Williams was done with his oscillators, he cooked some hot dogs. I am ashamed to admit that I ate a McDonalds.

12. Now I am obsessed with trying to make a digitally controlled version of Cordell’s oscillator. 🙂

Blameless first sound! :D

Today, after much testing with various dummy loads, including the dreaded 4 ohm reactive one (which showed up some parasitics that I managed to get rid of) the Blameless was finally plugged into a speaker.

It werks!
It werks!

Attempts to measure the THD have so far failed. They really just show up the limits of my  THD measuring system, which is currently no good for anything except finding gross faults.

For instance, the reading I previously got of 0.05% at 10kHz and 120W. When I took the amp out of circuit and connected the analyser straight to the oscillator, the THD reading increased to 0.09%.

The THD analyser does show up crossover spikes, though, if the output stage is underbiased. They were pretty much invisible by a bias voltage of 10mV per side (20mV total) which corresponded to 200mA total idle current. I set it to 13, which gives the 26mV total that some experts recommend.

Anyway, it’s working, and experimenter expectancy notwithstanding, not to mention lack of one channel, I swear it sounds better than my old MOSFET amp. Maybe there is something in Douglas Self’s claims of poor crossover distortion from MOSFETs. Once I get the other channel built and the system put together, I will make that low-distortion oscillator and do a THD shootout. Or an ABX test or something. Anyone want to lend me an Audio Precision test set? 🙂

More Blameless progress

The Blameless project is grinding on!

.

4-layer boards for the output stages were designed in Eagle and ordered from PCB Train. Some samples of the ONSemi NJL4281/4302 transistors with built-in thermal sensing diodes were obtained. The whole lot was fitted to a large heatsink using Sil-Pad A1500 high performance thermal pad stuff.

After testing using a bench power supply, it was connected to a large transformer, rectifier and some capacitors.

The power was turned on and amazingly it failed to explode.

More detailed info to come, but the maximum output is about 120-150W into 4 ohms, the THD about 0.05% or less at 10kHz and 120W (so should be nearer 0.005% at 1kHz) and the short circuit protection, thermal compensation etc. all works as planned.

Scripting fun: Rename files by date in Windows

When I’m working on a computer, I frequently make backups of what I’m doing. There are a lot of ways to do this, but the one I use is a bit ghetto.

1. Right click the folder with my work in it, and select “Send To > Compressed (zipped) folder”

2. Rename the resulting zip file so that the name includes the date in ISO format. You have to rename it in order to store multiple versions in the same place, so might as well add some useful data to the name.

3. Copy it to a backup drive somewhere.

I got fed up of doing the renaming manually, so I created (cobbled together from various Howtos) a batch file to do it for me. Here’s the code:
@echo off
FOR %%V IN (%1) DO FOR /F "tokens=1-6 delims=/: " %%J IN ("%%~tV") DO IF EXIST %%~nV-%%L%%K%%J-%%M%%N%%O%%~xV (ECHO Cannot rename %%V) ELSE (Rename %%V %%~nV-%%L%%K%%J-%%M%%N%%O%%~xV)

Paste that all into a text file (one long line!) and call it something like RenameByDate.bat.

Now, if you drag and drop another file onto this batch file’s icon, it should get renamed to its original name, plus the date and time of its timestamp.

If this doesn’t work, you may need to enter the following three commands at a command prompt, to enable drag and drop for batch files.
ftype batfile="%1" %*
assoc .bat=batfile
regsvr32 /i shell32.dll

(from here)

Finally, place the batch file in your Send To folder. (C:\Documents and Settings\YourUserName\SendTo)

Now you can rename any file, adding the date and time to the name, by right-clicking it and selecting “Send To > RenameByDate.bat”.

In other news, I’ve mostly been automating Bill Of Material generation with Perl.

First THD analyser results!

I’ve finally got the THD analyser hooked up and working! Not very well, though, because I have to use it with my not-too-hi-fi signal generator, on account of the analyser’s own oscillator section being AWOL. My sig gen is DDS-based, so it puts out lots of high-frequency crud and DAC quantization errors, and these overwhelm the amp’s own contribution to the residual. Except if I test at 10kHz and press the analyser’s low-pass filter button, which kind of fixes it…

Anyway, I hooked the Blameless up to an unregulated power supply to pump in plenty of hum and grunge (got to test that ripple rejection too!) and made some THD + Noise measurements.

THD test setupTHD at 50W50W residual

10kHz, 50W into 4 ohms: 0.086%

10kHz, 2W into 4 ohms: 0.037%

(I measured at 10kHz to try and force the amp to generate more noticeable THD levels. And yes I have the hi-pass button pressed: some hum is getting in somewhere…)

I also tried setting the bias pot to minimise THD.  At 50W, this happened at a setting so cold that there was barely any bias at all! I measured a Vq of around 300uV. But at 2W, the minimum occurred at a Vq (across each emitter resistor) of about 14mV.

2W THD, underbiased2W THD, bias just right2W overbiased

I think what’s happening is that at high power and high frequency, an overly cold bias helps to counteract the transistors’ slow turnoff. Too cold bias effectively starts turning them off in advance. This gives a false THD null. 2W seems to be a better power level for setting it.

At both power levels the THD nulls were very broad, and seemed to stay stable when I let the heatsink get burning hot, and then applied a fan to cool it back down.

Still a long way to go in terms of refining the THD measuring setup… but it’s a start!

Blameless short circuit protection

So, now the short-circuit protection is tested.

I used a dual-slope VI limiter as described by Self in his book, except I simulated it in LTSpice and played with the component values to lower the power dissipation a little. Self’s original design allowed the transistors to dissipate nearly their full rated 250W, and I thought that was excessive, since it’s only possible at a case temperature of 25’C, and that will never happen in practice.

I guess his reasoning is that since the amp will only amplify AC signals, then under short-circuit conditions each transistor will conduct with a duty cycle of 50%, so the mean dissipation will only be 125W. But I can imagine situations where that wouldn’t work.I also plan to try the NJL4281/NJL4302 transistors in the future, and these have less SOA than the MJ15024/MJ15025, the devices that Self designed the circuit for.

My new values were supposed to make the circuit limit at about 125W. Anyway, so I made the circuit up and tested it with the method described on Rod Elliot’s site. Namely, I shorted the amp’s output with a 0.1 ohm resistor, and fed 100us pulses at a repetition rate of 10Hz to the input. I did this with the amp running off two regulated supplies, allowing me to vary the rail voltage and note the current for each voltage.

At first, the negative rail had no limiting at all! It started out at 12A and headed skyward from there. It turned out that I put a diode in backwards, and also the gain of the PNP limiter transistor was low, and the VAS current limit was a little high. Once I got that fixed, I plotted out the two sets of results in Excel, and added loadlines for reactive and resistive loads on 40V rails.

Protection locus

So you can see that with one pair of output transistors installed, we can just barely drive a 4 ohm resistive load or an 8 ohm reactive one. To drive a 4 ohm reactive load, we’d need two pairs, which is what I was expecting, and two pairs is what I plan to fit.

Finally as a sanity check I rigged up a reactive load: A big iron cored choke wound with about 80 turns of heavy wire. I put two 4.7 ohm resistors in series with it, and it could drive that easily at any frequency. Go down to one 4.7 ohm resistor, and I found a frequency where the limiter would activate and cause crazy clipping, like in Rod Elliot’s Figure 4 linked above. Again this agrees with what I expected, so we’re good to continue!

Note that before trying this test, I added the catch diodes from the speaker output back to the rails. Otherwise the output devices would be destroyed when the limiter kicked in.

My Blameless is working!

I’m so happy! Ever since I was a humble EE student, I’ve wanted to design my own hi-fi power amp based on Douglas Self’s “Blameless” philosophy. I now proudly present the prototype.

doesn’t look goodbut seems to work well so far

I’ve built power amps from other people’s designs before, but this is the first one I’ve designed, albeit with a lot of help from Self’s “Power Amplifier Design Handbook.” It’s a modular system, with a driver board that can be hooked up to any kind of output stage, to make different kinds of experimental amps.

It’s still not finished: the protection circuitry and THD need testing. But it’s passed the first hurdle, in that it can run with a good DC offset (I measured 16mV), stand +/-60V rails and drive a load without blowing up.

The last three amps that I’ve built were powered by valves (tubes?), and the two before that had MOSFET output stages, so working purely with BJTs was a bit of a culture shock. Self always argued that they were the best amplifying devices, and they certainly seem pretty good. The OnSemi MJ15024/MJ15025 pair of transistors I used in the prototype cost a few dollars each, less than half the price of equivalent MOSFETs, and they make as much Umph as a pair of KT88s. They didn’t want to oscillate or explode, and the whole thing generally just worked first time. Apart from that evening I slipped with the scope probe and took out half a dozen trannies in the driver board.

This is something of a multicultural project. The output trannies were made by Motorola in Mexico, all of the other ones came from Continental Device in India (that’s what you get when you buy Farnell’s “Multicomp” value brand transistors) and the whole mess was assembled by a Scotsman wired on Fairtrade coffee beans.

And yes, Self convinced me to buy a distortion analyzer. So far all it’s told me is that I need to get a better signal generator.

Resampling in Mac OS part 2 :)

After a few snarky messages from Mac owners, I thought I had better post a follow-up. I experimented a little at the weekend and found the following:

If I leave my soundcard (Audiophile Firewire) permanently on 96kHz, then:

iTunes will resample to 96kHz internally, with quality that sounds just fine.

VLC will output at whatever the sample rate of the media is, and get resampled to 96k by AUHAL on its default quality setting, which sounds a bit sketchy.

But, VLC can be set to always output at a particular rate, resampling internally. There’s an option called “Frequency” in the advanced audio preferences. According to VLC’s debug stream, it uses a module called “bandlimited_resampler”, and that’s encouraging, because it suggests that the guy who coded it knows the word “bandlimited”. It uses about 6% CPU time, and again, sounds fine. Thanks to the wonders of open source, we can see bandlimited.h here! Ooo, a 1536 point sinc kernel with linear interpolation and single-precision floating point arithmetic.

I got VLC’s “Media Library” to work too, so it can store a playlist, remembering what FLAC stuff I have and the track order of it.

I’ve not tried to play DVDs yet, but hopefully the computer won’t catch fire.

So in conclusion, I’m upgrading this from “:(” to “:)”

Resampling in Mac OS :(

Recently I’ve been experimenting with higher definition music downloads. For example, the Studio Masters recordings from Linn Records, or the material from B&W Society Of Sound. Everything went nicely until I got my new Mac.

First of all, the only lossless format supported by iTunes is Apple Lossless. It won’t play FLAC (the open source Free Lossless Audio Codec) properly, even with the xiph.org extensions, Fluke, or whatever. A bummer, as I already had a fair amount of music in FLAC format. Sure, VLC will play it, but VLC can’t understand iTunes playlists.

Second, Linn don’t support Apple Lossless. They supply their music in FLAC and WMA formats only. I guess they’d rather you bought their own stupid, overpriced DS network media players, even if you have a Mac already.

Third, Mac OS resamples! Windows was smart enough (or dumb enough?) to set your audio hardware to the actual sample rate and bit depth of the track that was currently playing. Or at least the setup I used, Winamp Classic with the ASIO driver, would do that, guaranteeing bit-accurate output under all conditions.

The Mac doesn’t. You set the sample rate and bit depth once and for all in the audio control panel, and all the sound gets resampled to that. You can play 96kHz material till you’re blue in the face, using any player application you like, but if the system sample rate is set to 44.1, it’ll get downsampled. Watch a DVD, and the sound is getting resampled from 48 to 44.1.

I don’t know about you, but I wouldn’t trust any resampling algorithm I hadn’t written or at least tested myself. They’re notoriously hard to get right. And a “right” one consumes so much CPU power that there’s a real incentive to downgrade the performance deliberately.

Here’s the official line from the Coreaudio mailing list, found here

This was a comment posed to the list (which was replayed verbatim from Benchmark’s Elias Gwinn)
> […] If the user changes CoreAudio’s sample-rate in AudioMIDI Setup to something different than what iTunes is locked to, CoreAudio will convert the sample rate of the audio that it is receiving from iTunes. In this case, the audio may be undergoing two levels of sample-rate conversion (once by iTunes and once by CoreAudio). (The SRC in iTunes is of very high quality (virtually inaudible), but the SRC in CoreAudio is horrible and will cause significant distortion.) If the user wants to change the sample rate of CoreAudio, iTunes should be restarted so that it can lock to the correct sample rate.

This is the response from an Apple employee:
iTunes uses the AudioConverter API internally but we set the quality to “max” and AUHAL probably uses the default (I don’t know). One SRC at max quality followed by one at the default quality is not so great when analyzing sine tone playback.

So the bottom line seems to be, that if you have material recorded at a higher sample rate than 44.1, then you need to turn your system’s sample rate up to appreciate it. And if you do that, then all of your other stuff will get upsampled, though at least it uses Coreaudio’s best quality algorithm. Or does it? Leopard introduced a new “Mastering grade” algorithm, and it’s not obvious whether that one is used.

One step forward, two back. Come on Apple, twiddle those nose rings and come up with a sexy solution.