Introduction: Arduino Perpetual Calendar Clock

The clock uses 2 electro mechanical clock movements controlled by an Arduino to display the Day and Month. A third quartz controlled movement displays the time tide Low or High tide.

The Calendar is fully automatic and takes into account leap years as well as summer and winter time changes.

The clock also has full Westminster chime of all 4 quarters and hourly chimes.

The clock is stand alone no Master Clock required.
It has a built in Decoder for the DCF77 "Atomic Clock".

An Auxiliary LCD display shows time,date and also DCF77 signal and decoder information.

See my Calendar Clock web page here.

Step 1:

The clock is designed around a 12" (300mm) English Office Dial Clock case that I picked up off Ebay with no movement.

The metal dial was stripped off, repainted and re-lettered using my own dial design

The oak dial surround was stripped back, disassembled re-glued and screwed. It was then bleached to lighten the colour.

I fitted hinges and a catch so the dial can be opened to get access to the controls/electronics inside.

fig 1&2 show the clock components mounted on the back board.

fig 3 shows the empty back box behind the dial.

fig 4 shows the 3 clock movements mounted on the back of the dial. The 30 second Day movement is bolted direct to the dial. The Month and Tide movements are mounted on bars screwed to the wooden dial surround.

This hides the fixing nuts from view.

Step 2: Connections

Chimes fig 1 adafruit Audio FX Sound Board

The clock sounds the Quarter hours and hours via an adafruit Audio FX Sound Board + 2x2W Amp

16MB of storage on the board itself, so you can store up to 15 minutes of quality compressed audio. Double that if you go with mono instead of stereo
Built in Mass Storage USB - Plug any micro USB cable into the Sound Board and your computer, you can drag and drop your files right on as if it were a USB key

Compressed or Uncompressed audio - Go with compressed Ogg Vorbis files for longer audio files, or uncompressed WAV files

High Quality Sound -44.1KHz 16 bit stereo. The decoding hardware can handle any bit/sample rate and mono or stereo

11 Triggers - Connect up to 11 buttons or switches, each one can trigger audio files to play

Stereo line out - There's a breakout for both left and right channels, at line level, so you can always hook up to any kind of stereo or powered speaker

Five different trigger effects - by changing the name of the files, you can create five different types of triggers which will cover a large range of projects without any programming

There are 2 different chime options available for this clock

Option1 The hour chimes are recorded from a 4" longcase clock bell and the quarter chimes from a Glockenspiel. Option 2 The hours chime is a combination of hand bells and a long case clock bell while the Qtr chime is on hand bells.

Each note has been sampled separately and then put together in Audacity to make each section of music for the chimes.
For each type there are six chime samples in total, four for each quarter and two for the hour chime. The quarter chimes are made up in sections and give a Westminster type chime.

Option 1 (Glockenspiel) see zip folder above

There are for sections

Section 1 notes FAGC Quarter Chime T01.wav

Section 2 notes CGAF Half Chime T02.wav

Section 3 notes AGFC Three Quater Chime T03.wav

Section 4 notes CGAF Full Chime T04.wav

Quarter Past the Hour plays Section1

Half Past the Hour plays Section 1 then section 2

Three Quarters past the hour plays Section 1,2 then section 3.

Full Hour plays section 1,2,3 then Section 4.

Note the full hour chime is played on 59min 49 seconds so it can play out before the hour chime starts on the hour. Mod the code at line 843 to 49 eg if ( minutes == 59 && seconds == 49 && chimepwr == 1) // allows full Westminster chime to sound before hour chime starts was 49 old chimes

The hour chime comprises of 2 samples both single chimes. The first sample lasts just under a second and then the chime is faded out at the end. Hour Short T06.wav

The second sample lasts 9 seconds and contains the full single chime as it slowly fades away. Hour Long T05.wav

In a real clock the hammer hits the bell causing it to ring. Normally it would gently fade out to nothing but if the clock strikes the bell again e.g. if it is chiming more than 1 o'clock then the bell stops fading out and rings again loudly.

To simulate this effect all but the last chime are short chimes the last 9 second chime giving the effect of the bell ringing out.

Option 2 (Hand bells) see zip folder above

There are for sections

Section 1 notes FAGC Quater Chime T01.wav

Section 2 notes CGAF Half Chime T02.wav

Section 3 notes AGFC Three Quater Chime T03.wav

Section 4 notes CGAF Full Chime T04.wav

Quarter Past the Hour plays Section1

Half Past the Hour plays Section 1 then section 2

Three Quarters past the hour plays Section 1,2 then section 3.

Full Hour plays section 1,2,3 then Section 4.

