BMOW title
Floppy Emu banner

Archive for December, 2013

Fixing Electronics with a Wooden Stick

I’m feeling pleased with myself today after fixing a dead hot air rework station. My technique? Whacking things with a wooden stick! I used the same method a few months ago to fix a dead Mac Plus, so it’s proven its worth yet again. What could possibly go wrong?

This technique is useful for electronics that were working fine, then became progressively more flaky, before finally dying completely. If you can coax a flash of life out of it by slapping the case with your palm, or rapping it with your knuckles, then you’re probably looking at a loose connection or a bad solder joint somewhere – but where? How do you find it?

In my case, I had a two year old Sparkfun Hot Air Rework Station that gave up the ghost. It started working intermittently, and would be fine one minute, but the next minute the temperature display would go dark and I’d get nothing but cold air blowing from the nozzle. For a couple of weeks I could usually “fix it” by tapping on the side of the case, but eventually it failed completely. I was prepared to throw it in the trash, but I decided to open it up first and see if I could diagnose the cause of the failure. Inside I found a lot of… parts. There was a PIC, and lots of discrete components, a transformer, and lots of cable harnesses. Nothing looked obviously damaged or burnt. Hmm.

Enter the hero of the story: a wooden stick. With the cover off, I turned on the power, and began gently tapping on all the different components. Do not use your finger or anything conductive to do this! You don’t want to short anything or electrocute yourself. When gentle tapping didn’t accomplish anything, I resorted to heavier force. Hey, it was already broken, so I couldn’t make it any worse! I finally discovered that if I gave U1 a hard shove (that’s the TO-220 just right of top-center in the photo), I could semi-reliably bring the hardware to life. The suspect was identified.

Fixing it proved to be another matter. After removing all the screws, that circuit board still wouldn’t budge. I needed access to the back side of the board to examine and troubleshoot the connections there. Again, I almost gave up and threw the thing into the trash, but persistence paid off. There are two large knobs on the front of the hot air station for controlling air flow and temperature, and it turned out that these knobs actually anchor the circuit board to the case. I had to unscrew the tiny set screw to remove each knob, then unscrew some nuts and other hardware, before I was able to get the board out. Sure enough, there was a cracked PCB trace right at U1. After a quick solder repair, the hot air station is now as good as new. Thank you, wooden stick!

Read 1 comment and join the conversation 

Mastermind Game Rules, and Nibbler Near-Death Experience

And here’s why all your circuits should have some kind of reverse-polarity or over-voltage protection: I nearly killed Nibbler yesterday. I brought the hardware to a friend’s house for a nerdfest party, but when I demoed it, I accidentally plugged in the 9V AC power supply from Mozart’s Credit Card instead of the normal 5V DC supply. I’ve gotten lazy with my circuit designs, preferring to use an external regulated 5V supply instead of including power regulation on the board. Nibbler has no voltage regulator, rectifier, reverse-polarity protection, or fuse, so the 9V AC went straight to the power pins on all the chips. Baaaaaad!

Fortunately my mistake didn’t release the magic smoke from the chips. The speaker buzzed and the LCD showed some strange lines, and at first I thought a wire must have come loose during transport. It only took me about 10 seconds to recognize my error, and luckily Nibbler was fine after switching to the right power supply. If I’d left the 9V AC supply plugged in for longer, I think the board would have been toast.

Square Pegs in a Round Hole

Once Nibbler was up and running, we tried the Mastermind program that I wrote a few months back. It was a hilarious example of how six very smart guys can take fifteen minutes and a lot of arguing to solve a single Mastermind puzzle, but it also exposed some subtleties in the rules of Mastermind that I’d never considered before.

Most readers are probably familiar with the game: a codemaker chooses a four-element secret color code , and a codebreaker tries to guess it. After each guess, the codemaker gives feedback in the form of black or white pegs: a black peg means some element is the right color and in the right position, while a white peg means some element is the right color but in the wrong position. But what does that mean exactly, and what elements does it refer to?

