This is only a preview of the April 2006 issue of Silicon Chip. You can view 36 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "Studio Series Remote Control Module":
Items relevant to "4-Channel Audio/Video Selector":
Items relevant to "Universal High-Energy LED Lighting System":
Articles in this series:
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
You don’t need to be an expert to build a reliable 2-way radio link – just a pair of these new boards from Revolution
Education! Being PICAXE driven, they’re dead easy to build and program and have a myriad of serious applications.
PICAXE Goes
Pt.1: By CLIVE SEAGER*
Wireless
Get your PICAXE projects talking over the airwaves using
the latest high-tech 2.4GHz XBee modules!
I
N THIS, the first of a 2-part series,
we describe how to build and test
a pair of wireless data communications “nodes”. Each node is based
around “XBee” radio modules from
US company MaxStream, Inc (www.
maxstream.net). All parts, including
the XBee module, are carried on a
small PC board that’s designed specifically for experimenters.
With only a minor change, the XBee
module can be connected to either an
on-board PICAXE microcontroller or
an external computer. This means that
2-way PICAXE-to-PICAXE or PICAXEto-PC communications are possible,
*Clive Seager is the Technical Director of
Revolution Education Ltd, the developers
of the PICAXE system.
88 Silicon Chip
opening up a vast array of remote
control and sensing applications.
Construction is very easy, as the
XBee modules are pre-built and simply
plug into header sockets on the PC
board. These radio modules utilise
the “ZigBee” standard for ultra-lowpower, high-reliability, short-range
wireless communications (see the ZigBee feature in February 2006 SILICON
CHIP for more information).
Why XBee?
When considering a wireless PIC
AXE application for the first time,
some constructors will undoubtedly
compare the 2.4GHz XBee modules
with the lower-cost 433MHz RF modules that are now available from hobbyist outlets (see Stan Swan’s article
in SILICON CHIP, January 2006 to find
out how to interface these units to a
PICAXE micro).
However, while the low-cost 433MHz
modules are suitable for some very
simple PICAXE applications, the
XBee modules offer considerable advantages. For a start, a typical budget
433MHz system would offer only
1-way communication (one transmitter and one receiver module), whereas
each XBee module supports 2-way
data communication. And although
1-way communication may seem sufficient for some applications, it can
also be unreliable, as the transmitter
has no idea whether the receiver is
actually receiving the data!
Another big advantage is that of
unique addressing. Each XBee unit
siliconchip.com.au
Fig.1: here’s the complete circuit diagram (minus power supply) of the AXE210 Connect Board when a PICAXE chip
is plugged in. Note the 3 x 10kW resistor strings from the PICAXE outputs to ground. These reduce the signal levels
by 1/3 before they are applied to the lower voltage XBee inputs. The simplicity of this circuit belies the true power of
these incredibly versatile communications devices.
has a unique serial number, so two
(or more) units can be set up to exclusively “talk” to each other, ignoring
signals from other modules. This is
not easily achieved with the budget
433MHz modules as, unlike the XBee,
they don’t contain any networking
“intelligence”.
This intelligence leads us to several
other important features such as the
XBee’s selectable communications
channels and its in-built data packet
building and error checking. These
features ensure reliable data exchange
under less than optimal conditions.
So what applications would suit a
PICAXE-based wireless node? Here are
just a few examples (we know you’ll
think of many more):
• Remote control of robots and equipment (PC to remote PICAXE).
• Data collection from a greenhouse
(remote PICAXE to PC).
• An advanced security system (multiple remote PICAXEs to PC).
• Sensor modules in a weather station
(remote PICAXE to remote PICAXE).
Node hardware
The so-called “nodes” described
here are officially known as “AXE210
siliconchip.com.au
Connect Boards”. This rather nondescript name was chosen because the
boards can be built in several different
configurations. For the moment, it’s
only important to note that when an
XBee module is plugged in, the boards
can be operated in one of two distinct
modes, as follows:
(1). As a PICAXE to XBee wireless
modem interface; or
(2). As a computer (PC) to XBee wireless modem interface.
As an example, this allows a sensor
connected to a PICAXE chip (on one
AXE210 board) to transmit data to a
second AXE210 board that’s directly
connected to a PC – allowing the
remote data to be recorded and
displayed on the PC’s screen!
Let’s examine these two
modes of operation and the
hardware configurations needed
to make them work in a little
more detail.
while another bit (input7) receives
serial data.
So the BASIC command necessary
to send data from the PICAXE to the
XBee module would look something
like this:
serout 7,T2400,(“Data”)
Likewise, data received by the
The XBee is a hybrid radio
modem built on a tiny PC
board measuring just 24
x 27mm. All of the parts
are hidden beneath a
metal shield, with external
connections made via two
rows of 2mm-pitch
header pins spaced
22mm apart.
PICAXE to XBee interface (mode #1)
Fig.1 shows the connections when
a PICAXE-18X is inserted into its
18-pin socket. One port bit (output7)
of the PICAXE is used to send serial
data to the XBee for transmission,
April 2006 89
Fig.2: an external computer can communicate directly with the XBee module by plugging in a MAX3232. This IC
acts as an RS232 level converter, ensuring reliable 2-way communications between the XBee and a PC serial port or
USB-to-serial converter.
XBee module can be processed by the
PICAXE with an equally simple serial
command, for example:
serin 7,T2400, b1
A third port bit (output6) of the
PICAXE is connected to the SLEEP
input of the XBee module, allowing
it to be placed in a low-power mode
under software control, if desired.
Note that as the PICAXE operates
at 5V, the signal level on its outputs
must be reduced before connection
to the XBee’s 3.3V inputs. This is
achieved using simple voltage dividers
composed of three 10kW resistors. No
conversion is necessary in the opposite
direction, as the PICAXE readily interprets a 3.3V signal level at its digital
inputs as a valid logic high.
PC to XBee interface (mode #2)
When a MAX3232 chip is inserted
in its on-board 16-pin socket, the XBee
module is connected (via the download cable) directly to the PC’s serial
port. This can be seen in the circuit
diagram of Fig.2.
Obviously, this mode allows data to
Table 1: Jumper Summary
Jumper
Position
Function
J1
Open
Top
Bottom
(not used)
Normal
Ping test (XBee DOUT connected to DIN)
J2
Open
Fitted
XBee VREF pin not connected
XBee VREF pin connected to 3.3V
J3
Open
Top
Bottom
IND LED not connected
IND LED connected to XBee RF_TX (transmit) pin
IND LED connected to XBee ASSOCIATE pin
J4
Open
Fitted
PICAXE output6 not connected
PICAXE output6 connected to XBee SLEEP pin
Note: the default position of each jumper is shown in bold. Orientate the PC board as
shown in Fig.4 when referring to this table.
90 Silicon Chip
be transmitted from and received by
the computer. In addition, it allows
the XBee’s internal configuration to be
altered via the Programming Editor’s
XBee Wizard or by user-entered commands (see the XBee manual for more
details on configuration).
Important: the PC board has provision for both a PICAXE-18X micro
(IC1) and a MAX3232 (IC2), the latter being for computer (PC) support.
When a PICAXE is to be used on the
board (mode #1 above), it is inserted
in its 18-pin socket and the MAX3232
is removed from its socket.
Conversely, when used with a computer (mode #2 above), the PICAXE micro must be removed from its socket (if
installed) and the MAX3232 chip inserted in its 16-pin socket. Never have
both the PICAXE chip and MAX3232
chip installed at the same time!
Power supply
For ease of use, the AXE210 is designed to operate from either a regulated 5V DC supply or an unregulated
9V DC supply. It can also be used with
a 4.5V battery pack (typically three
AA cells).
Fig.3 shows the circuit details. Note
that two voltage regulators are included
on the PC board – the ZSR500C (RG1)
siliconchip.com.au
Par t s Lis t
Fig.3: two regulators provide +5V and +3.3V for the PICAXE micro and
XBee module. Advanced experimenters looking for maximum battery life
in remote nodes may wish to design their own power supply and bypass
these regulators entirely.
provides +5V for the PICAXE micro,
whereas the ZSR330C (RG2) provides
+3.3V for the XBee module.
Power input to the board is via a
3-way terminal block (CONN2). If a
9V DC supply is used, its positive (red)
lead is connected to the top terminal
(see Fig.4). Alternatively, a regulated
5V supply (or 4.5V battery pack) can
be connected to the bottom terminal.
Note that the bottom terminal bypasses
the on-board 5V regulator. The ground,
or 0V (black) lead is connected to the
centre terminal of the connector in
both cases.
Important: take great care with
the power supply connections to the
board. Accidental reversal of the power
leads (or batteries) or the application
of more than 5V to the 5V input will
destroy many components, including
the PICAXE micro or MAX3232 and
the XBee module.
Construction
Assembly of the AXE210 Connect
Board is very straightforward, with
all parts mounting on a small, doublesided PC board.
Fig.4 shows the assembly details.
Install the resistors first, followed by
the IC sockets, voltage regulators, LEDs
and then all remaining parts.
Take particular care with the two
regulators, as they look identical.
Check the package markings with a
magnifying glass if necessary; the 5V
regulator (marked “500”) goes into the
RG1 position and the 3.3V regulator
(marked “330”) goes into the RG2
position. Be sure to orientate the flat
side of each device as indicated on the
overlay diagram.
The orientation of several other
siliconchip.com.au
components is also critical. The
positive leads of the two electrolytic
capacitors must go in as indicated by
the “+” markings on Fig.4, while the
anode (longer) leads of the three LEDs
must go into the holes marked “A”
or “+”. Finally, be sure to match the
notched end of the IC sockets with
that shown.
Initially, both boards must be configured for mode #2 (computer to XBee)
use, so insert the MAX3232 (IC2) into
its 16-pin socket, making sure that
its notched (pin 1) end matches the
notched end of the socket. Do not install the PICAXE chip (IC1); its socket
must remain empty whenever IC2 is
installed!
The jumpers (J1-J4) are made from
the longer 10-way section supplied in
the kit by cutting it into two 3-way and
two 2-way sections. A sharp knife or
side cutters can be used here.
The XBee module is carefully inserted into the two header sockets
(H1 & H2), while making sure that
the chamfered corners of the module
match the outline marked on the PC
board. The correct orientation is also
evident in the photos.
Note that header socket H3 is not
used with this project and therefore the
position is left empty. This header is
used for connecting a GPS (rather than
XBee) module to the board and this will
be covered in a future article.
You board should now be complete.
Before moving on, repeat the above
steps to assemble the second board
in preparation for the testing phase.
XBee reset
Initially, you have to connect each
board to a PC to initialise the XBee
Two complete kits containing the
following parts are required for
this project:
1 AXE210 PC board
1 3-way screw terminal block
2 6mm miniature tactile switches
(SW1,SW2)
1 10-pin 2.54mm pitch header
(cut down for J1-J4)
2 10-way 2.0mm pitch header
sockets (H1, H2)
1 3.5mm stereo socket
4 jumper shunts (links)
1 16-pin IC socket
1 18-pin IC socket
1 3 x AA battery holder
1 battery clip
Semiconductors
1 PICAXE-18X micro (IC1)
1 MAX3232CPE RS232 transceiver (IC2)
1 ZSR500C +5V 200mA regulator (RG1) (Farnell 384-8541)
1 ZSR330C +3.3V 200mA regulator (RG2) (Farnell 384-7780)
3 3mm red LEDs
Capacitors
1 100mF 16V PC electrolytic
1 4.7mF 16V PC electrolytic
7 100nF MKT polyester
Resistors (0.25W 5%)
1 22kW
1 4.7kW
7 10kW
4 180W
Also required (not in kits):
2 MaxStream XBee modules
1 AXE026 PICAXE download
cable
6 AA alkaline cells
Note 1: if your PC does not have a
9-pin serial port, you also require
a USB-to-serial adapter, part no.
USB010.
Note 2: the PICAXE Programming Editor software (v4.1.15 or
later) can be downloaded free of
charge from www.picaxe.co.uk or
ordered on CD, part no. BAS805.
Note 3: the design copyright for
this project is owned by Revolution
Education Ltd. Complete kits (part
No. AXE210) and the XBee modules are available from authorised
PICAXE distributors. Australian
readers can contact MicroZed
Computers on 1300 735 420 or go
to www.microzed.com.au.
April 2006 91
Fig.4: follow this diagram very closely when assembling the PC boards. Note in particular the orientation of the two
regulators, the electrolytic capacitors, LEDs, ICs and the XBee module! For ease of experimentation, all PICAXE and
XBee I/O lines have been made available on rows of pads, shown here with their designated signal names (refer to
the AXE210 & XBee manuals for detailed information).
modules and ready them for the communications tests.
To begin, select one of your completed boards and install links (shunts)
on jumpers J1-J4 as shown in the configuration panel below.
XBee Reset Board Configuration
Board #1
Board #2
MAX3232 fitted
MAX3232 fitted
J1 at “top”
J1 at “top”
J2 fitted
J2 fitted
J3 at “bottom”
J3 at “bottom”
J4 not fitted
J4 not fitted
That done, connect the board to your
chosen power supply, as described
earlier in the “Power supply” section.
If using the supplied 3-cell battery
pack, the red wire goes in the bottom
(5V) terminal and the black wire goes
in the centre (0V) terminal.
Next, connect the board to your PC
via the PICAXE download cable and
launch the Programming Editor software. From the main toolbar, select
View -> Options and click the “Serial
Port” tab. Make sure that the selected
serial port matches the physical port
that you’re plugged the cable into.
Next, open the “XBee Setup” window by selecting PICAXE -> Wizards
-> AXE210 PICAXE Connect from the
toolbar. Click the “Factory Reset” button, which you’ll note also changes the
baud rate to “9600”. Now change the
XBee baud rate to “2400” and click on
92 Silicon Chip
the “Write” button. This operation also
automatically changes the PC baud
rate to “2400”.
To confirm that the module is operating correctly, click on the “Read
Version” button. The results should
appear in the “Buffer” window, as
shown in Fig.5. Of course, you may
get different version numbers to that
shown in our screen shot, which is
perfectly OK!
That completes the preliminary
setup for the first board, so disconnect
power and unplug the serial cable. You
must now repeat all of the above steps
to initialise your second board.
Once done, both XBee modules have
default settings, including a baud rate
of 2400 bits/s. In this condition, they
will respond to any other XBee module – ie, they are address independent
(we will look at how to use unique
addresses in Pt.2 next month). The
boards are now ready for their first
communications test!
Ping test
To check communication between
the modules we’ll first perform a
“ping” test. In this test, one board is
connected to the PC (board #1) and
the other is stand-alone (board #2).
To prevent any confusion, mark one
of your boards as “#1” and the second
as “#2” before proceeding.
The PC first sends data to board #1,
where the XBee module transmits it
over the airwaves. Board #2 receives
the data and immediately re-transmits
it (ie, echoes or loops it back). Board
#1 receives the data back from board
#2 and sends it on to the PC via the
serial port cable, where the software
compares the sent data against the
received data for discrepancies.
As noted, one of the boards is connected to the PC (board #1). This board
operates in mode #2, so all its jumpers
must be set to their default positions
and the MAX3232 must be installed.
The “Ping Test Board Configuration”
panel below shows what you have
to do.
Ping Test Board Configuration
Board #1
Board #2
MAX3232 fitted
PICAXE fitted
J1 at “top”
J1 at “bottom”
J2 fitted
J2 fitted
J3 at “bottom”
J3 at “bottom”
J4 not fitted
J4 not fitted
As you can see, changes are required
to the second board (board #2). It will
be operated stand-alone, so remove
the MAX3232 chip and install the
PICAXE-18X in its 18-pin socket. Also,
move J1 from its default (top) position
to the bottom position, which connects
the XBee’s DOUT & DIN pins together
for the ping test.
As before, connect board #1 to your
PC via the PICAXE download cable.
That done, position board #2 about 1m
away from board #1 and apply power
to both units.
Next, launch the Programming Edisiliconchip.com.au
If both boards are correctly configured
and operating normally, a text string
will be transmitted by board #1 and
echoed back by board #2. The result
is displayed in the “XBee Setup”
window.
In addition, the RSSI LED on both
boards should flash while they are
communicating.
PICAXE to PC test
Fig.5: the XBee module can be reset
and tested using the Programming
Editor’s XBee Setup wizard. This
screen shot shows the results after
clicking on the wizard’s “Read
Version” button (you may get different
version numbers).
tor software. From the main toolbar,
select View -> Options and click on
the “Serial Port” tab. Make sure that
the selected serial port matches the
physical port that you’re using with
the download cable.
Next, open the “XBee Setup” window by selecting PICAXE -> Wizards
-> AXE210 PICAXE Connect from the
toolbar. Make sure the PC baud rate
matches the current XBee baud rate
setting, which should be “2400”.
Now click on the “Ping Test” button.
siliconchip.com.au
In this test, data is transmitted from
the PICAXE microcontroller on board
#2 to board #1. It is then is sent to
the PC via the download cable and
subsequently displayed in a terminal
window.
If you have just performed the ping
test, then move J1’s jumper from the
bottom position to the top position on
board #2, as shown below.
PICAXE To PC Test Configuration
Board #1
Board #2
MAX3232 fitted
PICAXE fitted
J1 at “top”
J1 at “top”
J2 fitted
J2 fitted
J3 at “bottom”
J3 at “bottom”
J4 not fitted
J4 not fitted
Next, we need to program the PICAXE chip with a simple BASIC
program. To do this, disconnect the
download cable from board #1 and
plug it into board #2. Using the Pro-
Table 2: LED Indicators
LED
Indication
RSSI XBee received signal strength
STAT XBee module is active or sleeping
IND
XBee module has associated with
another module or is transmitting
(depends on position of J3).
gramming Editor, enter the following
program and download it into the
PICAXE chip:
init:
high 7
pause 100
main:
serout 7, T2400, (“Value =”, #b1,CR,LF)
let b1 = b1 + 1
pause 500
goto main
When that’s complete, disconnect
the download cable from board #2
and plug it back into board #1. If all is
well, the data being transmitted by the
PICAXE over the wireless link should
now be displayed in the Programming
Editor’s terminal window.
Summary
And that’s it! Next month, we’ll see
how to get two PICAXE chips talking
to each other. We’ll also show you
how to use computer software to save
any data that’s received from a remote
SC
wireless node!
April 2006 93
|