Note the full hour chime is played on 59min 47 seconds so it can play out before the hour chime starts on the hour. Mod the code at line 843 to 47 eg if ( minutes == 59 && seconds == 47 && chimepwr == 1) // allows full Westminster chime to sound before hour chime starts was 49 old chimes

The hour chime comprises of 2 samples both single chimes. The first sample lasts just under a second and then the chime is faded out at the end. Hour Short T06.wav

The second sample lasts 9 seconds and contains the full single chime as it slowly fades away. Hour Long T05.wav

In a real clock the hammer hits the bell causing it to ring. Normally it would gently fade out to nothing but if the clock strikes the bell again e.g. if it is chiming more than 1 o'clock then the bell stops fading out and rings again loudly.

To simulate this effect all but the last chime are short chimes the last 9 second chime giving the effect of the bell ringing out.

There is also a test wave file that is played when the "Test Tone Button" is pressed. This allows you to set the volume without having to wait for the clock to strike. T00.wav

Hour Chime Sequence

On the hour.

1 o'clock- long chime

2 o'clock- short chime then long chime

3 o'clock- short chime, short chime then long chime

4 o'clock- short chime, short chime, short chime then long chime. etc.

Step 3: Control Panel

Apart from the Arduino reset switch on the main board the control panel houses the switches to control the calendar clock.

See table fig 4 above for details on each switch.

Step 4: LCD Display

The clock has a 4x20 LCD display mounted on the back board.

The display is used to monitor the DCF77 library and some basic clock functions. A switch on the control panel is used to turn the display on and off and is normally left on only when the clock is opened.

The display shows the following info.
Row 1

Time and date. Note the date is in the UK format dd/mm/yyyy

Row 2

Section 1 rotates between 3 states

1 Displays the next calculated leap year

2 The quartz tuned frequency as set by the DCF77 library

3 The quartz crystal accuracy in Hz.

Note this is not the clock accuracy but the quartz crystal accuracy should the DCF77 signal be lossed. The DCF77 library auto tunes the Arduino quartz crystal frequency by comparing it to the DCF77 signal.

Section 2 time zone and summer/winter time indicator

Row 3

Section 1 Shows if the chimes have been disabled on power up. Chimes are disabled on power up as the sound board defaults to full volume on power restore. I don't want to be woken up by full volume chimes in the middle of the night after a power cut. Chimes are enabled by pressing the "Chime On" switch on the control panel. Once on they stay on until the power cut and restored. There is a manual " Speaker On/Off" switch on the control panel if needed.

Section 2 Displays the DCF77 library status "Sync'd", "Locked", "Dirty", or "Fail"

Row 4

Section 1 Shows Signal match as a percentage. The library predicts what the signal should be and compares it to the incoming DCF77 signal.

Secton 2 Displays the status of the Month Motor logic.

Step 5: Dial

fig 1 dial with bezal ready for mounting the clock movements

fig 2 blank dial designed in Turbo Cad

The Calendar Clock dial was designed and drawn up using Turbo Cad.

The final design is then printed out on A3 Lazertran inkjet paper as a giant decal.

The original dial is first rubbed down to remove all old paint and lettering. It is then primed and painted an off white colour (white looks terrible in an old clock case). The dial decal is then applied to the blank dial and then when dry 3 coats of acrylic varnish are sprayed over the top. This makes the decal background go clear so the off white dial can be seen with the dial lettering on top.

Step 6: Day Movement Control

The day movement is a 30 second slave movement. These movements were fitted to clocks in offices and factories and were stepped once every 30 seconds by a master Clock.

I use the Synchronome movement fig 1 in this clock as it is more compact.

fig 2 & 3 Most 30 second slaves work in the same way as the larger Gent type movement.

The parts and operation are as follows .
A is the main ratchet-wheel, having 120 teeth

B the operating electromagnet

C the armature

D the armature lever

E the driving pawl, which moves the ratchet-wheel one tooth on the release of the armature

F the driving spring, which normally holds the driving pawl in engagement with the ratchet wheel, and the armature away from the electromagnet

G the back-stop lever, which prevents movement of the ratchet-wheel when the armature is attracted, as might be possible from vibration or on clocks with exposed dials - by pressure of wind on the hands

H the momentum stop, which prevents the ratchet wheel being moved more than one tooth per impulse and, with the pawl E, locks the ratchet wheel between pulses

J the stroke-limit stop, which limits the travel of the armature, and

When electromagnet B is energized by a pulse from the Master Clock, the armature C is attracted, pawl E is propelled to the right against the pressure of spring F, and drops into the next tooth on ratchet-wheel A. When the pulse ceases, spring F drives the paw! E forward, and the ratchet-wheel rotates one tooth, equivalent to a half-minute on the dial. The ‘minute’ hand is attached to the. ratchet-wheel which also drives the ‘hour’ hand through a train of gears having a reduction ratio of 12 to 1.

