Alarm Clock Journal

Goal: Streaming MP3 alarm clock

Contest results: Second overall, plus "connected apps" prize - but note that I've been improving the software since then.

Project Files


For Calgary OLED replacements, try OSD Displays

PC Boards:

Files for solderless breadboard adapters:


Cabinet design files:

To-Do List


Just a quick note to say I've updated the project files to include the latest bugfixes and features.


Finished the other two, for two friends who wanted the spares.


It's done!


More woodworking. Did the speaker cutouts and volume control.


Fixed the buzzing. What didn't work: fiddling with the ceramic cap values, or just adding a 100u 25v electrolytic. What did work: that 100u with 10u 16v 1206 tantalums. No buzz!

There's still a minor ripple in the oled's 12v line (see photo). But it's 80 mVpp instead of 500 mVpp, and only 23mVpp of that is "ripple" while the rest is a load spike (which I hope the OLED deals with, with on-display decoupling caps, if it even matters).

Anyway, I updated the schematics and board to correspond to these changes.


Turned all the little buttons today. Mostly on the metal lathe; it's more precise than the wood lathe. Still have to cut the speaker grills and volume control hole. Note: the bits of the dovetails that stick out will be sanded off later, after it's glued up.


Got most of the woodworking done, at least all the parts are made. The auxiliary boards were made today, and the fasteners epoxied into place. I still have to turn the buttons and assemble everything.

Also, I think I figured out the buzzing. The +12v rail has insufficient bulk capacitance, and the high ripple causes the ceramic caps to buzz due to ferromagnetic resonance. I ordered some different caps as well as some 100uF bulks for that line.

Added the volume feedback. Of course, you can't see it when the music isn't playing, as that line is used to mute the amps, so we can't sense the volume control setting.


Spent some time woodworking today, I have a "blank" cabinet for the clock. I still need to do all the cutouts, fab the button PCBs, etc. But at least I have something.

Started working on the sleep timer. It's going to have to be limited to a specific web destination (say, destination zero) as we're out of buttons on that screen. Need to add a 24-hour mode for displaying elapsed time instead of am/pm time.


Added the gui screen to set the alarm time, day, date, and type. And still trying to track down the buzzing.


Still fiddling with the GUI. Also, the board's been making an annoying buzzing sound that I haven't been able to track down.


Wrote a quick and dirty simulator for the GUI. Basically, it's just an X windows program that simulates the buttons, OLED, and eeprom, and natively compiles some of the actual clock sources. It also loads the actual eeprom binary from the eeprom tool, so I can see the actual images, and I can dump them to image files (for documentation, of course).

To emulate the OLED, I just provided my own SPI functions. The OLED interface is pretty simple, and there was no reason to duplicate any of the image drawing code.

I've prepared the wood for the cabinet, and ordered some more hardware (specifically, I need 4-40 standoffs to go into the cabinet), but haven't started building the cabinet yet.


Today's the day. Assembling the first board. Stay tuned...

It works! Photos from left to right: initial power up and programming, overview of the programming, and all connected up. The top-side SMTs were done with the usual brass paste mask and hotplate technique. Then I did the few back-side SMTs (mostly bypass caps), then through-hole parts. I can't test everything until I put the female connectors on the speakers, switches, volume control, etc, although I did hot-wire in the volume control to check the amps. Note that the 3.3v supply is much cleaner and closer to 3.3 (3.290v) than on the protoboard, even though the protoboard used a PCB for the power supply itself.

Tomorrow, I hope to prototype one of the cabinets and start stuffing it.

I've also been plodding along on the GUI. So far, I can turn alarms on/off, and select one, but I can't change the time yet.


Placed another order for parts. I need a new op-amp anyway, so I ordered what I needed to complete all three boards. Still need to make the paste mask, I think I'll experiment with the gelatin paper, since I can align two of those for a double-sided etch resist.

Also got an email that the extra Calgary displays have shipped. Yay! The extra speakers are on back-order but I don't need them yet anyway.


The board arrived! Very pretty and fairly accurate, but we've got company this weekend so they'll have to wait until I can sacrifice the prototype :-)


Added support for type C icons too.


Created icons for the setup screens, ended up fixing a bug in the type A compression routines.


Added the Type A graphics support, expanded the TOC to hold a bank of images for painting to the screen. Started on the GUI.


Got the snooze button working. Set to ten minutes, no zen timer when it expires. Alarm keeps reconnecting until it's played for an hour (or disabled), then it gives up. In preparation for the button GUI, I added a "timeout" button - button "0" means timeout. Also tweaked the photocell so that when it's completely dark in the room, the image is just a dim outline - but any ambient light at all fills it in. The ADC routines for the photocell were a bit unoptimal - they kept switching between adjacent quanta, so I added a hysteresis to reduce the number of changes needed.


