Introduction: Arduino LCD Master Clock

This clock is designed as a stand alone clock or as a master clock to drive slave clocks and is portable with battery backup. See the clock's website for further details LCD Master Clock Home Page

Update- Automatic Summer advance and Winter Retard button added to the version using Udo Klein's DCF77 library. Press button once to watch the clock advance or Retard 1 hour.

This clock uses an Arduino 328 Microprocessor to decode Time from the DCF77 "Atomic" Clock in Mainflingen near Frankfurt Germany. Time is displayed on a modified skeleton clock controlled by the microcontroller and a Blue 4x20 LCD display. Clock pulses to drive slave dials are monitored on an LED panel. 3 x 1.5volt AA cells provide battery backup when disconnected from the mains. The main board has a USB to UART connector so the clock software can be updated from a PC or even a Mac. Serial code is included for monitoring over the USB but is commented out.

Updated code included to run Udo Klein's DCF77 library. Udo Klein's DCF77 library keeps the clock in sync and keeps perfect time even with a massive amount of noise on the received DCF77 signal. The DCF77 library also continually "Auto Tunes" the quartz crystal so in the rare event the signal can't be decoded the clock remains accurate within 1 sec over many days. This is crucial for a Master clock that drives 1 second slaves as seconds drift will cause the slave clocks to lose sync with the Master Clock time.

Code for the standard library is also included if you have a very good DCF77 signal.

Step 1: Making the Case

The case is a modified BORRBY candle lantern from Ikea.

The case is modified as follows:

1 Drill out the welds holding the top to the main frame

2 Remove the top

3 Cut out the ventilation grill on the front to make space for the LCD display

4 Cut wood or metal sheet to fill the ventilation grills that remain

5 Fill gaps between base and frame with wooden strips. The base circuit board sits on this wood. Remove candle spike from base and add four feet.

6 Add a new plywood top and fix with hinges a the back. A recess will need to be cut in the top to take the top of the LCD circuit board that protrudes from the base.

7 Add a handle and cut a hole in the base for the cables.

8 Fix LCD display in cutout

9 Fix Skeleton Clock movement by suspending from top

10 Slide in PCB and LED display panel

Step 2: LCD Display Using Udo Klein's DCF77 Library

The LCD display has the following specs.
· Operating voltage: 5V· Alphanumeric character set· 4 lines of 20 characters· Blue Backlight· Module size: 98 x 60 x12mm· Display size: 75 x 25mm· I2C 2-wire connection· Built-in Contrast Adjustment

LCD Display using Udo Klein's DCF77 Library

The code uses a PIR movement detector to turn the LCD display on and off. This Library is able to decode the DCF77 signal even if it contains a massive amount of noise. The library also "auto tunes" the Arduino Quartz crystal in the rare event the DCF77 signal is lost (no backup RTC required). For this Library to work your Arduino must use a Quartz crystal as a timebase not a problem if you build your own Arduino as I have. If you are using an Arduino Uno a Quartz crystal can be added my modding the UNO board. See how to do it here Mod standard Uno

Row 1 always shows the current time and date
Row 2 Clock Name, also shows the makers name and software version number. Row 2 then switches to show Slow and Fast 1 second pulses.

As this clock drives other slave clocks as well as the built in analogue display this row monitors the main decoded display and it detects a jump in the seconds backwards or forwards. These will be shown as fast or slow seconds on Row 2 along with the date and time they were detected. On initial power up there are no fast or slow pulses so Row 2 Slow Pulse will be "0" and the date and time indicates when the clock was first power up and synchronized. The Fast Pulse will also show "0" but the date and time will show as "Never" The only time you would expect to see a Slow or Fast pulse detected is if the DCF77 signal was removed for several days then reconnected or if a leap second is injected (fast pulse)

Row 3 DCF77 decoder state

Row 4 Sig Match - Once locked into the DCF77 signal Udo Klein's library can predict what the next signal pulse should be. The Signal Match displayed as a percentage shows the quality of the received signal. 100% being a perfect match to the predicted signal.

Row 4 also shows the "auto tuned " quartz frequency.
When receiving the normal DCF77 signal Udo Klein's library uses this to work out how well the internal quartz crystal is running. It will then tune the quartz frequency up or down to allow it to keep almost perfect time if the DCF77 signal is lost.

Row 4 also shows the tuned accuracy of the quartz crystal. Once the clock has run for a number of days the accuracy of the quartz crystal is tuned until it reaches a max accuracy of 1Hz.
The attained accuracy is displayed. This is fully dynamic so the quartz crystal is continually tuned no matter the temperature or age drift of the crystal. Remember this is not the accuracy of the clock but the accuracy of the quartz crystal if the DCF77 signal was to fail.

Row 4 also shows Winter/Summer time.

Step 3: LCD Display Using Standard DCF77 Library

The standard DCF77 library and code display is shown above.

This code also switches the LCD display off overnight. On start-up the clock attempts to decode the DCF77 signal and will show the "Waiting DCF77 Sync" screen image 1.

Once the signal is decoded the display switches to full time, date and data display. image 2 and 3.

The LCD display shows;
Time and Date Last time the clock sync'd to the DCF77 signal The sync status Last time the clock missed a pulse ( and was corrected by adding a pulse) Number of pulses missed in last 24hrs Pulse length 100ms = 1, 200ms = 2 Cycle length 1000ms and EOF (end of field) indicator The clock will shutdown the LCD after midnight and will turn back on at 06:00hrs. This can be easily changed if required by editing the code.

Step 4: Analogue Skeletal Display

Apart from the LCD display the clock also tells the time on an analogue display driven and controlled by the Atmega microcontroller.

The skeletal display is a modified quartz unit. The quartz crystal board is cut out and the 1 second drive from the main board is connected direct to the drive motor.

The hour and minutes are set from the standard knob on the back of the movement but the seconds are set by using 2 switches on the rear the the clock case. 1 stops the seconds and the other advances the seconds.

Step 5: Code V1 Using Udo Klein's DCF77 Library

LCD Master Clock using Udo Klein's DCF77 library or download from here Download code

Note this clock uses Udo Kleins Release 2 library download here DCF77 Release 2

Step 6: Code V2 Standard DCF77 Library

DCF77 master Clock using the DCF77 library from https://github.com/thijse/Arduino-Libraries/downloads

Download the code from here

Step 7: Video

Short Video clip showing the clock operating and chiming from 23:59:55 to 00:00:32

Chimes are via separate circuits but can be electromechanical or samples via a sound board.

Step 8: Pulse Monitor Display

LED panel shows the slave clock and chime pulses output from the clock. See panel above.

Step 9: Vero Board

The clock is controlled by a Atmega 328 the same as a Arduino UNO.

Vero Board layout
The cut out on the right of the board goes to the back of the case and allows cable access to sockets to all pins. Outputs are included to enable feeds to other clocks via transistor drivers as required.

There is a 3.3v power module on the board that feeds the DCF77 aerial/receiver.

The board also contains a USB to serial adaptor so the Atmega IC can be updated.

zip files contain full size board layouts

Step 10: Schematic

zip file contains full size schematic

Reuse Contest

Participated in the
Reuse Contest