Docsity

Beginner's guide to Robotics projects, Notas de estudo de Introdução à Robótica

Pré-visualização parcial do texto

Baixe Beginner's guide to Robotics projects e outras Notas de estudo em PDF para Introdução à Robótica, somente na Docsity!

This page intentionally left blank.

PIC Robotics

A Beginner’s Guide to Robotics Projects Using the PICmicro

John Iovine

McGrawHill

New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto

For more information about this title, click here.

Contents

viii Contents

  • Chapter 1. Robot Intelligence Preface xi
    • What Is a Microcontroller?
    • Why Use a Microcontroller?
    • Designer Computers—So Many Microcontrollers
    • The Compiler
    • PIC Programming Overview
    • Software and Hardware
    • PicBasic and PicBasic Pro Compilers
    • EPIC Programmer
    • Firmware
    • Consumables
    • 16F84 PIC Microcontroller
    • Step 1: Writing Code (the Basic Program)
    • Step 2: Using the Compiler
    • Step 3: Installing the Firmware, or Programming the PIC Chip
    • Ready, Steady, Go
    • Parts List
  • Chapter 2. Installing the Compiler
    • Installing the PicBasic Compiler Software
    • Installing the PicBasic Pro Compiler
  • Chapter 3. Installing the EPIC Software
    • Installing the EPIC Software in Windows
    • Installing the EPIC Software, DOS Version
    • Supplemental—Applications Directory
  • Chapter 4. CodeDesigner
    • CodeDesigner Features
    • Software Installation
    • Setting CodeDesigner Options vi Contents
    • First Program
    • The EPIC Programming Board Software
    • Parts List
  • Chapter 5. Using DOS to Code, Compile, and Program
    • Compile
    • Programming the PIC Chip
    • The EPIC Programming Board Software
      • Using EPIC DOS Version
      • Continuing with the wink.bas Program
  • Chapter 6. Testing the PIC Microcontroller
    • The PIC Microntroller
      • The Solderless Breadboard
      • Three Schematics, One Circuit
      • Wink
      • Troubleshooting the Circuit
    • PIC Experimenter’s Board and LCD Display
      • PIC Experimenter’s Board
      • Use
      • Simple Experiment
      • Builtin LCD
      • Using the LCD: PicBasic and PicBasic Pro Examples
    • Introduction to Binary and the PIC Microcontroller
      • Using TRIS and Port Registers
      • Accessing the Ports for Output
      • Counting Program
      • Counting in Binary by
      • Input
      • The button Command
      • A button Example
      • peek
      • peek and PicBasic Pro
      • Basic Input and Output Commands
    • Servomotors
    • Parts List
  • Chapter 7. Intelligence
    • Approaches to Building Intelligence
    • Where’s the Intelligence?
    • Layered Behavioral Responses
    • BehaviorBased Robotics
  • Chapter 8. Walter’s Turtle
    • BehaviorBased Robotics
    • William Grey Walter—Robotics Pioneer
    • Four Modes of Operation
      • Center (Tilt) Servomotor
      • Sensors
      • Electronics
      • Microcontroller Program
    • Parts List
  • Chapter 11. Speech Recognition
    • Applications
    • Software Approach
    • Learning to Listen
    • SpeakerDependent and SpeakerIndependent Recognition
    • Recognition Style
    • Speech Recognition Circuit
      • Circuit Construction
      • Keypad
      • To Train
    • Testing Recognition
      • Error Codes
      • Clearing the Trained Word Memory
    • Independent Recognition System
    • Voice Security System
    • Speech Interface Control Circuit
      • How the Circuit Works
      • PIC 16F84 Microcontroller Program
      • Active High Output
      • SPDT Relay Output
    • Circuit Construction
    • Programming the Speech Recognition Circuit: Training, Testing, and Retraining
    • SRI02 and SRI03 Interfaces
    • Robot Control
    • Parts List
  • Chapter 12. Robotic Arm
    • Servomotor Building Blocks for Robotics
    • Basic Servomotor Bracket Assembly
    • Assembling MultipleServomotor Assemblies
    • Building a FiveServomotor Robotic Arm
    • Servomotors
      • Servomotor Controllers
      • Simple Servomotor Controller
    • Four and FiveServomotor Controllers
    • Increasing the Lifting Capacity of the Robotic Arm
    • Adding a Robotic Arm Base
    • Parts List
  • Chapter 13. Bipedal Walker Robot
    • A Question of Balance?
    • A Little Feedback
    • Servomotors
    • Servomotor Brackets Contents ix
    • Footpads
    • Assembly
    • Schematic
    • Program
      • Subroutines M1, M2, and M3
    • Going Further
      • Turning Right and Left
    • Parts List
  • Chapter 14. Color Robotic Vision System
    • CMU Camera
    • Serial Communication
    • VB Application Program
    • Interfacing the CMU Camera to a Robot
    • PIC 16F84 Runs at 16 MHz
    • Program
    • Program
      • Incandescent or Fluorescent Lighting
      • Servomotors for Robot
    • Program
      • Robot Construction
    • Running the Program
    • Going Further
    • Parts List
    • Suppliers
    • Index

Preface

This is a project book on building small robots. Each robot utilizes the PICmicro

series of microcontrollers from Microchip Technologies Inc. for intelligence, nav

igation, motor control, and sensory readings. By changing the microcontroller

programming and sensory electronics we can create a zoo of robots that includes

photovores, behaviorbased (neural) robots, hexapod and bipedal walkers, and

