Monday, 7 January 2019

Boat progress!

Rather a lot of progress, accomplished through the simple expediency of spending money. This was necessary because we're moving to Perth in the next couple of months, so the boat must now be mobile.

Looks rather nice on a trailer, I reckon.

Top on the priority list for the new place is somewhere I can store Elena, on her trailer, and finish her off. :)

Modifying the trailer a little to give me a means of supporting my mast:

Saturday, 14 April 2018

Achieving low THD at modest power level with jellybean parts

My power amps to date follow a reasonably simple recipe: Differential JFET front end, a couple more voltage gain stages, then power MOSFET followers, based on the Tilbrook AEM6000, with updates to more modern parts and some minor tweaking. They work pretty well. I'm able to achieve reasonably good distortion performance, hitting 1ppm THD at 1KHz, low input referred noise level, of 5 ish nV/√Hz, and plenty of output power, easily putting 100W into an 8Ω load.

But most of my speakers don't need 100W. Most of them don't last terribly long at such power levels, and I get a lot of complaints from Perry when I wind the wick up too much anyway.

Also, they're expensive. Each of those output transistors are >$10. The differential JFET on the front end is another $5. I'm probably up for $100 or so in parts just to build one amp, which is something of a waste if I use it with a little 4" bass driver or tweeter.

I'd like to play with line arrays - it would be cool if I could drive each speaker independently, as then I could play with multi-channel DSP. That's not going to happen when the amp for each driver is $100. I have a workmate who's doing similar things - his question each time I suggest he use a linear amp rather than a class-D eBay one is "how much?" This is perfectly valid.

So I got to wondering what was possible using really cheap transistors for driving a single 3.5" speaker. I set the following as my design goals:

  • Absolutely no compromise in THD. Preferably 1ppm at 10KHz.
  • 5-10W should be adequate.
  • Better noise performance than my AEM6000 derived amps, as I'll be running them at lower levels where noise will dominate.
  • For exactly the same reason, better PSRR. I really don't like listening to hum.
  • Really, really cheap. Like $10 per amp in parts.
Given that each of my nice Lateral MOSFETs costs more than my budget, that totally rules them out. This means I'm stuck with jellybean bipolars.

My basic three stage amp design should work well with a bipolar input stage. Similarly I can whack a bipolar follower stage on the output. How about if I use a diamond configuration for the current buffer. Even better, how about if I cascade a pair of diamond stages, to minimise loading of the final voltage amp transistors. Rumour has it that this is sure to oscillate, but I'm game.

I was able to get this topology to work well in simulation, with BD139 & BD140 transistors as my final drivers. I could hit 120dB open loop DC gain, with better than 50dB available to correct output stage distortion at 10KHz. This led straight away to sub ppm THD at 10KHz with 20dB gain under simulation. However I wanted a bit more output current than the 1.5A max the BD139 was happy giving me, so I tried TIP41 & TIP42, which are good for 6A. They proved a little slow with stability issues, so I stepped back to a BD179 & BD180, which provides up to 3A in a TO-126 package and is reasonably fast, plus really cheap, at $0.40 each in quantity.

A few simulations later I had the following: A simple input differential pair using BC547's for reasonably low noise, followed by a folded cascode with differential current sink loads to a pair of differential amps, then finally a very conventional symmetrical voltage amp stage using 2N3904 & 2N3906 transistors, then the first current gain stage; a diamond composed of 2N3904 and 2N3906 transistors, and finally our output stages, a bunch of BD179 & BD180's in a diamond configuration. One nice thing about the diamond is that the quiescent current is set by a simple current source/sink pair, making them immune to thermal runaway. A bad thing is that I'm effectively doubling the number of output drivers. Not a big problem when they're $0.40 each.

I published the simulated design on DIYAudio, and received some really useful feedback, adding a cool "clipping control" stage, which sucks charge out of the compensation caps in the event of clipping, ensuring there's no sticking to the supplies.

I then went ahead and knocked out a PCB for the "5W" version, using two sets of output drivers. I used KiCAD, as it's completely open source and it was about time I broke away from closed PCB software (Protel) and used something where I could share the design work with others.

This worked reasonably well, though I initially missed my THD target by rather a lot - measuring 15 ppm at 1 KHz into 8Ω when I was expecting closer to 1 ppm.

After some measurements I found the source of the problem was simply due to where I was sampling the output voltage for the feedback network. By tapping the net away from the output connection, I wasn't getting an honest representation of the output, being influenced by currents between output drivers. Cutting a trace and adding a link from feedback resistor to the actual output connection of the amp fixed this, and I was able to achieve around 2.4 ppm at 1 KHz, up to 6W into 8Ω with gain of 10 (20 dB). This mod has been folded into the rev 2 PCB.

Noise performance is also pretty good - with 4.2nV/√Hz (input referred - the plot shows the output with a gain of 10) at 1 KHz with the input shorted.

The folded cascode gives me a pretty wide common mode range of ~10V with +/-18V supplies, and the current sink loads for the first stage mean the whole lot will keep on trucking with a supply as low as +/-5V or so. When it clips, it does so cleanly, with no rail sticking or oscillation.

It plays square waves neatly too - here's a 10KHz square wave. Slew rate is ~12V/µs.

There's also a 10W variant with twice as many output transistors, a dual 5W/15W version with active crossover for driving my two way transmission line "noiseUnit" speakers, and a preamp implementation with relay-based volume control.

So if you're keen on a no compromises driver for headphones or small speakers, give this one a shot - the full design details, including all my KiCAD design files and Gerbers are at diyAudio. It's cheap but good :)

Wednesday, 17 January 2018

A new Microbee disk controller, from original design films.

One of the guys at the Microbee Software Preservation Project got his hands on design films for a Bee disk controller, so he imported them into KiCAD as image files, cleaned them up, and generated beautiful Ger bets that look exactly like they were made with Bishop graphics.

He sent me one of the resulting PCBs, and I spent some time last night throwing it together, using bits from my junk box. Note the cool labelling on my TI TMS2793 floppy disk controller IC. The bit on the right comes off when scrubbed with isopropyl, revealing the writing on the left. It’s still a TMS2793, but with a HP part number. I wonder if TI was responsible for the relabelling way back when?

Friday, 1 December 2017

Applix 1616

The Applix 1616 was a very cool 32 bit computer designed in Australia in 1985 by Andrew Morton. It used the Motorola 68000 (like a Macintosh!) and had a fully bit-mapped display. All very cool stuff. Many people (myself included) see the Applix as something of a successor to the Microbee, though minus the commercial success of the 'bee. Incidentally Microbee designed their own 68K machine (the Microbee Gamma) not long after the Applix became available, but struggled badly in development. The Gamma was never released publicly, and only a handful of prototypes exist now.

There were kits of the Applix available, and a blurb in ETI magazine, but things like 68K processors were obscenely expensive back then, so there was no way I was going to build one. That's all different now. I've got pretty-much all the bits in my various junk boxes and drawers to make one. Now all I've gotta do is reverse engineer the PCB layout, come up with some PAL designs, and go for it. Unlike the bee there are no issues with IP ownership and sharing.

There are four sheets - CPU, CRTC, and a couple of I/O ones. How hard can it be?

Edit March 2018.

I've managed to borrow a real Applix 1616 (Thanks heaps Philip), which after a quick clean I've taken some really detailed macro photos of to help with the replication.

Friday, 17 February 2017

More fakes

Here are some fake 2SK1058 & 2SJ162 MOSFETs I just bought from ebay. These came from an American seller. Different 2SJ162s:

In each case I've put a real 2SJ162 next to the fake. In all photos the fake is on the left and the real deal is on the right.

The real transistor is the most modern version of the 2SJ162, made after Hitachi spun their semiconductor foundry off as it's own entity under the "Renesas" brand. Note the absence of Hitachi markings, or indeed Renesas. Note also that the real thing has it's marking done with a printing process, whereas the fake has markings done by laser, in a raster pattern.

Lots of transistors are marked by laser now - indeed it's the standard way for product to be identified these last fifteen years or so. However that's after Hitachi became Renesas. Note the real Renesas product (perhaps twelve years old) still hasn't got laser markings.

The other tell-tale is that the date code on the two wildly different 2SJ162 packages is identical. Fabs do change their packaging from time to time, but not with the same date code.

Note further that the raster pattern isn't just where the markings are, but extends all the way across the package. I'm hypothesising that this is how they obliterate the original markings without resorting to sanding.

And their counterfeit complementary pairs, 2SK1058s:

Again, real deal on the right, fakes on the left. Same thing with the laser markings, but this time the raster pattern is only where the text is. Perhaps they got a pile of transistors that were unmarked so there was no erasing needed?

