Photo of WWVB clock
There are many DIY versions of
WWVB clock designs available on the web. Commercial "atomic" clocks are inexpensive and widely available, but I wanted to try my hand at designing one to gain insight into
WWVB reception and to learn a little about programming a PIC microcontroller. My version is not the simplest available, but it works well and I think it offers a few unique features.
The
WWVB signal is broadcast as a 60 kHz carrier that is AM modulated with a time code frame that is updated once per minute. The data rate is one bit per second. Along with time code information, the data frame also contains synchronization bits, calendar data, UT1 correction, leap year, and leap second data. The clock design presented here only decodes the time data and daylight savings correction data. The software could easily be modified to include decoding of the other information bits, if desired. The the low frequency
WWVB signal strength is weak and reception can be problematic. Signal acquisition time is variable, depending on location and atmospheric conditions. Reception is usually best at night between 8pm - 4am. To use the clock, just apply power and wait for reception of the
WWVB signal. When the clock receives a complete error-free frame of data, it will automatically reset the display to show the correct time. After the initial time correction, the clock will maintain time even if
WWVB reception is lost.
schematic WWVB clock
the heart of the clock is a PIC 16F628 microcontroller running at 4 MHz. Decoded time data is sequentially output from the
microcontroller (RA0 - RA3) to the 7-segment decoder/drivers on a 4-bit data bus. The data is output sequentially as seconds, 10s of seconds, minutes, 10s of minutes, hours, and 10s of hours. The
microcontroller outputs (RB1, RB2, RB3) route a 10 uSec stroble pulse from RB4 out to each of the 7-segment decoder/drivers at the proper time to latch the data bus values. Seconds and 10s of seconds display values are updated once per second. Minutes, 10s of minutes, hours, and 10s of hours are updated once per minute. The display consists of 1" red-orange LED 7-segment displays. The decimal points on the displays are used to form colons to separate the seconds, minutes, and hours. The 10s of seconds and 10s of minutes displays are mounted upside down to form the upper colon dots. The
WWVB receiver is a C-MAX model CMMR-6 and is available from Digi-Key.
I have built two of these clocks, one using point-to-point wiring and one using a pcb. Both versions perform well. Just keep the receiver away from noise sources and the wire / trace lengths short to minimize inductance. I found that the receiver is also sensitive to magnetic fields produced by power supplies. I used a 9V, 200 mA "wall-wart" instead of an internal power supply to eliminate this problem.
The software is interrupt driven, from the PIC Timer 2 module. The basic timing is set to provide 32 interrupts/sec for both receiver sampling and for internal time propagation. The received data is sampled at 32 samples per second. The software cross correlates the input samples with stored "ideal" samples of the one, zero, and synch patterns. The beginning of a data frame is identified by two consecutive sync bits in a row. When this pattern is detected, the seconds data is reset to zero, and subsequent bits are detected as one's or zero's to extract the minutes and hours data. Only the data that is relevant to the time display is decoded. Bits within the data frame that do not contain time data are ignored. The bit detection cross-correlation algorithm requires 31 out of 32 sample agreements between the received data and the stored "ideal" sync pattern.
The decimal point on the seconds digit is turned on when sync is detected and turned off when sync is lost. Bit detection for one's and zero's require 28 out of 32 sample agreements between the received data and the stored "ideal" patterns. If any of the detected bits do not meet or exceed the correlation thresholds, the entire frame is discarded and a new search for frame sync is initiated. When sync and all of the time data within a frame is successfully detected, the data is corrected for Pacific Standard Time and Daylight Savings Time. The software must be changed for the proper corrections for other time zones. The time is also corrected for a one minute offset caused by
WWVB time being valid at the start of each data frame. The fully corrected time is converted to a 12-hour format and then updates the internal time values. If the
WWVB signal is lost, the internal time continues from where it was and relies on the PIC crystal oscillator to propagate time until the next
WWVB data frame is received and validated.