Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

What is a Microcontroller (Paralax, v2.2, student guide, 2004)

.pdf
Скачиваний:
118
Добавлен:
12.08.2013
Размер:
5.64 Mб
Скачать

Chapter #1: Getting Started · Page 1

Chapter #1: Getting Started

HOW MANY MICROCONTROLLERS DID YOU USE TODAY?

A microcontroller is a kind of miniature computer that you can find in all kinds of gizmos. Some examples of common, every-day products that have microcontrollers built-in are shown in Figure 1-1. If it has buttons and a digital display, chances are it also has a programmable microcontroller brain.

Figure 1-1

Every-Day Examples of

Devices that Contain

Microcontrollers

Try making a list and counting how many devices with microcontrollers you use in a typical day. Here are some examples: if your clock radio goes off, and you hit the snooze button a few times in the morning, the first thing you do in your day is interact with a microcontroller. Heating up some food in the microwave oven and making a call on a cell phone also involve operating microcontrollers. That’s just the beginning. Here are a few more examples: turning on the television with a handheld remote, playing a handheld game, using a calculator, and checking your digital wristwatch. All those devices have microcontrollers inside them that interact with you.

THE BASIC STAMP 2 - YOUR NEW MICROCONTROLLER

Parallax, Inc.’s BASIC Stamp® 2 module shown in Figure 1-2 has a microcontroller built onto it. It’s the black chip with lettering on it that reads “PIC16C57”. The rest of the components on the BASIC Stamp module are also found in consumer appliances you use every day. All together, they are correctly called an embedded computer system. This name is almost always shortened to just “embedded system”. Frequently, such modules are commonly just called “microcontrollers.”

The activities in this text will guide you through building circuits similar to the ones found in consumer appliances and high-tech gizmos. You will also write computer programs that the BASIC Stamp module will run. These programs will make the BASIC Stamp module monitor and control these circuits so that they perform useful functions.

Page 2 · What’s a Microcontroller?

Figure 1-2

The BASIC Stamp® 2

Microcontroller Module

BASIC Stamp 2 modules are the most popular microcontrollers made by Parallax, Inc.

In this text, “BASIC Stamp” refers to Parallax Inc.’s BASIC Stamp® 2 microcontroller module. There are other BASIC Stamp modules, some of which are shown in Figure 1-3. Each BASIC Stamp module is color coded. The BASIC Stamp 2 is green. The BASIC Stamp 2e is red. The BASIC Stamp 2SX is blue, and the BASIC Stamp 2p is gold. Each variation on the BASIC Stamp 2 is slightly different, featuring higher speed, more memory, additional functionality, or some combination of these extra features.

Figure 1-3

BASIC Stamp®

Modules

From Left to Right: BASIC Stamp® 2, 2e, 2SX, and 2p

AMAZING INVENTIONS WITH BASIC STAMP MICROCONTROLLERS

Consumer appliances aren’t the only things that contain microcontrollers. Robots, machinery, aerospace designs and other high-tech devices are also built with microcontrollers. Let’s take a look at some examples that were created with BASIC Stamp modules.

Robots have been designed to do everything from helping students learn more about microcontrollers, to mowing the lawn, to solving complex mechanical problems. Figure 1-4 shows two example robots. On each of these robots, students use the BASIC Stamp 2 to read sensors, control motors, and communicate with other computers. The robot on

Chapter #1: Getting Started · Page 3

the left is Parallax Inc.’s Boe-Bot. The projects in the Robotics with the Boe-Bot text can be tackled using the Boe-Bot after you’ve worked through the activities in this one. The robot on the right was built by a group of students and entered into a First Robotics competition. The goal of the contest is different each year. In the example shown, the goal was to see which group’s robot could sort colored hoops the fastest.

Figure 1-4

Educational Robots

Parallax Boe-Bot™ (left) First Competition Robot (right)

