January
2006, Issue 186
Electronic
Scarecrow
BASE
UNIT
The
base unit features a modified evaluation board. A separate
board contains a 2 × 16 LCD and three push buttons (see
Photo 3). The evaluation board came with an MC9S08GT60
microcontroller, but all of the hardware and software
was based on a MC9S08GT16 microcontroller, as with the
remote unit (see Figure 3). I used almost all of the
MC9S08GT16’s I/O pins and most of the internal peripherals.
|

(Click
here to enlarge)
|
Photo
3—The base unit is built around an MC13192 evaluation
board. I modified its power supply and added an
X10 interface. The LCD daughterboard mounts on top
of the evaluation board. The heatshrink insulated
backup battery is sandwiched in between. |
|

(Click
here to enlarge)
|
Figure
3—The main unit is straightforward. The MC9S08GT16
microcontroller receives sensor status packets from
the remote units. It can activate countermeasures
using X10 power line commands. The backup battery
keeps the clock running during power failures. |
The
evaluation board includes an MC13192 2.4-GHz radio transceiver
with an NEC Electronics uPG2012 antenna switch that
enables you to use one antenna for both transmission
and reception. I had to find a suitable antenna to fit
the board’s SMA connector because most Wi-Fi antennas
use a nonstandard reverse-polarity plug (RP-SMA). The
board also includes an RS-232 port for downloading flash
memory updates and a USB port, which is currently unused.
An RJ-11 connects to a PL-513 or TW-523 X10 transmitter,
enabling the base unit to send X10 commands over the
power line.
The
base unit is normally in Receive mode, where it waits
to hear from a remote. When the unit acknowledges a
valid trigger event, it instructs the remote to activate
its audio or logic-level outputs, generates a local
logic-level output (which is currently unused), or sends
a command to an X10 interface. The X10 protocol is a
simple 120-kHz on-off keyed modulation, which must be
synchronized to the power line’s zero crossings. The
external X10 transmitter, which provides an optoisolated
zero-crossing output that’s fed to one of the microcontroller’s
timer capture channels, does this. Another channel’s
PWM output feeds the X10 transmitter’s input, which
controls the 120-kHz signal.
I
had some difficulty with the first LCD I used because
its inputs appeared to require CMOS levels even though
the datasheet specified them as TTL. One manufacturer
I contacted confirmed the problem, but I was told that
the company wasn’t concerned that its datasheets didn’t
match the parts. The company claimed that everyone else
does it. Caveat emptor!
Living
in the woods, I frequently experience power failures,
some of which last for several days. A regulated 5-V
wall adapter normally powers the base unit, but I wanted
it to be able to keep time for at least a week without
requiring external power. I also wanted to use a lithium
battery so I wouldn’t have to remember to replace it.
During
a power failure, the 3-V regulator sends a signal to
the MC9S08GT16 microcontroller. This puts the MC13192
in Doze mode with its CLKO output driving the MC9S08GT16
microcontroller’s clock and real-time interrupt (RTI)
counter at 32 kHz. In this state, the system consumes
35 µA, which is low enough to run for approximately
eight months using a CR2032 lithium coin cell. The clock
stops automatically if power isn’t restored after a
few days. In this state with the radio held in reset
and all the microcontroller functions stopped, the system
draws 2.5 µA. This will last for the lithium battery’s
10-year shelf life. The DC power jack’s switch contact
is also connected to a microcontroller input pin. If
I unplug the power connector, the clock will stop sooner
than if the power had just failed. This eliminates the
need for a separate power switch.