Boards ordered! Went with Sierra Proto Express this time, to try them out.


Ok, the alarm works. I forgot to shut it off yesterday, and it went off today, zen start and all :-)

Checked out some alternate display options (for a future design). LCDs are pretty cheap, but you can't see them in the dark (without the glowing grey rectangle backlight). VFDs are self-illuminating like OLEDs but cost around $165 each.

Also, always check your parts against a printout of the board. I discovered that my 12v regulator is a SC-63 footprint, but I had a TO-220 regulator in the project. Tweaked a lot of drill sizes, too.


Got the alarm clock part running - the zen timer and the actual trigger. Also, I reset the mp3 chip when it goes idle, to avoid the messy blips when we restart an interrupted stream.

Time to order the board, too.


Redid the TOC code so it always reads the eeprom, rather than cache the value. Now it functions properly after a reprogram. Finished the URL lookup code, so now it can play songs on its own.


Still working the next day, I think that solved it. Still a minor "tic" in the mp3 stream with high-rate streams. I'll add a "process queue" call in the OLED update code.

Yup, that did it. Nice clean music now :-)


Using the board layout as a guide, I re-arranged the mapping between physical pins and their functions. This is mostly easy because all the pins are either (1) GPIOs, (2) reprogrammable anyway, or (3) ADC inputs. I also gave the Calgary module its own SPI lines, by recycling the console (moved to the ICE pins) and the ethernet IRQ (not needed). Now the ethernet/mp3 SPI can run at full speed, the Calgary SPI can run at 4MHz, and the two don't interfere. Seems to be working so far :-)

I've also taken a moment to remove a lot of the debugging stuff I'd added to the TCP/IP stack, to make it as close to "original" as I could get and still work.

Currently using 65% of the program space, and 44% of the data space.


The nice folks at Digikey let me order two more of the displays, but there will be no more orders taken after Oct 15. Meanwhile, I continue debugging... it seems that with the Calgary module installed, the clock only plays for a few minutes before losing track of its open TCP connections.

Also, I got the MPLAB debugger to work. Turns out, you need to program the device from the debugger if you're going to debug it; programming it standalone is insufficient.


Just found a note that Osram will no longer be making the OLED displays I'm using. Sigh.


Ok, this is why we build prototypes. I hooked up the Calgary module today, and it didn't work. After much worry and debugging (smoke... no, power... yes, whew) it turns out I got the SDI and SCK signals swapped. I thought of this only because I did exactly the same thing with the Atlanta module. So now I get to go fix the symbol, schematics, and board. But at least the module works. It has some streaking, as if the number of pixels determines the brightness of each row. I'll have to see if I can fix that. Oh, in the photo, the oled still has the plastic protective cover on it.

Anyway, the Calgary module is HUGE compared to the Atlanta (that was why I chose it), almost twice as big (1.6" vs 2.7") and seems to work best on the higher voltage the wall wart produces (15.5v vs 10.7v for the ATX supply). I think the ATX supply needs a heavy 5v load to bring everything else into regulation.


Started on the actual alarm stuff. Reworked the real time clock code so that it reads the time only once and exports it for everyone, added the alarm module, and started writing the URL lookup stuff. You get spoiled with a full Linux environment; the alarm clock will need to use full host names in its urls; it doesn't know what its default domain is :-P


Replaced the port 37 time client with a simple NTP client (RFC 2030). It now updates more accurately (NTP has an "is it mine?" field that lets me prevent bogus packets from changing the time). It's done as a broadcast - no configuration needed as long as the server is on your own subnet, and the fastest (first) reply wins.

The PCB layout is done, but I need to make a protoboard for the larger OLED panel and verify that circuit before committing to it.


Worked on the PCB for the last few days. Got it down to 4.5 by 3.5 inches, on four layers.


After some debugging, got the Type B and C image formats working. Type B is the 2bpp run length compressed format used for the "main" font, where we want to adjust the display's intensity according to ambient light. Type C is a 4bpp format for the smaller fonts and other graphics. Type A, which I haven't done yet, is a 1bpp format, but I haven't needed that yet.

Also hooked in the RTC updates and set up the main clock display. It's a clock!


Didn't fry the CS3443, just had the buffer code wrong for the new eeprom based beep code. So, now the mp3 module can play the internal beep (from eeprom) and act as an mp3 server. Still don't have the fetch-url method working, and I'm just using the buttons to directly control the mp3 stream, mute, etc.. Oh, here's a picture of the new (bigger) speakers in a quick enclosure I built for them.

