(Now a bi-weekly program)

Feb 26, 2013

Join the "CWTD Yahoo Group" for email discussion in between our bi-weekly sessions by clicking here.

Time and Time Again   

Adding a real-time clock to the CWTD Precision Arduino Clock project

Breadboard #2 ... Like final form of the project shield 
(Click photo for bigger view)              
          Breadboard #1 ... Great for Debugging 
                 (Click photo for bigger view)


In our last episode we overviewed sources for time synchronization (WWV, CHU, Internet , Rubidium) and we introduced our little group project ... the CTWD Precision Arduino Clock.  Useful as a phased-development training vehicle for Arduino development, our "PAC" promises to evolve into a full-fledged useful precision clock for our ham radio shacks.  Whether you mount it to the wall for viewing at your operating position, or couple its 1 pulse per second output signal to your transceiver for WSPR and JT65A digital mode moonbounce QSOs, the Precision Arduino Clock will be a great way for the homebrewer in you to become comfortable with the Arduino computing platform.

In this week's episode we'll be advancing the capabilities of the Clock to the Phase 1 milestone by adding a Real Time Clock chip ...

Part 1) ….. We’ll be taking our basic “phase 0” Arduino clock and advancing the project to the phase 1 milestone with the addition of a Real Time Clock chip (the DS1307). With this hardware addition, our “CWTD Arduino Clock” can be set with accurate time and retain it when power is removed. Of course we’ll discuss the principles and background for this RTC chip technology, in addition to the actual implementation of it on our growing shield (the hardware interface board).

Part 2) ….. We’ll take a close, step-by-step look at the initial sketch (software) used on the Arduino last time, and show the construct and way that it works. Some guys mentioned that they were mystified by the code, so we want to explain the pretty standard way that software is constructed and arranged on the Arduino. After all, if you are going to follow along with this project, we want you to have a good feel for what’s inside. You won’t need to become an expert on sketch design, but it’s always good for a homebrewer to at least have a feel for what makes a project tick. [pun]

73, George N2APB  & Joe N2CX

Audio Recording ... (Listen to the MP3 podcast)

Discussion Notes:  (Scroll down below this for the start of the actual whiteboard.)

<20:16:45> "Joe N2CX": Semi manufacturer for the RTC chip is Maxim/Dallas due to corporate merger
<20:19:33> "John - NG0R": my parts just arrived yesterday
<20:33:07> "Howie K3HW": clipboard mounting is a great idea Joe!!
<20:33:58> "Clint-ka7oei": The DS3231 is a really cool RTC chip - used in the "Chronodot" - http://shop.evilmadscientist.com/productsmenu/partsmenu/159-chronodot
<20:34:34> "Todd K7TFC": Re: clipboard--It sure beats stuff flopping all around the bench.
<20:38:07> "Todd K7TFC": The accuracy of the DS1307 is determined by the xtal, isn't it?
<20:39:18> "Brent KD0GLS": Yes, it is. That's where the DS3231 really shines. It measures the ambient temperature and compensates by adding or subracting capacitance from its internal crystal. That gives the device an accuracy of (if I recall correctly) less than 1 minute per year.
<20:41:42> "Todd K7TFC": < 1minute per year would be better than 2 ppm!
<20:42:57> "Brent KD0GLS": The DS3231 itself is not breadboard friendly because it's a SMT device, but the Chronodot breaks it out to 0.1" headers, plus has a spot for a battery on-board.
<20:46:36> "Todd K7TFC": Here's a link to Chronodot specs: http://docs.macetech.com/doku.php/chronodot_v2.0
<20:48:07> "Todd K7TFC": From that link: "virtually identical to the register addresses of the popular DS1337 and DS1307 RTCs, which means that existing code for the Arduino, Basic Stamp, Cubloc, and other controllers should work with no modification."
<20:55:23> "Brent KD0GLS": George, shouldn't "serial.begin" come before "serial.println" ?
<21:06:33> "Todd K7TFC": George: To what extent does the execution time of the routines within the main loop (and the loop itself) influence the time keeping of the system?
<21:09:35> "Todd K7TFC": How well does the Arduino compiler "optimize" the hex code such that it's as efficient as possible?
<21:10:34> "Todd K7TFC": Okay, that makes sense. thanks!
<21:25:10> "Al - N8WQ": excellent sound effects George!
<21:27:56> "Paul - wa0rse": Very nice show, guys! See you next time, I hope. My hardware collection is getting close to complete!
<21:29:12> "Rick K3IND": or just google "liquidcrystal.h"
<21:31:54> "Brent KD0GLS": Great code walkthru guys!
<21:44:27> "Ray K2ULR": My 2 WWVB clocks have been very solid... lucky, I guess.
<21:45:16> "George - N2APB": I'm excited about tying in my CMMR-6P-60 module into the Arduino for WWVB reception.
<21:46:17> "Clint-ka7oei": Switching supplies and Compact Fl. Lamps often run at 30 kHz and the 2nd harmonic "jams" WWVB. Other supplies often run at 50-70 kHz.
<21:46:34> "Clint-ka7oei": Google NIST publication 432.
<21:47:03> "Brent KD0GLS": WWVB is in the process of changing their modulation scheme, but it's supposed to be compatible with existing radio controlled clocks/receivers. Just not with those that phase lock to the carrier.
<21:47:23> "George - N2APB": Great document! "NIST Time and Frequency Services"
<21:52:52> "Clint-ka7oei": I did this many years ago: http://www.ka7oei.com/wwvb_antenna.html
<21:54:27> "Howie K3HW": used an antenna like this to copy VLF submarine broadcast back in the 70's - 80's
<21:55:02> "Clint-ka7oei": Yes - to "relay" a signal indoors to clocks.
<21:59:25> "Howie K3HW": 73 all robot combat league on SyFy channel @ 2200 AR K
<22:01:21> "George - N2APB": I found the VLF antennas that I saw ... http://www.stormwise.com/

