Picaxe Manual [Getting Started]-01
Picaxe Manual [Getting Started]-01
www.picaxe.co.uk
revolution
www.picaxe.co.uk GETTING STARTED
Section 1 2
Contents:
SECTION 1 - GETTING STARTED
About this manual ............................................................................................ 3
This first section provides general information for getting started with the PICAXE
system. No prior understanding of microcontrollers is required. A series of
tutorials introduce the main features of the system.
For more specific information, syntax and examples of each BASIC Command
please see section 2 ‘BASIC Commands’.
The software used for programming the PICAXE is called the ‘Programming
Editor’. This software is free to download from www.picaxe.co.uk. This manual
was prepared using Version 4.1.0 of the Programming Editor software. Please
ensure you are using this version (or later) of the software, as earlier versions may
not support all the commands and features described.
If you have a question about any command please post a question on the very
active support forum at this website.
Quick Start
It is strongly recommended that you read the first few chapters of this manual
before using the PICAXE system. However if you cannot wait to get going, this
quick start guide provides a summary of the information explained in much more
detail later in this manual!
1. Install the Programming Editor software from the CDROM (or download
from www.picaxe.co.uk).
2. Insert the serial cable into the 9 pin serial COM socket at the rear of the
computer. (See the USB adapter section of the manual if you wish to use the
USB port).
3. Start the Programming Editor software (click Start>Programs>Revolution
Education>Programming Editor). Then click View>Options menu to display
the Options panel (this may also automatically appear on startup). On the
‘Mode’ tab select the correct type of PICAXE chip. On the ‘Ports’ tab also select
the appropriate serial COM port (the port where you connected the serial
cable).
4. Connect an LED and 330 ohm resistor to the output pin 4 of the PICAXE
chip. On ‘home-made’ or prototype circuits connect the LED/resistor between
the output pin and 0V. On project boards (which have a Darlington transistor
buffered output) connect the LED/resistor between V+ and the output pin.
Ensure correct polarity of the LED.
5. Connect the PICAXE cable to the hardware.
6. Connect the 4.5V (3xAA battery) or 5V regulated power supply to the project
board. Do NOT use a 9V PP3 battery.
7. Using the software, type in the following program:
main: high 4
pause 1000
low 4
pause 1000
goto main
8. Click the PICAXE>Run menu to download the program to the hardware. After
the download the output LED should flash on and off very second.
V+
output pin 4
330R
330R
project board
output 4
0V connection
What is a microcontroller?
A microcontroller is often described as
a ‘computer-on-a-chip’.
DE
F
CL
EA
The PICAXE system overcomes this problem by use of a much simpler, easy to
learn, BASIC programming language. Programs can also be created graphically by
use of the flowchart editor.
Output transducers are electronic devices that can be switched on and off by the
process block of the electronic system. Some of the output transducers of the
electronic toy are:
• a motor to make the eyes and mouth move
• a speaker to produce sounds
• an infrared LED (light-emitting diode) to send signals to other toys.
infra-red
receiver motor
light infra-red
dependent microcontroller transmitter
resistor
speaker
tilt switch
press switch
The PICAXE uses a simple BASIC language (or graphical flowcharts) that younger
students can start generating programs with within an hour of first use. It is much
easier to learn and debug than industrial programming languages (C or assembler
code).
Unlike other BASIC ‘module’ based systems, all PICAXE programming is at the
‘chip’ level. Therefore instead of buying an expensive pre-assembled (and difficult
to repair) surface mount module, with the PICAXE system you simply purchase a
standard chip and use it directly in your project board.
The PICAXE ‘Programming Editor’ software is free and so the only cost per
computer is the download cable (£3). In the educational environment this
enables students to buy their own cable and for schools to equip every single
computer with a download cable. Other systems that require an expensive
programmer or ‘module’ are generally too expensive to implement in this way.
Finally as the PICAXE chip never leaves the project board, all leg damage (as can
occur when the chip is moved back and forth from a programmer) is eliminated.
If you wish to make your own PCB some reference designs are available at the
PCB section of the PICAXE website at www.picaxe.co.uk
PCB samples are available for educational use in the popular realPCB and PCB
Wizard formats.
The PICAXE bootstrap code is not available for programming into blank
microcontrollers. You must purchase PICAXE microcontrollers (rather than blank,
un-programmed microcontrollers) for use in the PICAXE system.
All these items are included within all the PICAXE ‘starter’ packs.
To run the software you require a computer running Windows 95 or later. Any
computer that runs the Windows operating system will work in textual ‘BASIC’
mode, however a Pentium 3 processor or later is recommended for graphical
flowchart work.
The computer also requires a 9 pin serial port for connecting the download cable.
If your laptop does not have this type of connector a USB to serial adapter (part
USB010) will also be required. See the Serial Port setup section for more details.
Within a chip size there are also up to 3 variants (e.g. for the 18 pin PICAXE the
18, 18A and 18X variants are available). The principle difference between the
variants is the amount of memory (ie how long a program can be downloaded
into the chip). The higher specification variants also have some increased
functionality (e.g. high resolution analogue inputs and i2c compatibility,
described in the next section). Any project can be upgraded to the next level
variant at any point (e.g. if your program is too long for the variant of chip used)
by simply replacing the microcontroller in your circuit with the upgraded variant.
All upgraded variants are pin and program compatible with the lower
specification device.
The following table shows the primary functional differences between the
available PICAXE microcontrollers.
Software Installation
Computer Requirements:
To install the software you require a computer running Windows 95 or later with
approximately 20MB free space. Any computer that runs the Windows operating
system will work in textual ‘BASIC’ mode, however a Pentium 4 processor or later
is recommended for graphical flowchart work.
Installation:
1) Start up and log into your computer (some operating systems require that you
log in as ‘Administrator’ to install software).
2) Insert the CD, or download and run the installation file from the software
page at www.picaxe.co.uk
3) Follow the on-screen instructions to install the software. On older computers
you may be instructed to restart the computer after installation.
4) Insert the cable into the 9 pin serial port at the back of the computer. If your
laptop does not have a 9 pin serial port, a USB to serial adapter will need to
be installed. See the ‘USB Adapter’ section for more details. Note the ‘COM’
port number used (some computers are labelled A and B rather than
numbers – A is generally COM1 and B is COM2).
5) Click Start>Programs>Revolution Education>Programming Editor to start the
software.
6) If the Options screen does not automatically appear, click the View>Options
menu. On the ‘Mode’ tab select the size and type of PICAXE microcontroller
you are using. On the ‘Port’ tab select the appropriate serial COM port then
click OK.
The USB interface system is an intelligent system that requires the connected
device to automatically configure itself when connected to the computers USB
port. Although it is theoretically possible to build a USB version of the PICAXE,
the extra memory required would increase the cost of every single PICAXE chip by
almost £3 ($5).
Therefore an alternate system is used. The user purchases a one-off low-cost ‘USB
to serial’ adapter, which is a universal device that allows the standard download
cable and chips to be programmed via the USB port. These universal adapters are
approximately £15 ($20) and can be used with all serial devices the user may
own.
(Please see the USB to Serial Adapter (USB010) help file for more detailed
instructions. This is available on the software page at www.picaxe.co.uk or the
\USB folder of the CDROM).
Notes:
• Windows XP users must use the XP certified driver for correct operation. This
is available from the software page at www.picaxe.co.uk
• Windows 95 and NT do not support USB devices.
• The drivers on the PICAXE website only apply to part USB010, which uses the
‘Prolific’ chipset. These adapters are the only brand for which Technical
Support is available. However all other brands of adapter should work, once
the correct driver for the used Windows version is installed.
Do not use a 9V PP3 battery, this is above the maximum rating of the PICAXE
chip and will cause permanent damage. Note that most 3xAA and 4xAA battery
boxes use the same ‘press-stud’ style connector and battery snap/clip as a PP3 9V
battery. Note the provision of this style of clip does not mean that a project board
should use a PP3 9V battery, it is just unfortunate that all battery boxes use the
same style connector.
PP3 9V batteries are designed for very low-current, long term applications (e.g. a
smoke alarm or multi-meter). Although a PP3 9V supply regulated to 5V will
work for short periods with a microcontroller, it will drain very quickly when an
output device (e.g. LED, motor or buzzer) is connected. Therefore always use AAA
or AA battery packs rather than 9V PP3 batteries in microcontroller projects (as
used with many portable consumer goods e.g. CD players, LED torches etc.)
Take care when inserting PICAXE chips into your circuit to ensure they are the
correct way around. Take extra care with 18 pin chips, as if inserted ‘upside-down’
the power supply connections will be reversed causing permanent damage to the
chip.
AA Battery Packs
Alkaline AA cells have a nominal voltage of 1.5V, so 3 cells will give 4.5V. If you
wish to use 4 cells, also use a 1N4001 diode in series with the battery pack. The
diode provides voltage polarity protection, and as the diode has a 0.7V drop the
microcontroller voltage will be an acceptable 5.3V (6V-0.7V).
Rechargeable AA cells have a nominal voltage of 1.2V, so 4 cells will give 4.8V.
Take care not to short circuit any battery pack, as the large short circuit current
may cause considerable heat damage or start a fire.
1N4001
>8V 78(L)05 +5V
regulator
+ +
In Out
100n 100u 100n 100u
0V 0V
input input
0V 0V
output output
PICAXE-08 PICAXE-08M
+V 1 8 0V +V 1 8 0V
Serial In 2 7 Output 0 / Serial Out Serial In 2 7 Output 0 / Serial Out / Infraout
In 4 / Out 4 3 6 In 1 / Out 1 / ADC 1 In 4 / Out 4 / ADC 4 3 6 In 1 / Out 1 / ADC 1
Input 3 4 5 In 2 / Out 2 Input 3 / Infrain 4 5 In 2 / Out 2 / ADC 2 / pwm 2 / tune
5V
1 8
22k
serial in
2 7 out 0
serial out
08
in / out 4 3 6 in / out 1
in 3 4 5 in / out 2
10k
1
2
3
0V
See the Serial Download Circuit section of this manual for more details about the
download circuit.
Notes:
1) The 10k/22k resistors must be included for reliable operation.
2) Output pin 0 (leg 7) is used during the program download, but can also be
used as a general purpose output once the download is complete. On the
project boards a jumper link allows the microcontroller leg to either be
connected to the download socket (PROG position) or to the output (OUT
position). Remember to move the jumper into the correct position when
testing your program!
If you are making your own pcb you can include a similar jumper link or small
switch, or you may prefer to connect the microcontroller leg to both the output
device and the program socket at the same time. In this case you must remember
that your output device will rapidly switch on and off as the download takes
place (not a problem with simple outputs like LEDs, but could cause problems
with other devices such as motors).
PICAXE-18 PICAXE-18A
ADC 2 / Input 2 1 18 Input 1 / ADC 1 ADC 2 / Input 2 1 18 Input 1 / ADC 1
Serial Out 2 17 Input 0 / ADC 0 Serial Out 2 17 Input 0 / ADC 0 / Infrain
Serial In 3 16 Input 7 Serial In 3 16 Input 7 / keyboard data
Reset 4 15 Input 6 Reset 4 15 Input 6 / keyboard clock
0V 5 14 +V 0V 5 14 +V
Output 0 6 13 Output 7 Output 0 6 13 Output 7
Output 1 7 12 Output 6 Output 1 7 12 Output 6
Output 2 8 11 Output 5 Output 2 8 11 Output 5
Output 3 9 10 Output 4 Output 3 9 10 Output 4
PICAXE-18X
ADC 2 / Input 2 1 18 Input 1 / ADC 1
Serial Out 2 17 Input 0 / ADC 0 / Infrain
Serial In 3 16 Input 7 / keyboard data
Reset 4 15 Input 6 / keyboard clock
0V 5 14 +V
Output 0 6 13 Output 7
The minimum operating Output 1 / i2c sda 7 12 Output 6
Output 2 8 11 Output 5
circuit for the 18 pin devices is:
Output 3 / pwm 3 9 10 Output 4 / i2c scl
5V
4k7
in 2 1 18 in 1
serial out
2 17 in 0
22k
serial in
3 16 in 7
PICAXE-18
4 15 in 6
5 14
10k
out 0 6 13 out 7
1 out 1 7 12 out 6
2
3 out 2 8 11 out 5
0V
See the Serial Download Circuit section of this manual for more details about the
download circuit.
Notes:
1) The 10k/22k resistors must be included for reliable operation.
2) The reset pin must be tied high with the 4k7 resistor to operate.
3) No external resonator is required as the chips have an internal resonator.
PICAXE-28A PICAXE-28X
Reset 1 28 Output 7 Reset 1 28 Output 7
ADC 0 2 27 Output 6 ADC 0 / In a0 2 27 Output 6
ADC 1 3 26 Output 5 ADC 1 / In a1 3 26 Output 5
ADC 2 4 25 Output 4 ADC 2 / In a2 4 25 Output 4
ADC 3 5 24 Output 3 ADC 3 / In a3 5 24 Output 3
Serial In 6 23 Output 2 Serial In 6 23 Output 2
Serial Out 7 22 Output 1 Serial Out 7 22 Output 1
0V 8 21 Output 0 0V 8 21 Output 0
Resonator 9 20 +V Resonator 9 20 +V
Resonator 10 19 0V Resonator 10 19 0V
Input 0 / Infrain 11 18 Input 7 / Keyboard data In0 / Out c0 / Infrain 11 18 In7 / Out c7 / keyboard data
Input 1 12 17 Input 6 / Keyboard clock In 1 / Out c1 / pwm 1 12 17 In6 / Out c6 / keyboard clock
Input 2 13 16 Input 5 In 2 / Out c2 / pwm 2 13 16 In 5 / Out c5
Input 3 14 15 Input 4 In 3 / Out c3 / i2c scl 14 15 In 4 / Out c4 / i2c sda
5V
4k7
1 28 out 7
ADC 0 2 27 out 6
ADC 1 3 26 out 5
ADC 2 4 25 out 4
ADC 3 5 24 out 3
6 23 out 2
PICAXE-28
serial in
22k
serial out 7 22 out 1
10k 8 21 out 0
9 20
4MHz
1 10 19
2
3 in 0 11 18 in 7
in 1 12 17 in 6
in 2 13 16 in 5
in 3 14 15 in 4
reset
0V
See the Serial Download Circuit section of this manual for more details about the
download circuit.
Notes:
1) The 10k/22k resistors must be included for reliable operation.
2) The reset pin must be tied high with the 4k7 resistor to operate.
3) An external 4MHz 3-pin ceramic resonator is required.
PICAXE-40X
Reset 1 40 Output 7
ADC 0 / In a0 2 39 Output 6
ADC 1 / In a1 3 38 Output 5
ADC 2 / In a2 4 37 Output 4
ADC 3 / In a3 5 36 Output 3
Serial In 6 35 Output 2
Serial Out 7 34 Output 1
ADC 5 8 33 Output 0
ADC 6 9 32 +V
ADC 7 10 31 0V
+V 11 30 Input 7 / keyboard data
0V 12 29 Input 6 / keyboard clock
Resonator 13 28 Input 5
Resonator 14 27 Input 4
In c0 / Out c0 15 26 In c7 / Out c7
In c1 / Out c1 / pwm 1 16 25 In c6 / Out c6
In c2 / Out c2 / pwm 2 17 24 In c5 / Out c5
In c3 / Out c3 / i2c scl 18 23 In c4 / Out c4 / i2c sda
Input 0 / Infrain 19 22 Input 3
Input 1 20 21 Input 2
The minimum operating circuit for the 40 pin device is the same as the 28 pin
minimum circuit (altering the appropriate pin numbers as required).
See the Serial Download Circuit section of this manual for more details about the
download circuit.
Notes:
1) The 10k/22k resistors must be included for reliable operation.
2) The reset pin must be tied high with the 4k7 resistor to operate.
3) An external 4MHz 3-pin ceramic resonator is required.
The minimum download circuit is shown here. This circuit is appropriate for
most educational and hobbyist work.
serial out
Above view
serial in
22k 0V
x x
x x
10k
x
PICAXE
3 2 1 serial out
serial in
22k 0V
10k
1 PICAXE
2
3
1
2
3
2. to PICAXE serial out
3. to PICAXE serial in
5. to PICAXE 0V
Note that the two resistors are not a potential divider. The 22k resistor works with
the internal microcontroller diodes to clamp the serial voltage to the PICAXE
supply voltage and to limit the download current to an acceptable limit. The 10k
resistor stops the serial input ‘floating’ whilst the download cable is not
connected. This is essential for reliable operation.
The two download resistors must be included on every PICAXE circuit (i.e. not
built into the cable). The serial input must never be left unconnected. If it is left
unconnected the serial input will ‘float’ high or low and will cause unreliable
operation, as the PICAXE chip will receive spurious floating signals which it may
interpret as a new download attempt.
3 2 1
180
serial out
Above view
serial in
22k 0V
x x
x x
10k
x BAT85 PICAXE
The BAT85 Shottky diode operate at a lower device voltage than the internal
microcontroller diodes, providing a more accurate voltage reference. The
additional 180R resistor provides additional preventative short circuit and static
protection on the serial output pin.
Download Cables
The standard download cable (part AXE026) consists of a
3.5mm stereo plug, which mates with a stereo socket (part
CON039) on the project board. This type of connection is
more robust and reliable than the Molex header in the
educational environment.
All computer connection is via the serial port (9 pin D connector). Most desktop
computers have this type of connector. If your laptop only has ‘USB’ style
connections, you also require the USB to serial adapter (part USB010). See the
‘USB adapter’ section for more details.
If you have an older computer with a 25pin serial port, you require a 25-9 pin
adapter (part ADA010), which are also available from most high street computer
stores.
Reset Circuit
All 18, 28 and 40 pin PICAXE have a ‘reset’ pin. This pin must be in the high
condition for the PICAXE microcontroller to function. If this pin is left
unconnected the microcontroller will not operate. To tie this pin high connect a
4.7k resistor between the reset pin and V+ supply rail. A reset switch is optional,
but highly recommended. This should be a ‘push to make’ type and connected
between the reset pin and 0V.
All 8 pin PICAXE do not have a reset pin. Therefore to reset the microcontroller
the power supply must be disconnected and then reconnected. Note that, when
using capacitors in your supply circuit, these capacitors may hold enough charge
to keep the microcontroller powered for several seconds after the power supply is
disconnected.
Resonator
All 28 and 40 pin PICAXE require an external resonator (the resonator is internal
in the 08 and 18 pin PICAXE). Note that the internal resonator within the 08 and
18 PICAXE is not quite as accurate as an external resonator. Although this does
not cause any issues with the majority of projects, if a specialised project requires
very high precision a 28 or 40pin PICAXE should be used.
If desired a 2 pin resonator, or 2 pin crystal, can be used with the PICAXE-28X or
40X. In this case two appropriate loading capacitors must also be used with the
resonator/crystal. See the crystal manufacturer’s datasheet for more information.
V+
output pin 4
330R
330R
project board
output 4
0V connection
1. Connect the PICAXE cable to the computer serial port. Note which port it is
connected to (normally labelled COM1 or COM2).
2. Start the Programming Editor software.
3. Select View>Options to select the Options screen (this may automatically
appear).
4. Click on the ‘Mode’ tab and select the correct PICAXE type.
5. Click on the ‘Serial Port’ tab and select the serial port that the PICAXE cable is
connected to.
6. Click ‘OK’
7. Type in the following program:
main: high 4
pause 1000
low 4
pause 1000
goto main
(NB note the colon (:) directly after the label ‘main’ and the spaces between
the commands and numbers)
8. Make sure the PICAXE circuit is connected to the serial cable, and that the
batteries are connected. Make sure the LED and 330R resistor are connected to
output 4.
9. Select PICAXE>Run
A download bar should appear as the program downloads. When the
download is complete the program should start running automatically – the
LED on output 4 should flash on and off every second.
If your program does not download use the check list and hard-reset procedure
described in the next two sections to isolate the mistake.
Hard-reset procedure
The download process involves the PICAXE microcontroller regularly checking
the serial input line for a new download signal from the computer. This is
automatic and not noticed by the PICAXE user. However there can be rare
occasions when the PICAXE does not check the serial input line quickly enough
whilst running its program. These situations can include:
• Corrupt program in PICAXE (e.g. if power or cable removed part way through
a new download)
• Incorrect clock frequency (set by setfreq command)
• Pause or wait commands longer than 5 seconds used in program.
• Use of serin, infrain or keyin within program.
Fortunately it is very simple to resolve this issue, as the very first thing any
PICAXE chip does on power reset is check for a new computer download.
Therefore if you reset the PICAXE whilst a download is being started by the
computer, the new download will always be recognised. This process is called a
hard-reset.
To perform a hard-reset using the reset switch (18, 28, 40 pin PICAXE):
Download CheckList
If you cannot download your program, check the following items. Remember that
all new PICAXE are pre-programmed and tested, therefore if a new chip does not
download it is generally a hardware setup issue.
If the program fails part way through a download this is generally a power supply
issue (or loose cable connection). Try with 3 new alkaline cells giving exactly
4.5V.
PICAXE microcontroller
• Is the correct PICAXE chip correctly inserted in socket
• Is a PICAXE chip (not blank un-programmed PIC chip) being used.
• Is a damaged PICAXE chip being used (e.g. chip that has had over-voltage or
reverse power supply applied)
• Is a smooth 4.5V to 5.5V DC supply correctly connected.
• Is the reset pin connected to V+ via 4.7k resistor (18 / 28 / 40 pin chips)
• Is the correct 3 pin resonator connected (28 / 40 pin chips)
• Are the serial download 10k/22k resistors correctly connected.
Software
• Latest version Programming Editor installed (v4.1.0 or later, see software page
at www.picaxe.co.uk for up to date information)
• Correct serial port selected (View>Options>Port menu).
• Correct resonator speed selected (if appropriate) (View>Options>Mode
menu)
• No conflicting serial port software running on computer (in particular PDA
type ‘hotsync’ software and interactive whiteboard software)
Download Cable
• Correctly wired download cable.
• Correctly wired download socket with 10k/22k resistors.
• All download socket pins correctly soldered to PCB.
• Download cable correctly connected between computer and microcontroller.
• Download cable inserted fully into socket.
Program Memory.
Program memory is where the program is stored after a new download. This is
‘FLASH’ rewritable memory that can be reprogrammed up to (typically) 100,000
times. The program is not lost when power is removed, so the program will start
running again as soon as the power is reconnected.
On standard PICAXE chips you can download around 40 lines of BASIC code. On
A or M revision parts you can download around 80 lines and on X parts around
600 lines. Note these values are approximate as different commands require
different amounts of memory space. To check your memory usage use the
PICAXE>Check Syntax menu option.
Data Memory
Data memory is additional storage space within the microcontroller. The data is
also not lost when power is removed. Each download resets all data bytes to 0,
unless the EEPROM command has been used to ‘preload’ data into the data
memory. See the EEPROM, read and write command descriptions for more
details.
On the PICAXE-08 / 08M / 18 the data memory is ‘shared’ with the program
memory Therefore larger programs will result is a smaller available data memory
area.
On all other PICAXE chips the data and program memory are completely
separate.
RAM (Variables)
The RAM memory is used to store data temporary data in variables as the
program runs. It looses all data when the power is removed. There are three types
of variable - general purpose, storage, and special function.
Variables are memory locations within the PICAXE microcontroller that store data
whilst the program is running. All this information is lost when the
microcontroller is reset.
For information about variable mathematics see the ‘let’ command information
in section 2 of the manual.
However for larger numbers two byte variables can be combined to create a word
variable, which is capable of storing integer numbers between 0 and 65335. These
word variables are labelled w0 to w6, and are constructed as follows:
w0 = b1 : b0
w1 = b3 : b2
w2 = b5 : b4
w3 = b7 : b6
w4 = b9 : b8
w5 = b11 : b10
w6 = b13 : b12
Therefore the most significant byte of w0 is b1, and the least significant byte of
w0 is b0.
In addition bytes b0 and b1 (w0) are broken down into individual bit variables.
These bit variables can be used where you just require a single bit (0 or 1) storage
capability.
You can use any word, byte or bit variable within any mathematical assignment or
command that supports variables. However take care that you do not accidentally
repeatedly use the same ‘byte’ or ‘bit’ variable that is being used as part of a ‘word’
variable elsewhere.
Storage Variables.
Storage variables are additional memory locations allocated for temporary storage
of byte data. They cannot be used in mathematical calculations, but can be used
to temporarily store byte values by use of the peek and poke commands.
The number of available storage locations varies depending on PICAXE type. The
following table gives the number of available byte variables with their addresses.
These addresses vary according to technical specifications of the microcontroller.
See the poke and peek command descriptions for more information.
PICAXE-08 none
PICAXE-08M 48 80 to 127 ($50 to $7F)
PICAXE-18 48 80 to 127 ($50 to $7F)
PICAXE-18A 48 80 to 127 ($50 to $7F)
PICAXE-18X 96 80 to 127 ($50 to $7F), 192 to 239 ($C0 to $EF)
PICAXE-28A 48 80 to 127 ($50 to $7F)
PICAXE-28X 112 80 to 127 ($50 to $7F), 192 to 239 ($C0 to $FF)
PICAXE-08M 112 80 to 127 ($50 to $7F), 192 to 239 ($C0 to $FF)
The variable pins is broken down into individual bit variables for reading from
individual inputs with an if...then command. Only valid input pins are
implemented.
Note that pins is a ‘pseudo’ variable that can apply to both the input and output
port.
When used on the left of an assignment pins applies to the ‘output’ port e.g.
let pins = %11000011
will switch outputs 7,6,1,0 high and the others low.
When used on the right of an assignment pins applies to the input port e.g.
let b1 = pins
will load b1 with the current state of the input port.
The variable pins is broken down into individual bit variables for reading from
individual inputs with an if...then command. Only valid input pins are
implemented.
Note that pins is a ‘pseudo’ variable that can apply to both the input and output
port.
When used on the left of an assignment pins applies to the ‘output’ port e.g.
let pins = %11000011
will switch outputs 7,6,1,0 high and the others low.
When used on the right of an assignment pins applies to the input port e.g.
let b1 = pins
will load b1 with the current state of the input port.
The variable pins is broken down into individual bit variables for reading from
individual inputs with an if...then command.
pins = pin7 : pin6 : pin5 : pin4 : pin3 : pin2 : pin1 : pin0
5V
PICAXE
0V
5V
Digital Inputs
Digital input switches can be
interfaced with a 10k pull down
resistor. The resistor is essential as it
prevents the input ‘floating’ when the
input pin
switch is in th open position. This
would give unreliable operation.
10k
PICAXE
Note the 10k resistor is pre-fitted to
the project board inputs. 0V
V+
Analogue Inputs
Analogue inputs can be connected in a
potential divider arrangement between V+
analogue ADC pin
and 0V. The analogue reference is the input
supply voltage, and the analogue signal
must not exceed the supply voltage. PICAXE
0V
Flowchart or BASIC?
The software supports both textual BASIC programming and graphical flowchart
programming. Both methods use the same BASIC commands and syntax. The
flowchart method simply provides a graphical way of joining the BASIC
commands together, to save typing in programs. Flowcharting uses a smaller sub-
set of the BASIC commands, and is generally used by younger students in the
educational environment.
Most hobbyist and experienced educational users prefer the textual BASIC
method of programming. It is much more powerful that flowcharts, which can
become very complicated for large programs.
For further information on the flowchart programming method, please see the
flowchart appendix.
start
main:
high 0
wait 1
low 0 high 0
wait 1
goto main
wait 1
low 0
wait 1
The program will start running on the PICAXE automatically. However the
program can also be restarted at any time by pressing the reset switch.
This program uses the high and low commands to control output pin 4, and uses
the pause command to make a delay (1000 ms = 1 second).
The last goto main command makes the program ‘jump’ back to the label main:
at the start of the program. This means the program loops forever. Note that the
first time the label is used it must be followed by the colon (:) symbol. This tells
the computer the word is a new label.
(NB note the colon (:) directly after the label ‘main’ and the spaces between
the commands and numbers)
6. Connect an LED (and 330R resistor) to output pin 4. If connecting the LED
directly to a PICAXE chip on a proto (or home-made) board, connect the LED
between the output pin and 0V. When using the project boards (as supplied
within the 18 and 28A starter packs), connect the LED between V+ and the
output connector, as the output is buffered by the darlington driver chip on
the project board. (Make sure the LED is connected the correct way around!).
7. Make sure the PICAXE circuit is connected to the serial cable, and that the
batteries are connected.
8. Select PICAXE>Run. A download bar should appear as the program
downloads. When the download is complete the program will start running
automatically – the LED should flash on and off every second.
Remember that comments (an explanation after the apostrophe (‘) symbol) can
make each line of a program much easier to understand. These comments are
ignored by the computer when it downloads a program to the PICAXE
A label (e.g. main: in the program above) can be any word (apart from keywords
such as ‘switch’), but must begin with a letter. When the label is first defined it
must end with a colon (:). The colon ‘tells’ the computer that the word is a new
label.
This program uses the wait command. The commands wait and pause both
create time delays. However wait can only be used with whole seconds, pause can
be used for shorter time delays (measured in milliseconds (1000th of a second)).
It is also a good programming technique to use tabs (or spaces) at the start of
lines without labels so that all the commands are neatly aligned. The term ‘white-
space’ is used by programmers to define tabs, spaces and blank lines, and the
correct use of white-space can make the program listing much easier to read and
understand.
Note:
Some early BASIC languages used ‘line numbers’ rather than labels for ‘goto’
commands. Unfortunately this line number system can be inconvenient to use,
because if you modify your program by later adding, or removing, lines of code
you then have to modify all the line numbers within the ‘goto’ commands
accordingly. The label system, as used in most modern BASIC languages,
overcomes this problem automatically.
This program flashes the LED connected to output pin 1 on and off 15 times. The
number of times the code has been repeated is stored in the general purpose RAM
memory of the PICAXE chip using variable b1 (the PICAXE contains 14 general
purpose byte variables labelled b0 to b13). These variables can also be renamed
using the symbol command to make them easier to remember.
main:
for counter = 1 to 15 ‘ start a for...next loop
high LED ‘ switch pin 7 high
pause 500 ‘ wait for 0.5 second
low LED ‘ switch pin 7 low
pause 500 ‘ wait for 0.5 second
next counter ‘ end of for...next loop
Note again how white-space (extra spaces) has been used to clearly show all the
commands that are contained between the for and next commands.
main:
sound 2,(50,100) ‘ freq 50, length 100
sound 2,(100,100) ‘ freq 100, length 100
0V
sound 2,(120,100) ‘ freq 120, length 100
pause 1000 ‘ wait 1 second
goto main ‘ loop back to start
To test this program you must add a piezo sounder between the output pin (in
this case output 2) and 0V. Note that on the project boards (supplied in the
PICAXE-18 and 28A starter packs) fitted with a Darlington driver the piezo must
be connected directly to the PICAXE output pin (not the buffered output
connection).
The first number provides the pin number (in this case output 2). The next
number (in brackets) is the tone, followed by the duration. The higher the tone
number the higher pitch the sound (note that only valid tones are 0 to 127).
The following program uses a for…next loop to produce 120 different sounds.
main:
for b0 = 1 to 120 ‘ start a for...next loop
sound 2,(b0,50) ‘ make a sound, freq from b0
next b0 ‘ next loop
end
The following program does the same task but backwards, by using step value of
-1 (rather than the default of +1 as above).
main:
for b0 = 120 to 1 step -1 ‘ count down in loop
sound 2,(b0,50) ‘ make a sound. freq from b0
next b0 ‘ next loop
end
• microswitches
• push and rocker switches
• reed switches
This program below shows how to react to switch pushes. In this program output
pin 4 flashes every time the push switch on input pin 3 is pushed. Note that if
using an 18 pin chip you should select a different input pin (e.g. pin0, as pin3
does not exist on this size chip).
In this program the first three lines make up a continuous loop. If the input is off
(=0) the program just loops around time and time again. If the switch is on (=1)
the program jumps to the label called ‘flash’. The program then flashes output 4
on for two seconds before returning to the main loop.
Note carefully the spelling in the if…then line – pin3 is all one word (without a
space). This is because pin3 is the name of a variable that contains the data from
the input pin. Note also that only the label is placed after the command then –
no other words apart from a label are allowed in this position.
Two switches (or more) can be combined by the NAD and OR key words.
To isolate individual pins (e.g. 6 and 7) within the port, mask the pins variable
with an & (logical AND) statement
let b1 = pins & %11000000
Voltage
varying voltage signal. This
voltage signal can be
represented by a number in dark
This program uses the readtemp command to read the temperature from a
DS18B20 digital temperature sensor connected to input 1.
The counting system used in everyday activities is the decimal system. This
number system uses the ten familiar digits 0 to 9 to explain how big or small the
number is.
A single binary digit is referred to a bit (binary digit). The PICAXE systems use 8
bits (1 byte), with the least significant bit (LSB) on the right hand side and the
most significant bit (MSB), on the left hand side.
Therefore the binary number %11001000 means set bits 7,6,3 high (1) and the
others low (0). The % sign tells the computer you are working in binary instead
of decimal.
This means that all 8 outputs can be controlled at the same time, instead of
multiple high and low commands. The following program demonstrates how to
make the seven segment display on the AXE050 tutorial board count from 0 to 9.
main:
let pins = %00111111 ‘ digit 0
pause 250 ‘ wait 0.25 second
let pins = %00000110 ‘ digit 1
pause 250 ‘ wait 0.25 second
let pins = %01011011 ‘ digit 2
pause 250 ‘ wait 0.25 second
let pins = %01001111 ‘ digit 3
pause 250 ‘ wait 0.25 second
let pins = %01100110 ‘ digit 4
pause 250 ‘ wait 0.25 second
let pins = %01101101 ‘ digit 5
pause 250 ‘ wait 0.25 second
let pins = %01111101 ‘ digit 6
pause 250 ‘ wait 0.25 second
let pins = %00000111 ‘ digit 7
pause 250 ‘ wait 0.25 second
let pins = %01111111 ‘ digit 8
pause 250 ‘ wait 0.25 second
let pins = %01101111 ‘ digit 9
pause 250 ‘ wait 0.25 second
goto main
Each ‘let pins=’ line changes the number of bars that are lit on the seven segment
display on the tutorial board. This is quicker, and more memory efficient, than
using lots of ‘high’ and ‘low’ commands.
Tutorial 10 - Sub-procedures
A sub-procedure is a separate ‘mini-program’ that can be called from the main
program. Once the sub-procedure has been carried out the main program
continues.
Sub-procedures are often used to separate the program into small sections to
make it easier to understand. Sub-procedures that complete common tasks can
also be copied from program to program to save time.
The X part PICAXE microcontrollers support 255 sub-procedures. All other parts
support 15 sub-procedures.
The following program uses two sub-procedures to separate the two main
sections of the program( ‘flash’ and ‘noise’).
noise:
high buzzer ‘ buzzer on
pause 2000 ‘ wait 2 seconds
low buzzer ‘ buzzer off
return ‘ return from the sub-procedure
This second program shows how a variable can be used to transfer information
into a sub-procedure. In this case variable b2 is used to tell the microcontroller to
flash 5, and then 15, times.
The interrupt inputs condition is any pattern of ‘0’s and ‘1’s on the input port,
masked by the byte ‘mask’. Therefore any bits masked by a ‘0’ in byte mask will be
ignored.
e.g.
to interrupt on input1 high only
setint %00000010,%00000010
to interrupt on input1 low only
setint %00000000,%00000010
to interrupt on input0 high, input1 high and input 2 low
setint %00000011,%00000111
etc.
Only one input pattern is allowed at any time. To disable the interrupt execute a
SETINT command with the value 0 as the mask byte.
Notes:
1) Every program which uses the SETINT command must have a corresponding
interrupt: sub-procedure (terminated with a return command) at the bottom
of the program.
2) When the interrupt occurs, the interrupt is permanently disabled. Therefore to
re-enable the interrupt (if desired) a SETINT command must be used within
the interrupt: sub-procedure itself. The interrupt will not be enabled until the
‘return’ command is executed.
3) If the interrupt is re-enabled and the interrupt condition is not cleared within
the sub-procedure, a second interrupt may occur immediately upon the return
command.
4) After the interrupt code has executed, program execution continues at the next
program line in the main program. In the case of the interrupted pause, wait,
play or tune command, any remaining time delay is ignored and the program
continues with the next program line.
The second number, the ‘input mask’, defines which pins are to be checked to see
if an interrupt is to be generated ...
- %00000001 will check input pin 0
- %00000010 will check input pin 1
- %01000000 will check input pin 6
- %10000000 will check input pin 7
- etc
These can also be combined to check a number of input pins at the same time...
- %00000011 will check input pins 1 and 0
- %10000100 will check input pins 7 and 2
Having decided which pins you want to use for the interrupt, the first number
(inputs value) states whether you want the interrupt to occur when those
particular inputs are on (1) or off (0).
Once a SETINT is active, the PICAXE monitors the pins you have specified in
‘input mask’ where a ‘1’ is present, ignoring the other pins.
An input mask of %10000100 will check pins 7 and 2 and create a value of
%a0000b00 where bit ‘a’ will be 1 if pin 7 is high and 0 if low, and bit ‘b’ will be
1 if pin 2 is high and 0 if low.
The ‘compare with value’, the first argument of the SETINT command, is what
this created value is compared with, and if the two match, then the interrupt will
occur, if they don’t match then the interrupt won’t occur.
If the ‘input mask’ is %10000100, pins 7 and 2, then the valid ‘compare with
value’ can be one of the following ...
So, if you want to generate an interrupt whenever Pin 7 is high and Pin 2 is low,
the ‘input mask’ is %10000100 and the ‘compare with value’ is %10000000,
giving a SETINT command of ...
- SETINT %10000000,%10000100
The interrupt will then occur when, and only when, pin 7 is high and pin 2 is low.
If pin 7 is low or pin 2 is high the interrupt will not happen as two pins are
‘looked at’ in the mask.
Example:
setint %10000000,%10000000
‘ activate interrupt when pin7 only goes high
loop:
low 1 ‘ switch output 1 off
pause 2000 ‘ wait 2 seconds
goto loop ‘ loop back to start
interrupt:
high 1 ‘ switch output 1 on
if pin7 = 1 then interrupt ‘ loop here until the
‘ interrupt cleared
pause 2000 ‘ wait 2 seconds
setint %10000000,%10000000 ‘ re-activate interrupt
return ‘ return from sub
In this example an LED on output 1 will light immediately the input is switched
high. With a standard if pin7 =1 then.... type statement the program could take
up to two seconds to light the LED as the if statement is not processed during the
pause 2000 delay time in the main program loop (standard program shown
below for comparison).
loop:
low 1 ‘ switch output 1 off
pause 2000 ‘ wait 2 seconds
if pin7 = 1 then sw_on
goto loop ‘ loop back to start
sw_on:
high 1 ‘ switch output 1 on
if pin7 = 1 then sw_on
‘ loop here until the condition is cleared
pause 2000 ‘ wait 2 seconds
goto loop ‘ back to main loop
Make sure you also study sections 2 (BASIC Commands) and 3 (Microcontroller
Interfacing Circuits) of the manual for additional information.
There are a large range of project ideas and examples within the Help files of the
Programming Editor software. Studying these exemplar projects will provide
further ideas, as will looking at the very active forum within the technical support
section of the main PICAXE website (www.picaxe.co.uk)
There is no limit to how creative PICAXE users can be! Have a go at your own
project, you might be surprised how quickly you can start developing exciting
microcontroller based electronic projects!
PICAXE-40X Commands
Output high, low, toggle, pulsout, let pins = ,
Input if...then, if portA…then, if portc then…, pulsin, button,
Counting count
ADC readadc, readadc10
Portc config. let dirsc =
Portc output high portc, low portc, let pinsc =
PWM pwmout
RAM peek, poke
Sound sound
Serial serin, serout
Program Flow goto, gosub, return, branch
Loops for...next
Mathematics let (+, -, *, **, /, //, max, min, &, |, ^, &/, |/, ^/ )
Variables if...then, random, lookdown, lookup
Data memory eeprom, write, read
Delays pause, wait, nap, sleep, end
Miscellaneous symbol, debug
Interrupt setint
Servo Control servo
Infrared infrain
Temperature readtemp, readtemp12
1-wire Serial No readowsn
Keyboard keyin, keyled
With the -08, -18 the internal resonator is fixed at 4MHz and cannot be altered.
With the -08M, -18A, -18X the internal resonator has a default value of 4MHz.
However it can be increased by the user to 8MHz via use of the ‘setfreq’
command.
With the -28 and -28A an external 4MHz resonator must be used.
With the -28X / -40X an external 4MHz 3 pin ceramic resonator is normally
used, but it is also possible to use a faster resonator (8 or 16Mhz), although this
will affect the operation of some of the commands.
• count
• debug
• i2cread/i2cwrite
• pause, wait
• pulsin, pulsout
• pwm. pwmout
• serin, serout, sertxd
• sound, tune, play
Note that nap and sleep are not affcted by resonator speed as they use their own,
separate, internal timer.
The following commands will not work at 8 or 16MHz due to timing issues with
the external device listed:
PICAXE-08 PICAXE-08M
+V 1 8 0V +V 1 8 0V
Serial In 2 7 Output 0 / Serial Out Serial In 2 7 Output 0 / Serial Out / Infraout
In 4 / Out 4 3 6 In 1 / Out 1 / ADC 1 In 4 / Out 4 / ADC 4 3 6 In 1 / Out 1 / ADC 1
Input 3 4 5 In 2 / Out 2 Input 3 / Infrain 4 5 In 2 / Out 2 / ADC 2 / pwm 2 / tune
Pin 0 must always be an output, and pin 3 must always be an input (this is due to
the internal construction of the microcontroller). The other 3 pins can be selected
to be inputs or outputs, and so the user can select any input/output combination
between the limits of 1 input-4 outputs and 4 inputs-1 output.
If you are making your own pcb you can include a similar jumper link or small
switch, or you may prefer to connect the microcontroller leg to both the output
device and the program socket at the same time. In this case you must remember
that your output device will rapidly switch on and off as the download takes
place (not a problem with simple outputs like LEDs, but could cause problems
with other devices such as motors).
Therefore the simplest way to setup outputs is just to put a ‘low’ command at the
start of the program for each output pin. This tells the microcontroller to make
the pin an output, and to make sure the output is condition low (off).
The input and output commands have no effect on pin 0 (output) and pin 3
(input), which cannot be altered.
PORTA Functions
Leg Default Function Second Function
2 analogue 0 porta input 0
3 analogue 1 porta input 1
4 analogue 2 porta input 2
5 analogue porta input 3
PORTB Functions
PORTB pins are fixed as outputs and cannot be altered.
PORTC Functions
Leg Default Second Function Special Function
11 input 0 output portc 0 infrared (input)
12 input 1 output portc 1 pwm 1 (output)
13 input 2 output portc 2 pwm 2 (output)
14 input 3 output portc 3 i2c scl clock (input)
15 input 4 output portc 4 i2c sda data (input)
16 input 5 output portc 5
17 input 6 output portc 6 keyboard clock (input)
18 input 7 output portc 7 keyboard data (input)
The portC pins can be used as the default inputs, changed to outputs, or used
with their special function via use of the infrain, keyin, i2cslave, or pwmout
command as appropriate.
It is not possible to access the portA pins with any other ‘input’ type commands
(count, pulsin etc). Therefore these pins should be reserved as simple on/off
switches.
Note that ‘dirsc’ uses the common BASIC notation 0 for input and 1 for output.
(Advanced - If you are more familiar with assembler code programming you may
prefer to use the command ‘let trisc =’ instead, as this uses the inverted assembler
notation - 1 for input and 0 for output. Do not attempt to directly
poke the trisc register (poke command) as the PICAXE bootstrap refreshes the
register setting regularly).
PORTC Functions
Leg Default Second Function Special Function
15 input portc 0 output portc 0
16 input portc 1 output portc 1 pwm 1 (output)
17 input portc 2 output portc 2 pwm 2 (output)
18 input portc 3 output portc 3 i2c scl clock (input)
23 input portc 4 output portc 4 i2c sda data (input)
24 input portc 5 output portc 5
25 input portc 6 output portc 6
26 input portc 7 output portc 7
The portC pins can be used as the default inputs, changed to outputs, or used
with their special function via use of the i2cslave or pwmout command
PORTD Functions
Leg Default Function Special Function
19 input 0 infrared (input)
20 input 1
21 input 2
22 input 3
27 input 4
28 input 5
29 input 6 keyboard clock (input)
30 input 7 keyboard data (input)
It is not possible to access the portA pins with any other ‘input’ type commands
(count, pulsin etc). Therefore these pins should be reserved as simple on/off
switches.
(Advanced - If you are more familiar with assembler code programming you may
prefer to use the command ‘let trisc =’ instead, as this uses the inverted assembler
notation - 1 for input and 0 for output. Do not attempt to directly
poke the trisc register (poke command) as the PICAXE bootstrap refreshes the
register setting regularly).
Flowchart Tools
Select Tool
Use this to select and move shapes. When a single shape is selected it’s BASIC
code can be edited in the edit bar at the bottom of the window.
Select Area
Use to select a particular area.
Zoom
Use to zoom in to an area of the graph. Right click to zoom out.
Zoom In/Out
To zoom in click and move the mouse up. To zoom out click and move the
mouse down.
Pan
Use this tool to move around the flowchart.
Line Tool
Use this tool to draw lines between shapes. Corners can be added by clicking
once. When the line is near to a shape it will ‘snap’ to the shape.
Connection Points
Use instead of a long complicated line. This gives two ‘connection points’ that can
be placed at different points within the flowchart.
Label Tool
Use this tool to add descriptive labels or titles to the flowchart.
Drawing Flowcharts
To draw a flowchart click on one of the command menu buttons (out / if / delay /
sub / other) on the toolbar to move to the appropriate command sub-menu.
Select the appropriate command and then click on the screen where the shape is
required. Do not try to locate the shape precisely at first – just drop it in the
general area and then use the select tool to move the shape to the correct
position.
After dropping a shape the cursor will remain in that shape mode until either:
1) the select tool is selected
2) the right hand mouse button is clicked to move back to select mode
Once the shape is in position click on it so that it is highlighted. The BASIC code
for the shape will then appear in the edit bar at the bottom of the screen. Edit the
code as required.
For further information about each command see section 2 of the manual -
‘BASIC Commands’. Any BASIC Command not supported by the simulation can
be added via the ‘generic’ shape, indicated by three dots.
Joining Shapes
Shapes are joined by moving them close together until they ‘snap’ together.
Alternately lines can be drawn between the shapes using the ‘line tool’ from the
main toolbar. Note that it is only possible to join the bottom (side) of shapes to
the top of other shapes (you cannot connect lines to lines). Only one line is
allowed out of the bottom of each shape.
To enable neat diagrams, corners to the lines can be added by clicking with the
mouse. When a line moves close to a connection point it will snap into position
and then a click will finish the line.
Lines cannot be moved. If you try to move a line it will be deleted and a new line
must be created.
start
high 0
wait 1
low 0
wait 1
On Screen Simulation
To simulate the flowchart, click ‘Simulate’ from the Flowchart menu. The
program will then start to run on-screen.
As the program runs each cell is highlighted red as it is carried out. The ‘Inputs/
Outputs’ and ‘Variables’ windows also appear when a simulation is being carried
out. To adjust the input values click the on-screen switch (shown beneath the
output LED) or slide the analogue input slider.
The time delay between shapes can be adjusted via the Flowchart options
(View>Options>Flowchart menu).
Downloading Flowcharts
Flowcharts are not directly downloaded to the microcontroller. First the flowchart
is converted into a BASIC program, which is then downloaded.
To convert a program select ‘Convert’ from the Flowchart menu. The BASIC
program for downloading will then be created.
Shapes that are not connected to the ‘start’ or ‘sub’ shapes in the flowchart are
ignored when the conversion takes place. The conversion will stop if an
unconnected shape is found. Therefore always use a ‘stop’ shape or line to
complete the flowchart before simulation or conversion.
Zooming
To zoom in and out you can use the two toolbar zoom features, or the rapid
zoom button at the bottom right hand corner of the screen. Left click this button
to zoom-in and right click to zoom-out.
Using Symbols
Inputs, Outputs and Variables can all be renamed using the ‘Symbol Table’ from
the Flowchart menu. When a symbol is renamed the new name appears in the
drop-down menus on the edit bar. Note that you should not use commands (e.g.
switch or sound) as a symbol as this will generate errors in your converted BASIC
program.
My laptop only has a USB connector - is there a USB version of the PICAXE?
To make a USB version of the PICAXE we would have to use a more expensive
USB enabled microcontroller, which would increase the unit cost of each PICAXE
chip significantly. To avoid this increased chip cost we instead supply a 'USB to
Serial Adapter' (part USB010) which enables USB users to use the standard serial
download cable. The one-off cost of purchasing this adapter is cheaper (in the
long term) than the cost of buying multiple expensive chips.
I've built a second pcb (without the download circuit) and the PICAXE program will not
run!
If you program a PICAXE chip in a different board, and then move the chip to a
board without the download circuit, you must ensure that the 'serial in' pin is
tied to ground (0V) on the second board for reliable operation.
I’ve bought some blank PICs and they don’t work in the PICAXE system!
The PICAXE microcontroller is not a blank PICmicro! It is a microcontroller that
has been pre-programmed with a ‘bootstrap’ program that enables the download
via the direct cable link (the bootstrap program tells the microcontroller how to
interpret the direct cable programming commands). Therefore you must buy
‘PICAXE’ microcontrollers, rather than blank microcontrollers, to use with the
PICAXE system. However we sell PICAXE microcontrollers at approx. the same
price as blank devices, so there is very little price difference for the end user,
particularly if you purchase the multi-packs.
Can you reprogram microcontrollers (that I have accidentally erased) with the bootstrap
program?
No. We do not accept microcontrollers from unknown sources due to the correct
storage/handling procedures required by these devices. We use gang programmers
costing several thousand pounds to program the bootstrap code into the blank
microcontrollers, and so must protect this expensive equipment from damage. It
is also likely that if we did offer this service the handling cost would end up more
expensive than new PICAXE microcontrollers anyway!
Can you supply the bootstrap program so that I can make my own PICAXE?
No. The small royalty made on each PICAXE chip sold is the only financial
benefit to our company to support the PICAXE system - the software is free and
the cables/development kits are sold at very low cost. Therefore we do not allow
anyone else to manufacture PICAXE microcontrollers.
Can I see the assembler code that is downloaded into the PICAXE?
If you own a Revolution Serial PIC Programmer, you can convert PICAXE BASIC
programs into assembler code, to program blank PICs or to just learn how
assembler code works by 'disassembly'. However some of the more complex
commands (e.g. serin) are not supported, and the assembler code program
generated is optimised for sequential learning (not optimised for compactness as
with the PICAXE system) and so the code is not 100% identical to that
downloaded to the PICAXE.
Can you alter the input/output pin arrangement of the PICAXE microcontroller?
The PICAXE-08 has 5 pins that can be configured as desired. The PICAXE-28X/
40X pin configuration can be altered. The PICAXE-18/18A/18X and PICAXE-28/
28A input/output pin arrangements are fixed and cannot be altered.
You can use the ‘PICAXE>Check Syntax’ menu to test the length of your program
without a download.
These notes presume the user is familiar with PIC microcontrollers, their
configuration fuse settings and programming in assembler code.
The bootstrap code also contains common routines (such as how to generate a
pause delay or a sound output), so that each download does not have to waste
time downloading this commonly required data. This makes the download time
much quicker.
The second advantage is the direct cable download method. The software is free
and so the only cost per computer is the download cable (£3). This enables
students to buy their own cable and for schools to equip every single computer
with a download cable. Other systems that require an expensive programmer are
generally too expensive to implement in this way.
Finally as the PICAXE chip never leaves the board, all leg damage (as can occur
when the chip is moved back and forth from a programmer) is eliminated.
The program and read/write memory is overwritten with every download. Use the
EEPROM command to preload data (within the program) for the read/write
commands. The readmem/writemem memory is not changed during a download.
What are the electrical characteristics of the PICAXE (e.g. operating voltage range etc.)?
The electrical characteristics of the PICAXE microcontroller is dependant upon
the base PIC microcontroller that is programmed with the PICAXE bootstrap
code to create the PICAXE microcontroller. Therefore see the Microchip datasheet
(from www.microchip.com) for the appropriate microcontroller characteristics.
The lowest operating voltage from these datasheets is shown below (Note this is
the ‘operating voltage’ only. You may require a higher voltage (minimum 4.5V
recommended) whilst doing the actual serial download from the computer to
ensure accurate memory programming of the chip).
Can you supply the bootstrap program so that I can make my own PICAXE?
No. The small royalty made on each PICAXE chip sold is the only financial
benefit to our company to support the PICAXE system - the software is free and
the cables/development kits are sold at very low cost. Therefore we do not allow
anyone else to manufacture PICAXE microcontrollers.
Can I see the assembler code that is downloaded into the PICAXE?
If you own a Revolution Serial PIC Programmer (part BAS800), you can convert
PICAXE BASIC programs into assembler code, to program blank PICs or to just
learn how assembler code works by 'disassembly'. However some of the more
complex commands (e.g. serin) are not supported, and the assembler code
program generated is optimised for sequential learning (not optimised for
compactness as with the PICAXE system) and so the code is not identical to that
downloaded to the PICAXE.
Can you alter the input/output pin arrangement of the PICAXE microcontroller?
The PICAXE-08 has 5 pins that can be configured as desired. The PICAXE-28X
and 40X can also be altered to give more inputs or outputs. The PICAXE-18 and
PICAXE-28 input/output pin arrangements are fixed and cannot be altered.
There is no fixed ‘byte’ formula as to memory usage e.g. pause 5, pause 50 and
pause 500 will all take different amounts of memory space! To calculate memory
usage use the ‘Check Syntax’ option from the PICAXE menu. This will report the
amount of memory used.
Why does the PICAXE only support up to 2400 baud rate on serout/serin commands?
Can I send and receive serial data via the download cable?
The maximum baud rates were originally selected for reliable operation with
microcontrollers with internal resonator. The early internal resonators were not
as accurate as an external device, and a slower baud rate ensures reliable
operation. The X parts support a higher 4800 baud rate, and use of a faster
resonator will increase the baud rates.
The PICAXE-08 can send data via the download cable via a ‘serout 0’ command.
The X parts can send data via a ‘sertxd’ command. The ‘serial in’ pin is reserved for
program downloads and cannot be used for receiving general data.
Software Version
The latest version of the Programming Editor can be downloaded from the
following website:
www.picaxe.co.uk
This manual was prepared using version 4.1.0 of the software. Ensure you are
using this version or later when referencing this manual.
A very active forum for the discussion of PICAXE projects, and for technical
support, also exists at this site.
Contact Address:
Revolution Education Ltd
4 Old Dairy Business Centre, Melcombe Road, Bath, BA2 3LR
http://www.rev-ed.co.uk/
Acknowledgements:
Revolution Education would like to thank the following:
Clive Seager
Vardan Antonyan
John Bown
LTScotland
Higher Still Development Unit
UKOOA