From Tim's website
Jump to: navigation, search

Electronic Projects - Rugby Clock

This project uses a PIC micro-controller to decode the Rugby time signal and show the time and date on an LCD display.

Radio clock


This clock receives the time and date transmitted from Anthorn (previously Rugby) by the National Physics Laboratory. It uses a PIC micro-controller from Microchip (the 16F873) to decode the signal and display the time and date on an LCD screen. This was the first project where I wrote the PIC code in C rather than Assembler and so I hope it can be used as guidance for decoding the Rugby time signal or driving an HD44780 based LCD display.

The sources below were invaluable during this project, and I have included them with other links at the bottom of the page:

Circuit Design

The circuit is split into four parts:

  • Power Supply
  • Rugby MSF receiver
  • PIC Micro-controller
  • LCD display

The power supply is simply a 7805 regulator supplied from a 9v battery or mains adapter. I connected a green LED to the 5v output to indicate when the supply was on, which was particularly useful when trying to get signs of life from the PIC micro-controller! The 5v supply powers the MSF decoder module, the PIC micro-controller and the LCD display.

I used an EM2 MSF receiver module with a pre-tuned ferrite rod antenna to demodulate the 60kHz signal transmitted from Anthorn. MSF is the call sign of the time signal in the UK, which is also transmitted across several other countries in the 60-80kHz band (See Markus Kuhn's pages). The output is 0v or 5v depending on the presence of the MSF signal, and this is read by analogue port AN0 on the PIC micro-controller.

The PIC 16F873-04 is mounted on the strip board with a connector for in-line programming / debugging. Two extra resistors are connected to simulate the ICD module, which allows the PIC to run debug code without the ICD module being connected. Two 5v LEDs are connected to lines 4 and 5 on Port B to assist with debugging the LCD driver software.

The PowerTip 1602F LCD display is connected to Port C on the PIC, with some control lines from Port B. The PowerTip display uses an HD44780 compliant interface, which is surprisingly simple and versatile once set-up. I used a preset resistor to set the voltage at the contrast pin of the LCD module to 0.45v (for room temperature). Without this the LCD contrast is so low the display appears blank.


See the PIC Software page for the source code used in this project. There are three groups of functions:

  • Reading pulses from the demodulator
  • Decoding the pulses
  • Writing to the LCD display

The software samples the signal on the analogue port continuously until it falls below the threshold value. This is the start of a pulse, at which point it samples the signal 5 more times to classify it as a short pulse, a long pulse, a double pulse or a very long pulse. If the samples do not form a known pulse shape it is classified as erroneous.

The software waits for a very long pulse. It then reads in the following 52 pulses and interprets the Binary Coded Decimal values. Erroneous pulses are recognised but the software assumes that they never occur and carries on regardless. The interpreted values are displayed as they are decoded, and it takes a full minute to receive all the pulses necessary to display the time and date.

The cursor is moved to the required position on the display just before the value is written. In this way the new value overwrites the old as it is received. One problem with this is that the new hour is decoded and displayed during the 59th minute of the old hour.