accesses a new 16-bit background
timer/counter, with a user-accessible
timer variable. It can operate in one
of two modes: timer mode and
counter mode. In timer mode, your
program can set up a timer that runs
in the background and increments at
a frequency you can specify, e.g.,
once per second. “In the
background” means that your
program can go about its business
and check the timer variable
periodically to determine its current
value. In other words, it’s possible to
include a real-time clock function in
your program without needing an
external clock chip; we will do
exactly that in the near future. In
counter mode, your program can
count the number of pulses received
on input 0 (again, in the background)
so it can be carrying out other tasks
simultaneously.
Pins 13, 22, 23, and 25 are all
used to implement the 28X1’s new
hardware PWM command which is
used for advanced motor control and
is a more powerful alternative to the
more traditional “pwmout” command
(pins 12 and 13) which we will also
implement in an upcoming Primer
installment.
Pins 14, 15, and 16 provide the
necessary I/O lines to implement the
standard three-wire SPI protocol.
SPI is a much faster alternative to
RS-232 serial communications; many
inexpensive peripheral SPI chips are
readily available to carry out a variety
of communications functions. For
example, the Max7219 is a 24–pin
chip that can be used to interface
with up to eight seven-segment LED
displays. An upcoming Primer I/O
project will use the MAX7219 to
implement a stand-alone, four-digit
seven-segment LED display.
I’ve saved the best until last —
pins 17 and 18 can now be used in
conjunction with the new hardware-based “hserin” and “hserout”
commands. These commands
support much higher serial baud
rates than the older serin and serout
commands (which are also still
available). More importantly, hserin
can operate in the background and
automatically save the received data
in a special area of memory. This
means that your program no longer
has to sit and wait for serial input; it
can be doing other tasks while serial
data is being received and when it’s
convenient, it can retrieve the
received data for processing.
In addition to the new features
whose presence is clearly announced
on the 28X1’s pin-out, there are
many additional new commands and
improvements to older commands
that can be discovered by reading
the documentation. Don’t forget, you
will need to install the latest version
of the Programming Editor software
(available at www.rev-ed.co.uk/
picaxe) to be able to use these new
features in your programs. We’ll
explore the vast majority of them in
detail as we need them in our various
I/O projects in the coming months.
In the meantime, the following
summary list of the major
improvements in the 28X1 should
whet your appetite:
• ADC Commands (calibadc,
calibadc10): In the past, ADC
readings have been based on the
supply voltage. Therefore, in battery-powered systems, changes in the
supply voltage produced inaccuracies
in the ADC readings. The new
commands allow access to a fixed,
internal 0.6V supply for increased
accuracy.
• Data Storage Table (table,
Reset - 1
ADC 0 / In A0 / ULPWU - 2
ADC 1 / In A1 - 3
ADC 2 / In A2 - 4
ADC 3 / In A3 - 5
Serial In - 6
Serial Out - 7
Gnd - 8
Resonator - 9
Resonator - 10
In 0 / Out C0 / timer clock - 11
In 1 / Out C1 / pwm 1-12
In 2 / Out C2 / hpwm A / pwm 2 - 13
In 3 / Out C3 / i2c sci / spi sck - 14
PICAXE PRIMER
readtable): Allows for a 256-byte
data lookup table in EEPROM; we’ll
find it useful for LCD menu text.
• I2C Commands (hi2cin, hi2cout,
hi2csetup): The 28X1 is able to
function as either an I2C master
or slave which (among other
advantages) allows for the networking
of multiple 28X1 processors.
• IR Commands (irin, irout): IR
communication can now be
implemented on any I/O pin.
Also, the irin command includes a
“timeout” feature so your program
won’t hang if data is not received.
• Keyboard Input (kbin): Similar to
the older “keyin” command, but now
also includes a timeout feature.
• Memory Access (get, put): Provide
access to the 128-byte scratchpad
memory area for additional data/
variable storage.
• One-Wire Commands (owin,
owout, readowsn): Provides full
support for the 1-Wire protocol on
any I/O pin.
• Power-reduction Commands
(disablebod, enablebod, hibernate):
Implements the new ULPWU
feature. We’ll explore disablebod
and enablebod next.
• Serial Communications
■ FIGURE 2.
PICAXE-28X1
pin-out.
28 - Out 7
27 - Out 6
26 - Out 5
25 - Out 4 / hpwm D
24 - Out 3
23 - Out 2 / hpwm B
22 - Out 1 / hpwm C
21 - Out 0
20 - +V
19 - Gnd
18 - In C7 / Out C7 / ser rx / kb data
17 - In C6 / Out C6 / ser tx / kb clock
16 - In C5 / Out C5 / spi sdo
15 - In C4 / Out C4 / i2c sda / spi sdi
August 2008 17