Sunday, March 14, 2010

Vacuum Tubes

Part of the reason I worked on restoring this old radio is because I wanted to learn how vacuum tubes work, as well as how radio transmission works.

The simplest vacuum tube is a diode -- a device that allows current to pass only in one direction:
  • Green element = the heater. This is a filament that gets hot when current flows through it. Its only purpose is to radiate heat onto the red element = the cathode.
  • Red element = the cathode, or the emitter. This is a filament coated in a special substance that can emit electrons when it's heated up.
  • Blue element = the anode, the collector, or the plate. This is a flat piece of metal which collects the electrons emitted by the cathode.
The key feature of the diode is that current can only go from red to blue, not the other way. In other words, if the heater is hot, then current can flow from red to blue as shown above. However, if we flip the polarity of the battery (the + would be connected to the red element), no current can  flow.

Notes:
  1. The heater circuit operates at low voltage, around 5V.
  2. The anode/cathode circuit operates at much higher voltage, frequently above 200V (in my radio, the anode/cathode rail goes up to 750V). This is because, even in a vacuum, the voltage has to be high enough to force electrons to jump across the small gap between the two leads. This high voltage makes older appliances dangerous, they can definitely kill you if you're not careful.
  3. The reason tubes are vacuum'ed is because the air molecules get in the way of electrons "jumping" from the cathode to the anode.
  4. All vacuum tubes "wear out" in time: the substance that covers the cathode is literally stripped away and eventually stops emitting electrons entirely. This is why vacuum tubes in old appliances had to be replaced every so often (typically measured in years, but it depends on how heavily the device is used).
This is it. All vacuum tubes are variations on this theme. They contain various additional elements that serve to amplify or dampen the flow of current between the cathode and the anode, but the basic principle is the same.

So why is a diode useful? Who cares that we have a device that lets current flow in only one direction?

To answer that question we need to look at the simplest form of radio transmission: Amplitude Modulation, or AM. More on that in the next post.

Friday, March 12, 2010

Radio Frankenstein

About 6 months ago I wrote the first post about my classic radio restoration project. The project is done, the radio is functional, but I somehow never got around to writing anything more about it. I'm going to try to fix that in the next series of posts.

I read a few useful guides on how to get started restoring an old radio. Bringing a radio up to life for the first time is risky-business, since the radio components can become compromised over time, and you run the real risk of burning up the radio (literally) if you're not careful.

The most useful I found was from Phil's Old Radios, recommending roughly the following:
  • Spot gross defects first: leaks, stains, smells, etc.
  • The electrolytic capacitors are probably dead: replace them.
  • Use a variac to slowly turn the radio on.
At the high-level, my Philco was in reasonable shape: it was missing two vacuum tubes, but aside from that it wasn't leaking or showing other signs of gross physical damage.

I proceeded to test all the capacitors in the radio: there's about 10-15 of them total, so it's not that hard. The most important test for a capacitor is to verify that it's not shorted, in other words the resistance between its two leads should be infinite. Over time, electrolytic capacitors dry-up (literally), and as a result short circuit the leads, which can be catastrophic (it can burn up the power transformer, which is hard and expensive to replace).

My Philco has two kinds of capacitors:

1. Two very large electrolytic capacitors (8 muF each). These are visible on the top of the main board, and serve to smooth the DC coming out of the rectifier bridge. It is essential that these not be shorted as I explain above. Sure enough, when I measured them, one was shorted, and the other was on its way. I bough two replacement Sprague Atom's, disconnected the leads from the existing electrolytics and connected the new capacitors in place. Incidentally, the Spragues are very solid, high-quality capacitors, great to work with. Here's a sample:


2. Bakelite capacitors: these look like a little "vat" with 6-7 leads. Inside it are 2-3 capacitors, sealed in a hard, black, gunky insulator. Fortunately, none of the bakelites were bad, they all tested good on the multi-meter and, fortunately, ended up working in the end.

Serious radio enthusiasts try to "hide" the new capacitors inside the old electrolytics, in order to make the restoration even more authentic. This is a process called "re-capping", it works like this:
  1. Use a Dremel to cut open the bottom of the electrolytic capacitor
  2. Gut its contents, leaving an empty aluminum shell
  3. Insert the new electrolytic capacitor in the old shell, solder each end to the two leads
  4. Glue the bottom of the electrolytic back with epoxy glue