Operating current The operating current for the movement is 250 mA. The resistance of the electromagnets is between 7.5 and 10 ohms and they may be connected in circuit without reference to polarity.

The minute hand drive is used to indicate the day of the month. This hand is directly connected to the 120 tooth wheel driven by the clock motor ratchet.
Therefore in the original clock 120 x 30 second pulses would drive the minute hand exactly 1 hour.

fig 4 the 120 tooth wheel is enlarged and superimposed over the clock display to show how each tooth relates to the day of the month. There are a maximum of 31 days in each month so 120 teeth divided by 31 gives 3.87 teeth to move the hand 1 day segment. This clearly is not possible so the clock is designed to move the day hand 3 teeth each day. This uses a maximum of 3x31 days or 93 teeth in a month. At the end of each month extra pulses are added to move the day hand to the 1st of the month. As the number of days in each month varies the Arduino Microcontroller works out when each month ends and how many extra pulses are required to move the day hand to the 1st of the month.

fig 5 shows how many extra pulses are required to step the day hand back to the 1st from the end of each month.

This can be seen in fig 6. To move the day hand from 1 day to the next requires 3 pulses so for example at the end of a 31 day month an extra 30 pulses are sent to stop the day hand at the 1st of the month.

Step 7: Month Dial

fig 1 Month Dial

The month hand is driven by a Lavet type stepping motor.

The motor is sourced from a quartz clock movement with the quartz control board cut out. The motor requires very low current to drive it and can be driven direct from the Arduino output via a trimmer resistor. The resistor is used to adjust the current to the motor so it works without being over driven.

fig 2 The motor is driven by reversing the polarity to the drive coil which causes the permanent magnet toothed rotor (in red below) to turn 180°. The toothed rotor will continue to turn in the same direction each time the drive motor polarity is reversed.

2 output pins from the Arduino are used to pulse the drive motor with 1 pin always the opposite to the other.

The Month indicator hand is connected to the seconds cog wheel. This wheel turns once every 60 polarity changes and as there are 12 months in a year the clock motor has to be stepped 5 times (60 teeth/12months) to move the month hand 1 month on the dial.
Note the code always sends 6 pulses as the first pulse will be ignored as the polarity will not have changed. At the end of the 6 pulses both Arduino pins are set to "LOW" so no current is passed through the drive coil until the next month.

On initial setup the month hand can be controlled by 2 switches, "stepmonth 1" & "stepmonth 5". This is a single centre off locking switch. The "stepmonth 1" switch applies single alternating pulses to the month motor once per second and is held on until the hand starts to move. If the switch is left on the month motor will continue to step until the switch is moved to the centre off position. The "stepmonth 5" switch applies 5 alternating pulses to the moth motor once per second. To use move the switch to the on position and wait for the month hand to start moving then return to the centre off position. The month hand will then advance 1 whole month then stop. To set the month hand first use the "stepmonth 1" switch to set the hand to a month then use the "stepmonth 5" switch to step whole months until the correct month is shown.

Step 8: Month Movement Modification

U.T.S. Quartz Clock Movement Hack

I use U.T.S. movements fig. 1 in most of my clocks as they are good quality, have a secure minute hand fixing and are available in high torque models for large hands.

If you don't have U.T.S. movements then you should be able to find a way of modifying it as they are all very similar. The only ones you can't use are the "silent" movements with sweep second hands as they don't rely on a 1 second pulse to drive them. Carefully prise the movement apart by sliding a thin screwdriver down the slots visible on the top and bottom of the case in fig.2 and release the locking tabs. Fig. 3 remove the top and bottom case sections. Fig. 4 The quartz PCB and motor section can then be lifted out as 1 part leaving the empty case and battery holder section. Pull the battery terminal out and discard. Fig. 5 The quartz PCB and motor section removed in the previous step can now be modified. Fig 6 Cut the track from the integrated circuit (the black blob) to one of the drive coils with a sharp knife. Solder wires to the drive coils and feed them out into the empty battery bay. Fig. 7 Using a small piece of vero board 19 holes x 4 strips make the quartz motor drive interface circuit. The circuit has protection zener diodes x2 @ 8.3v, a 10K preset resistor to set the Lavett motor drive current, an On/Off switch and a pair of PCP connectors to connect the circuit to the drive output from the Arduino circuit board. Fig. 8 shows the rear of the Vero board and the position of cut tracks. Fig. 9 finally solder the wires from the motor coils to the Vero Board and snap the case back together. Glue the Vero Board in place with a couple of dabs of hot melt glue.

