Thursday, May 8, 2014

Wall Clock with Atmel Microcontroller

Time measuring devices always look special to me.  I admire the royal nobility of a tower clock,the steady pace of a pendulum mechanism, the instant obedience of a stop watch. Eventually I decided to build one such device myself. While making a mechanical device is out of my ability, building an electronic clock is a relatively easy task. All that you need nowadays is a few inexpensive  components, rudimentary soldering skills and some programming experience.  







The clock above is what I made for our bedroom (thanks to my wife who allowed me to put this creature on the wall).
What is special about this clock: 
  •  It is a twenty four hours clock with accuracy up to one minute.
  • It uses a single active component: Atmega328 controller, which keeps the time and controls LEDs without help of any external microchip.
  • Time accuracy is provided  by an external oscillator while internal oscillator provides processor working frequency. 
  • Technique known as charlieplexing is used to handle the number of  LEDs exceeding number of controller's  I/O pins. 
  • This bedroom clock  possess an important feature: it can turns light OFF  and ON according to the schedule. This way it's light does not distract us during sleep time but allows easy time reading at dawn.
Let us describe the clock interface. This clock has two dials: inner (yellow) dial for hours and outer (green) dial for minutes. These two dials provide time reading with accuracy up to three minutes. Three correction  LEDs in the middle improve accuracy up to one minute.

Rules to read the time are simple:
  •   During AM hours single LED is turned ON  showing current hour. LED which points to XII hour  is always OFF.
  • During PM hours group of LEDs are ON staring from the LED which points to XII LED and ending with the current hour. 
  • Next LED is switched ON when there are two minutes left till the start of new hour.
  •  Each green LED of outer dial represents 5 minutes interval. LED which point to 60 minutes is always ON  as well as LED next to the current minute and all LEDs in between. This way the clock provides at least three minutes accuracy.
  • Three LEDs in the middle allow time correction:


Pictures below illustrate time reading rules.

Clock contains this set of components:
  • Atmel controller. I have used Atmega 328 but less powerful controller could be used as well.
  • Clock oscillator 32768 Hz.
  • Thirty LEDs (5 mm size).
  • 15 resistors 51 Ohm each (0.25 or 0.125 does not matter).
  • Radio Shack protopype board (catalog number 276-170)
  • Two three pins  headers (to build ISP connection between controller and PC)
  • Capacitor 0.047 micro farad 
  • Encoder to set up clock time. I have used Panasonic EVQ-WTEF2515B
  • Hookup wire and old IDE cable.
  • Power supply 5 V. It must provide at least 300 mA of current. I have used supply from old Sharp  handheld computer.
These components are connected according to the circuit diagram below:
To make soldering of  four LEDs to the single resistor I  prepared the board by making some cuts with a knife.

Here is how the board looks after soldering of all components.

I decided to use as a clock plate the wooden board from Michael's. As you can see I did not try hard to make it strictly symmetrical, having in mind the asymmetrical shape of the board. 

The clock was programmed with help of Atmel  studio 6.1 in C language. Source code and project file are  available here https://bitbucket.org/jumbleview/clock30/src.

Setting the time is not hard. For that three LEDs at the back of clock are used:

To set the time there is the need to follow next steps:


  1. Push the encoder: reserved LED is turned on
  2. Rotate the encoder to choose value you want to set (hour or minute).
  3. Push the encoder  again, now clock are ready to set the value.
  4. Rotate the encoder to set the proper value.
  5. Push the encoder again: the value is set.

To set the other value you  may repeat steps 1-5.

And here is the movie, which shows process of setting clock minutes.



1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete