SHARPENING YOUR TOOLS OF CREATIVITY
PICAXE PRIMER
■ BY RON HACKETT
INTRODUCTION TO THE
PICAXE-18M2 PROCESSOR
As promised, in this month’s Primer we’re going to take our first look at the
new PICAXE-18M2 processor. If you read the brief “teaser” of new 18M2
features that I included in the previous installment, you already know that it’s
an impressive processor, to say the least. (If not, see Figure 1 which is
reprinted from that installment.) Compared to the older 18M, the 18M2 has
eight times the program memory, twice the number of general-purpose
variables (b0 to b27), more than five times as many storage variables (that
can be accessed via the peek and poke commands), and 256 bytes of
EEPROM storage that aren’t decreased by the size of the program. The 18M2
can also run up to four times faster than the 18M, and do so with voltages as
low as 1.8 volts which means that battery-powered projects now only need a
two AA-cell supply to function correctly.
The 18M2 processor has a total of 16 I/O lines, and 13 of them are
bi-directional which provides a
considerable amount of flexibility for
designing projects. In addition, up to
10 of the I/O lines can be configured
as ADC inputs. Even better, the
18M2 is the first PICAXE processor to
include internal capacitive touch-sensitive sensors. Any (or all) of the
ADC inputs can be configured to
automatically detect the touch of a
human finger. All it takes is a small
piece of metal as the sensor plate –
no switches or other moving parts
are required. In fact, the finger
doesn’t actually need to touch the
metal, just come very close. This means
that it will be easy to design custom
touch-sensitive “key” pads, and then
print a custom graphic layout on a
self-adhesive sheet which will result in
a very professional-looking project.
18M2
Program Storage (bytes) 2048
General Purpose Vars (bytes) 28
Storage Variables (bytes) 256
EEPROM Storage (bytes) 256
Max Operating Speed (MHz) 32
Min Operating Voltage (V) 1.8
18M
256
14
48
256-prog
8
3.0
■ FIGURE 1.
Comparison of
18M2 vs. 18M
selected features.
As I mentioned last time, the
18M2 also includes several new
software enhancements. For
example, there’s a new built-in time
variable that automatically keeps
track of elapsed time (in seconds) in
the background while your program
is carrying out other tasks. This
means that a project will be able to
include a real-time clock feature
without necessitating additional
hardware or complicated software
interrupt routines. The time variable is
reset to 0 each time your program is
run, but a new value can be assigned
to it at any point during a program,
so it can be manipulated as simply as
any other variable in a program. Also,
the 18M2 will be able to run up to
four different program tasks in
parallel at the same time by rapidly
switching among the various program
“threads.” This new capability isn’t
multitasking in the strict sense, because
program instructions are still being
executed one at a time. However, the
16
December 2010