AVR Color Clock
|The colors and corresponding values for hours and minutes.|
This page describes a color clock that displays the time using two RGB LEDs, one for hours and one for minutes, showing time by using the standard color coding used for components (with two additional colors as the standard color coding only has ten colors and twelve is needed). The time could have been shown more analogue by fading the colors but then it would be harder to read as the human color perception is quite bad. With the discrete solution with 12 well defined steps for both hours and minutes it is possible to tell the time with an accuracy of five minutes, and this accuracy is often good enough.
The reason I made this clock was that my wife has really bad sight and need strong glasses to read the clock, and putting on the glasses at night just to see the clock at night if she wakes up will really make her awake and make it hard to get back to sleep. So I made her this clock as my birthday present for her on her 26th birthday (October 2007) to make it possible for her to see what time it is without putting on her glasses.
To make the clock always showing the time correctly I've also added a receiver for the German DCF77 time code transmitter in Frankfurt.
|The clock (Click to enlarge)||The clock in action! (Click to enlarge)|
As you can see in the schematic to the right it is a very simple design. The clock is controlled by an ATMEGA88 that drives the two RGB LEDs directly. The RGB LEDs have 220ohm resistors for current limiting, as it turns out the color temperature gets about right when all resistors are the same for the RGB LEDs that I used. The two RGB LEDs are pulse width modulated by the built-in 6-channel PWM-circuit in the AVR. There is a status RG LED to indicate status of the DCF receiver, this is too driven directly by the AVR using only current limiting resistors (220/440ohms to get yellow when both are lit). The DCF receiver is a module that is just a radio that only outputs the DCF-time code according to the pulse width carrier modulation format that it is sent out from the transmitter in Frankfurt and thus must be decoded in the AVR. The DCF-receiver is just connected to an IO-pin of the AVR and the rest is taken care of by software. For times when the DCF-signal is not available it is possible to set the time manually using a switch, the switch is very straight-forward too just connected to an IO-pin. Finally, the power supply is very standard, just using a 7805 to get 5v, and as usual I put a rectifying diode to protect the circuit against wrong polarity.
As this was a very simple and quick build, I've not made any PCB for it, I'm just using experimental "dotted" board. This also means that you can't buy a kit for this project in my webshop, but if there is a large interest for a kit I'll make a PCB layout and kit for my shop. To get the two color dots separated and to get a longer light conductor to get the colors really mixed (the longer light conductor the better the colors get mixed) I've used two Plexiglas rods that I've heated up and bent to a nice shape. The experiment board that the system is built on is divided into two parts, one main board with RGB LEDs, AVR and power supply, and one board with the status RG LED and the switch, the later board is also used to make the light conductors (Plexiglas rods) more stable by reducing the torque where the rods are glued to the box as it gives support on a second place as shown in the sketch here down to the right:
|"Under the hood picture" (Click to enlarge)||Cross-section sketch over the mechanical layout inside the box|
The software is very simple, the PWM for the RGB LEDs is taken care of by the AVRs hardware so that only means setting up some timers to get that right, then the PWM-registers are just loaded with the values from a lookup table. Then there is one state machine that handles the three modes of setting minutes, setting hours and just showing the time. Mode is changed by holding down the switch for a couple of seconds until the LEDs start blinking, and then a short push will change the time (color). The status LED is updated by the status of the time, it will be blinking red according to the received DCF signal when it was more than 72 hours since the last correct time code was received. When it was less than 72h but more than 40h since the last time code the status LED will be yellow and if 40h or less it will be lit green.
The DCF receiving is taken care of by a separate dcf-decoder I made for this project but it is separate and very general so it can be used for other projects. It is built basically by one state machine and a simple command parser, the state machine handles the timing of the pulse width modulated bits including the sync bit. Then the command parser decodes the bits into a meaningful data structure, each command has information on how many bits to decode and if parity shall be counted and most important, how it shall be decoded. If you only want part of the time code then you can change the struct and some of the decoding commands to ignore commands to be able to get smaller memory footprint. This program was intended to run on an AVR MCU but could easily be fitted for any MCU. The decoder is intended to be polled at the frequency defined in the dcf77.h file but you can quite easily change it to be interrupt driven if you have a hardware timer that can replace the "period_timer"-variable.
The schematics, source code and compiled .hex is included in the following zip-file: colorclock.zip(31kB)
GNU General Public License
AVR Color Clock by Rickard Gunee is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.