This is only a preview of the May 2005 issue of Silicon Chip. You can view 38 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:
Items relevant to "Voice Recorder":
Items relevant to "MIDI Theremin, Pt II":
Items relevant to "What’s this? Free PC Boards for Schools?":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
PICAXE
Part 1: Assembling your
Schools Experimenter board
In the first part of this new series, we look at how to
build and test a very low cost experimenter’s kit based
on the PICAXE-08M microcontroller chip. Next month,
we will introduce some more formal programming
exercises for schools to use in the classroom.
D
ubbed the “Schools Experimenter”, this versatile
design allows simple exercises to learn the BASIC programming
language using LEDs and simple
sensors, but the board can also
be used alongside a breadboard
prototyping system for much more
advanced experiments.
What is a microcontroller?
Microcontrollers are single-chip
computers that are finding use in
just about every electronically enabled device you care to name. Toys,
mobile phones, microwave ovens
and MP3 players are just a small
sample of the consumer items now
microcontroller equipped.
The “PICAXE” system is a power-
# About the Author:
Clive Seager is the Technical Director
of Revolution Education Ltd, the
developers of the PICAXE system.
86 Silicon Chip
by Clive Seager
#
ful, yet very low cost microcontroller programming system designed
to simplify educational and hobbyist
use of these devices.
A unique feature of the PICAXE
system is that no special programming hardware is required. Programs that you write on your PC
using free Windows software can
be downloaded straight into the
microcontroller chip with a direct
cable connection.
This low-cost approach also means
Table 1: PICAXE-08M Pinouts and Functions
Pin
1
2
3
4
5
6
7
8
Function Description
+V Power supply positive (4.5V to 5V only)
SERIN Serial input for programming
IN 4/OUT 4 General-purpose input/output 4
IN 3 Digital input 3
IN 2/OUT 2 General-purpose input/output 2
IN 1/OUT 1 General-purpose input/output 1
OUT 0 Output 0 (also used as serial output)
0V Power supply ground (0V)
Use
LDR input
Switch input
Green LED
Yellow LED
Red LED
-
siliconchip.com.au
that students can use the whole programming system at home.
Naturally, the easiest-to-use
member of the PICAXE family,
the PICAXE-08M, was chosen for
use in this project. It is contained
in an 8-pin dual-in-line (DIL) IC
package. Two pins connect to
the power source, two more are
used for downloading the BASIC
programs while the remaining
four are general-purpose inputs
and outputs. These can be used
to control LEDs and relays, make
sounds, read sensors, etc.
Some pins have alternate
functions, which we’ll explore in
more detail in future articles.
Schools Experimenter
In short, the Schools Experimenter board provides a socket for
the PICAXE-08M microcontroller
as well as a series of simple
devices (LEDs, switches, etc) that
you can control and interrogate
with your BASIC programs.
A socket is also included for
programming purposes.
More detail is to be had from the
complete circuit diagram in Fig.1.
Red, yellow and green LEDs
are connected to the first three
outputs (outputs 0, 1 and 2) of
the PICAXE. A 330W resistor in
series with each output limits LED
current flow to less than 10mA.
A piezo transducer can also be
connected to output 2 for making
sounds and playing musical tunes.
Not surprisingly, a miniature
push-button switch (SW1) on
input 3 and a light dependent
resistor (LDR) on input 4 act as
the on-board input devices.
Each input has a 10kW pulldown resistor (to the 0V rail) to
ensure correct operation; this will
be explained in more detail next
month. A serial download socket
and 10kW and 22kW resistors
make up the computer interface
for programming.
The PC board also contains
provision for a 10-pin header
strip (H1) that enables each
of the input/output pins to be
connected to a breadboard for
more advanced experiments.
The three holes marked “H2”
are reserved for future use and
can be ignored at present. Finally,
a 100nF capacitor is included for
siliconchip.com.au
CALLING ALL SCHOOLS
with electronics/technology courses:
Want some FREE PICAXE PC boards?
Here’s an offer you don’t see every day: FREE PICAXE
blank project PC boards. Yes, free. Or gratis, zip, zilch,
without charge, nothing... just as long as you qualify
AND you’re quick!
To celebrate the launch of our “PICAXE in Schools”
column, Revolution Education Ltd has kindly donated
2000 “Schools Experimenter” PC boards, as used in
this feature, to be given away, free of charge, to
Australian and New Zealand High Schools.
The first 200 teachers to email (NOT phone!) their
full name, school, position and school address to
siliconchipoffer<at>microzed.com.au
will each receive not 1, not 2 but a whole 10 PC boards
– absolutely free of charge!
Your email will be acknowledged within 24 hours
but please allow up to 30 days for delivery.
* The fine print: limit 10 boards per school. Blank PC boards
and programming sockets only supplied (ie, no components), as
shown above. Strictly while stocks last, and in order of receipt.
For special deals on kits of parts, visit
www.microzed.com.au
high-frequency power supply decoupling.
Table 1 shows the function of
each physical pin on the PICAXE08M chip and how it is used on
the Experimenter’s board.
Note that the 4-pole dual-in-line
(DIL) switch on the PC board can
be used to disconnect the LEDs,
switch and LDR from the PICAXE
input/outputs. This allows the
input/outputs to be used for other
purposes when experimenting
with a breadboard.
For the time being, all four
contacts of the switch must be
closed (set to the “ON” position).
Putting it all together
Assembly of the Schools ExperiMay 2005 87
Fig.1: the complete circuit diagram shows how simple it is – there are only about a dozen components!
menter is quite straight-forward.
Begin by soldering all of the resistors in place using the overlay
diagram in Fig.2 as a guide.
We’ve shown all the resistor
colour codes (all three of them) in
a table elsewhere in this feature.
Alternatively (or as well as?), a
quick check with your multimeter
will also confirm resistance values.
Next, install the IC socket for
the microcontroller (IC1) followed
by the two switches (SW1 & SW2).
The 4-pole DIL switch (SW2) must
go in the correct way around (see
photos).
The serial programming socket
can be installed next; make sure
that it is pushed right down on the
surface of the PC board before soldering. Follow with the three LEDs,
The completed schools Experimenter, ready for the
addition of a 4.5V battery pack (ie, 3 x AA cells, NOT 4!)
88 Silicon Chip
siliconchip.com.au
Fig.2: Here’s how to place the
components on the PC board. Use a
socket for IC1.
LDR and 10-pin header (H1). Note
that with the flat (cathode) sides
of the LEDs must be oriented as
shown, while the LDR can sit about
5mm proud of the board surface.
The last job is to solder the wires
for the battery clip and piezo to
their respective pairs of pads.
Pass the wires through the adjacent strain-relief holes before
soldering (see photos). Make sure
that the positive (red) wires connect to the pads marked “+”!
When inserting the PICAXE-08M
into its socket, it is very important
that the indented (pin 1) end is
oriented as shown on the overlay
diagram and photos.
Your completed project should be
powered from a 3 x AA alkaline cell
(4.5V) battery pack or a regulated
5V DC supply.
Never use a 9V PP3 battery,
as this is way above the voltage
rating of the chip. Take particular
care that you have the power leads
around the right way; otherwise,
you’ll destroy the PICAXE chip!
Programming introduction
The easiest way to check that
your board is working properly is to
type in a short BASIC program and
download it to the PICAXE micro,
so let’s do that next.
Those new to PICAXE programming will first need to download the
Programming Editor software from
www.picaxe.co.uk and obtain a
low-cost download cable from their
local distributor (see parts list).
Connect the download cable to
the serial port at the back of your
siliconchip.com.au
Yeah, we know, this photo is turned 90° compared to the overlay at left. But
between the two, you should be able to identify and place all components.
Parts List – PICAXE Schools Experimenter
1
1
1
1
1
1
1
1
1
1
AXE092 PC board
3.5mm stereo socket
miniature pushbutton switch (SW1)
4-pole DIL switch (SW2)
8-pin IC socket
miniature piezo transducer
10-pin SIL 2.54mm (0.1”) pitch header (H1)
100nF polyester capacitor (code 100n or 0.1mF)
battery clip
3 x AA battery holder
Semiconductors
1 PICAXE-08M
1 5mm green LED
1 5mm red LED
1 5mm yellow LED
Resistors (0.25W 5%)
3 10kW
3 330W
1 miniature LDR
1 22kW
Also required (not in kit)
PICAXE Programming Editor software (v4.1.0 or later)
PICAXE download cable (part no. AXE026)
3 x AA alkaline cells
Obtaining kits and software
The design copyright for this project is owned by Revolution
Education Ltd. Complete kits (part no. AXE092K) or the PC
board only (part no. AXE092) for this project are available from
authorised PICAXE distributors – see www.microzed.com.au
and resellers. Phone MicroZed on (02) 6772 2777.
The PICAXE Programming Editor software can be downloaded
free of charge from www.picaxe.co.uk or ordered on CD
(part no. BAS805).
May 2005 89
Sample Program
main:
high 0
pause 500
low 0
high 1
pause 500
low 1
high 2
pause 500
low 2
goto main
‘red LED on
‘wait 0.5 second (=500ms)
‘red LED off
‘yellow LED on
‘wait 0.5 second (=500ms)
‘yellow LED off
‘green LED on
‘wait 0.5 second (=500ms)
‘green LED off
‘jump back to start
Fig. 3: a screen grab of the chip and port setup from the programming editor software. Make sure you set the details
correctly or it won’t work! In the background is the sample program, again reproduced in Fig. 4 (above right).
computer. Note that if you have a
late-model laptop without a serial
port then you will also need to
purchase the USB to Serial Adapter
(part no. USB010).
After installing and running the
Programming Editor software,
select View -> Options from the
toolbar and configure the software
for “PICAXE-08M” mode (see Fig.3)
Also, make sure the serial port
number (COM1, COM2, etc.) corresponds to the physical port where
the cable is connected and then
click OK.
Now type in the test program
shown in Fig.4.
Be sure to include all punctuation, including the colon (:) after
the first word “main”; this tells the
computer that you want the word
“main” to be a label.
This enables the program to later
use the command “goto main”, i.e.
jump back to the start.
When the program is complete,
click PICAXE -> Run to download
the program into the PICAXE chip.
Note that programming can only
be successful if the cable is connected and power is applied to the
PC board.
All being well, the three LEDs will
light in turn.
Don’t be worried that the red LED
on output 0 flickers during a download; this is normal, as the LED is
indicating that
the computer and
PICAXE chip are
communicating.
Troubleshooting
If the program
fails to download,
disconnect power
and recheck all
of your soldering
and component
placement and
orientation.
If no problems
can be found,
use your multimeter to verify
that there is 4V The PICAXE has a maximum 5V supply and operates quite
- 5V between the happily at 4.5V. For this you need either a special threepower pins (1 & cell “AA” battery holder, as shown here, or a four-cell
8) of the PICAXE modified to take three cells, to ensure that the 5V limit
chip when power isn’t exceeded.
is connected.
Finally, check that the download look at how to write programs that
cable is fully inserted in its socket respond to inputs (both digital and
and that the serial (COM) port analogue) and how to make sounds
chosen under the View -> Options on the piezo transducer.
In the meantime, if you’re an
menu matches the port that the
electronics or technology student
cable is physically plugged into.
in an Australian or NZ school, make
Summary
sure you show this article to your
Congratulations – you have teacher so your school can claim
now assembled and programmed their 10 PC boards.
Remember that it is strictly first
your first PICAXE microcontroller
SC
project! Next time around, we’ll come, first served!
Resistor Colour Codes
o
o
o
Qty.
1
3
3
90 Silicon Chip
Value
22kW
10kW
330W
4-Band Code (5%)
red red orange gold
brown black orange gold
orange orange brown gold
5-Band Code (1%)
red red black red brown
brown black black red brown
orange orange black black brown
siliconchip.com.au
|