SESSION NOTES ....  Adding a real-time clock to our CWTD Precision Arduino Clock

A simple demonstration and training accessory that will evolve into an ongoing useful addition to the ham shack


Project Resources:















                Prototype #2 ... More in the form that the ending shield will be like.   (Click photos for larger view.)


CWTD Clock Software ... load using the Arduino 1.0 development environment


The main circuit we use in our Phase 0 implementation is that from the Rookey Kit ... http://midnightdesignsolutions.com/rookey/index.html





Phase 0: Tone detection at top of minute from WWV or CHU
Phase 1: Addition of 1pps input signal from GPS for seconds sync
Phase 2: Addition of RTC chip to maintain date/time
Phase 3: Addition of NMEA input from GPS for date/time setting & sync
Phase 4: Addition of USB serial input from PC for sync via Internet
Phase 5: Addition of MC145442 modem chip to decode WWV digital data

- 12/24/UTC display
- 1 pps output
- Alarm function
- More?






WWV/CHU minutes “tick” to sync CWTD clock


         Elongated 1 second tone at 0 seconds of each minute

         567 tone decoder can detect tone

         Audio from receiver needs to be approx 0.2 to 1V p-p to 567 decoder

         Can be noisy so software needs to “debounce” signal

o    And subtract decode plus debounce time for exact sync


Receiving time signals in the US (or Canada)


         CHU at 3330, 7580, 14670 kHz

o    Xmtr located in Quebec, Canada


         WWV at 2.5, 5, 10, 15 and 20 MHz

o    Xmtr at Ft Collins, CO


         WWVH at 2.5, 5, 10 and 15 MHz

Xmtr in Hawaii


If you have a receiver with settable memories plug in the above frequencies to scan thru them for best signal strength and lowest noise


In Northeast and north central US

         In daylight try CHU on 7580 kHz

                or WWV on 10 or 15 MHz


         At night try CHU at 3330 or 7580 Khz

               or WWV at 5 or 10 MHz


Southeast or south central US


         In daylight try CHU on 7580 or 14670 kHz

               or WWV on 10 or 15 MHz


         At night try CHU at 3330 or 7580 Khz

               or WWV at 5 or 10 MHz


West central US


         In daylight try CHU on 14670 kHz

               or WWV on 10 or 15 MHz


         At night try CHU 7580 Khz

               or WWV at 2.5, 5 or 10 MHz


West coast


         In daylight try CHU on 14670 kHz

             or WWV on 10 or 15 MHz or WWVH on 15 MHz


         At night try CHU 7580 Khz

            or WWV at 5 or 10 MHz







Code Block #1:




Code Block #2:




Code Block #3:




Code Block #4:




Code Block #5:




Code Block #6:




Code Block #7:




Code Block #8:




Code Block #9:




That was easy, huh?!!!!








    Back to CWTD Home