UNLEASH THE POWER OF THE PICAXE! The PICAXE is a powerful and easy-to-use processor, capable of highly sophisticated projects, without the complexities and high costs of alternative chips. Beginners can produce tangible results within minutes, and experienced users can achieve truly professional results. Programming and Customizing the PICAXE Microcontroller, Second Edition, has been fully updated for the latest hardware and software upgrades, and shows you, step by step, how to take full advantage of all the capabilities of the PICAXE and build your own control projects. This practical guide is packed with helpful illustrations, detailed examples, and do-it-yourself experiments. Perfect for beginners and students, the book also contains advanced information for more experienced programmers, hobbyists, manufacturers, and research institutions.
Programming and Customizing the PICAXE Microcontroller, Second Edition, covers: PICAXE architecture The latest chips, including M2, M, X, XI, and X2 series Windows, Mac, and UNIX platforms Interfacing and input/output techniques BASIC programming and compilers PICAXE arithmetic and data conversion Dozens of ready-to-run projects Useful routines to plug into your own designs Hands-on projects include: LED and LCO display control Motor control Water detector Bipolar transistor output driver Interfacing MOSFETs to a PICAXE Radio-control servo motor Infrared wireless links Telephone intercom Dual-temperature display Radio frequency identification (RFID) reader display Memory and I/O expansion Real-time clock/calendar Data logger Robotic components Many more
Table of Contents:
Chapter 1 Introduction
What Is a Microcontroller?
Where Are Microcontrollers Used?
The Advantages of a Programmable Device
Why Is It Important to Understand Microcontrollers?
What Is a PICAXE® Microcontroller?
Handling Precautions
The Experiments
Chapter 2 PICAXE Architecture
Chip Architecture
Powering the PICAXE
Resetting the PICAXE
Downloading Programs to the PICAXE
Clocking PICAXE Chips
PICAXE Memory
General-Purpose Variables
System Variables
Scratchpad
Storage Variables
Special Function
EEPROM
Table
Pointers
Ports
Interrupts
Chapter 3 Interfacing and Input Output Techniques
PICAXE Input and Output
Hardware Interfacing
Digital Interfacing
Port Addressing
Setting the Direction of Configurable Pins
Analog Interfacing
Parallel and Serial Interfacing
Asynchronous—RS232
Personal Computer Connectivity
I2C
SPI
UNI/O
1-Wire
Keyboard
Infrared
Pulses
Servo Motors
Chapter 4 Programming
What Is a Program?
Writing BASIC Code
Compiler Directives
Data
Meaningful Names
Commands
Labels
Comments
Reserved Words
Assigning Values to Variables
Advanced Programming
Program Flow
Code Structures
Selection
Iteration
Pointers
Subroutines
Pausing and Stopping Program Execution
Power Saving
Interrupts
Program Testing and Debugging
Programming with Flowcharts
Chapter 5 PICAXE Arithmetic and Data Conversion
Number Systems
Binary
Octal
Hexadecimal
Decimal
Binary-Coded Decimal
ASCII
Picaxe Arithmetic
Multiplication
Division
Boolean Arithmetic
Data Conversion
Converting between Decimal Digits (BCD) and ASCII
Converting between Binary and Octal
Converting between Binary and Hexadecimal
Converting Binary to Decimal and BCD
Converting ASCII, BCD, and Decimal to Binary
ASCII Integers
ASCII Fractions
Advanced Arithmetic
Decimal Fractions
Adding and Subtracting Decimal Fractions
Multiplying Decimal Fractions
Dividing Fractions
Converting Decimal Fractions to ASCII
BCD Arithmetic
BCD Addition
Subtraction of BCD Digits
Arithmetic with Signed Numbers
Addition and Subtraction of Signed Binary Integers
Multiplying and Dividing Signed Binary Numbers
Comparing Signed Numbers
Converting Signed Binary Numbers to Decimal
Arithmetic with Binary Fractions
Converting Binary Fractions to Decimal
Converting ASCII Fractions to Binary Fractions
Floating-Point Arithmetic
Lookup
Lookdown
Chapter 6 Experiments
Basic Experiments
Constructing the Schools Experimenter Board
Testing
If It Doesn’t Work
Using Programming Editor to Download Programs to the
Schools Experimenter Board
If Program Downloading Fails
Connecting External Devices
Flash the Red LED
Flash the Yellow LED
Flash the Red and Green LEDs Alternately
Play Sounds through the Piezo Speaker
Digital Input
Turn the Red LED On If the Switch Is Pressed
Turn the Red LED On If Dark
Analog Input
Turn the Red, Green, and Yellow LEDs On Depending on
Light Level
Turn On the Red, Green, and Yellow LEDs Using a
Potentiometer
Using a Transistor to Drive a Relay
Using a Transistor to Operate a Motor
Controlling Motor Speed
Controlling Motor Speed with a Potentiometer
Operating a Solenoid
Operating an Incandescent Lamp
Water Detector
Chapter 7 Advanced Experiments
Bipolar Transistor Output Driver
Interfacing Bipolar NPN Transistors
Interfacing MOSFETs to a PICAXE
N-Channel MOSFETS
Transistor Input Driver
Interfacing TTL Chips
Integrated Driver Circuits
H Bridge Motor Drivers L293, SN754410, L298
Controlling Motor Speed and Direction with a Potentiometer
Stepper Motors
Identifying the Windings
Identifying the Winding Sequence
Circuit Description
Servo Motors
Input and Output Expansion
Input and Output Expansion Using Shift Registers
Input and Output Expansion Using Addressable
I/O Expansion Chips
Using Switches for Input
Relays
Wireless Links
Infrared
Radio
Light-Emitting Diodes
Seven-Segment LED Displays
Liquid Crystal Displays
Connecting an LCD Using a Shift Register
Keypad Input
Telephone Intercom
Testing
If It Doesn’t Work
Connecting Phone Lines
Voltmeter
Circuit Description
1-Wire Serial Number
1-Wire Temperature
Radio Frequency Identification
Simple ASCII Terminal
I2C Memory Expansion
I2C I/O Expansion
I2C Clock/Calendar
SPI Memory Expansion
SPI I/O Expansion
UNI/OTM Memory Expansion
Chapter 8 PICAXE M2 Supplement
Introduction
Powering the PICAXE M2 Series Chips
Resetting the M2 Series Chips
Downloading Programs to the M2 Series Chips
Clocking the M2 Series Chips
Memory Arrangement for M2 Series Chips
General-Purpose Variables for the M2 Series Chips
System Variables for M2 Series Chips
Storage Variables for the M2 Series Chips
Special Function Variables
EEPROM
Pointers
Byte-Scratchpad Pointer
Ports
Setting the Direction of Configurable Pins
Interrupts
Interfacing and Input Output Techniques
Programming
Compatibility with Existing M and X Series Programs
Subroutines
PICAXE Arithmetic and Data Conversion
Parallel Task Programming (Multitasking)
Examples of Parallel Task Processing
Touch Sensing
Digital to Analog Conversion
Fixed-Voltage Reference
Elapsed Seconds Timer
SR Latch
M2 Experiments
Touch Sensing
Code Description
Digital to Analog Conversion
Code Description
Minute Timer
SR Latch Demonstration
Appendix Circuit Symbols
Index