PROGRAMMING AND CUSTOMIZING

Similar documents
MAKING PIC MICROCONTROLLER INSTRUMENTS AND CONTROLLERS

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

Arduino Cookbook O'REILLY* Michael Margolis. Tokyo. Cambridge. Beijing. Farnham Koln Sebastopol

SECOND EDITION. Arduino Cookbook. Michael Margolis O'REILLY- Tokyo. Farnham Koln Sebastopol. Cambridge. Beijing

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

MECHATRONICS. William Bolton. Sixth Edition ELECTRONIC CONTROL SYSTEMS ENGINEERING IN MECHANICAL AND ELECTRICAL PEARSON

Programming 8-bit PIC Microcontrollers in С

EasyPIC5 Development System

NOTIFICATION (Advt No. 1/2018) Syllabus (Paper III)

MSP430 Microcontroller Basics

EMBEDDED SYSTEMS: Jonathan W. Valvano INTRODUCTION TO THE MSP432 MICROCONTROLLER. Volume 1 First Edition June 2015

The PICAXE VSM Tutorial is split into a number of chapters. Each chapter can be downloaded free of charge from the website.

C for Electronic Engineering

Design of Embedded Systems Using 68HC12/11 Microcontrollers

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite.

EasyAVR6 Development System

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

ARM Microcontroller Interfacing - Warwick A. Smith ISBN Elektor. Table of Contents

Microcontrollers. Principles and Applications. Ajit Pal +5 V 2K 8. 8 bit dip switch. P2 8 Reset switch Microcontroller AT89S52 100E +5 V. 2.

DEPARTMENT OF ECE QUESTION BANK SUBJECT: MICROPROCESSOR AND MICROCONTROLLER UNIT-1 PART-A (2 MARKS)

ADVANCED TRAINING INSTITUTE, HYDERABAD

Bolt 18F2550 System Hardware Manual

LabVIEW Graphical Programming

Developement of Multi Interface Board for Educational Trainer Kit


Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

CONTENTS CHAPTER 1: NUMBER SYSTEM. Foreword...(vii) Preface... (ix) Acknowledgement... (xi) About the Author...(xxiii)

Overview of Microcontroller and Embedded Systems

DIGITAL ELECTRONICS. Vayu Education of India

Microcontrollers. Microcontroller

Digital Fundamentals

VHDL. Douglas L. Perry. Third Edition

Digital Design Using Digilent FPGA Boards -- Verilog / Active-HDL Edition

Contents: revolution SECTION 3 - MICROCONTROLLER INTERFACING CIRCUITS MICROCONTROLLER INTERFACING CIRCUITS.

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

BASIC INTERFACING CONCEPTS

Microcontroller & Interfacing

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.

DTMF BASED HOME AUTOMATION

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

ARM Microcontroller Interfacing Hardware and Software

Lecture 1: Introduction to Microprocessors

INTRODUCTION. Mechanical Considerations APPLICATION NOTE Z86E21 THERMAL PRINTER CONTROLLER ZILOG

AC : INFRARED COMMUNICATIONS FOR CONTROLLING A ROBOT

ENG460 Engineering Thesis

Digital System Design with SystemVerilog


Microsoft Visual Studio 2010

USING LEDs, LCDs. AND GLCDs IN MICROCONTROLLER PROJECTS. Dogan Ibrahim. Near East University, Cyprus WILEY. A John Wiley & Sons, Ltd.

1 of 8. I. (13pts) TRUE OR FALSE

Robotic Systems ECE 401RB Fall 2006

Microprocessors/Microcontrollers

1 Digital tools. 1.1 Introduction

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

Robotic Systems ECE 401RB Fall 2007

Diploma in Embedded Systems

SOME ASSEMBLY REQUIRED

BHARATHIDASAN ENGINEERING COLLEGE. III Year / V Semester / EEE MICROPROCESSORS AND MICROCONTROLLERS (R-2013)

RoboSpecies Technologies Pvt. Ltd.

С and the Programming for Multitasking. Thomas W. Schultz. Purdue University West Lafayette, Indiana

MICROCONTROLLER BASED SMART FAN SYSTEM

CS-3410 Systems Programming Spring 2013

INDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING YEAR : III SEM : VI

GOPALAN COLLEGE OF ENGINEERING AND MANAGEMENT Department of Mechanical Engineering COURSE PLAN

Western Washington University. Electrical Engineering Technology. Etec 471. Professor Morton. Senior Hardware Description. Automated Aquarium

GIE 8051 Professional Kit. User Manual

Robotic Systems ECE 401RB Fall 2006

Digital Techniques. Lecture 1. 1 st Class

Programmable Control. Name Class Teacher. Ellon Academy Technical Faculty

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