Other robots solve complex problems, such as the autonomous remote flight robot shown at the left of Figure 1-5. This robot was built and tested by mechanical engineering students at the University of California, Irvine. They used a BASIC Stamp module to help it communicate with a satellite global positioning system (GPS) so that the robot could know its position and altitude. The BASIC Stamp also read level sensors and controlled the motor settings to keep the robot flying properly. The mechanical millipede robot on the right was developed by a professor at Nanyang Technical University, Singapore. It has more than 50 BASIC Stamp modules, and they all communicate with each other in an elaborate network that helped control and orchestrate the motion of each set of legs. Robots like this not only help us better understand designs in nature, but they may eventually be used to explore remote locations, or even other planets.

Figure 1-5

Examples of Research

Robots that Contain

Microcontrollers

Autonomous flying robot at UC Irvine (left) and Millipede Project at Nanyang University (right)

Page 4 · What’s a Microcontroller?

With the help of microcontrollers, robots will also take on day-to-day tasks, such as mowing the lawn. The BASIC Stamp module inside the robotic lawn mower shown in Figure 1-6 helps it stay inside the boundaries of the lawn, and it also reads sensors that detect obstacles and controls the motors that make it move.

Figure 1-6

Robotic Lawn Mower

Prototype by the Robot

Shop

Microcontrollers are also used in scientific, high technology, and aerospace projects. The weather station shown on the left of Figure 1-7 is used to collect environmental data related to coral reef decay. The BASIC Stamp module inside it gathers this data from a variety of sensors and stores it for later retrieval by scientists. The submarine in the center is an undersea exploration vehicle, and its thrusters, cameras and lights are all controlled by BASIC Stamp microcontrollers. The rocket shown on the right is one that was part of a competition to launch a privately owned rocket into space. Nobody won the competition, but this rocket almost made it! The BASIC Stamp controlled just about every aspect of the launch sequence.

Figure 1-7

High-tech and Aerospace

Microcontroller Examples

Ecological data collection by EME Systems (left), undersea research by Harbor Branch Institute (center), and JP Aerospace test launch (right)

From common household appliances all the way through scientific and aerospace applications, the microcontroller basics you will need to get started on projects like these are introduced here. By working through the activities in this book, you will get to

Chapter #1: Getting Started · Page 5

experiment with and learn how to use a variety of building blocks found in all these hightech inventions. You will build circuits for displays, sensors, and motion controllers. You will learn how to connect these circuits to the BASIC Stamp 2 module, and then write computer programs that make it control displays, collect data from the sensors, and control motion. Along the way, you will learn many important electronic and computer programming concepts and techniques. By the time you’re done, you might find yourself well on the way to inventing a gizmo of your own design.

HARDWARE AND SOFTWARE

Getting started with BASIC Stamp microcontroller modules is similar to getting started with a brand-new PC or laptop. The first things that most people have to do when they get a new PC or laptop is take it out of the box, plug it in, install and test some software, and maybe even write some software of their own using a programming language. If this is your first time using a BASIC Stamp module, you will be doing all these same activities. If you are in a class, your hardware may already be all set up for you. If this is the case, your teacher may have other instructions. If not, this chapter will take you through all the steps of getting your new BASIC Stamp microcontroller up and running.

ACTIVITY #1: GETTING THE SOFTWARE

The BASIC Stamp Editor (version 2.0 or higher) is the software you will use in most of the activities and projects in this text. You will use this software to write programs that the BASIC Stamp module will run. You can also use this software to display messages sent by the BASIC Stamp that help you understand what it senses.

The BASIC Stamp Editor is free software, and the two easiest ways to get it are:

Download from the Internet: Look for “BASIC Stamp Windows Editor version 2.0…” on the www.parallax.com → Downloads → BASIC Stamp Software page.

Included on the Parallax CD: Follow the Software link on the Welcome page. Make sure the date printed on the CD is May 2003 or newer.

In a Hurry? Get your copy of the BASIC Stamp Windows Editor version 2.0 (or higher) and install it on your PC or laptop. Then, skip to: Activity #3: Setting Up the Hardware and Testing the System.

If you have questions along the way, Activity #1 can be used as a step-by-step reference for getting the software, and Activity #2 can be used as a reference for the installation procedure.

