SlideShare a Scribd company logo
PICAXE Microcontrollers
  An Introduction by NearSys
What is a PICAXE?
• A family of microcontrollers
• Based on the PIC microcontroller
• Internally programmed with an interpreter and
  communications program
• Program stored in the PIC’s internal EEPROM
• Interpreter operates on one instruction at a time
PICAXE Variations
   PICAXE-08M2
   PICAXE-14M2
   PICAXE-18M2
   PICAXE-20M2
   PICAXE-28X2
   PICAXE-40X2
PICAXE Voltages
Five volt chips, but can operate at 1.8 volts
PICAXE Multiple Programs
       PICAXE-08M2
       PICAXE-14M2
       PICAXE-18M2
       PICAXE-20M2
       PICAXE-28X2
       PICAXE-40X2
PICAXE Multiple Programs
       PICAXE-08M2
       PICAXE-14M2
       PICAXE-18M2
       PICAXE-20M2
       PICAXE-28X2
       PICAXE-40X2
PICAXE Clock Speed
    PICAXE-08M2
    PICAXE-14M2
    PICAXE-18M2
    PICAXE-20M2
    PICAXE-28X2
    PICAXE-40X2
PICAXE Clock Speed
    PICAXE-08M2
    PICAXE-14M2
    PICAXE-18M2
    PICAXE-20M2
    PICAXE-28X2
    PICAXE-40X2
PICAXE Pins
• Logic low < 1.4 V
• Up to four banks, A, B, C, and D
  depending on variation
• Most I/O pins are bidirectional
• Hardware interrupts on the X2
• Software interrupts on both the M2 and X2
PICAXE Memory
•   Program
•   RAM
•   Data
•   Scratch Pad
PICAXE Memory
•   Program
•   RAM
•   Data
•   Scratch Pad
PICAXE Memory
•   Program
•   RAM (variables)
•   Data
•   Scratch Pad
PICAXE Memory
•   Program
•   RAM
•   Data
•   Scratch Pad
PICAXE Memory
•   Program
•   RAM (variables)
•   Data
•   Scratch Pad
Code Examples
          Input Commands
•   PIN
•   COUNT
•   PULSIN
•   SERIN
•   READI2C
•   READADC and READADC10
•   IRIN
•   RFIN
Code Examples
          Output Commands
•   HIGH and LOW
•   PULSOUT
•   SEROUT
•   WRITEI2C
•   PLAY and TUNE
•   SERVO
•   PMWOUT
•   IROUT
•   RFOUT
Code Examples
    Program Flow Control Commands
•   GOTO
•   GOSUB-RETURN
•   FOR-NEXT
•   DO-LOOP (UNTIL or WHILE)
•   IF-THEN-ELSEIF
•   ON-GOTO (GOSUB)
•   SELECT-CASE
•   BRANCH
Code Examples
    Communications Commands
• I2cslave 10100000,i2cfast,i2cword
• writei2c 0,("hello")
• readi2c 0,(b0,b1,b2,b3,b4)
Code Examples
      Communications Commands
•   debug
•   serout B.0, T1200_4,(“Testing”)
•   serin C.1, T1200_4,(“X”),B.0, B.1, B.2
•   sertxd (“Value: ,”B.5)
•   serrxd (B.0, B.1, B.2, B.3)
•   hsersetup b9600_4, %10
•   hserout 0,(b.0)
•   hserin 0,50
Code Examples
       Memory Commands
• PEEK-POKE
• READ-WRITE
• GET-PUT
The Editor
Editor
Selecting the Mode
Editor
Selecting the Serial Port
Editor
Example of a Text Program
Editor
Example of a Flowchart Program
Editor
Example of a Wizard
Editor
Example of Syntax Check
Editor
Downloading Program
Editor
Simulating a Program
Editor
Debugging a Program
Editor
Terminal Program
Want to Learn More?
Boise Robotics Group (The BoRG)
   Third Saturday of the Month
 Hobby Town at Cole and Ustick
        10:00 AM to noon

     Learn to Make a Robot
  A community education class
“Whether we're fighting climate change or
    going to space, everything is moved
 forward by computers, and we don't have
      enough people who can code”.

                         Richard Branson

More Related Content

