--- /dev/null
+title: WWVB
+linktitle: wwvb
+parent: Home
+ctime: 2011-10-28
+
+Repositories: SOON
+
+TMI uses a WWVB receiver in its RWS product.
+[WWVB](http://www.nist.gov/pml/div688/grp40/wwvb.cfm) is a radio station
+operated out of Ft. Collins, CO by NIST, which provides a 60Hz carrier wave on
+which is encoded the current time as synchronized with a pair of on-site atomic
+oscillators. The low frequency of the WWVB broadcast means it is available
+through most of North America. Perhaps you have heard of *Atomic Clock* radios.
+These simply incorporate a WWVB receiver which is then used to automatically
+set, and periodically compensate, the radio's internal real time clock
+circuitry.
+
+TMI's RWS (Remote Weather Station) project collects weather data completely
+autonomously, time-stamping recorded data using its onboard RTC. The WWVB
+broadcast is used to both initially set the RTC, and to periodically compensate
+for its drift over time.
+
+TMI chose to incorporate the C-MAX
+[CMMR-6](http://www.c-max-time.com/products/showProduct.php?id=31) WWVB receiver
+into its RWS design. This simple board requires very little power, and the fact
+that the WWVB receiver need only be consulted occasionally to compensate for RTC
+drift means its time averaged power consumption is very low. The CMMR-6 offers
+a simple output, TCO, treated as a digital signal. TCO is logic high when the
+WWVB carrier is transmitting at full power, and is logic low when the WWVB
+carrier is transmitting at reduced power. Each second uses a variable period in
+which the carrier is at reduced power to encode one of three values: a 0 bit, a
+1 bit, and a frame marker. 60 of these tri-state bits form a time frame
+containing the time, to the minute, during the current frame transmission. More
+about the WWVB signal format is available
+[here](http://tf.nist.gov/stations/wwvbtimecode.htm).
+
+While the [WWVB time code format](http://tf.nist.gov/stations/wwvbtimecode.htm)
+is easy to parse, this is not so true in the presense of noise. TMI has chosen
+to address noise by implementing a digital 4th order Butterworth filter, using a
+32Hz sample rate and a 3 Hz cutoff frequency. The filter inputs are either 0.0
+and 1.0, sampled from the CMMR-6 TCO pin, and the filter output is some fraction
+inclusive of the range 0.0 through 1.0. The microprocessor code implements
+hysteresis to generate a digital output, where outputs >= 0.7 are treated as
+logic 1, outputs <= 0.3 are logic zero, and any value in between these
+thresholds leave the logic output unchanged. This filter, implemented within
+the uC, requires up to 5% of the CPU while WWVB is in operation, but does a
+stellar job at cleaning up the WWVB signal. To evaluate filters and generate
+their implementation logic, we used the simple and easy to use
+[Fiview](http://www.uazu.net/fiview) design tool.
+
+Consider the following oscilliscope capture of live WWVB reception. TCO is the
+output from the CMMR, and FOUT is the output from the digital filter. Note that
+the filter delays the signal by approximately 200 ms.
+
+![Oscilloscope capture image](images/wwvb-capture.png)
+
+As mentioned earlier, the duration of the low period indicates the bit type.
+200 ms for bit 0, 500 ms for bit 1, and 800 ms for a frame mark. As can be seen
+in the TCO trace, there is a significant amount of relatively high frequency
+noise interfering with the TCO signal. A discrete algorithm would likely be
+unreliable in decoding TCO. However, the filtered output, FOUT, successfully
+removed all the noise with minimal signal distortion. A discrete algorithm can
+parse FOUT with a high degree of reliability. In this case, the trace as
+decoded -- 0 0 1 0 M 0 0 1 1 -- was the correct sequence for the captured frame.
+
+The decode algorithm determines a bit value for the current low period duration
+that is best matched by the expected durations. But the low pass filter cannot
+remote all sources of error, so a frame may be received with bits in error.
+Frames are validated according to the [WWVB time code
+format](http://tf.nist.gov/stations/wwvbtimecode.htm), and two frames must have
+matching data to consider a valid time acquisition. Of course in this sense,
+matching frames do not have the exact same values, but the second frame's
+contents differ from the first frame's only by the number of minutes separating
+their acquisition.
+
+There are still a few enhancements possible in this design. First, the TCO
+signal could be captured via an ADC, to bring additional information on each
+bit into the filter. This, however, might require some software gain control
+depending upon how good the CMMR-6 AGC circuitry is, and may not be worth the
+effort.
+
+The second enhancement is one that will be implemented. Instead of matching two
+complete frames to indicate valid aquisition, instead match complete frame
+sections. Three incoming frames all with errors in different sections would
+allow this latter approach to construct a known good frame, where the current
+algorithm could not. In very noisy cases, this enhancement should perform
+better.