PICAXE PRIMER
to adjust the size of the stripboard to
fit your project box.
You may have noticed that I
haven’t included a circuit diagram
for either the IR transmitter or the
receiver. That’s because all the
necessary circuitry is already
contained on the IRMB boards. All
you need to do is make sure that
both IRMB circuits are properly
connected to +5V and ground. On
the transmitter circuit, you may also
want to connect an LED and current-limiting resistor from the 08M
output1 to ground. I used it to blink
after each transmitted digit just so I
knew the circuit was functioning
properly. To test your SIRC IR
link, type the SIRC transmission
program (listed in Figure 5) into the
Programming Editor, connect a
programming adapter and cable from
your PC to the IRMB, and use the
Programming Editor to load the
program into your battery-powered
IRMB transmitter. For the receiver circuit, you can again use the “IRMB_
Remote.bas” program we tested last
time (available at ww.nutsvolts.com).
Don’t forget to leave the receiver’s
cable connected to your PC because
the received data will be sent to the
Terminal Window. The transmitter
program repetitively sends the digits
0 through 8 to the receiver, which
serially sends the data on to the
Terminal Window. Don’t forget, the
“IRMB_Remote” program adds 1 to
each received signal to correspond to
the digits on the TV remote, so you
should see the digits 1 through 9
being received in the Terminal
Window.
It’s a simple matter to test the
range of your system. Just move the
portable transmitter a few feet from
the receiver (making sure the IR LED
is pointed directly at the receiver)
and walk back to the PC to see if the
correct data is being received. (Of
course, if you walk between the two
systems you may get some garbled
data, but the transmission should
correct itself as soon as you get out
of the way.) I was easily able to get
reliable operation at a distance of 20
feet, which is as far away as I could
get in my basement work area.
USING IR FOR
OBJECT DETECTION
; === IRMB_SIRC_Tx.bas =====
; === Declarations =========
The next PICAXE IR function
we'll investigate is obstacle detection. In this case, the same IRMB
circuit will implement both the
transmission of the IR carrier wave
and the detection of an echo that
indicates the presence of an
obstacle in front of the IRMB. The
software ( IRMB_Echo.bas) is too
long to include here — you can
download it from the Nuts & Volts
website and open it with the
Programming Editor. You can use
either a horizontal or a vertical
IRMB setup to test the software.
Also, be sure you include an LED
and current-limiting resistor on
output1, because it's used to indicate the presence of an obstacle.
There are a couple of points
about the "IRMB_Echo" program that
may require explanation. To begin
with, let's examine the process
involved. Essentially, the IRMB emits
five short bursts of a 42 kHz IR signal
and immediately after each burst
listens for the presence of an echo.
Since the signal is traveling at the
speed of light, it's necessary for the
08M to be very fast in making the
transition between transmitting and
listening.
This is why the program is
configured to run at 8 MHz; 4 MHz
is just too slow to detect the echo
signal. Figure 6 presents a graph of
the sensitivity of the PNA4602 verses
the frequency of the incoming IR
signal. As you can see, the sensitivity
decreases as the
frequency varies
either up or down
from the 4602's
central frequency of
38 kHz. Considering
this, you're probably
wondering why I
chose 42 kHz rather
than 38 kHz for the
PWM frequency.
When I first
symbol index = b0
symbol LED = 1
; === Directives ===========
#com1
#picaxe 08M
; === Begin Main Program ===
high 2
; enable IRMB
; transistor
do
for index = 0 to 8
high LED
infraout 1, index
pause 250
low LED
pause 250
next index
loop
■ FIGURE 5. SIRC Tx program.
began development of the program
(using only single transmissions), I
naturally did choose 38 kHz but my
results were plagued with sporadic
false positives. The IRMB would
frequently report an echo when there
was no obstacle anywhere near it.
My first thought was that the
heat-shrink tubing that shields the
sides of the IR LED might be
"leaking," so I used a toothpick to
apply a small amount of black
silicone sealant wherever I thought it
would help, especially around the
base of the LED on the horizontal
version of the IRMB. This did reduce
the false echoes somewhat, but it did
not eliminate them entirely. At that
■ FIGURE 3. 78L05 circuit schematic.
■ FIGURE 4. 78L05
circuit stripboard
layout.
December 2008 77