Imagine you’re the codebreaker, and your guess is yellow-red-blue-green:

The codemaker comes back with three black pegs and one white peg:

Depending on your interpretation of the rules, you may think this is an invalid result, and the codemaker has made a mistake. After all, if three of the guesses are the right color in the right position, then there’s only one incorrect position remaining. The color guess at that position must either be correct (which would result in a black peg) or incorrect (which would result in no peg at all). Right? Wrong!

The critical question is whether the black and white pegs reflect the codebreaker’s guess with respect to the secret code, or the secret code with respect to the codebreaker’s guess. It might seem that it would be the same either way, but it’s not. Translated into pseudo-code, the two possible scoring algorithms are:

Secret-centric algorithm:

for (i in the range 1 to 4) {
    if (secretCode[i] == guess[i]) {
        emit black peg;
    else (for j in the range 1 to 4) {
        if (secretCode[i] == guess[j]) {
            emit white peg;

Guess-centric algorithm:

for (i in the range 1 to 4) {
    if (guess[i] == secretCode[i]) {
        emit black peg;
    else (for j in the range 1 to 4) {
        if (guess[i] == secretCode[j]) {
            emit white peg;

If we assume the secret code is yellow-green-blue-green:

and with the yellow-red-blue-green guess shown earlier, then the secret-centric scoring algorithm will result in black-black-black-white, but the guess-centric algorithm will result in black-black-black.

I think most people play the game using the guess-centric scoring algorithm, without realizing it. It seems more natural, as the score pegs are a reflection of how closely the guess matches the secret code, not how closely the secret code matches the guess. But surprisingly, I can’t find any definitive answer to which algorithm is correct. The online descriptions of Mastermind rules that I’ve found are vague on this point, or contradictory. The Wikipedia description of the rules implies both of these scoring algorithms are wrong, but isn’t specific enough to define an alternate algorithm. This page sounds like the guess-centric algorithm in its text, but the provided example uses the secret-centric algorithm. Unfortunately the official Hasbro game rules for Mastermind to Go only gives one example, which is ambiguous as to which algorithm should be used. The Parker Brother game rules are also ambiguous, and don’t give any examples. But the published rules for Pressman Ultimate Mastermind (which uses five colors instead of four) uses the secret-centric algorithm.

So how can we know which algorithm is the right one? I’m not sure we can. Mastermind is just a modern version of an old pencil-and-paper game called Bulls and Cows, which may date back more than a century. I couldn’t find anything definitive about the origins of that game or the correct rules. Ultimately it doesn’t really matter which scoring algorithm is used, as long as both players agree on it. For Nibbler I chose the secret-centric algorithm. Even though it’s less intuitive to me, it seems to be the most common choice among those people who pay attention to this quirk in the game rules. What do you think?


Read 2 comments and join the conversation 

Macintosh DiskCopy 4.2 Floppy Image Converter

Here’s a quick-and-dirty utility I whipped up called DiskCopy2Dsk. A few people asked how to create raw .dsk floppy images to use with Floppy Emu. The hardware supports both DiskCopy 4.2 and raw .dsk image files, but DiskCopy 4.2 images are treated as read-only, so .dsk images are preferred. However, many emulation sites have their entire collection in DiskCopy 4.2 format.

On a vintage Mac, DiskDup+ will create .dsk images, or convert between DiskCopy 4.2 and .dsk images.

For 21st century computers, this DiskCopy2Dsk utility will bulk-convert DiskCopy 4.2 image files into .dsk format. It received at least 45 seconds of testing, so I’m sure it’s good. Source code is included for the curious.

DiskCopy2DSK for Windows
DiskCopy2DSK for Mac OSX (Intel Macs only)

Cameron Kaiser contributed this command-line version of dc2dsk, which works on PPC or Intel Macs. The source code has been rewritten for any generic Unix system, so that Linux and NetBSD users can play too.

Read 11 comments and join the conversation 

Floppy Emu Back in Stock

Macintosh Floppy Emu is back in stock. The elves have been working overtime to build more of these. Get yours today before they sell out again!

Floppy Emu is a prototype floppy disk drive emulator for vintage Macs. It uses an SD memory card and custom hardware to mimic a 400K, 800K, or 1.4MB 3.5 inch disk drive and floppy disk. It plugs into the Mac’s external or internal floppy connector, and behaves exactly like a real floppy drive, requiring no special software on the Mac. Floppy Emu is available now for $89.


Read 1 comment and join the conversation 

No-Connector AVR Programming

Here’s a handy trick I developed while searching for ways to reduce the cost and assembly time of Floppy Emu boards. The board has space for a 3 x 2 shrouded IDC header, where the AVR ISP cable should connect. But that connection is only needed once, the first time the AVR is programmed – all future software updates are loaded from the SD card using the bootloader. So why waste 75 cents and 30 seconds of soldering on a part that’s only ever going to be used once? It’s a small saving, I admit, but those savings add up.

OK, the programmer cable has a 3 x 2 female connector, and the board has an unpopulated footprint of 3 x 2 holes. Now what? My first attempt at a “no connector” solution was a straight 3 x 2 male header plugged into the cable connector, with the other end placed loosely inside the board footprint’s holes without soldering. By itself the fit was too loose, and the pins didn’t make reliable contact with the insides of the holes. If I pushed and twisted the connector with my finger, though, I could usually get all six pins to make contact long enough to successfully program the AVR. But as this only gave me one free hand, and didn’t work 100% reliably anyway, I gave up on that technique.


With board revision 1.1 I tried something new. Using Eagle, I created a staggered 3 x 2 header footprint, offsetting every other pin 5 thousandths of an inch from the centerline. I hoped this would help lock the pins tightly in place, keeping them pressed against the insides of the holes without solder and without my hand to brace it. But when the new boards came in, I was disappointed to find that while the staggered footprint was somewhat better than the original, it still didn’t work reliably. Sigh.

But every failure is just another step on the road to success! After more experiments, I finally hit upon a winning solution using a 3 x 2 right-angle header, with a small piece of scrap wedged under it for leverage. And I later found that the SD card holder is exactly the right size and in the right location to provide the necessary leverage, making for a quick and easy connection that’s 100% reliable with no soldering. I just plug one end of the 3 x 2 right-angle header into the programmer cable, and the other end into the holes in the board, with the connector and cable pressed against the top of the SD card holder. Once AVR programming is complete, I pull everything out and can re-use the parts for the next board. Hooray!

Read 20 comments and join the conversation 

Floppy Emu – Ready For Sale

The Floppy Emu Macintosh Disk Emulator is finally available for sale! Get one now for $89. Each one is hand-assembled, programmed, and tested by me. After more than two years in development, and two months of preparation for “production”, I’m very excited to share this with you today. The initial inventory is quite small, but should grow over the next few weeks as more boards get built.

Floppy Emu is a prototype floppy disk drive emulator for vintage Macs, compatible with everything from the original Mac 128K through the Mac II and Power Mac series. It uses an SD memory card and custom hardware to mimic a 400K, 800K, or 1.4MB 3.5 inch disk drive and floppy disk. It plugs into the Mac’s external or internal floppy connector, and behaves exactly like a real disk drive, requiring no special software on the Mac. Floppy Emu is perfect for setup or troubleshooting of a Mac without a hard drive or a working OS. Just plug in the Floppy Emu, and you’re booting up in seconds. Keep it as a permanent solution, or use System 6/7 installer disk images to do a new hard drive installation. The hardware is also great for moving files between vintage Macs.

As always, you can also build your own if you’re comfortable with SMD soldering and have the necessary programming tools.

Thanks to everyone who offered feedback, advice, and encouragement over the long course of development. It’s great to be part of such a positive community!

Be the first to comment! 

Older Posts »