artificial vision systems that can track and follow objects.

Each robot project has something to teach.

John Iovine

xi

This page intentionally left blank.

2 Chapter One

Programs can also make the microcontroller behave as a neural network

and/or a fuzzy logic controller. Microcontrollers are incorporated in consumer

electronics and are responsible for the “intelligence” in these smart electronic

devices.

Designer Computers—So Many Microcontrollers

There are a large variety of microcontrollers on the market. We will use the

versatile microcontroller chips called PIC chips (or PICmicro chips) from

Microchip Technology Inc.

The Compiler

There are a number of compilers on the market that allow users to write pro

grams (code) in different highlevel languages. Highlevel language frees the

programmer from wrestling with and controlling the microcontroller’s regis

ters when writing code and accessing the different aspects of the microcon

troller’s features and memory.

The highlevel language I use is a derivative of the Basic language. It is

called PicBasic. (The PicBasic and PicBasic Pro compilers used to write

PicBasic programs are products and trademarks of microEngineering Labs,

Inc.) PicBasic is similar to the PBasic language used in programming the

Basic Stamp series. Programming microcontrollers directly using the

PicBasic (or PicBasic Pro) compiler offer two major advantages over the Basic

Stamp series of microcontrollers which use external serial EEPROM for

memory storage, faster program execution speed (20 to 100fold increase),

and reduced cost.

PIC Programming Overview

Programming PIC microcontrollers is a simple threestep process: Write the

code, compile the code, and upload the code into a microcontroller. Following

is an overview of the process; stepbystep instructions will be provided in the

following chapters.

Software and Hardware

You will need two items to begin programming and building microcontroller

based projects and robotics. First is the compiler, either the PicBasic Pro or

PicBasic compiler (see Fig. 1.1). The PicBasic Pro compiler from

microEngineering Labs, Inc. has a suggested retail price of $249.95. The

PicBasic compiler from microEngineering Labs, Inc. has a suggested retail

price of $99.95. In addition to a compiler you need the EPIC programming

board and software; this package sells for $59.95 (see Fig. 1.2). (EPIC is a

product and trademark of microEngineering Labs, Inc.)

PicBasic and PicBasic Pro Compilers

The PicBasic and PicBasic Pro compilers both function in the same way. Saved

program code (text file) is run through a compiler (either the PicBasic or

PicBasic Pro compiler). The compiler reads through the text file and creates

(compiles) an equivalent machine code instruction listing (.hex file) of the program. The machine code (.hex file) is a list of hexadecimal numbers that represent the PicBasic program. The list of hexadecimal numbers (.hex file)

is uploaded (programmed) into the microcontroller. When the microcontroller

Robot Intelligence 3

Figure 1.1 PicBasic Pro and PicBasic software packages and manuals.

Figure 1.2 EPIC Programmer software and hardware.

Firmware

Many writers use the term firmware. This word is used when software is

embedded in a hardware device that can read and execute by the device but

cannot be modified. So when our program (software) is embedded (uploaded)

into the microcontroller, it may be referred to as firmware. Other phrases may

include the term firmware instead of software, such as “upload the firmware”

or “once the firmware has been installed into the device.”

Consumables

Consumables are the electronic components, the PIC microcontroller chip

itself, with a few support components to get the microcontroller up and run

ning. I recommend beginning with the 16F84 PIC microcontroller. The 16F

is an 18pin dip chip with 13 I/O lines and has 1K � 14 of rewritable memory.

The rewritable memory allows you to reprogram the PIC chip up to 1000 times

to test and troubleshoot your programs and circuits. The minimal support

components are a 5V dc power supply, oscillator (4.0MHz crystal), and one

pullup 1 � 4 W resistor (4.7k�).

16F84 PIC Microcontroller

The PIC 16F84 microcontroller is shown in Fig. 1.4. It is a versatile microcon

troller with flash memory. Flash memory is the terminology used to describe

“rewriteable” memory. The 1K � 14bit onboard flash memory can endure a

Robot Intelligence 5

Figure 1.3 Closeup of EPIC programming carrier board.

6 Chapter One

Figure 1.4 Pinout of 16F84 PIC microcontroller integrated cir cuit. General features: RISC CPU 35 singleword instructions; operating speed dc, 10MHz clock input; 1K program memory; 14bitwide instructions; 8bitwide data path; direct, indirect, and relative addressing; 1000 erase/write cycles. Peripheral fea tures: 13 I/O pins with individual direction control; highcurrent sink/source for direct LED drive (25mA sink max. per pin, 20 mA source max. per pin); TMRO—8bit timer/counter with 8bit programmable prescaler.

minimum of 1000 erase/write cycles. So you can reprogram and reuse the PIC

chip at least 1000 times. The program retention time between erase/write

cycles is approximately 40 years. The 18pin chip devotes 13 pins to I/O. Each

pin may be programmed individually for input or output. The pin status (I/O

direction control) may be changed on the fly via programming. Other features

include power on reset, powersaving sleep mode, powerup timer, and code

protection. Additional features and architectural details of the PIC 16F84 will

be given as we continue.

Step 1: Writing Code (the Basic Program)

Both the PicBasic and PicBasic Pro compilers are packaged with a free version

of CodeDesigner software. CodeDesigner is an integrated development envi

ronment (IDE) for writing and programming PIC microcontrollers.

CodeDesigner is an advanced text editor that is capable of calling and using

both the PicBasic and PicBasic Pro compilers and the EPIC software.