Useful as a
phased-installment training vehicle for Arduino development,
our Precision Arduino Clock project
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
synchronizing WSPR, JT65A, and EME/moonbounce communications, the Precision Arduino Clock will be
a great way for the homebrewer in you to become comfortable with the Arduino
computing platform and the convenient XBee RF modules for providing command &
control nodes throughout your hamshack and QTH.

This is the home
page for the Precision Arduino Clock, the ongoing group design project
providing instructional and motivational guidance to ham homebrewers looking
to become familiar with hardware and software aspects of the Arduino
platform. The project is chronicled in the
live, bi-weeklyChat With The Designers program.

The Precision
Arduino Clock project displays date and time by means of an LCD display
module connected to an Arduino microcontroller board (Uno, Nano, etc.)
An XBee RF module is also interfaced to this "base" Arduino in order to send
the time over a 2.4 GHz RF link to a battery-powered remote display node,
consisting of another XBee module and a 4-digit multiplexed 7-segment LED
array connected to second Arduino controller (e.g., an RBBB board).
The time is synchronized to WWV or CHU by means of a LMC567 tone decoder
indicating the "top of minute" tones to the base Arduino controller, which
resets its seconds count on the next minute value. Future installments
of the project will likely include more sophisticated and automated methods
of time synchronization (see Roadmap below), and a formal, dedicated shield
(hardware adapter) may be produced as an inexpensive kit for others to later
easily replicate the refined design.

Sketches
(software) -- Here we have
collected each of the sketches used in the evolution of this
project, allowing the builder to see the progression of features and
to construct this Arduino project in the same orderly steps as we
followed in the CWTD episodes.

Phase 2b--
Software now uses the RTC chip
for date/time retention and timing. Current time set from
computer when you first load the sketch onto the Arduino ... no
more need for cumbersome serial console and "user time setting"
menus!! Also no longer depend on "wait 1000ms" for timing ... we
now let the RTC chip do it and we look for the transition of its
output pin, clocking at 1 Hz interval. LED added to show RTC
heartbeat. Software greatly simplified. Needs the RTClib (see
next item).

Emonlib_test.pde
- This is the code that N3PUU uses on the whole house power monitor which sends
the data off over XBee. The XBee portion is adapted from the "Series2_Tx"
example sketch that comes with the XBee library.

In this
first installment, we get a simple "software clock" loaded into the Arduino,
which is wired to an LCD in order to display the time.
No special efforts are made for clock accuracy in the Phase 0/1 sketch
used here, as it is a simple training vehicle for now to illustrate
the simplicity of the Arduino programming environment, and the nice
displaying capability we have with a standard LCD connected
to the Arduino.

Reference:CWTD Episode #48 (Feb 5, 2013),
wherein we introduce the Arduino Clock project and various methods of
getting
(and synchronizing to) accurate time in today's world. Take special
notice of the WWV, CHU and WWVB discussion
segments, as we'll be implementing some of the concepts in follow-on
installments of the project.
Also, listen to the podcast #48 for
yet additional information.

Further, you can listen ahead to the
podcast #49, in whichwe describe
step-by-step the initial sketch (software) used on the
initial
Arduino
Clock.
We explain
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.

So far we have covered the basics of this prescient design,
both from a hardware and software perspective, using initial methods for
timekeeping and synchronization with WWV and CHU. This time we implement
the software for a key element for moving forward: the Real-Time Clock.
Surprisingly, the Arduino sketch (software) is vastly simplified and we
have the stage set now for making the Arduino and our CWTD shield
(hardware) a very useful addition to anyone's shack.

So this time
we
take
our basic “phase 0” Arduino clock to the phase 1 milestone
with the addition of a Real Time Clock chip (the DS1307). With thishardware
addition, our “CWTD Arduino Clock” can be set with
accurate time and retain it when power is removed.

Reference: CWTD
Episode #49 (Feb 26, 2013), wherein we discuss
the principles and background for thisRTC chip
technology, in addition to the actual implementation of it
on our growing shield
(the hardware interface board).Also, listen to the
podcast #49 for yet additional
information about the hardware implementation, and podcast #50 for a walk-thru of the
software flow chart.

Precision Arduino Clock Functional Flow Chart
Phase_2b

3) Experiment:Basic Radio Link for Text-to-Text Connection ... The
First Step in our XBee Experiments

Understanding that we ultimately wish to have a remote clock node for the
shack (hanging on the wall, on multiple operatioing benches, etc), we
introduce the XBee RF modules as a way to interconnect our Arduino with the
displays and measurement nodes. So in this
experiment we
use a couple of "Series 1" XBee modules in default, out-of-the-box
configuration to set up a remote terminal modem capability ... typing on the
remote XBee node's serial port terminal is sent wirelessly to an Arduino
connected serially to the other node.

