One of the nice features of the Pololu Baby Orangutan is a 20MHz ceramic resonator (specs), the small three-pin (looks like six, but they go straight across) metal chip near the programming header. This resonator is just fine for most purposes, like faster instruction execution, PWM for h-bridge or servo control, etc… I happen to need a clock source with less frequency drift over time (I’m trying to keep periodic signals from two unconnected Baby-O’s synchronized to within 75 microseconds for ten minutes!), so I decided to mod two Baby-O’s with quartz crystal oscillators.
There are other reasons you might want to mod your Baby-O with a crystal. You might want to increment a counter at a specific frequency you can’t get from 20MHz and a prescale divider, or you might want to swap in a watch crystal to generate a real-time-clock. In any case, I thought I would present my sneaky way to swap the resonator for a crystal, without special surface-mount equipment (well, except for some small soldering iron tips).
The optional zero’th step is to program your Baby-O to run on its internal resonator, just in case. I tested the new crystals by switching the system clock back to external source, so this was a somewhat unnecessary step (but it did make me feel better). There is a fuse on the ATMega168 to output the system clock signal on a pin, so I suppose I could have used one Baby-O as a rescue clock source for the other, sort of like how they perform laser eye surgery one eye at a time. Well, no, not really.
The first step is, of course, to remove the ceramic resonator, the little metal box the iron tip is pointing to. While it may look like a six pin chip, there are really only three pins which go straight across the bottom. You can heat all three at once with a small spade-bit soldering iron by spreading a little solder between the pins on one edge. It should slide right off:
I found this was almost impossible to do without getting some solder on the metal case, but a little solder-wick took it right off, and cleaned up the three pads. Also, you can see more clearly in this picture that I (carefully) cut the plastic housing of the programming header flush with the pins to make more room for the clock. I used a hot exacto-knife blade in a homemade soldering iron chuck, but I’ve seen similar things sold in craft stores for wood marking:
Unless you’re using a watch-crystal, or another 3-pin ceramic resonator, you’ll need loading capacitors between each clock pin and ground. I used two 12pF, 0402 (1mm long) package ceramic capacitors (Digikey: 490-1279-1-ND). At three cents a piece you should pick up plenty of spares, because if (when) you drop one of these, it’s gone! The clock I’m using asks for 8pF capacitors, but the ATMega168 spec sheet recommends 12-18pf. An EE friend of mine explained that too little capacitance and the crystal can damage itself, but too much capacitance doesn’t become a problem for a while, so I went with 12pf, which seems to be working just fine. I switched to a fine point iron tip for these guys, pre-tinned each end, held them in place with very fine tweezers, and heated the ends and the solder left on the pads. It took a few tries to get them straight, but it doesn’t have to be pretty to work:
This is the most tightly toleranced 20 MHz surface mount crystal package I could find (Digikey: 644-1039-1-ND). I initially imagined I could just stack it on top of the capacitors and solder it from the sides, but its way too big (no, seriously):
So instead I soldered on some stripped 30AWG wirewrap wire, pointed in slightly:
I bent the wires to a right angle at the bottom of the chip, and trimmed them so they stuck out about 2mm. I adjusted their inward bend with tweezers so that they would grip the two capacitors ever so slightly, and soldered them on, more to the leads on the board than to the sides of the capacitors. I switched the Baby-O back over to the external clock, and it worked just fine, huzzah! I thought I was using minimal solder, but up close you can see I could have used much less:
Finally I folded the clock down to keep it out of the way. The whole stack is lower than the plastic housing of the programming header, so the connector won’t hit it. The first time I did this, one wire separated from the capacitor, so maybe there was a point in using so much solder after all:
And while I had some spare clocks and capacitors around I figured, why not speed up my new Orangutan as well:
This was much more straightforward, I just lightly pre-tinned the pads on the Orangutan and the clock, brought them together, and heated them from the side. I am a little embarrassed with how not-straight it turned out, but it works just fine. Of course, I could have used larger package capacitors, but I didn’t think ahead when I was ordering. I also removed the two 0ohm resistors (and promptly lost one of them, which I guess isn’t a huge deal):
So there you have it, the worlds most precise (least time/temperature dependant frequency drift) Baby Orangutans. Now I just need to get the calibration program to work…