This is only a preview of the June 2007 issue of Silicon Chip. You can view 35 of the 104 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 "20W Class-A Amplifier Module; Pt.2":
Items relevant to "A Knock Detector For The Programmable Ignition":
Items relevant to "Versatile 4-Input Mixer With Tone Controls":
Items relevant to "Fun With The New PICAXE 14-M":
Items relevant to "Frequency-Activated Switch For Cars":
Purchase a printed copy of this issue for $10.00. |
Even More PICAXE
Developments . . .
As well as the new PICAXE 14-M introduced over the past few
pages, Revolution Education Ltd, the UK based developers of the
PICAXE system, have been hard at work for the last few months.
Clive Seager talks us through the latest PICAXE developments.
PICAXE 14-M
+V
Serial in
ADC 4 /input 4
Infrain/Input 3
Input 2
Input 1
ADC 0 / Input 0
PICAXE-28X1
1
14
2
13
3
12
4
11
5
10
6
9
7
8
0V
Output 0 / Serial Out / Infraout
Output 1
Output 2
Output 3
Output 4
Output 5
The new PICAXE-14M has been primarily designed for
those 08M projects “when you need just one more input /
output!”. The main difference is that the 14M has 11 i/o
pins (5 inputs and 6 outputs), as opposed to the 08M’s 5 i/o
pins. The pin-out of the new chip is shown in figure X, and
those of you who like to use stripboard or breadboards to
test out your projects will be pleased to see the very straight
forward ‘inputs on left – outputs on right’ layout.
V+
08M
0V
RXD
OUT0
IN4
OUT1
IN3
OUT2
IN2
OUT3
IN1
OUT4
IN0
OUT5
14M
Apart from the pin-count, the 14M is almost identical to
the 08M, with the same memory capacity (approximately 80
lines of code) and music ring tone commands. The 08M and
14M are also pin compatible, so with care it is also possible
to design a system that will support both parts.
Reset
ADC0 / In a0 / ULPWU
ADC1 / In a1
ADC2 / In a2
ADC 3 /in a3
Serial In
Serial Out
0V
Resonator
Resonator
In0 / Out c0 / timer clk
In1 / Out c1 / pwm1
In2 / Out c2 / pwm2
In3 / Out c3 / i2c scl / spi sck
1
28
2
27
3
26
4
25
5
24
6
23
7
22
8
21
9
20
10
19
11
18
12
17
13
16
14
15
Output 7
Output 6
Output 5
Output 4
Output 3
Output 2
Output 1
Output 0
+V
0V
In 7 / Out c7 / ser rx kb data
In 6 / Out c6 / ser tx / kb clk
In 5 / Out c5 / spi sdo
In 4 / Out c4 / i2c sda / spi sdi
and features at an equivalent, or even lower, cost. Therefore Revolution have recently announced the launch of the
PICAXE-28X1, which is based upon the new PIC16F866,
and supersedes both the 28A and 28X.
The 28X1 is pin and program compatible with previous
versions, so to upgrade an existing design you can simply
swap chips over. However the new 28X1 has a much larger
memory capacity, which in turn means more features and
support for a longer user program.
In fact the 28X1 is a complete new ‘generation’ of PICAXE
chip, in which the compilers and bootstrap firmware have
been completely re-written. At the same time Revolution
have tried to include all the commonly requested extra
features from customers.
28X1 New Features
Program / Data Memory
PICAXE-28X1
The original PICAXE chip, the PICAXE-28A, was based
upon one of the very first ‘self re-writeable’ PIC chips
that Microchip produced, the PIC16F872. This was later
followed by the enhanced PICAXE-28X, based upon the
PIC16F873A.
However, as microcontroller technologies have progressed,
both these PICs have now been effectively superseded by a
new generation of PIC chips, which have additional memory
78 Silicon Chip
The 28X1 program memory capacity has been doubled
to 4096 bytes. This equates to approximately 1000 lines
of BASIC code. The data eeprom memory (for read/write
commands) has also been doubled to 256 bytes.
Variables
The 28X1 directly accessible variables (b0, b1 etc.)
have also been doubled to 28 bytes (14 words). However a
completely new feature is the scratchpad, which is a new
separate, additional 128 byte RAM area for rapid saving of
siliconchip.com.au
CON2
+4.5V*
temporary
variable data. A common example
of use would
DB9
IO
PROGRAMMING
RESISTORS
CHANNELS
2
be in saving
a long received serial data
stream from a GPS
module or for storing arrays.
λ via the
330Ω∗
3 scratchpad address can be directly
Each
accessed
1
2
13
OUT0
PUT and GET commands.
However
a more versatile use is
22k RXD
EQUIVALENT
λ
330Ω∗
PICAXE
10k(scratch pad pointer),
via the5 ptr
3
08M 12 which is a unique virtual
OUT1
FOOTPRINT
‘pointer variable’. IN4
λ
330Ω∗
11
The pseudo variable4 name ‘<at>ptr’
can then be used in
6x
IN3
OUT2
PROGRAM
commands
as if it was a PICAXE
normal variable330Ω∗
but in λuse actuLEDS
EDITOR
10
ally
to the5 current
address
on the scratchpad
(TO‘reads/writes’
PC
14M
IN2
OUT3
SERIAL PORT)
pointed
to by ptr. Similarly if ‘<at>ptrinc’
is330Ω∗
used as aλ variable
9
6
in a command, read/write
is to theOUT4
current pointer address
IN1
λ to point
330Ω∗
K
and
then Kthe pointer (ptr)
automatically
increments
8
7
14
LEDS A
A
IN0
OUT5
to the next address.
PICAXE
Therefore ‘<at>ptrinc’ can be* WITH
repetitively
RED, GREEN ORused
YELLOW in
LEDS com14M
SUPPLY
CAN
BE 3V AND 330
Ω
7
mands
such as serin
to save data
in
different
scratchpad
RESISTORS CAN BE OMITTED
14
addresses1 e.g.
Hibernate / Sleep
2007
new Picaxe 14m – led chaser
Reset
ptr = 10
serin 1,N2400, <at>ptrinc, <at>ptrinc, <at>ptr
The reset command will reset the chip, clearing variable
values and restarting the program.
In this example the three serial bytes received will be
saved in scratchpad positions 10, 11 and 12 and can then
be later accessed, for example, by GET commands.
An additional 96 bytes of memory are available via the
traditional peek/poke commands and so the 28X1 now has
over 250 user byte variables.
Setint
Resonator
a) Serial Communications
SC
The 28X1 can use either an internal (max. 8MHz) or
external (max. 20MHz) resonator. The setfreq command is
used to switch between frequencies (internal and external
frequencies may be used within the same program). To
reduce PCB costs/simplify circuits the resonator may be
totally omitted if desired. If the external resonator fails,
operation will automatically drop back to the 4MHz internal resonator.
Some commands with specific timing (eg, readtemp or
irout) always use the internal resonator, switching back to
normal timing after the command completes.
New Commands
Table/Readtable
A 256 byte data lookup table can now be defined when
the program is written and automatically downloaded (as
part of the program) into the 28X1. This is a very convenient
and efficient way of storing data, eg, for storing LCD menu
text, calibration values etc.
The new hibernate command enters a permanent low
power sleep state. The 28X1 can then only be woken by a
hardware interrupt, eg, a hardware serial or i2c reception.
Play / Tune
The 28X1 supports the mobile phone ring tone play and
tune commands (as 08M) on any output pin.
Calibadc
The ADC reading within PICAXE chips is based upon the
supply voltage, which can sometimes vary over time (eg, as
a battery runs down). The new calibadc command uses a
fixed internal 0.6V source to provide a known voltage ADC
reading. This enables users to calibrate their ADC readings
to a known fixed voltage, regardless of battery state.
The polled interrupt now also has the option to operate
when a condition is NOT true, as well as the original ’match
condition’ option.
Enhanced Peripheral interfacing
Serial communication can now be carried out in three
different ways:
1) serin/serout act via the standard input/output pins
as before. However the serin commands now support a
timeout feature.
2) serrxd and sertxd act via the PICAXE download cable.
This enables user program data to be both transmitted and
received via the download pins of the 28X1.
3) hserin and hserout are a more advanced method of
communication via the on-board serial hardware pins.
This allows advanced features such as wake-up from sleep,
background receive and much higher serial baud rates. The
background receive allows serial data to be automatically
saved into the scratchpad area as the PICAXE chip completes
other tasks.
b) I2C
The 28X1 can now act as an I2C master or I2C slave.
The new slave mode is fully automatic and is the rec-
Pauseus
5V
The additional pauseus command creates a smaller time
delay than pause. Pauseus operates in 10us multiples.
MASTER
Timer
Data – SDA
The 28X1contains a general use 16 bit background timer/
counter. When in timer mode this timer runs in the background at a user defined frequency (eg every second). The
timer variable can be read at any time. Timer overflow is
used to set a flag bit (toflag).
When in counter mode, the timer records the number of
rising edge pulses on input 0. This occurs in the background,
while the PICAXE program performs other tasks.
siliconchip.com.au
5V
4.7k
4.7k
Clock – SCL
0V
5V
SLAVE 1
SCL
5V
UP T0 120
SLAVES ARE
SUPPORTED
SLAVE 2
SCL
SDA
SDA
0V
0V
0V
June 2007 79
ommended method of networking multiple PICAXE-28X1
chips. The slave features are completely automatic, so the
PICAXE chip acting as a slave can still run a normal program, with the I2C slave read and writes occurring in the
background without program intervention.
The I2C interface operates in the same manner as the
popular 24LCxx EEPROM chips, with the 128 scratchpad
bytes as the read/write memory area.
This method theoretically allows one 28X1 master to
control over 120 28X1 slaves, all connected via a common
two wire I2C bus.
However the software has also been enhanced and now
supports improved compilers for all PICAXE chips. The
enhanced compilers support many new programming structures, such as ‘do…loop’, ’if…elseif…endif’ and ‘select case’
to simplify the process of writing PICAXE programs. To use
these new structures simply make sure you have selected
the ‘enhanced compiler’ from the View>Options>Editor
menu.
Simulation
c) SPI (3 wire)
The 28X1 supports 3-wire (SPI) communications on
input/output pins or via the dedicated hardware pins
(which provide a faster transfer rate). Normal input/output
pin support is included to allow both i2c and SPI on the
same system (as hardware SPI and hardware i2c use the
same pins).
d) Infrared
The 28X1 supports infrared input (with timeout) and
output. Sony SIRC format.
e) One Wire
The 28X1 fully supports the Dallas/Maxim 1-wire protocol, allowing direct control of all 1-wire parts.
Enhanced Mathematical Capability
The 28X1 has enhanced mathematical capabilities, such
as support for brackets within mathematical statements:
eg, let b4 = b1 + (b2*5)
A number of new mathematical and trigonometric
functions (sin, cos, sqr, <<, >> etc) are now supported, as
well as new commands for converting number types (eg
bintobcd, bintoascii etc.)
Another new feature within the software is the ability to
simulate, and single-step through BASIC program listings.
This allows you to try out your BASIC programs before they
are even downloaded to the PICAXE chip.
During simulation, each line is highlighted as it is carried
out and an on-screen graphic of the PICAXE chip enables
inputs to be changed and the state of output pins to be
studied. Naturally all variables can also be viewed as the
program simulates.
Summary
Programming Editor Software
The free PICAXE Programming Editor software has been
updated to support the new 14M and 28X1 new parts.
Please make sure you are now using version 5.1.0 or later
– if you need to upgrade, a free patch is available on the
www.picaxe.co.uk website.
The new PICAXE-14M, PICAXE-28X1 (and the new 40
pin option, PICAXE-40X1) provide a range of enhanced
features and/or pinout options compared with existing
PICAXE parts. For further details please visit the PICAXE
website at www.picaxe.co.uk
SC
Next month: We look
at putting
thePage
28X1
30/3/07
2:12 PM
1 to work, creating a PICAXE MP3 player.
RF_SiliconChip_60x181mm.qxd
Enhanced Compiler
ELECTRO CHEMICALS
Chemical Technology
80 Silicon Chip
• Dust Off • Freezing Spray • Electronic Cleaning Solvent No. 1
• Electronic Circuit Board Cleaner • Electrical Contact Cleaner Lubricant
• Video Head Cleaner • Ultrasonic Bath Cleaner • Isopropyl Alcohol
• Protek • Contact Treatment Grease • Contact Treatment Oil
• Solvent Diluted Oil • Contact Cleaning Strip • Circuit Board Lacquer
• Q43 – Silicon Grease Compound • Heat Sink Compound
Contact us to find your nearest distributor:
sales<at>rfoot.com.au Tel: 02 9979 8311 Fax: 02 9979 8098
Richard Foot Pty Ltd, 14/2 Apollo Street,Warriewood NSW 2102
siliconchip.com.au
|