Sometimes you can pick up a nice office clock or station clock at a bargain price. To ensure that these clocks all show the same time inside an organization such as the railway system and avoid hassles with changing between winter time and summer time or replacing empty batteries, these clocks are normally connected to a clock pulse network that is driven by a master clock or radio signal. The master clock generates a pulse every minute, with successive pulses having opposite polarity. If you want to use a clock of this sort, you naturally want it to keep good time. This is handled by the circuit described here, which offers the following features:
it is synchronised to the DCF77 time reference signal at 77.5 kHz (from Mainflingen, Germany) so the time is always correct; • it is inexpensive – by using a microcontroller (in this case a PIC16F648A), the circuit requires only a few components, and it can easily be assembled on a piece of perfboard; • it generates pulses at one-minute intervals with alternating polarity; • it also shows the time and date on an alphanumeric LCD module; • automatic switching between winter and summer time; • time data is backed up in case of power failure (stored in PIC EEPROM).
When using a clock of this sort, note that some models have jumpers that can be fitted or removed to configure the clock for different working voltages. If you have this type of clock, select the lowest voltage (usually 24 V). Based on the author’s experience, clocks from the Dutch PTT (former postal and telecommunication authority) also work OK at 12 V.
Figure 1 shows the schematic diagram of the hardware. The circuit is built around a PIC16F648A clocked by its internal 4-MHz oscillator. A standard two-row LCD (HD44780 compatible) is connected to the microcontroller to display operating instructions or the date and time. The circuit can be powered from an AC mains adapter that supplies a DC voltage in the range of 9 to 18 V. A voltage regulator (IC2) generates a stable 5-V supply voltage for the electronics from this. The supply voltage from the adapter is connected directly to the TI4427A MOSFET driver IC that drives the clock coil. This driver IC has a operating voltage range of 4.5 to 18 V and a maximum rated output current of 500 mA (1.5 A peak). This is adequate for most clocks. If you need more current, you can add a transistor or relay to the output stage. The clock coil has a fairly high inductance, so the supply voltage has extensive decoupling in the form of several ceramic capacitors (C1–C4) and an electrolytic capacitor (C5). A DCF77 receiver/decoder module from Conrad Electronics (p/n 641138) provides the time reference signal. It is also powered by the 7805 voltage regulator. The non-inverted output of this module is connected to port RA4 of the microcontroller. As reception of the long-wave signal from the DCF transmitter may not be good in some locations, especially if you fit the circuit in a metal enclosure, it is advisable to fit the DCF module in a separate plastic box that can be placed a certain distance away from the clock. The source code of the software is written in Flowcode 3 Pro and is available free on the Elektor website for downloading (item number 090035-11).
It is based on the software for the EBlocks DCF clock published in the December 2007 issue (075094- 11). The original software has been adapted to this application and extended with code that generates a pulse signal on ports B6 and B7 with a period of 1 minute and alternating pulse polarity. Pushbutton switch S1 is used for most of the operator functions. This button is connected to port A1 and has several functions: – if S1 is not pressed when the power is switched on, the microcontroller executes a warm start. This is the normal situation. In the event of a power failure, the analog time and the polarity are saved in EEPROM, and they are restored after the next warm start; – if S1 is pressed when the power is switched on, a cold start is executed. This must be done the first time the circuit is used (see below for more information); – if S1 is pressed during normal operation, the variables ‘a_hrXX’ and ‘a_minuteXX’ are shown on the display, which enables the user to set the analog clock. In order to synchronize the analog clock to the digital clock, the analog clock must first be set to exactly 12 o’clock.
If you have a clock that can only be operated electrically, which means it does not have any mechanism (such as a knob) to set the time manually, you can hold S1 pressed after the cold start to cause the circuit to generate a continuous series of clock pulses. Release S1 when the clock reaches exactly 12 o’clock. If you have a clock that can be set manually, first set it to 12 o’clock and then switch on power to the circuit with S1 held pressed. Release S1 when the message ‘cold start… done’ appears on the LCD. If the DCF signal is being received properly, the date and time will be shown on the display after a few minutes and the analog clock will be set to the right time. If the time shown by the analog clock differs from the time shown on the LCD by one minute, the polarity of the pulses does not match the state of the stepper motor in the clock. This can be corrected by first setting the clock to the right time and then swapping the two leads. This action must be completed within one minute.