PPTX
Ss r164 d4eb4em212t
PDF
10 Reasons to Use Next-Generation HMI Solution Kits for RX
PPTX
Ss r8 d3bb3bsys-500
PDF
Stream it10 Reasons to Use RZ/A Stream it! Solution Kit to encode and stream ...
PPTX
R164 d4eb4em21 2t
PPT
Networking of Micro-Controllers through USB
PPTX
R164 d4fb4f 2t
PPTX
R84 d2fb4fm18 2t
Ss r164 d4eb4em212t
10 Reasons to Use Next-Generation HMI Solution Kits for RX
Ss r8 d3bb3bsys-500
Stream it10 Reasons to Use RZ/A Stream it! Solution Kit to encode and stream ...
R164 d4eb4em21 2t
Networking of Micro-Controllers through USB
R164 d4fb4f 2t
R84 d2fb4fm18 2t

What's hot (20)

PPTX
R4 b4dcmb 5g
PPTX
R84 d2eb4em18 1t
PPTX
CodeRage XI international Conference: Arduino + Delphi Mobile Apps
PPTX
Arduino plus Delphi Mobile Apps - Basics
PPTX
Arduino plus Delphi Mobile Apps - Beyond Basics
PPTX
Costruiamo un Rover in 60 minuti
PPTX
UGM CAN PXI
PPTX
2015 02 28 DotNetSpain2015 Coding4Fun
PPTX
R4 b4ecmb 5g
PDF
ZKTeco iClock580 Bangladesh
DOC
Bl lw085-specification-www.ttbvs.com
PPTX
R84 d3fb3f 1t
DOC
OV7670 Camera interfacing-with-arduino-microcontroller
PPTX
2015 02 28 DotNetSpain IoT Fight
PPTX
Arduino camera interfacing OV7670
PPTX
2015 06 11 Windows 10 Developer Readiness by MVPs - Internet Of Things
PPTX
R4 d1fb3fcmb 5g
DOCX
Spec00313
R4 b4dcmb 5g
R84 d2eb4em18 1t
CodeRage XI international Conference: Arduino + Delphi Mobile Apps
Arduino plus Delphi Mobile Apps - Basics
Arduino plus Delphi Mobile Apps - Beyond Basics
Costruiamo un Rover in 60 minuti
UGM CAN PXI
2015 02 28 DotNetSpain2015 Coding4Fun
R4 b4ecmb 5g
ZKTeco iClock580 Bangladesh
Bl lw085-specification-www.ttbvs.com
R84 d3fb3f 1t
OV7670 Camera interfacing-with-arduino-microcontroller
2015 02 28 DotNetSpain IoT Fight
Arduino camera interfacing OV7670
2015 06 11 Windows 10 Developer Readiness by MVPs - Internet Of Things
R4 d1fb3fcmb 5g
Spec00313
Ad

Similar to Introduction to PICAXE Microcontrollers (20)

PPTX
Basics Of Embedded Systems
PPT
8051 microcontroller introduction
PPTX
EC18713 EMBEDDED SYSTEMS LABORATORY, EC18713
PDF
PIC Microcontrollers: Powering Versatile Embedded Solutions"
PPT
student_pres120202final
PPTX
Processors selection
PDF
Serving Deep Learning Models At Scale With RedisAI: Luca Antiga
PPTX
embedded-systems-for-beginners
PDF
Programming with PIC microcontroller
PDF
Microcontroladores: Programación con microcontrolador PIC
PPTX
arduinoedit.pptx
PPTX
Codasip application class RISC-V processor solutions
PPTX
embedded system and AVR
PDF
Vlsi lab
PDF
Project Basecamp: News From Camp 4
PDF
M&m comparison for elcetrical engineering
PDF
Webinar mdc i_kan_20170417 final
PDF
Iot Bootcamp - abridged - part 1
PPTX
Raspberry Pi Introduction
PPT
S2C China ICCAD 2010 Presentation
Basics Of Embedded Systems
8051 microcontroller introduction
EC18713 EMBEDDED SYSTEMS LABORATORY, EC18713
PIC Microcontrollers: Powering Versatile Embedded Solutions"
student_pres120202final
Processors selection
Serving Deep Learning Models At Scale With RedisAI: Luca Antiga
embedded-systems-for-beginners
Programming with PIC microcontroller
Microcontroladores: Programación con microcontrolador PIC
arduinoedit.pptx
Codasip application class RISC-V processor solutions
embedded system and AVR
Vlsi lab
Project Basecamp: News From Camp 4
M&m comparison for elcetrical engineering
Webinar mdc i_kan_20170417 final
Iot Bootcamp - abridged - part 1
Raspberry Pi Introduction
S2C China ICCAD 2010 Presentation
Ad