Update on the proto board, with all (I think) of the hardware in place. You can see the power supply in the upper left, although I'm backfeeding +12v from the ATX supply (yellow banana plug). You can also see how the PIC programmer plugs in, and the pushbutton switches. In the real clock, three switches go on each side of the OLED, and the seventh is the snooze button. The CS4334 is the SOIC-8 on the adapter near the middle of the left edge of the breadboard. The OLED is scanning at about the shutter speed, which causes the variable intensity. It doesn't look like that in real life. Nine home-made PCBs in it so far!

The ribbon cable goes to my logic analyzer. That lets me keep all the hookups in place if I need to use the LA for something else; I just unplug the cable from the LA. Also, the 40 pin connectors act like mini breadboards, which is easier to hook up than the flying leads the LA uses.

Also, I checked the current draw - about 0.7 amps at full volume.


Fonts and eeprom utility (eetool!) are done, for now. Still need to test them. Added some mp3 calls to start/stop the various streams, hooked them into buttons, hooked the beep chunk of the eeprom in, and... nothing. It seems I've fried my third CS4334 chip. Sigh.

Oh, and the eetool only knows how to do single read/write chunks, or replace the whole thing. No individual adjustments, like "set alarm" or "change url".


Found some time to start working on fonts. Went with Impact Condensed Bold, which fits the 128x64 OLED display nicely. Here's a sample, in approximately the right colors. You have to imagine it with the right numbers, and one of the two colons in the middle. Yes, it's got 3-D shading. This will be the main font, and the brightness of this will be determined by the photocell. I still have to do the half-size font. For the mini font I'll just use the console (5x7) font.



Decided to start journalling regularly on this. Ok, call it a blog if you want. Status so far: the prototype (solderless breadboard) is done, and the software is starting to come together. I'll write some "old" entries to match up with photos I've taken.

I spent the weekend getting the network stuff running better. I have the mp3 server running (yay! sound!) and the eeprom remote programmer. To stream the mp3 cleanly on such a small system, I had to do two things: first, I allocated a big buffer for the st013 chip, which meant fiddling with the linker script to put it at the end of ram (it overlaps part of the "far" address space, else something else is far and the chip crashes), and I had to reduce the tcp retry timeout from 1 second to 5 milliseconds. The tcp window is only 300 bytes, so I need to fill it quickly when there's space.

As for the eeprom server, I discovered that my FC6 machine has a bad checksum routine! Commented out the checksum stuff in the pic. Also had to add a "I'm done" return byte on the write op, else the protocol got confused.

Today I added the "mute" functionality. The ADC pin that monitors the setting of the volume control can also pull it to ground, which puts the amps in a low power mute mode. Otherwise, you get a buzz when there's no music playing.

Listening to Jessica Andrews on my mp3 server :-)


Working on getting the RTC running. It's way off calibration. Turns out it's picking up interference from the GPIO pin next to it (the OLED's CS). So, I swapped that GPIO with the +12v enable, which doesn't switch once it's running.

I did experiment with different resistor and capacitor values. Lessons: The "load capacitance" is the total capacitance (crystal's plus two caps in parallel), not the value of the capacitors. Replaced 8pF with 15pF ;-) Also, the resistance value (330Ω) was Ok, I tried bigger ones but it didn't change the frequency any. I'll have to tune the caps once it's on a PCB; it's within 40ppm now on the logic analyzer, but seems to gain a few minutes per day.

I also added the network time routines; it reads the old port 37 time for now.


Smoke test! This is the prototype of the power supply. I did this one on a PCB because the switcher needs to be laid out properly, and it would have been expensive to do it on the proto board. The supply worked perfectly the first time. This is also my first board made with liquid tin.

The board runs off a wall wart (12-17v) but I'm going to backfeed it from the protoboard and the ATX supply for now.


More stuff done - the PIC24F is in place, as well as the OLED and ethernet. I've also switched to more powerful amplifiers, but fried the DAC. Twice. First, I wired up its Vcc to the amp's Vcc (12v). Pop. The second time it was due to the bypass cap, which was charged to +12 when I inserted it. I short all caps before installing now.

Note the tiny crystal adapters.


Started playing with the various chips. The first experiment was to build up the mp3 system, talking to it from a gumstix (less variables at once ;-). The speakers are "notebook" speakers - reasonable range, but tinny. Partly due to size, partly due to the open air setup. Hey, it works though!

I did find a set of "mini monitors" to replace them - 1.8" across and a much better low-frequency response. Also more powerful. I built a small wooden box for them so I could hear how they sound when properly encased. They sound much better!

Note the ATX supply converted to a bench supply. And the mess.

  webmaster     delorie software   privacy  
  Copyright 2008   by DJ Delorie     Updated Mar 2008