Embedded Systems. Embedded Programmer. Duration: 2 weeks Rs Language and Tools. Embedded System Introduction. Embedded C programming

Robotics Training Module ABLab Solutions

Experiment 10 Fall 2012

ECE3120: Computer Systems Hardware & Software Development Tools

Applications of 8051 Microcontrollers

Automation Engineers AB Pvt Ltd, NOIDA Job-Oriented Course on Embedded Microcontrollers & Related Software Stack

Module 12: Elementary Input/Output

Introduction to microcontrollers

Programming And Customizing The Picaxe Microcontroller 2nd Edition

The Microcontroller Idea Book

Professional Development Board (#28138)

END-TERM EXAMINATION

Digital Design. Verilo. and. Fundamentals. fit HDL. Joseph Cavanagh. CRC Press Taylor & Francis Group Boca Raton London New York

Supply voltage. Input current. Encoder supply. Memory

Supply voltage. Input current. Encoder supply. Memory SIMATIC S7-200, CPU 221 COMPACT UNIT, DC POWER SUPPLY 6 DI DC/4 DO DC, 4 KB CODE/2 KB DATA,

Embedded Systems and Kinetic Art. CS5968: Erik Brunvand School of Computing. FA3800: Paul Stout Department of Art and Art History.

Logistics. Embedded Systems. Kinetic Art. This Class. Embedded Systems and Kinetic Art. Kinetic Art

DEV-1 HamStack Development Board

ACADEMIC YEAR PLANNING - F.Y.J.C. ( ) F.Y.J.C. COMPUTER SCIENCE (Theory)

ericssonz LBI-38616B MAINTENANCE MANUAL FOR MTD TM SERIES AND DATA RADIO LOGIC BOARD 19D902151G3 DESCRIPTION CIRCUIT ANALYSIS TABLE OF CONTENTS

Pearson New International Edition. The 8051 Microcontroller and Embedded Systems Mazidi Mazidi McKinlay Second Edition

UNIT V MICRO CONTROLLER PROGRAMMING & APPLICATIONS TWO MARKS. 3.Give any two differences between microprocessor and micro controller.

Acknowledgments About the Author

Microprocessors and Interfacng. Question bank

Designing Embedded Systems with PIC Microcontrollers

Instruction Manual for BE-SP3 Circuit. 10/21/07

Chapter 3 DATA REPRESENTATION

Transcription:

PROGRAMMING AND CUSTOMIZING THE PICAXE MICROCONTROLLER SECOND EDITION DAVID LINCOLN Mc Grauu Hill New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto

CONTENTS Chapter 1 Introduction 1 What Is a Microcontroller? 1 Where Are Microcontrollers Used? 2 The Advantages of a Programmable Device 2 Why Is It Important to Understand Microcontrollers? 2 What Is a PICAXE Microcontroller? 2 Handling Precautions 3 The Experiments 3 Chapter 2 PICAXE Architecture 5 Chip Architecture 5 Powering the PICAXE 6 Resetting the PICAXE 7 Downloading Programs to the PICAXE 8 Clocking PICAXE Chips 9 PICAXE Memory 10 General-Purpose Variables 10 System Variables 12 Scratchpad 13 Storage Variables 13 Special Function 13 EEPROM 14 Table 16 Pointers 17 Ports 19 Interrupts 20 Chapter 3 Interfacing and Input Output Techniques 21 PICAXE Input and Output 21 Hardware Interfacing 22 Digital Interfacing 24 Port Addressing 26 Setting the Direction of Configurable Pins 26 Analog Interfacing 31 Parallel and Serial Interfacing 34 Asynchronous RS232 35 Personal Computer Connectivity 43 I2C 44 SPI 49 vii

viii CONTENTS UNI/O 52 1-Wire 55 Keyboard 57 Infrared 60 Pulses 62 Servo Motors 66 Chapter 4 Programming 69 What Is a Program? 70 Writing BASIC Code 70 Compiler Directives 71 Data 71 Meaningful Names 74 Commands 75 Labels 75 Comments 76 Reserved Words 76 Assigning Values to Variables 77 Advanced Programming 78 Program Flow 78 Code Structures 79 Selection 79 Iteration 81 Pointers 83 Subroutines 84 Pausing and Stopping Program Execution 56 Power Saving 89 Interrupts 89 Program Testing and Debugging 91 Programming with Flowcharts 93 Chapter 5 PICAXE Arithmetic and Data Conversion 95 Number Systems 96 Binary 96 Octal 96 Hexadecimal 97 Decimal 97 Binary-Coded Decimal 97 ASCII 97 Picaxe Arithmetic 98 Multiplication 99 Division 100 Boolean Arithmetic 101 Data Conversion 705 Converting between Decimal Digits (BCD) and ASCII 105 Converting between Binary and Octal 106 Converting between Binary and Hexadecimal 106 Converting Binary to Decimal and BCD 707 Converting ASCII, BCD, and Decimal to Binary 109

ASCII Integers 110 ASCII Fractions 111 Advanced Arithmetic 112 Decimal Fractions 112 Adding and Subtracting Multiplying Decimal Fractions 112 Dividing Fractions 113 Converting Decimal Fractions to ASCII 113 BCD Arithmetic 113 BCD Addition 113 Subtraction of BCD Digits 114 Decimal Fractions 112 Arithmetic with Signed Numbers 116 Addition and Subtraction of Signed Binary Integers 117 Multiplying and Dividing Signed Binary Numbers 118 Comparing Signed Numbers 119 Converting Signed Binary Numbers to Decimal 119 Arithmetic with Binary Fractions 120 Converting Binary Fractions to Decimal 120 Converting ASCII Fractions to Binary Fractions 122 Floating-Point Arithmetic 122 Lookup 122 Lookdown 124 Chapter 6 Experiments Basic Experiments 126 Constructing the Schools Experimenter Board 127 Testing 128 If It Doesn't Work 129 Using Programming Editor to Download Programs to the Schools Experimenter Board 130 If Program Downloading Fails 131 Connecting External Devices 737 Flash the Red LED 133 Flash the Yellow LED 734 Flash the Red and Green LEDs Alternately 735 Play Sounds through the Piezo Speaker 135 Digital Input 138 Turn the Red LED On If the Switch Is Pressed Turn the Red LED On If Dark 740 Analog Input 141 73S Turn the Red, Green, and Yellow LEDs On Depending on Light Level 141 Turn On the Red, Green, and Yellow LEDs Using a Potentiometer 145 Using a Transistor to Drive a Relay 146 Using a Transistor to Operate a Motor 146 Controlling Motor Speed 147 Controlling Motor Speed with a Potentiometer 148 Operating a Solenoid 149

x CONTENTS Operating an Incandescent Lamp 150 Water Detector 151 Chapter 7 Advanced Experiments 1S3 Bipolar Transistor Output Driver 154 Interfacing Bipolar NPN Transistors 154 Interfacing MOSFETs to a PICAXE 155 N-Channel MOSFETS 155 Transistor Input Driver 156 Interfacing TTL Chips 156 Integrated Driver Circuits 157 H Bridge Motor Drivers L293, SN754410, L298 157 Controlling Motor Speed and Direction with a Potentiometer 159 Stepper Motors 162 Identifying the Windings 162 Identifying the Winding Sequence 163 Circuit Description 163 Servo Motors 167 Input and Output Expansion 169 Input and Output Expansion Using Shift Registers 170 Input and Output Expansion Using Addressable I/O Expansion Chips 172 Using Switches for Input 172 Relays 175 Wireless Links 176 Infrared ) 77 Radio 179 Light-Emitting Diodes 181 Seven-Segment LED Displays 182 Liquid Crystal Displays 189 Connecting an LCD Using a Shift Register 190 Keypad Input 197 Telephone Intercom 199 Testing 203 If It Doesn't Work 204 Connecting Phone Lines 204 Voltmeter 205 Circuit Description 206 1-Wire Serial Number 208 1-Wire Temperature 210 Radio Frequency Identification 214 Simple ASCII Terminal 217 I2C Memory Expansion 221 I2C I/O Expansion 224 I2C Clock/Calendar 225 SPI Memory Expansion 234 SPI I/O Expansion 240 UNI/O Memory Expansion 245

