The robotic projects outlined in this book make extensive use of the PIC series of microcontroller from Microchip T echnology Inc. In addition to its ability to run programs, the microcontroller has input and output lines (pins) that are used to control motor drive systems, read sensors, and communicate. W e demand a lot from our microcontroller(s), so it’s important to have a good idea of what a microcontroller is right from the start.
What Is a Microcontroller?
A microcontroller is essentially an inexpensive singlechip computer . Single chip means the entire computer system lies within the confines of a sliver of silicon encapsulated inside the plastic housing of an integrated circuit. The microcontroller has features similar to those of a standard personal computer. The microcontroller contains a CPU (central processing unit), RAM (random access memory), ROM (readonly memory), I/O (input/output) lines, serial and parallel ports, timers, and sometimes other builtin peripherals such as ana logtodigital (A/D) and digitaltoanalog (D/A) converters. The key feature, however, is the microcontroller’s capability of uploading, storing, and running a program.
Why Use a Microcontroller?
Being inexpensive singlechip computers, microcontrollers are easy to embed into larger electronic circuit designs. Their ability to store and run unique programs makes them extremely versatile. For instance, one can program a microcontroller to make decisions and perform functions based on situations (I/O line logic) and events. The math and logic functions allow the microcontroller to mimic sophisticated logic and electronic circuits.
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. W e 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 programs (code) in different highlevel languages. Highlevel language frees the programmer from wrestling with and controlling the microcontroller ’s registers when writing code and accessing the different aspects of the microcontroller’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 (20to 100fold increase), and reduced cost.
PIC Programming Overview
Programming PIC microcontrollers is a simple threestep process: W rite 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.)