Step 9: Tide Clock

The tide clock displays the time to Low or High tide. As tide times are affected by many variables the tide clock uses an off the shelf tide clock module with just the tide hand connected.

To use find the tide times for your local seaside off the internet and just set with the adjusting wheel on the clock movement.

Step 10: Schematic

fig 1 shows the schematic and fig 2 the Arduino Uno connections

The Schematic can also be seen here

Step 11: Vero Board Layout

The components for the Arduino and the sound effects board are mounted on the vero board. This is then mounted on the backboard of the clock see blow. The board has a reverse polarity protection diode fitted

and this will drop the input voltage by a fraction of a volt. The board shows 5.6volts connect but this will need to be adjusted down so the supply is 5volts or less before the Arduino and sound boards are connected.

Step 12: Testing

As the clock is fully automatic and there is no manual setting of time and date. All testing is done by transmitting dummy radio time and date code in the DCF77 format to the clock.

Luckily Udo Klein the designer of the DCF77 library used to decode the DCF77 signal in this clock has also designed a DCF77 radio code generator for the Arduino.

To use the generator download Udo's code and program the Uno via the serial port.
Once the board is programmed connect a 1K resistor to pin 3 and a small loop of wire to the Gnd pin. Loop the wire once around the DCF77 aerial of the device you are testing. Load up a terminal program or just open the serial monitor from the Arduino interface. Set the baud rate to 115200 and hit enter. You should see the following on the serial monitor

running

output on pin D3

To set target time use one of the following formats

simple mode: sYY.MM.DD hh:mm.ss

extended mode: x:YY.MM.DD hh:mm.ss w sbtl

current time setup (YY.MM.DD hh:mm.ss w sbtl) w = weekday, s = summertime, b = backup antenna, t = timzone change scheduled, l = leap second scheduled 09.01.01 00:52:03 4 8001

This gives you basic instruction of how to set the time and date on the Uno ready to be set as the time and date on your device.

As an example to test my calendar stepping from 30th June to the 1st July I send this command "x16.07.01 06:30:00 1 1000" to set the date and time to 1st July 2016 06:30:00. My clock is set for GMT so when it decodes it will be set to 05:30. On all months bar January on the first of the month the calendar is set to correct at 06:00hrs rather than midnight (due to noise of the clock movement).

Remember once you send the command to your DCF77 generator the clock start at the time you set so by the time your clock decodes it it will be several minutes later. This is why I set it to 05:30 not 06:00 hrs. This give my calendar clock time to decode the signal ready to step the time and date on at 06:00hrs.

Here is another example

To trigger a leap second for GMT (for CET take an hour off)

Send x15.01.01 00:45:00 1 0001

Outputs

running

output on pin D3

current time setup (YY.MM.DD hh:mm.ss w sbtl)

w = weekday, s = summertime, b = backup antenna, t = timzone change scheduled, l = leap second scheduled 15.01.01 00:45:00 1 232001

To set target time use one of the following formats

simple mode: sYY.MM.DD hh:mm.ss

extended mode: x:YY.MM.DD hh:mm.ss w sbtl

current time setup (YY.MM.DD hh:mm.ss w sbtl)

w = weekday, s = summertime, b = backup antenna, t = timzone change scheduled, l = leap second scheduled 15.01.01 00:45:00 1 232001

This actually set my clock (set to GMT) once decoded to 23:45 31st December 2015 plus a few minutes for decoding time.

I used this on my Master Clock to check the injected leap second was detected and passed onto my 1 second slave clocks.

Further examples

x15.01.01 00:45:00 1 0001 = 23:52:00 31/12/2015 gmt+0 triggers a leap second

x14.03.30 01:50:00 1 0010 = 00:45:00 30/03/14 gmt+0 trigger clock +1 hour

x14.10.26 02:50:00 1 1000 = 02:45:00 26/10/14 gmt+1 trigger clocks go back

x21.03.01 05:20:00 1 1000 = 21.03.01 05:20:00 1 49000 after 28 Feb no leap year trigger at 06:00hrs

x16.02.28 06:20:00 1 1000 = 05:20 28 feb 2016 a leap year step to 29

x16.03.01 06:30:00 1 1000 = 05:30 01 March 2016 leap year step from 29 to 01

x16.07.01 06:30:00 1 1000 = 05:30 01 Jul 2016 step from 30 to 01

x14.03.30 23:30:00 1 0000 = 22:30 30 Mar 2014

x14.03.30 01:30:00 1 0000 = 00:30 30 Mar 2014

x14.03.30 13:30:00 1 0000 = 12:30 30 Mar 2014

Step 13: Code