This is incredibly frustrating. I'm a seasoned professional engineer with decades of experience. If I didn't have some known-good stock of these transistors, and if I hadn't been alerted to the possibility of trouble by the two different 2SJ162s with the same date code, then I'd have chucked them in a circuit and wondered why it didn't work. How's a fifteen year old enthusiastic kid going to cope? She'll build her amp, wonder why it vanishes in a cloud of smoke, and give up.

A very easy test can be done with a multimeter. Cgs on the real parts is ~0.8nF, and Cgd around 0.6nF for the 1058, and 1.1nF for the 162. For the fakes I didn't measure valid capacitances for most of the 2SJ162s (so they probably aren't even MOSFETs), and the remainder all measured ~5nF Cgd, so they're likely DMOS parts rather than lateral MOSFETs.

So the last photo shows a cotton bud soaked in isopropyl alcohol, having scrubbed the surface of the transistor:

Black scunge comes off, and the raster pattern is more obvious. I'm wondering if they paint the transistors with something where they've had to remove markings to blacken them up before remarking. I didn't get any black scunge off the "2SK1058" variety - I'm thinking this is because no remarking was needed for these ones.

I'll see how the seller goes with a refund.

Edit: The seller refunded immediately, and said "Hello I sold many of this item, without any complaint", which is I guess exactly my concern. So lots of people have bought these, put them into amps, found they don't work, then blamed either their own assembly skills or else the amp design, when the problem is that the actual parts are fakes. It's really unconscionable behaviour.

Finally, a quick disassembly. From left to right we have both the flavours of "2SJ162" then the "2SK1058":

The dies are all different sizes - 4.2mm square for the first "2SJ162", 4.1mm for the second, and 4.5 for the "2SK1058". They made rather a mess mounting the die, which is a little surprising and makes me wonder if perhaps these are specifically built to be fakes - ie that they buy die and package them, then put bogus labels on them.

Monday, 30 January 2017

Measuring a MOSFET Power Amplifier.

I'm on a bit of an audio kick of late. It's all about building some speakers and an amp for my study, as I stole the speakers and amp from there (some nice home-brew 2-way bookshelfs with Vifa P13WH mid-woofers and P27TG tweeters, and an old NAD 3020B) for my bedroom. Anyway, I've got a pre-existing amp design, based on David Tilbrook's AEM6000, and I've ordered the drivers to build a pair of Lynn Olsen "Ariel" MTM transmission lines. That'll make some pleasant noise, I think.

On to the amps. Back when I originally designed these amps, some 10 years ago, the distortion analyser I had had a noise floor of 0.0013%. I achieved that fairly easily so moved on. I've just bought a PCB for a super-low distortion oscillator based on the Linear Tech "AN67" circuit, which uses some scary high-gain opamps wrapped around a resonator to generate an "unmeasurably" pure tone.

Now I've got a sniff of a world beyond 0.001%, I'm very keen to see how far I can go. Part of that's developing a whole new completely over-the-top amplifier (see previous posts), part of that is just playing with my existing amps to see what they're really capable of.

The process is straightforward. Put one together on a heatsink with a dummy load and thrown together power supply using bits from the garage, apply a stimulus from either my mac, my function generator, or my new oscillator, measure what's being put into the load with my CRO and spectrum analyser, tweak, repeat. It's a process that's quite involving.

Here's the amplifier in question. It's a little 50mm x 100mm PCB, implementing a modified version of Tilbrook's AEM6000:

The one that we're concerning ourselves with today is the one on the left. It's an evolution of a couple of previous designs:

They started with my original "repackaging" of the AEM6000 using flat-pack MOSFETs, shown on the top left. Then I made a "baby" 50W version (top right). While making that I wondered whether I could roll a version that would fit on a 50mm wide heatsink, with off-board filter caps. That resulted in the two smaller boards below. They depart from the original in that the VAS stage is no longer differential-symmetrical, as I simply couldn't see the advantage of the differential structure in Tilbrook's original. Also I made much better use of the back-side of the PCB. Whereas the original has practically nothing on the back bar the MOSFETs, this one has a fairly even spread of parts on each side. That makes it more compact and keeps parasitics down. Despite the small size it's still using 1206 (or MELF 0204) parts.

The schematic for the small 100W flavour is below:

First measurement, after setting the bias to 100mA per MOSFET and setting the output offset to <1mV, is to check for oscillations. I simply connect the output to the load, monitor that with the 1M input on my spec-an, and use the spec-an tracking generator (via a 20dB pad) as the amplifier input:

No nasty surprises. Hitachi lateral MOSFETs are prone to oscillate around 1-2 MHz if the amp isn't well compensated. I find working with LTspice to prototype the compensation is straightforward, and as long as you check the DC conditions on the real thing you'll be good.

While it's connected to the tracking generator, I check the gain flatness across the audio band:

It's hard to tell the spectrum analyser from my amp at the bottom end, as the spectrum analyser has a high-pass at 20Hz. Anyway, it's flat to within 0.1dB or so from there to 20KHz, which should be plenty. Of note is that I measured my NAD3020B, and it's got 6dB of bass boost from 60Hz to about 500Hz, with the bass knob in the middle. It's relatively flat when the bass knob is turned all the way down. I guess that's how you sell amps. That one "sounds better" - ie colours the music.

From here the measurements get increasingly challenging. First the noise floor of the amp. My spectrum analyser has a direct noise readout in nV/sqrtHz, which is incredibly cool. Pulling the amp input off the tracking generator, terminating it into 50 Ohms, and then winding the spectrum analyser all the way down to find the noise floor, we get this:

With the marker at 1KHz, we read off 139nV/sqrtHz. Input referred (this amp has a gain of 16), that's just 8.7nV/sqrtHz. To put it into context, the OP134, a pretty well regarded low-noise opamp, has an input referred voltage noise density of 8nV/sqrtHz.

Next we start working our way down the THD rabbit hole. I started by using my macBook air, as it has a reasonably clean DAC. I used Audacity to generate a 1KHz tone, then played that at all the mac volume settings, both directly and via my amp output:

Okay, not bad. Note the amp appears better than the macBook around 100mW to 1W. This is simply because the amp provides a gain of 16, so what was buried in the noise of the spec-an without the amp, isn't with the amp. Things turn to custard after a few watts. Initially I passed that off on the wimpy 2x25V 80VA supply I was using for test, but we'll find later it's a much cooler problem.

To go deeper, I really do need a better source. So I spent some time building the 1KHz low-distortion oscillator. Here's a photo:

The new oscillator, coupled with a 1KHz notch filter between the amplifier and the spec-an, really does allow us to make a much better THD plot:

But the distortion still isn't anything to write home about - sure, it's better than 0.001% at medium levels, but it falls off badly after a few watts.

I wondered what sort of improvement I could get by substituting faster VAS and second stage transistors. The MJE340 and 350 are bullet-proof, but they're pretty slow really. I pulled them out and substituted KSC3503D & KSA1381E, then made another plot:

Wow, that didn't help. Much gnashing of teeth and measuring showed one of the output drivers was drawing half the current of the other one. I went to replace it, and found out I'd, ahem, forgotten to do the screw up holding it to the heatsink, so it was running _much_ hotter than it should have. Tightening the screw up fixed the god-awful distortion, and we were back where we were with the MJE parts, marginally better:

On the basis that the KSA and KSC parts are faster, and my sims showed considerably improved stability, I wondered if I could improve the THD a little by winding up the negative feedback. This has the effect of reducing the output level, but I can sort that with more gain in the preamp. So I substituted a 5K1 MELF resistor for the 15K thick-film 1206 that was setting the feedback ratio. Bam! Instant huge improvement in THD. Much better than the couple of dB that I should have gotten. So I tried a variety of other MELF resistors for Rf. All show dramatically improved THD over the 15K thick-film chip resistor, and a gradual increase in THD in line with reduction in feedback:

So next I did some reading about distortion in resistors, and found that it's actually a thing. Thick-film resistors are notorious for changing their resistance significantly with changes in applied voltage. That change in voltage directly leads to a change of division ratio, and hence to distortion - we get different gain in the peaks than we do at the zero-crossings. The MELF resistors are a thin-film that's carefully engineered for stable resistance, both with changes in temperature (+/-25ppm/deg) and voltage. So they really are worth the extra few cents. Anyway, there's a whole nother resistor in this feedback divider, and that's also a thick-film chip. Not for long:

Yeah, that's 1ppm there, right around 25W output. So finally I did a much more exhaustive measurement, carefully accounting for every harmonic at a huge range of output powers, from 100mW all the way to 140W. Then I modified the oscillator to do 10KHz and repeated the exercise. I'm rather happy with the results. This amp is lovely and clean all the way to clipping at 120W. Slew rate doesn't clobber the 10KHz THD result until around 80W. Note a peculiarity of the results where the 10KHz THD is slightly lower than the 1KHz result under 1W. I attribute this to a slight increase in noise at low frequency, both from 1/f noise and 50Hz harmonics getting into the measurement. These are reduced by 10KHz:

Tuesday, 17 January 2017

A fast 12dB gain current-mode buffer for my HP3325B function generator

I'm sprucing up my HP3325B, after it stopped working (shorted out tantalum).

One of the options for the HP3325B is the "high voltage" output, which allows up to 40Vpk-pk, at up to 1 MHz, into 500 Ohms. Usual output is 10Vpk-pk, at up to 21 MHz into 50 Ohms.

Anyway, I don't have that. I was wondering if I could perhaps build a buffer-amp that beats their spec. Ideally it'd do 40Vpk-pk at 21 MHz into 50 Ohms, without adding appreciable distortion (the HP3325 is only good for perhaps 0.01% at audio, so that's not a difficult number to reach).

I have an old design for a current-mode headphone amp that I thought might be suitable, so I spruced it up a little, thought in terms of HF rather than audio, and I think I've come reasonably close.

It's actually a challenging amp - it's gotta be DC coupled, stable with a gain of just 4, and have reasonably low offset and gobs of speed, with tolerable distortion driving 40Vpk-pk, and really good distortion at lower levels. Here's the schematic:

At the hard end of the spec it manages 0.08% THD pushing a 1 MHz 40Vpk-pk sine wave into 50 Ohms. Relax any of that and it gets a lot better. For example at 1Vpk-pk, 1MHz, 50 Ohms it does 0.002%. At the "High Voltage option" max spec (500 Ohm load), it manages 0.05%, not a lot different from the 50 Ohm case, due mainly to the heavy feedback current.

At audio frequency it's kinda cool, and would make a neat uber headphone amp. (0.001%, 10KHz, 40Vpk-pk into 50 Ohms). And it's got gain that just keeps going. Yeah, 12dB gain at 100 MHz:

Wednesday, 23 December 2015


Varnishing isn't easy. It takes a while to get good results. The good thing about it is you can always just apply another coat. I think I'm getting better at this, after (thinks!) six coats on my rowing thwart, I've got a reasonably good recipe that looks set to provide a tolerable finish, at least after a few more coats...

My ingredients are Feast Watson spar varnish, Penetrol and real gum turpentine to help the stuff flow, and a proper varnish brush, which is wide and very thin, so it doesn't hold too much varnish, with super smooth bristles, so it doesn't leave great big ugly brush marks. I'm thinning the varnish out with ~15 percent penetrol and a further 5 odd percent turpentine. That gives me a mix that flows out nicely. Of course that's a recipe that's highly dependent on environment, brush, technique...

I started sanding with 180 grit, but found 400 works better in the latest coats. Here's the rowing thwart thus far. There's a bit of general lumpiness but the gloss level I'm getting is fairly good:

My rowlock bases and tabernacle have had a couple fewer coats. In the case of the rowlock base that doesn't seem to be an issue, but the tabernacle still needs some love.

I find when I'm putting it on it's good to keep a little container with mixed varnish+penetrol+turps, plus one with half an inch of pure turps in it handy, so I can thin out and clean the brush periodically, to keep it from sticking to everything.

Sunday, 20 December 2015

Camouflaged cat is camouflaged.

See if you can spot the cat hiding in this picture:

Of course like all good cats, Mogget's goal in life is to ensure his paw prints are in all varnish.

Saturday, 12 December 2015

Finished the coamings

After gluing the coamings in place, the next step involved trimming them so they were the correct size. This involved a process not-unlike trimming my fringe. Take a little off one side, look at it from afar, take a little off the other side, look at it from a distance, take some more off... Luckily I managed to stop myself before I reached the deck.

Then I sanded things smooth, coated with epoxy + filler (this 4mm ply has a pretty crap open-grained face ply, which swallows epoxy), then a couple of coats of unthickened epoxy, then sand down to 180 grit, and finally toplac paint.

Here's what it looks like tonight.

The shaped bit in the bow is to allow clearance so I can flip the forward thwart hatches over. The coaming is about 65mm above the deck at the bow, and 22mm above deck where I'm likely to sit on it.

Next job is to complete sanding the decks out to 180 grit and then paint them with top coat. No, I'm not using undercoat. I really dislike the stuff - it clogs emery way too fast for my liking.