Page 6 · What’s a Microcontroller?

Computer System Requirements

You will need either a PC or laptop computer to run the BASIC Stamp Editor software. Getting started with BASIC Stamp programming is easiest if your PC or laptop has the following features:

Microsoft Windows 95® or newer operating system

A serial or USB port

A CD-ROM drive, World Wide Web access, or both

USB Port Adapter If your computer only has USB ports, you will need a USB to Serial Adapter. See Appendix A: USB to Serial Adapter for details and installation instructions.

Downloading the Software from the Internet

It’s easy to download the BASIC Stamp Editor software from the Parallax web site. The web page shown in Figure 1-8 may look different from the web page you see when you visit the site. Nonetheless, the steps for downloading the software should still be similar to these:

Using a web browser, go to www.parallax.com (shown in Figure 1-8).

Point at the Downloads menu to display the options.

Point at the BASIC Stamp Software link and click to select it.

Figure 1-8

The Parallax Web Site:

www.parallax.com

Chapter #1: Getting Started · Page 7

When you get to the BASIC Stamp Software page, find the most recent version of the BASIC Stamp Windows Editor download, with a version number of 2.0 or higher.

Click the Download icon. In Figure 1-9, the download icon looks like a file folder to the right of the description: “BASIC Stamp Windows Editor version 2.0 Beta 1 (6MB)”.

Figure 1-9

The Parallax Web Site

Downloads Page

When the File Download window shown in Figure 1-10 appears, select: Save this program to disk.

Click the OK button.

Figure 1-10

File Download Window

Figure 1-11 shows the Save As window that appears next. You can use the Save in field to browse your computer’s hard drives to find a convenient place to save the file.

After choosing where to save the file you are downloading, click the Save Button.

Page 8 · What’s a Microcontroller?

Figure 1-11

Save As Window

Selecting a place to save the file

Wait while the BASIC Stamp Editor installation program downloads (shown in Figure 1-12). This may take a while if you are using a modem connection.

When the download is complete, leave the window shown in Figure 1-13 open while you skip to the next section - Activity #2: Installing the Software.

Figure 1-12: Download Progress Window

Figure 1-13: Download Complete

Finding the Software on the Parallax CD

You can also install the BASIC Stamp Editor from the Parallax CD, but it has to be May 2003 or newer so that you can get the version of the BASIC Stamp Editor that is compatible with the examples in this text. You can find the Parallax CD’s Year and Month by examining the labeling on the front of the CD.

Place the Parallax CD into your computer’s CD drive. The Parallax CD Welcome application shown in Figure 1-14 should run as soon as you load the CD into your computer’s CD drive.

Chapter #1: Getting Started · Page 9

If the Welcome application does not automatically run, double-click My Computer, then double-click your CD drive, then double-click Welcome.

Figure 1-14

The Parallax CD

Browser

Click the Software link shown in Figure 1-14.

Click the + next to the BASIC Stamps folder shown in Figure 1-15.

Click the + next to the Windows folder.

Click the floppy diskette icon labeled “Stamp 2/2e/2sx/2p/2pe (stampw.exe)”.

Move on to Activity #2: Installing the Software.

Page 10 · What’s a Microcontroller?

Figure 1-15

The Parallax CD

Browser

Select the BASIC Stamp Editor installation program from the Software page.

Free downloads at the Parallax web site are included in the Parallax CD, but only up to the date the CD was created. The date on the front of the CD indicates when it was created. If the CD is just a few months old, you will probably have the most up-to-date material. If it’s an older CD, consider requesting a new one from Parallax or downloading the files you need from the Parallax web site.

ACTIVITY #2: INSTALLING THE SOFTWARE

By now, you have either downloaded the BASIC Stamp Editor Installer from the Parallax web site or located it on the Parallax CD. Now let’s run the BASIC Stamp Editor Installer.

Installing the Software Step by Step

If you downloaded the BASIC Stamp Editor Installer from the Internet, click the Open button on the Download Complete window shown in Figure 1-16.