■ FIGURE 23
■ FIGURE 24
■ FIGURE 25
carrier and attach the piezo to the PVC cap as you did
before. Next, run the AC adapter cable down through the
other hole and then into the coax connector. You can
now place the cap on the top of the Dog Detector.
The Program
The Doggy1.txt program is straightforward. The first
thing the program does after initializing the I/O ports is
to take a set of calibration readings with the docal
subroutine. This allows you to place the detector in many
locations without having to change the code. The docal
subroutine makes several calls to the sensor read routines
then sets a couple of variables based on the last reading
of each sensor. The value 10 is subtracted from this
reading and will be used as the detection point for each
sensor.
The Main Loop is where all the work gets done. An
A-to-D (Analog-to-Digital) reading is taken every 10
milliseconds and compared against the calibration
reading taken earlier. If the current reading is less than the
calibration reading, the sensor is considered tripped.
Once tripped, a slight 50 millisecond pause is
observed then 30 readings are taken from the upper
sensor at 10 millisecond intervals. These readings again
are compared against the calibration values and if
triggered, it is assumed a human has passed the detector.
If all 30 readings are taken without tripping the upper
sensor, it is assumed that a dog has passed the detector
and the chirp routine is called. After a pause of two
seconds, the whole process starts again.
Normally, the RX lead of each sensor is held low to
disable them from taking readings. When a reading from a
sensor is needed, the RX lead is brought high, then after a
10 millisecond delay an A-to-D reading is taken from the
sensors AN lead. After the reading, the RX lead is again
taken low.
How Does it Work?
Unlike the early experiments using the IR sensors, the
EZ4 sensors have proven a real winner. The small chirp
from the piezo is just quiet enough not to annoy or wake
you. It is enough to let both you and the dog know that
he/she has entered where they should not have.
Going Further
I added a three-pin header that would make it possible to add some sort of negative feedback to the detector.
The height of the lower sensor should be high enough
to let small cats pass if you wish, and low enough to catch
the dog. You could space the sensors to detect small
children roaming where they should not be. NV
PARTS LIST
❑ Kronos Robotics — www.kronosrobotics.com
❑ Perseus Chip
www.kronosrobotics.com/xcart/product.php?productid=16382
❑ Perseus Carrier 1
www.kronosrobotics.com/xcart/product.php?productid=16390
❑ Perseus Carrier 1 Option 1
www.kronosrobotics.com/xcart/product.php?productid=16391
❑ Piezo Alarm
www.kronosrobotics.com/xcart/product.php?productid=16252
❑ EZ232
www.kronosrobotics.com/xcart/product.php?productid=16167
❑ DiosCompiler
Free Download from www.kronosrobotics.com
❑ SparkFun — www.sparkfun.com
NOTE
All the example programs, as well as the source code
are available for download at www.kronos
robotics.com/Projects/dogdetect.shtml.
❑ EZ4 Sonar Sensor
www.sparkfun.com/commerce/product_info.php?products_id=8504
❑ MaxBotix — www.maxbotix.com
❑ EZ4 Sonar Sensor
www.maxbotix.com/Maxbotix__Buy_Now.html#
December 2008 45