Reference: See CWTD Episode #51 for a
good background on the XBee RF modules, where to order and how to configure.
Also listen to the podcast #51
for audio notes on making this first implementation of Arduino + XBee work.

XBee
RF Data Link for Ham Station Mesh Networking,
Part 1 -- This is the start of an
interesting group project that will lead to the creation of a
functional, useful and indeed valuable "mesh network" for data and
control within our ham stations. We begin
by using a couple of "Series 1" XBee modules in default, out-of-the-box
configuration to set up a remote terminal modem capability ... typing on
the remote XBee node's serial port terminal is sent wirelessly to an
Arduino connected serially to the other node. Then we reconfigure
the standalone remote node to independently make periodic A/D readings
of an LM34 temperature sensor and send the readings over the RF link to
the XBee receiver on the base Arduino, which converts the raw ADC
readings to accurate temperature values for display in the Arduino's
serial console.

Here are the components that we'll be
using in our XBee experiments. Bare minimum needs are two XBee
Series 1 modules (item 1) and one each of the carrier boards (items 2
and 3.)

1) XBee Series 1 Radio Modules
-- Series 1 modules are the easiest to
use in setting up and learning about XBee capabilities ...
Adafruit product ID : 128 (http://www.adafruit.com/products/128)

Two Series 1 modules are connected here in our test system
breadboard(s).

The XBee in the left node is connected
to a serial port of a PC using the XBee in a convenient USB carrier
board (Adafruit p/n: 247,
http://www.adafruit.com/products/247?gclid=CI3H56bP37YCFUFo4AodkiQAWA ). Keystrokes made in a dumb terminal
program application (like TeraTerm or X-CTU) running on the PC gets sent over
the RF link to the other XBee node.

The XBee node on the right is
plugged into the "level translation" carrier board (Adafruit p/n:
126,
http://www.adafruit.com/products/126?gclid=CMHgzpTP37YCFYPd4Aod_jwA9A), which in turn is plugged
into the wire plugboard containing the Arduino.The Arduino is running the sample sketch
"NewSoftSerial_1"
that acts as a modem: Keyboard data entered into the Arduino serial console
(i.e., the "terminal" program in the Arduino environment running on
the PC)
is sent via a serial Rx/Tx digital signal stream to the XBee node, which
get sent via the RF to the left node XBee.

Using this arrangement,
one is able to type in either "terminal" window and see the data appear in the other!

See the diagram below for the schematic
version of this modem exchange.

And finally, the terminal windows (below)
showing the respective left XBee node and the right XBee node.The process starts with the Arduino on the right node starting up and
displaying "Goodnight moon!" in its own serial console, and thensending "Hello, World?" to the left XBee node.

Then to illustrate the interactive nature of
the bi-directional modem link, I typed into the text entry area of the right
window "now is the time"and hit <Send> to send that string over to the left XBee node ... resulting
in that string being received and displayed in the window.

I then typed "for all good Homebrewers to
build!" into the terminal of the left XBee node, and the characters were
transmitted (as I typed) to the right XBee node, resulting in that string being displayed in the
Arduino's serial console on the right.

We now
reconfigure the standalone remote node to independently make periodic A/D
readings of a simple LM34 temperature sensor and send the readings over the RF link to
the XBee receiver on the base Arduino, which converts the raw ADC
readings to accurate temperature values for display in the Arduino's
serial console.

The first thing to do is to reconfigure
the XBees to do something slightly different than the transparent
pass-thru character mode done so far.
We will:1) configure the standalone remote XBee
node to periodically make A/D readings, send them to the base node,
and then go to sleep in between readings; and 2) configure the receiving XBee node
(at the Arduino) to be listening for this periodically incoming
ADC reading

First, we need to connect each XBee, in
turn, to the PC using the
USB carrier and a program from the XBee people called: X-CTU.
This program provides a convenient way to read and configure the many
internal settings of the XBee. Just download and install the
X-CTU
program for Windows, connect to your XBee in the USB carrier, and
make the following settings in each module, as shown in the chart below
(transmitter XBee settings are in the left column, and the Receiver XBee
settings are in the right column). If you have any problems, you
can refer to the good
X-CTU manual.)

TRANSMITTER XBEE NODE:

RECEIVER XBEE NODE:

Connected to PC via XBee USB Adapter

In X-CTU:
Modem is set to XB24
Function Set is XBEE 802.15.4
Version set to 10ED
Click Write (updates firmware)

Screen shot of the Arduino Serial Console
displaying the temperature
coming in from the remote node.

Here is the sketch (Series1_Read_Remote_TMP36_via_XBee.ino)
to be loaded into the Arduino Base Controller to read the remote
temperature sensing node and display it on the Arduino's Serial
Console, as pictured above.