More from L. Paul Verhage (6)

PPT
Autumn 2016 Easy Star Gazing
PPT
Near Space for Hams for Northwest APRS 2016
PPT
Meteor Showers
PPT
Robotics Introduction
PPT
Easy Star Gazing
PPT
Get Involved with BalloonSat Classes
Autumn 2016 Easy Star Gazing
Near Space for Hams for Northwest APRS 2016
Meteor Showers
Robotics Introduction
Easy Star Gazing
Get Involved with BalloonSat Classes

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Machine Learning_overview_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
cuic standard and advanced reporting.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
MYSQL Presentation for SQL database connectivity
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
Encapsulation theory and applications.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Machine Learning_overview_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MYSQL Presentation for SQL database connectivity

Introduction to PICAXE Microcontrollers

Editor's Notes

  • #2: I’d like to talk about my favorite microcontroller, the PICAXE. I like it for two major reasons. First, its cheap, only a few dollars for the smallest type And second, its programmed in BASIC. So the learning curve to using them is very shallow. The PICAXE was developed after the BASIC stamp and has many similarities.
  • #3: PICAXE is a family of programmable microcontrollers from the UK company, Revolution Education. Each PICAXE is a PIC microcontroller programmed with a communications program and BASIC interpreter. The user programs the PICAXE in BASIC using the PICAXE programming Editor. Like a word processor, the Editor lets you type code, save the program in a text file on the PC, and checks the program for syntax errors. When a program is syntactically correct, the Editor allows the user to download the program into the PICAXE connected to the PC. The program is downloaded over a three wire serial port. The three connections in the serial cable are ground, signal in and signal out. The user created program is stored in the PICAXE’s internal memory. PICAXEs do not store their program in a separate memory chip like the BASIC Stamp. After having received the program or when the PICAXE is powered up, the PICAXE’s interpreter begins executing the instructions stored in its EEPROM memory, one command at a time.
  • #4: There are six types of single-chip PICAXE microcontrollers that I want to discuss. The name given to the variations of PICAXE microcontrollers is based on the number of I/O pins on the IC and it generation. The smallest is the PICAXE-08M2 and it looks like an eight-pin 555 IC. Some have called the PICAXE-08 the 21 st century 555 timer. I want to mention the voltages, ability to execute multiple programs, and clock speeds of these six microcontrollers. Voltages
  • #5: First, both the M2 and X2 series operate at 5 volts but can operate down to 1.8 volts. This permits you to create applications that don’t require a voltage regulator. Clock Speed M2 has an internal 4 MHz oscillator, but it can be clocked up to 8 times faster, or to a speed of 32 MHz. X2 has an internal 8 MHz oscillator, but can be clocked twice as fast, or 16 MHz.
  • #6: Both variations can operate multiple programs, but in different ways. The M2 series can run either two or four programs in semi-parallel. Semi-parallel execution means each program gets a turn executing a single command. Commands waiting for input and without time outs can stall the switching between programs. The programs are stored in a single program slot.
  • #7: The X2 series stores programs in separate slots. It uses the RUN command to switch execution between two or four program slots.
  • #8: Finally there clock speeds. The M2 series has an internal 4 MHz oscillator, but it can be clocked up to 8 times faster, or to a speed of 32 MHz.
  • #9: The X2 has an internal 8 MHz oscillator, but can be clocked twice as fast, or 16 MHz.
  • #10: I/O pins are the microcontroller’s access to the real world. The I/O pins detect binary states where a logic low is less than 1.4 volts and a logic high is above 1.4 volts. Several I/O pins can handle analog voltage using the READADC command The PICAXE-08M2 has only a bank C of six I/O pins while The PICAXE40X2 has four banks of eight I/O pins. Its banks are A, B, C, and D. Most pins can be used as both input and output while a few can only be configured to be just input or output The X2 series has pins that can be configured as hardware interrupts. The interrupts are not instantaneous however. Pins configured as hardware interrupts are scanned constantly in background. When the interrupt condition occurs, the interrupt flag of the PICAXE is set. The PICAXE does not check the interrupt flag until it executes the SETINTFLAGS command. Both the M2 and X2 series have a software interrupt that is established by the SETINT command. The command causes the PICAXE to scan selected pins for specified high and low conditions. When conditions are met, the PICAXE jumps execution to the specified subroutine.
  • #11: PICAXE microcontrollers have four types of internal memory, program, RAM, data, and scratch pad.
  • #12: First kind of memory is program memory. This is non-volatile memory and used to store user-created programs. The useful life of this kind of memory is predicted to be 10 years. The amount of memory depends on the specific microcontroller. The M2 series has 2k bytes of program memory. This is enough memory to store a program over 1,000 lines long. The X2 series has 4k bytes of program memory. However, the memory is arranged in slots. The X2 series chips have either one or four slots of program memory and there are commands to switch between slots. In addition, some X2 PICAXE microcontrollers allow you to add up to an additional 32 external program slots using I2C memory chips.
  • #13: The second type of memory is RAM memory and its used to store variables used in math and I/O. The lower level of RAM is accessed in bytes by their names. Some of the bytes can also be accessed at the bit and word level. The M2 series has up to 512 bytes of RAM. The first 28 bytes are named B0 to B27 while the rest are accessed indirectly using the PEEK and POKE commands The X2 series has up to 256 bytes of RAM. The first 56 bytes are named B0 to B55 while the rest are accessed indirectly.
  • #14: The M2 series has a third type of memory called data memory. There is 256 bytes of data memory which is useful for storing sensor readings in datalogger applications and storing configuration settings. The memory is non-volatile and accessed at the byte level with READ and WRITE commands.
  • #15: The X2 series has a fourth type of memory called scratch pad memory. They have 1 kilobyte of scratch pad memory and it can be used to store serial data over the chip’s hardware serial port in background. The stored data string can be accessed later using the GET and PUT commands
  • #16: The PICAXE can read its input pins several ways. At the simplest level, at any time during a program, the state of a pin can be detected as being either high or low. In addition, the PICAXE can count the number of high to low transitions in an I/O pin over a specified length of time. It can also measure how long a pulse is held high. There are several ways to read serial-type data over the I/O pins. These include the following Serial data from speeds 600 baud to 64k baud Serial data from I2C devices at speeds of either 100 kHz or 400 kHz Analog voltages can be converted into their digital representation with either 8-bit or 10-bit resolution Seven bit value from infrared devices like television remotes And eight bytes of data from inexpensive radio devices
  • #17: The PICAXE can set its output pins in several ways. At the simplest level, the state of a pin can be set to high or low at any time in the program. In addition, a pin may be set high for a specified length of time. There are several ways to pulse an I/O pin and these include the following Send serial data from 600 baud to 64k baud Write to I2C devices at a speed of either 100 kHz or 400 kHz Play an embedded tune or musical note Send pulses to position a servo Send a seven bit value to infrared devices like television sets Send eight bytes of data through inexpensive radio devices
  • #18: Execution of a program can be altered or controlled unconditionally or conditionally with the following commands. The GOTO and GOSUB commands are unconditional branching commands. The FOR-NEXT command is a looping control command. DO-LOOPs repeat commands while or until a condition is met. The branching condition can be tested either as part of the DO or the LOOP statement. The UNTIL and WHILE sub-commands state the condition at which the do loop is repeated or broken. The IF-THEN command is a conditional branching command. Incorporating the ELSEIF statement allows the command to create additional branches for additional conditions. It also allows a single condition to result in the execution of several commands, or essentially subroutines. ON-GOTO branches to an address in the program based on the current value of a variable. SELCT-CASE conditionally executes code statements depending on the value stored in a variable. The command is useful as a replacement for nested IF-THEN statements. The BRANCH command jumps execution to a new location in the program based on the value of a variable. The location is indicated by the address name.
  • #19: This code snippet shows the three commands required to setup a PICAXE for communication with a I2C memory chip, to write values to memory, which in this example is the word hello, and to copy the stored data from I2C memory into RAM memory.
  • #20: This code snippet shows seven examples of commands used to communicate over a serial link. The first is the DEBUG command. When ever this command is executed, the PICAXE sends the current values in RAM variables. The next two examples illustrate sending messages and values over any I/O pin. The command indicates which I/O pin to use, the baud rate, and the text or values which must be stored in RAM variables. The following two illustrate the same thing, but this time the data is sent and received over the PICAXE’s programming port. The speed is only 4800 baud. The last three illustrate how a hardware serial port is setup for a PICAXE. The hardware serial port allows the PICAXE to receive serial data in background and dump it into scratch pad memory. The PICAXE can parse through the data at a later time.
  • #21: The POKE commands copies the value of one or more named RAM variables into unnamed RAM memory, or EEPROM. The command can copy data in bytes or words. The PEEK command does the reverse and copies one or more values from unnamed RAM memory into named RAM memory. The READ-WRITE commands do the same thing as PEEK and POKE, except data is copied into data memory, or EEPROM. The GET and PUT commands copy byte values to scratchpad memory.
  • #22: The Editor is only PC based, there is no Mac version. The Editor allows you to do the following Select the variant of PICAXE to be programmed Select the com port for programming Create source code in either text or flowcharts Generate desired command parameters with the use of wizards Check syntax Download source code into a PICAXE Simulate a program running in a PICAXE Debug code by placing DEBUG commands that return variable values Communicate the PICAXE through a serial terminal program
  • #23: The Editor can program any one of the PICAXEs. Therefore, you need to select which PICAXE will be programmed. One reason this is important s that not all commands and parameters are valid for every PICAXE. You select your PICAXE by clicking the Options button located at the top of the Editor. The Mode tab presents a drop down menu where you can select your PICAXE. The mode is sticky, so the next time the Editor is started, the previously selected PICAXE mode is in effect.
  • #24: Since most PCs and laptops do not have serial ports, most PICAXEs are programmed through a USB to Serial adapter. This can create a forest of serial ports on the PC. The Editor does not try searching all possible serial ports in order to find which one a PICAXE is hanging off. You must set the correct serial port for the Editor. The serial port is selected by clicking the Options button at the top of the Editor screen. Serial ports is found in the Serial Port tab. There you will find a drop down menu where you can select the proper serial port.
  • #25: The Editor is smart the way it displays programs. A comment followed by text is displayed in green. Comments are not downloaded into the PICAXE. Commands are displayed in blue text. Program labels are displayed in black text. Labels in the program must end in a colon, but labels used in commands do not end in colons. I/O pins and variables are displayed in purple. The Editor edits text like a word processor. So you can find characters, copy, paste, and make global replacements.
  • #26: A second way to create a program is to use a flowchart. This graphical version of a program requires more space to display and can be converted into a text version of the program.
  • #27: Wizards help you set up parameters for specific commands. Wizards are found under the PICAXE option. There are two wizards related directly toe PICAXE programming, ring tones and PWM output. In addition, there are wizards for converting a program into one that runs on an X2 version of a PICAXE and for converting serial data into TCP/IP data for remote programming a PICAXE.
  • #28: Clicking the Syntax button checks over the current program in the Editor. This verifies that the program is correctly written for the PICAXE version specified in Mode. This does not verify that the program will work as desired. It only verifies that the code can operate in the PICAXE.
  • #29: The Program button opens communication with the PICAXE connected to the serial port selected in Mode. Once communications have been established, the program is downloaded into the PICAXE. The PICAXE verifies with the Editor that it properly received the program. A graphic is displayed that indicates how much progress has been made in downloading the program. If there is an error, the Editor warns you that communications with the PICAXE has failed. After the program is correctly downloaded, the Editor notifies you and indicates how much memory the program requires.
  • #30: Prior to downloading a program, you can simulate the operation of the program by clicking on the Simulate button. In the background is the text of the program which shows the currently executing line highlighted in a blue block. Three additional windows open up. The first windows displays the values of the variables in the PICAXE memory and the status of each I/O pin. You can set pins high or low by clicking its icon. In addition, you can enter analog voltage values for each of the pins capable of using the READADC command. The second window is a memory map. It displays the byte values of addresses in three types of memory. These are EEPROM memory which is accessed with READ and WRITE commands, RAM which is addressed directly or indirectly with PEEK and POKE commands, and Scratchpad memory which is accessed with GET and PUT commands. The last wind displays serial data that the PICAXE may generate.
  • #31: Programs can be debugged live. By leaving the PICAXE connected to the PC and using the DEBUG command, your program will display the current values stored in RAM. The Debug window opens as soon as the program is downloaded to the PICAXE. The window displays the values in each byte in binary, decimal, hexadecimal, and ASCII. In addition, RAM memory values is also displayed in words. The last thing displayed in the Debug window is the values in several PICAXE registers.
  • #32: Another feature of the Editor is its terminal program. The terminal displays serial data sent by any microcontroller. The PICAXE uses the SEROUT command to send serial data through any of its I/O pins that can be used as an output. One parameter of the SEROUT command is the baud rate. The terminal program can read serial data at ten different baud rates. You just need to make sure the terminal’s baud rate matches the baud rate of the PICAXE’s SEROUT command.