CONTENTS xl Chapter 8 PICAXE M2 Supplement 247 Introduction 248 Powering the PICAXE M2 Series Chips 249 Resetting the M2 Series Chips 250 Downloading Programs to the M2 Series Chips 250 Clocking the M2 Series Chips 250 Memory Arrangement for M2 Series Chips 250 General-Purpose Variables for the M2 Series Chips 251 System Variables for M2 Series Chips 251 Storage Variables for the M2 Series Chips 251 Special Function Variables 252 EEPROM 252 Pointers 253 Byte-Scratchpad Pointer 253 Ports 253 Setting the Direction of Configurable Pins 254 Interrupts 256 Interfacing and Input Output Techniques 259 Programming 260 Compatibility with Existing M and X Series Programs 260 Subroutines 260 PICAXE Arithmetic and Data Conversion 261 Parallel Task Programming (Multitasking) 261 Examples of Parallel Task Processing 263 Touch Sensing 264 Digital to Analog Conversion 266 Fixed-Voltage Reference 268 Elapsed Seconds Timer 268 SR Latch 269 M2 Experiments 270 Touch Sensing 271 Code Description 273 Digital to Analog Conversion 273 Code Description 275 Minute Timer 275 SR Latch Demonstration 276 Appendix Circuit Symbols 277 Index 299