In this
experiment we
again use a couple of "Series 1" XBee modules in default, out-of-the-box
configuration to set up a remote clock display node using a 7-segment,
4-digit multiplexed LED display. The base Arduino+RTCC+XBee sends
the time code wirelessly to the remote node: XBee+Arduino+Display

Reference: See CWTD Episode #52
for additional notes on this step of the project evolution.
And podcast #52 provides some
good "live" discussion about how the remote display node was created.

This is installment of our
ongoing Arduino project starts bringing together the various experimentation
threads we've been doing so far:

1) The basic Arduino Clock
displaying time to an LCD;

2) Its synchronization with an
accurate external source;

3) The Real-Time Clock chip (DS1307)
and use of it to maintain time through power cycles of the platform;

4) Wireless communication between two
Arduinos using the modular XBee radios; and

5) Display of the clock information to
a 7-segment, 4-digit multiplexed LED module

So what we are focusing on
this now is the start of our Ham
Station Mesh Network in the form of a remotely located clock
connected by RF link to the base station Arduino controller!

The Precision Arduino Clock operates the
same as it has recently evolved to work in conjunction with the DS1307
Real-Time Clock chip to keep accurate time, even when the power goes
down of course, and displays the date and time to the LCD display on
this "base station", as shown on the white breadboard in the photo
below.

However this time we are starting to use
a new 7-segment, 4-digit, multiplexed LED module from Adafruit
Technologies. This display is controlled by a set of i2c control
lines coming from a second Arduino sitting on the plugboard situated on
the left side of the photo. This "remote" Arduino is connected
wirelessly to the Base Arduino by using those little XBee radio nodes we
used last time in establishing a link between two "terminals" for
bidirectional textual communication, as well as between a remote node
measuring temperature and the base node displaying that temperature.

So this time we are using the same
"transparent" protocol for the two nodes to be sending raw data between
them, but we are only using one-way communication from the Base node to
the Remote node, and we're sending the time digits!

The Base Arduino timekeeping sketch has
some extra lines of code added to "send time to remote node", and the
Remote node sits there waiting for the incoming time codes (happening
every second), and it then displays those time digits to the 7-segment
display!

Series 2 modules run the Zigbee stack.
Every Zigbee network must have one (and only one) "Coordinator" to
manage the network.
"Router" nodes are end devices on the network that will also relay
traffic from other nodes. Because they are relaying, their power usage
is higher. Because of this, "router" duties are generally reserved for
devices with 24x7 line power.
The third type of Zigbee node is an "End Device." These will not relay
traffic from other nodes, and are generally used when the node is
battery powered.

The tables below indicates the configuring steps and settings to use with
the Series 2 XBee modules, using the X-CTU Configuration software program.

Now that we have the basics of the "system" working,
we'll now concentrate on getting the Remote Display Node into the usable
state that we ultimately want: bigger digits, sixty LEDs for
indicating each second, a power-saving motion detector to turn off the
displays when the room is vacant, and suitable battery operation.

Control Words send to
MAX7219 chip in order to display the digit information

MAX7219 8x8 Display Driver

This is a surprisingly powerful chip from
MAXIM that enables the Arduino to control up to 8-digits of a 7-segment
LED array using only 3 bits in a bit-banged SPI serial manner. The
MAX7219 has a great deal of flexibility in that it can be programmed to
accept raw abcdefg segment data for each digit, or binary-coded decimal
(BCD) numbers and do the internal decoding to display the BCD number
using the 7 segments. The chip can be programmed to shut down the
display (to save on power consumption), the intensity may be programmed
in 1/32 step increments, and the scan rates can also be set.

A couple of good tutorials on controlling a 7-seg multi-digit LED array with the
MAX7219 chip can be found at ...

We'll need 9 pins to do 60 LEDs (9 pins actually does 72
max, but 8 only does 56). An interesting side benefit of this
method is that by design only 1 LED is illuminated at a time which
should help keep our power down.

= 2.4576 seconds ... too short! (The displays will turn off if you
are still for about 2.5 seconds!

So we'll need to increase R10 and C6 by factor of 10
each, yielding 245 seconds = 4 minutes. This is good, as you will
likely not be perfectly still for more than this time and the display
will stay on. But if you leave the room (with no
reason to have the clock display on) the PIR sensor will go inactive and
the Arduino will turn off the displays to conserve battery power.

12) Rookey + LCD Combo from Midnight Design .... If you don’t already have a Rookey Kit, this project will be a good
set of parts to use in this Arduino project. We reduced the price of the Rookey
Kit to make this a good deal for our Arduino project and you’ll benefit from
getting it along with the LCD (if you need either.)