I got so far as step 2 above: the "gunk" inside my electrolytics was a very nasty, black, foul smelling tar-like substance that wouldn't come out no matter what. I read that some people use a hair-dryer to literally melt this stuff out of the shell, but I decided that was too much for me, so I just put the electrolytics back on the circuit board (without the bottom) and left it at that.

The next step was to replace the missing vacuum tubes. I got the complete set of schematics and repair bulletins from the excellent Philco Repair Bench. It was easy to detect that the two missing tubes were:
These are ancient tubes, in fact the names alone should give you an idea: the tube manufacturers simply started to count at 1 and worked their way up to around 100 or so, each number representing one type of tube. There were only a handful of tube manufacturers at the time (Philco, Tung-Sol, RCA), and they made a majority of all the tubes on the market.

I thought I'd be totally out of luck finding replacements for them. In fact, it turned out quite the opposite: there a vibrant community of old-timers who sell tubes like these for cheap. I was able to find both tubes for around $15. Not only that, but I was actually able to find them NOS = "New Old Stock", which means that the tubes were in mint condition, they had never been used! Imagine: these are tubes made 80 years ago and they still work. Here's what the rectifier looks like:


Notice how it says "Made in USA" on it. When was the last time you saw that printed on anything?

With both tubes in their sockets, now came the real test: turning on the radio. I don't have a variac, and I thought it too expensive to buy one. So instead I built a cheap home-made one: a dim-bulb tester. I first tested the radio with a large 100W bulb, and then with a smaller 45W bulb. In both cases the vacuum tubes slowly started to glow, and no weird smells or pops came out of the radio, so I decided it was safe to plug it directly into the wall.

Imagine my surprise and awe when, after 15 seconds of warm-up, the radio actually went on and started hissing! I kept a finger on the antenna lead, and was able to tune into a few AM radio stations (one was broadcasting a baseball commentary, and another had a show about aliens invading the earth).

A beautiful thing.

Tuesday, March 09, 2010

Shuffling tricks

I recently read this interesting article about an error in the EU Microsoft Browser Ballot. Briefly:
  • In the EU, Microsoft must give users a choice of browsers in Windows.
  • This is done via a message box with 5 top-choices (Firefox, Opera, Safari, MSIE, and Chrome), and a bunch of other intermediate-choices.
  • The box should display the 5 top-choices in random order.
As it turns out, the order is not exactly random! For instance, MSIE is more likely than not to appear towards the right-end of the list, and Chrome towards the left-end.

The reason for this is programmer error, as described in the article. The programmer implemented the shuffle algorithm incorrectly by assuming that JavaScript uses QuickSort, when in reality it uses some other algorithm.

It turns out that shuffling is notoriously hard to get right.


Consider the following two simple shuffling algorithms:
  1. For each entry Ex in the array: swap Ex with any other entry in the array.
  2. For each entry Ex in the array: swap Ex only with entries after it.
Intuitively, it seems like either approach should produce a good shuffle. However, your intuition would be wrong: the first approach produces a non-uniform shuffle, while the second approach produces a uniform shuffle.

Better writers than I have explained how and why this happens. One good explanation of this is at Coding Horror: The Dangers of Naivete. The crux of the proof is:
  • The total number of entries in a shuffle of n cards is n! (n factorial).
  • The total number of arrangements of cards where you swap each card with any other card is n^n (n to the power n).
  • n! does not divide evenly into n^n, so the shuffle cannot be uniform.
Prove to yourself that the 2nd algorithm above does not suffer from the problem described above. For extra credit, also prove that it is uniform.

In thinking about this problem, I was struck by one non-obvious fact: how can it be that, in the first (non-uniform) algorithm some configurations occur more than others? I mean, think about it:
  • Start with an array in some order.
  • For each element, randomly swap it with some other element.
Somehow, this makes it so that some configurations occur more often than others, and reliably so! Although the algorithm is random, somehow it favors certain configurations. This is quite surprising indeed. Really, spend a minute to let this sink in.

I haven't found a good "intuitive" explanation for why this favoritism happens. This explanation, from stackoverflow.com, comes close: "And that's the "intuitive" explanation: in your first algorithm, earlier items are much more likely to be swapped out of place than later items, so the permutations you get are skewed towards patterns in which the early items are not in their original places."

Magician-turned-statistics-professor Persi Diaconis has done a lot of very interesting work in randomness, nature, and our perception thereof. One interesting question he answered was: how many times do you have to shuffle a deck of cards so that it's "random"? Another is: how random is a coin flip, really? Both have surprisingly non-obvious and interesting answers.