June
2004, Issue 167
Wireless
Monitoring System
The
block diagrams here show how most of the building blocks
have moved from external hardware to internal software
modules. The transmitter’s block diagram counts only
three blocks outside the chip, as opposed to six internal
function blocks supported by the MCU through a combination
of software and on-chip peripherals (see Figure 2).
The parts outside the microcontroller are the sensor
mechanism and reed relay, two keys for setting up the
trap ID and arming the trap, and a 433-MHz low-power
transmitter with a rod antenna. The power comes from
a couple of button batteries.
|

(Click
here to enlarge)
|
Figure
2—As you study the transmitter and receiver block
diagrams, keep in mind that the microcontrollers
contain most of the functions required by the system.
This keeps the number of external parts to a minimum.
The functions listed in the MCU boxes are implemented
with a mixture of software and on-chip peripherals. |
Inside
the microcontroller, software modules implement a digital
generator for encoding data to be transmitted, a scheduler
for cyclic “keep alive” transmissions, storage of user-programmable
nonvolatile ID data, a detector for the battery charge
state, a manager for a simple mechanism to prevent overlapping
transmissions, and a module for administration of the
low-power modes.
The
monitoring station includes a 433-MHz receiver module
and its antenna, a relay stage for driving an external
alarm or phone dialer, a 2 × 16 LCD module, and a five-button
keyboard. I powered the unit with a wall-cube mains
adapter through a linear regulator stage. As for the
transmitter, many of the functional blocks are implemented
by the MCU that’s in charge of decoding the receiver
output and discriminating errors that result from bad
reception, interference, or the simultaneous transmission
of two or more mousetraps.
The
MCU also stores trap information. It registers trap
IDs in (internal) nonvolatile memory and programmatically
updates trap status records in RAM. The user interface
block consists of a trap data browser and a configuration
mode for learning trap IDs. A monitor station can handle
up to 20 transmitters—although a transmitter ID can
range among 128 different IDs—to allow more than one
monitor to operate on the same or overlapping areas.
MOUSE
SENSOR
The
first problem I had to solve was how to sense the presence
of mice. I discarded electronics-only methods (e.g.,
photocells and capacitive sensing) one after another.
Some were too sensitive to dirt, expensive, and difficult
to clean; others were too accessible to munching rodents
and consumed too much power. In this context, drawing
a continuous 5 µA (equivalent to a 1-MW resistor at
5 V) represents significant power!
I
was about to give up, when I saw a program on the National
Geographic Channel showing the natural curiosity and
vitality of mice. Realizing this, I added a little balance
to the trap transmitter (see Photo 1). Sooner or later,
an unwary mouse—frantically searching the trap for an
escape route—will reach the balance. The balance freely
pivots on the transmitter’s aerial. A small magnet glued
on one side counterweights it. I placed a reed-relay
inside the sensor body to detect magnet movements and
to trigger in turn the eight-pin processor. Bingo! It’s
like having the mouse switch on the transmitter for
you!
TRANSMITTER
CIRCUIT
The
transmitter’s schematic diagram accounts for few parts
other than the eight-pin processor (see Figure 3). The
more that’s inside the MCU, the less that’s outside.
This means not only a leaner bill of materials, but
also a small circuit footprint, which is important in
this application.
|

(Click
here to enlarge)
|
Figure
3—The 68HC908QT4 is the heart of the transmitter.
It embeds a brownout reset as well as a calibrated
oscillator that makes reliable data transmission
possible without crystals or resonators. The TX
module can be changed in order to suit national
regulations and frequencies. The reed switch closes
when the mouse moves the sensor balance. |
I
connected two of the six available I/O pins to push
buttons for rearming the trap after trigger detection
and to set up the trap ID. Another pin goes to the reed-switch
trap trigger. These pins are pulled up internally by
the MCU.
A
fourth pin drives the 433.92-MHz 2-5000-786 thick film
transmitter module. It is compliant with European frequency
standards and measures only 25.5 mm × 12.5 mm. The modulation
method is on/off keying (OOK) according to the status
of the PTA5 pin. When it isn’t transmitting, the module
consumes as little as 0.1 µA (more on this later). Check
this figure when replacing it with similar parts, because
it is vital for battery life.
The
only remaining components on the board are a bypass
capacitor (CF1) and an electrolytic capacitor (C1) required
to lower the output impedance of the two button-type
batteries that power the circuit. The circuit is compatible
with user-monitor mode in-circuit programming. Connect
the ICD interface to pin 7 to watch the code run.
MONITORING
STATION
Figure
4 reveals the receiver’s internals. I used modules for
the LCD and the radio receiver; therefore, the design
is noticeably neat and contains few parts. The MC68HC908QY
feature set contributes to the circuit’s tidiness. It
includes input pull-ups, a steady internal clock oscillator,
a brownout detector and reset generation, and flash
memory that can be used as a replacement for EEPROM.
|

(Click here to enlarge)
|
Figure
4—The receiver has few parts. Pull-ups, an oscillator,
reset generation, and EEPROM are all included in
the MCU. Connections to LCD pins 15 and 16 (backlight)
and R2 can vary to suit your LCD’s specifications.
Older LCDs need a contrast control voltage to be
set on pin 3. The relay can trigger a phone dialer
when a trap triggers. |
The
433.92-MHz receiver module takes the signal from the
antenna and converts it to a more manageable digital-level
pulse train. The receiver can be replaced with similar
models to suit national regulations and frequencies.
The
microcontroller processes the pulse train in order to
distill meaningful signals from the inevitable RF noise
background. It then displays the results on the 2 ×
16 LCD module, which is connected in 4-bit mode, requiring
six out of the 14 available MCU I/O pins. The LCD software
driver assumes pins DB0 through DB3 to be at logic level
1 or unconnected. Depending on your LCD module, you
may need to apply a contrast control voltage from 0
to 5 V to pin 3. Recent modules usually work well with
this pin unconnected.
The
keyboard, which consists of five push buttons, takes
another five pins, which have their internal pull-ups
enabled. I kept ICD pin (port A0) free for in-circuit
debugging, as I did for the transmitter, making the
board user monitor-debug compatible.
The
last available pin is used to drive the relay output,
which is realized with a classic transistor stage and
a diode for protection against coil’s over-voltages.
The circuit is mains powered through a wall adapter
supplying 9 to 12 VDC, regulated to 5 V by IC2, a classic
7805 stage. Diode D2 protects the circuit from power
reversals. Resistor R2 limits the current for the LED
backlight to a safe 40 mA. The backlight works from
an unregulated power supply.