The Tnychron Clock

by uhclem in Circuits > Microcontrollers

33577 Views, 142 Favorites, 0 Comments

The Tnychron Clock

DSC_0034_DxO.jpg
Have you ever seen a pocket calculator from the 1970s? If you have, you know that many used a series of tiny, red, LED seven-segment displays. These displays used little "bars" of light-emitting material which were placed behind little magnifying bubbles to make them more readily visible. They were very crisp and readable, and used a lot less power than vacuum fluorescent displays (VFD), which were also in use at that time.

I recall the little LED bubble displays were at one time in all sorts of handheld electronics and, in a slightly different form, watches. By the time LCDs became cheap in the late 1970's, the more power-hungry LED display was on its way out.

I was pleasantly surprised back in 2011 to find on ebay a seller with numerous rails of HP 5082-7433 LED displays. These are three-digit displays in a 12-pin standard DIP format. I bought a few rails since the price was good. I've a tendency to get "stuff" and then never get around to using it so I decided this time there would be a project to make use of all the displays.

The "Tnychron" clock was born!

Design

IMG_0013.JPG
Design requirements:
- 1970s-looking retro case
- Arduino IDE environment project
- use the HP displays effectively
- make it play music
- make it easy to use

The Case

IMG_0079.JPG
I settled on a Serpac A20. It looked retro enough and initial layout tests in Eagle indicated there would be enough space inside for the PCB.

The only downside to this case (and probably most cases) is the choice of pre-made front windows - clear or black/IR transparent. I wanted red, so I found an online supplier of 1/16" acrylic sheet and ordered some. I used a small table saw with a fine pitch blade to cut the plastic.

Measurements were obtained from the Serpac spec sheet and the PCB size was confirmed by exporting an image of the .brd file, punching the mounting holes out and making sure the holes matched the mounting posts and everything fit they way it should.

The Code

DSC_0009_DxO.jpg
This project used the Arduino 1.0.1 IDE. I found some of the libraries I used needed some rewriting to be compatible with 1.0. I have provided them along with the project source and the Eagle .brd and .sch files at my github site:

https://github.com/quarterturn/7-Segment-Clock

It is possible that the libraries have been updated since I last used them. But you can be sure what is on my github site will work if that's all you need.

Here's a photo of the breadboard prototype.

Using the Displays

IMG_0042.JPG
IMG_0043.JPG
IMG_0045.JPG
IMG_0046.JPG
IMG_0047.JPG
IMG_0048.JPG
IMG_0049.JPG
IMG_0050.JPG
IMG_0051.JPG
IMG_0052.JPG
IMG_0053.JPG
IMG_0054.JPG
IMG_0055.JPG
IMG_0056.JPG
IMG_0057.JPG
IMG_0059.JPG
IMG_0060.JPG
So a big issue with the clock was that board is horizontal but the displays need to be vertical so you can see them through the window. How to mount them?

My first idea was to use machined-pin, right-angle sockets. Nice, but very expensive - 7$ each!

I wasn't about to put $14/clock into just display sockets, so there had to be another way.

A better solution was to just bend the lower display pins so they are parallel to the back of the display and then solder wires from the board top row to the display top row. Zero-ohm resistors were just the right size to allow easy soldering.

You can see in the photos below how I used gaffer's tape to secure things in place. Gaffer's tape looks like "duct tape" but it is very different in that it is designed to be strong yet leave little or no residue when peeled off.

Playing Music

IMG_0087.JPG
IMG_0088.JPG
IMG_0089.JPG
I wanted a musical alarm. I never liked those "beep... beep..." alarms. But how to play music while not disturbing the display updates or button events?

The answer was the excellent Playtune library. (https://code.google.com/p/arduino-playtune/) On the ATMEGA328p used in the project, it is capable of three simultaneous voices. The sounds are generated using the hardware timers (with appropriate prescaler and dividers) and are squarewaves without any envelope. The great thing about this method is once you have the timer configured, it just runs and your code is free to do whatever else is needed until the next note event.

Typing in notes manually would be tedious so there is the MIDITONES tool to convert a .mid into code. it has helpful options to limit simultaneous notes from the source file which make the best of the available voices.

As implemented, I only use two of the possible three channels. That is because I wanted to keep timer0 for 'millis()' timing and other functions. As it turns out, playtune.cpp actually includes a substitute timing function that would have allowed a third voice. Oh well, something to keep in mind.

Sounds from the timer outputs are sent through 500 ohm resistors and then directly to a large piezo disc. The combination of driver, hole and case cavity help reinforce the sound. It is certainly loud enough to wake you up from a bedside table or even across the room.

Ease of Use

DSC_0035_DxO.jpg
DSC_0036_DxO.jpg
DSC_0037_DxO.jpg
DSC_0038_DxO.jpg
DSC_0039_DxO.jpg
DSC_0040_DxO.jpg
DSC_0042_DxO.jpg
Almost all the coding work of the project went into making the menu and setting system for the different parameters:
- time
- date
- alarm
- 12/24 hr
- daylight savings time
- setting defaults

Three buttons is about all that would fit across the back while leaving room for a power jack. That's just fine for decrement, increment and set. Each menu item does data validation.

Another code design feature is the use of a display buffer. The display is 8 characters (physically it is 9 but I don't use the last digit) but the buffer is 16, to allow for also storing the date. The actual display function grabs a window from the display buffer. This allows for the effect of the time scrolling out of the way to display the date, all the while the seconds (and everything else) continues to update.

Most important to me was having an alarm that knows not to go off on the weekend. The alarm is configurable to go off never, only on weekends, only on weekdays or every day.

Here are some photos of the menu options.

More Hardware Stuff

IMG_0090.JPG
IMG_0091.JPG
IMG_0083.JPG
IMG_0080.JPG
Physically, I had the hardest time doing the rear panel. With the tools at my disposal, there was no ideal way to cut out the rectangle for the power jack. I could not move the jack back due to the battery holder so a plain drilled hole could not be used. I created a template to help me accurately mark the back panels for drilling. As for the power jack hole, it turned out best to just use a small drill bit to go around the outline, nip it out using wire cutters and then file the sides to be smooth and even.

Here is what's in the clock as far as hardware:
ATMEGA328p clocked at 16 mHz with an external crystal
DS1307 RTC chip and 32 kHz crystal
1220 battery and 12mm battery holder
MAX7219 common-cathode, 7-segment display driver

I realize you could probably do the same features using just the ATMEGA328p. It would be more coding work and I think you would not achieve the same power failure battery life as obtained from the DS1307.

Conclusion

DSC_0045_DxO.jpg
This was my first project using Eagle CAD and PCB fab house BatchPCB. Adafruit and Sparkfun have both contributed excellent part libraries for Eagle which make building a board very easy, saving you from having to design parts yourself. BatchPCB did a great job - out of 20 boards I found only one small flaw - a random copper 'hair' across a small portion of board which caused a short. This was easily fixed with an exacto knife.

Getting to the final board layout took three revisions. On the first I somehow got the display wiring reversed; on the second I realized the switch mounts weren't quite right for the right-angle switches; the third was the charm, so to speak.

I had enough displays to build 10 clocks. I have 6 left at the time of writing this instructable, as well as 9 extra boards (note: BatchPCB's cart may say 'quantity 1' but that still means two boards). If you'd like to buy a clock or a bare board send me a personal message. If you don't have the same displays (or can't find them anywhere) you can certainly use my board to drive any common-cathode 7-segment LED display.