Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Basic stamp editor for mac

20/10/2021 Client: muhammad11 Deadline: 2 Day

Individual Assignment --

Over the weekend, please spend 1 hour to familiarize yourself with the Boe-Bot by reading the Parallax Getting Started Document (posted in Course Content). For further reference you may review Chapter 1 through the first part of Chapter 2 (pages 11-34) of the Boe-Bot Manual (posted in Course Content).

If possible, download and install the PBasic Stamp Editor to your personal computer to familiarize yourself with the menu and commands as you read the Getting Started Document. (https://www.parallax.com/downloads/basic-stamp-software --> download the first file “BASIC Stamp Editor Software for Windows” or “Mac BS2 Software”)

In class we will be doing some Activities noted in the manual but you should also prepare outside of class.

The following questions from the reading are DUE on BLACKBOARD by next thursday (2/21).

Questions:

1) What device will be the brain of your Boe-Bot? (1pt)

2) When the Basic Stamp sends a character to the computer, what type of numbers are used to send the message through the programming cable? (1pt)

3) What is the name of the window that displays messages sent from the BASIC Stamp back to your computer? (1pt)

4) What PBASIC commands did you learn in this reading assignment? List AND define them. (2pts)

5) What do each of the settings on the 3-position power switch mean? When should you use each setting? (3pts)

6) When should you power-down your board? List at least two examples and explain why. (2pts)

*Bonus: Where can you look up more PBASIC commands?

Robotics with the Boe-Bot

Student Guide

VERSION 3.0

WARRANTY Parallax warrants its products against defects in materials and workmanship for a period of 90 days from receipt of product. If you discover a defect, Parallax will, at its option, repair or replace the merchandise, or refund the purchase price. Before returning the product to Parallax, call for a Return Merchandise Authorization (RMA) number. Write the RMA number on the outside of the box used to return the merchandise to Parallax. Please enclose the following along with the returned merchandise: your name, telephone number, shipping address, and a description of the problem. Parallax will return your product or its replacement using the same shipping method used to ship the product to Parallax.

14-DAY MONEY BACK GUARANTEE If, within 14 days of having received your product, you find that it does not suit your needs, you may return it for a full refund. Parallax will refund the purchase price of the product, excluding shipping/handling costs. This guarantee is void if the product has been altered or damaged. See the Warranty section above for instructions on returning a product to Parallax.

COPYRIGHTS AND TRADEMARKS This documentation is Copyright 2003-2010 by Parallax Inc. By downloading or obtaining a printed copy of this documentation or software you agree that it is to be used exclusively with Parallax microcontrollers and products. Any other uses are not permitted and may represent a violation of Parallax copyrights, legally punishable according to Federal copyright or intellectual property laws. Any duplication of this documentation for commercial uses is expressly prohibited by Parallax Inc. Duplication for educational use, in whole or in part, is permitted subject to the following conditions: the material is to be used solely in conjunction with Parallax microcontrollers and products, and the user may recover from the student only the cost of duplication. Check with Parallax for approval prior to duplicating any of our documentation in part or whole for any other use. BASIC Stamp, Board of Education, Boe-Bot, Stamps in Class, and SumoBot are registered trademarks of Parallax Inc. HomeWork Board, PING))), Parallax, the Parallax logo, Propeller, and Spin are trademarks of Parallax Inc. If you decide to use any of these words on your electronic or printed material, you must state that “(trademark) is a (registered) trademark of Parallax Inc.” upon the first use of the trademark name. Other brand and product names herein are trademarks or registered trademarks of their respective holders.

ISBN 9781928982531

3.0.0-10.11.10-HKTP

DISCLAIMER OF LIABILITY Parallax Inc. is not responsible for special, incidental, or consequential damages resulting from any breach of warranty, or under any legal theory, including lost profits, downtime, goodwill, damage to or replacement of equipment or property, or any costs of recovering, reprogramming, or reproducing any data stored in or used with Parallax products. Parallax is also not responsible for any personal damage, including that to life and health, resulting from use of any of our products. You take full responsibility for your BASIC Stamp application, no matter how life- threatening it may be.

ERRATA While great effort is made to assure the accuracy of our texts, errors may still exist. Occasionally an errata sheet with a list of known errors and corrections for a given text will be posted on the related product page at www.parallax.com. If you find an error, please send an email to editor@parallax.com.

Table of Contents

Preface.........................................................................................................................5 About Version 3.0 ...........................................................................................................6 Audience .........................................................................................................................6 Support Forums ..............................................................................................................7 Resources for Educators ................................................................................................8 Foreign Translations .......................................................................................................9 About the Author .............................................................................................................9 Special Contributors .......................................................................................................9

Chapter 1 : Your Boe-Bot’s Brain ...........................................................................11 Hardware and Software ................................................................................................12 Activity #1 : Getting the Software..................................................................................12 Activity #2 : Using the Help File for Hardware Setup ....................................................17 Summary ......................................................................................................................19

Chapter 2 : Your Boe-Bot’s Servo Motors .............................................................23 Introducing the Continuous Rotation Servo ..................................................................23 Activity #1 : Building and Testing the LED Circuit.........................................................24 Activity #2 : Tracking Time and Repeating Actions with a Circuit .................................27 Activity #3 : Connecting the Servo Motors ....................................................................40 Activity #4 : Centering the Servos.................................................................................49 Activity #5 : How To Store Values and Count ...............................................................53 Activity #6 : Testing the Servos ....................................................................................58 Summary ......................................................................................................................67

Chapter 3 : Assemble and Test Your Boe-Bot.......................................................73 Activity #1 : Assembling the Boe-Bot Robot .................................................................73 Activity #2 : Re-Test the Servos ...................................................................................82 Activity #3 : Start/Reset Indicator Circuit and Program.................................................86 Activity #4 : Testing Speed Control with the Debug Terminal.......................................92 Summary ......................................................................................................................98

Chapter 4 : Boe-Bot Navigation ............................................................................103 Activity #1 : Basic Boe-Bot Maneuvers .......................................................................103 Activity #2 : Tuning the Basic Maneuvers ...................................................................109 Activity #3 : Calculating Distances ..............................................................................112 Activity #4 : Maneuvers—Ramping.............................................................................117 Activity #5 : Simplify Navigation with Subroutines ......................................................120 Activity #6 : Advanced Topic—Building Complex Maneuvers in EEPROM ................126 Summary ....................................................................................................................136

Chapter 5 : Tactile Navigation with Whiskers ..................................................... 143 Tactile Navigation .......................................................................................................143 Activity #1 : Building and Testing the Whiskers ..........................................................144 Activity #2 : Field Testing the Whiskers ......................................................................152 Activity #3 : Navigation with Whiskers ........................................................................155 Activity #4 : Artificial Intelligence and Deciding When You’re Stuck...........................160 Summary ....................................................................................................................165

Chapter 6 : Light-Sensitive Navigation with Phototransistors.......................... 169 Introducing the Phototransistor...................................................................................169 Activity #1 : A Simple Binary Light Sensor .................................................................171 Activity #2 : Measure Light Levels with Phototransistors............................................179 Activity #3 : Light Sensitivity Adjustment ....................................................................189 Activity #4 : Light Measurements for Roaming ...........................................................194 Activity #5 : Routine for Roaming Toward Light .........................................................203 Activity #6 : Test Navigation Routine with the Boe-Bot...............................................212 Summary ....................................................................................................................216

Chapter 7 : Navigating with Infrared Headlights................................................. 221 Infrared Light ..............................................................................................................221 Activity #1 : Building and Testing the IR Object Detectors .........................................223 Activity #2 : Field Testing for Object Detection and Infrared Interference ..................230 Activity #3 : Infrared Detection Range Adjustments ...................................................234 Activity #4 : Object Detection and Avoidance .............................................................237 Activity #5 : High-Performance IR Navigation ............................................................239 Activity #6 : The Drop-Off Detector.............................................................................242 Summary ....................................................................................................................248

Chapter 8 : Robot Control with Distance Detection ........................................... 255 Determining Distance with the Same IR LED/Detector Circuit ...................................255 Activity #1 : Testing the Frequency Sweep ................................................................255 Activity #2 : Boe-Bot Shadow Vehicle ........................................................................262 Activity #3 : Following a Stripe....................................................................................271 Activity #4 : More Boe-Bot Activities and Projects Online...........................................278 Summary ....................................................................................................................280

Appendix A : Parts List and Kit Options.............................................................. 289

Appendix B : Resistor Color Codes and Breadboarding Rules ........................ 293

Appendix C : Boe-Bot Navigation Contests ........................................................ 299

Index ........................................................................................................................ 303

Preface · Page 5

Preface Robots are used in the auto, medical, and manufacturing industries, in all manner of exploration vehicles, and, of course, in many science fiction films. The word "robot" first appeared in a Czechoslovakian satirical play, Rossum's Universal Robots, by Karel Capek in 1920. Robots in this play tended to be human-like. From this point onward, it seemed that many science fiction stories involved these robots trying to fit into society and make sense out of human emotions. This changed when General Motors installed the first robots in its manufacturing plant in 1961. These automated machines presented an entirely different image from the “human form” robots of science fiction. Building and programming a robot is a combination of mechanics, electronics, and problem solving. What you're about to learn while doing the activities and projects in this text will be relevant to real-world applications that use robotic control, the only differences being the size and sophistication. The mechanical principles, example program listings, and circuits you will use are very similar to, and sometimes the same as, industrial applications developed by engineers. The goal of this text is to get students interested in and excited about the fields of engineering, mechatronics, and software development as they design, construct, and program an autonomous robot. This series of hands-on activities and projects will introduce students to basic robotic concepts using the Parallax Boe-Bot® robot, called the "Boe-Bot." Its name comes from the Board of Education® carrier board that is mounted on its wheeled chassis. An example of a Boe-Bot with an infrared obstacle detection circuit built on the Board of Education solderless prototyping area is shown below in Figure P-1.

Figure P-1 Parallax Inc.’s Boe-Bot® Robot

The activities and projects in this text begin with an introduction to your Boe-Bot’s brain, the Parallax BASIC Stamp® 2 microcontroller, and then move on to construction, testing,

Page 6 · Robotics with the Boe-Bot

and calibration of the Boe-Bot. After that, you will program the Boe-Bot for basic maneuvers, and then proceed to adding sensors and writing programs that make it react to its surroundings and perform autonomous tasks.

ABOUT VERSION 3.0

This is the first revision of this title since 2004. The major changes include:

 Replacement of the cadmium sulfide photoresistor with an RoHS-compliant light sensor of a type that will be more common in product design going forward. This required a rewrite of Chapter 6.

 Moving the “Setup and Testing” portion of Chapter 1 and the Hardware and Troubleshooting appendices to the Help file. This was done to support both serial and USB hardware connections, and other programming connections as our products and technologies continue to expand. This also allows for the dynamic maintenance of the Hardware and Troubleshooting material.

 Removal of references to the Parallax CD, which has been removed from our kits, reducing waste and ensuring that customers download the most recent BASIC Stamp Editor software and USB drivers available for their operating systems (www.parallax.com/go/Boe-Bot).

In addition, small errata items noted in the previous version (2.2) have been corrected. The material still aims for the same goals, and all of the same programming concepts and commands are covered, along with a few new ones. Finally, page numbers have been changed so the PDF page and the physical page numbers are the same, for ease of use.

AUDIENCE

This text is designed to be an entry point to technology literacy, and an easy learning curve for embedded programming and introductory robotics. The text is organized so that it can be used by the widest possible variety of students as well as independent learners. Middle-school students can try the examples in this text in a guided tour fashion by simply following the check-marked instructions with instructor supervision. At the other end of the spectrum, pre-engineering students’ comprehension and problem-solving skills can be tested with the questions, exercises and projects (with solutions) in each chapter summary. The independent learner can work at his or her own pace, and obtain assistance through the Stamps in Class forum cited below.

Preface · Page 7

SUPPORT FORUMS

Parallax maintains free, moderated forums for our customers, covering a variety of subjects:

 Propeller Chip: for all discussions related to the multicore Propeller microcontroller and development tools product line.

 BASIC Stamp: Project ideas, support, and related topics for all of the Parallax BASIC Stamp models.

 Sensors: Discussion relating to Parallax’s wide array of sensors, and interfacing sensors with Parallax microcontrollers.

 Stamps in Class: Students, teachers, and customers discuss Parallax’s education materials and school projects here.

 Robotics: For all Parallax robots and custom robots built with Parallax processors and sensors.

 Wireless: Topics include XBee, GSM/GPRS, telemetry and data communication over amateur radio.

 PropScope: Discussion and technical assistance for this USB oscilloscope that contains a Propeller chip.

 The Sandbox: Topics related to the use of Parallax products but not specific to the other forums.

 Projects: Post your in-process and completed projects here, made from Parallax products.

Page 8 · Robotics with the Boe-Bot

RESOURCES FOR EDUCATORS

We have a variety of resources for this text designed to support educators.

Stamps in Class “Mini Projects”

To supplement our texts, we provide a bank of projects for the classroom. Designed to engage students, each “Mini Project” contains full source code, “How it Works” explanations, schematics, and wiring diagrams or photos for a device a student might like to use. Many projects feature an introductory video, to promote self-study in those students most interested in electronics and programming. Just follow the Stamps in Class “Mini Projects” link at www.parallax.com/Education.

Educators Courses

These hands-on, intensive 1 or 2 day courses for instructors are taught by Parallax engineers or experienced teachers who are using Parallax educational materials in their classrooms. Visit www.parallax.com/Education → Educators Courses for details.

Parallax Educator’s Forum

In this free, private forum, educators can ask questions and share their experiences with using Parallax products in their classrooms. Supplemental education materials are also posted here. To enroll, email education@parallax.com for instructions; proof of status as an educator will be required.

Supplemental Educational Materials

Select Parallax educational texts have an unpublished set of questions and solutions posted in our Parallax Educators Forum; we invite educators to copy and modify this material at will for the quick preparation of homework, quizzes, and tests. PowerPoint presentations and test materials prepared by other educators may be posted here as well.

Copyright Permissions for Educational Use

No site license is required for the download, duplication and installation of Parallax software for educational use with Parallax products on as many school or home computers as needed. Our Stamps in Class texts and BASIC Stamp Manual are all available as free PDF downloads, and may be duplicated as long as it is for educational use exclusively with Parallax microcontroller products and the student is charged no more than the cost of duplication. The PDF files are not locked, enabling selection of text and images to prepare handouts, transparencies, or PowerPoint presentations.

Preface · Page 9

FOREIGN TRANSLATIONS

Many of our Stamps in Class texts have been translated into other languages; these texts are free downloads and subject to the same Copyright Permissions for Educational Use as our original versions. To see the full list, click on the Tutorials & Translations link at www.parallax.com/Education. These were prepared in coordination with the Parallax Volunteer Translator program. If you are interested in participating in our Volunteer Translator program, email translations@parallax.com.

ABOUT THE AUTHOR

Andy Lindsay joined Parallax Inc. in 1999, and has since authored eleven books and numerous articles and product documents for the company. The last three versions of Robotics with the Boe-Bot were designed and updated based on observations and educator feedback that Andy collected while traveling the nation and abroad teaching Parallax Educator Courses and events. Andy studied Electrical and Electronic Engineering at California State University, Sacramento, and is a contributing author to several papers that address the topic of microcontrollers in pre-engineering curricula. When he’s not writing educational material, Andy does product and application and product engineering for Parallax.

SPECIAL CONTRIBUTORS

The Parallax team assembled to prepare this edition includes: excellent department leadership by Aristides Alvarez, lesson design and technical writing by Andy Lindsay; cover art by Jen Jacobs; graphic illustrations by Rich Allred and Andy Lindsay; nitpicking, editing, and layout by Stephanie Lindsay. Special thanks go to Ken Gracey, founder of the Stamps in Class program, and to Tracy Allen and Phil Pilgrim for consulting in the selection of the light sensor used in this version to replace the cadmium- sulfide photoresistor. Stephanie is particularly grateful to John Kauffman for his last- minute review of the revised Chapter 6.

Page 10 · Robotics with the Boe-Bot

Your Boe-Bot’s Brain · Page 11

Chapter 1: Your Boe-Bot’s Brain Parallax, Inc’s Boe-Bot® robot is the focus of the activities, projects, and contests in this book. The Boe-Bot and a close-up of its BASIC Stamp® 2 programmable microcontroller brain are shown in Figure 1-1. The BASIC Stamp 2 module is both powerful and easy to use, especially with a robot.

Figure 1-1 BASIC Stamp Module on a Boe-Bot Robot

The activities in this text will guide you through writing simple programs that make the BASIC Stamp and your Boe-Bot do four essential robotic tasks:

1. Monitor sensors to detect the world around it 2. Make decisions based on what it senses 3. Control its motion (by operating the motors that make its wheels turn) 4. Exchange information with its Roboticist (that will be you!)

The programming language you will use to accomplish these tasks is called PBASIC, which stands for:

 Parallax - Company that invented and manufactures BASIC Stamp microcontrollers  Beginners - Made for beginners to learn how to program computers  All-purpose - Powerful and useful for solving many different kinds of problems  Symbolic - Using symbols (terms that resemble English word/phrases)  Instruction - To tell a computer what to do  Code - In terms that the computer (and you) can understand

Page 12 · Robotics with the Boe-Bot

What’s a Microcontroller? It’s a programmable device that is designed into your digital wristwatch, cell phone, calculator, clock radio, etc. In these devices, the microcontroller has been programmed to sense when you press a button, make electronic beeping noises, and control the device’s digital display. They are also built into factory machinery, cars, submarines, and spaceships because they can be programmed to read sensors, make decisions, and orchestrate devices that control moving parts.

The What’s a Microcontroller? Student Guide is the recommended first text for beginners. It is full of examples of how to use microcontrollers, and how to make the BASIC Stamp the brain of your own microcontrolled inventions. It’s available for free download from www.parallax.com/go/WAM, and it's also included in the BASIC Stamp Editor Help as a PDF file. It is included in the BASIC Stamp Activity Kit and BASIC Stamp Discovery Kit, which are carried by many electronic retailers. These kits can also be purchased directly from Parallax, either online at www.parallax.com/go/WAM or by phone at (888) 512-1024.

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 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.5 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.

Computer System Requirements

You will need a personal computer to run the BASIC Stamp Editor software. Your computer will need to have the following features:

 Microsoft Windows 2K/XP/Vista/7 or newer operating system  An available serial or USB port  Internet access and an Internet browser program

Your Boe-Bot’s Brain · Page 13

Downloading the Software from the Internet

It is important to always use the latest version of the BASIC Stamp Editor software if possible. The first step is to go to the Parallax web site and download the software.  Using a web browser, go to www.parallax.com/basicstampsoftware.

Figure 1-2: BASIC Stamp Editor download page at www.parallax.com/basicstampsoftware

Use the “Click Here to Download” button to get the latest version of the software.  Click on the Click Here to Download button to download the latest version of the

BASIC Stamp Windows Editor software.

Page 14 · Robotics with the Boe-Bot

 A File Download window will open, asking you if you want to run or to save this file (Figure 1-3). Click Save.

Figure 1-3 File Download Window Click Save, then save the file to your computer.

 Follow the prompts that appear. When the download is complete, click Run. You

may see messages from your operating system asking you to verify that you wish to continue with installation. Always agree that you want to continue.

Figure 1-4 Download Complete Message Click Run. If prompted, always confirm you want to continue.

Your Boe-Bot’s Brain · Page 15

 The BASIC Stamp Editor Installer window will open (Figure 1-5). Click Next and follow the prompts, accepting all defaults.

Figure 1-5 BASIC Stamp Editor Installer Window Click Next.

 IMPORTANT: When the “Install USB Driver” message appears (Figure 1-6),

leave the checkmark in place for the Automatically install/update driver (recommended) box, and then click Next.

Figure 1-6 Install USB Driver Message Leave the box checked, and click Next.

Page 16 · Robotics with the Boe-Bot

 When the “Ready to Install the Program” message appears, click the Install button. A progress bar may appear, and this could take a few minutes.

At this point, an additional window may appear behind the current window while the USB drivers are updating. This window will eventually close on its own when the driver installation is complete. If you don’t see this window, it does not indicate a problem.

About USB drivers. The USB drivers that install with the BASIC Stamp Windows Editor installer by default are necessary to use any Parallax hardware connected to your computer’s USB port. VCP stands for Virtual COM Port, and it will allow your computer’s USB port to look and be treated as a standard RS232 serial port by Parallax hardware.

USB Drivers for Different Operating Systems The USB VCP drivers included in the BASIC Stamp Windows Editor software are for certain Windows operating systems only. For more information, visit www.parallax.com/usbdrivers.

 When the window tells you that installation has been successfully completed,

click Finish (Figure 1-7).

Figure 1-7 BASIC Stamp Editor Installation Completed Click Finish.

Your Boe-Bot’s Brain · Page 17

ACTIVITY #2: USING THE HELP FILE FOR HARDWARE SETUP

In this section you will run the BASIC Stamp Editor’s Help file. Within the Help file, you will learn about the different BASIC Stamp programming boards available for the Stamps in Class program, and determine which one you are using. Then, you will follow the steps in the Help to connect your hardware to your computer and test your BASIC Stamp programming system.

Running the BASIC Stamp Editor for the first time

 If you see the BASIC Stamp Editor icon on your computer desktop, double-click it (Figure 1-8).

 Or, click on your computer’s Start menu, then choose All Programs  Parallax Inc  BASIC Stamp Editor 2.5  BASIC Stamp Editor 2.5.

Figure 1-8 BASIC Stamp Editor Desktop Icon Double-click to launch the program.

 On the BASIC Stamp Editor’s toolbar, click Help on the toolbar (Figure 1-9) and then select BASIC Stamp Help… from the drop-down menu.

Figure 1-9 Opening the Help Menu Click Help, then choose BASIC Stamp Help from the drop-down menu.

Page 18 · Robotics with the Boe-Bot

Figure 1-10: BASIC Stamp Editor Help

 Click on the Getting Started with Stamps in Class link on the bottom of the

Welcome page, as shown in the lower right corner of Figure 1-10.

Your Boe-Bot’s Brain · Page 19

Following the Directions in the Help File

From here, you will follow the directions in the Help file to complete these tasks:

 Identify which BASIC Stamp development board you are using  Connect your development board to your computer  Test your programming connection  Troubleshoot your programming connection, if necessary  Write your first PBASIC program for your BASIC Stamp  Power down your hardware when you are done

When you have completed the activities in the Help file, return to this book and continue with the Summary below before moving on to Chapter 2.

What do I do if I get stuck?

If you run into problems while following the directions in this book or in the Help file, you have many options to obtain free Technical Support:

 Forums: sign up and post a message in our free, moderated Stamps in Class forum at forums.parallax.com.

 Email: send an email to support@parallax.com.  Telephone: In the Continental United States, call toll-free to 888-99-STAMP

(888-997-8267). All others call (916) 624-8333.  More resources: Visit www.parallax.com/support.

SUMMARY

This chapter guided you through the following:  An introduction to the BASIC Stamp module  Where to get the free BASIC Stamp Editor software you will use in just about all

of the experiments in this text  How to install the BASIC Stamp Editor software  How to use the BASIC Stamp Editor’s Help and the BASIC Stamp Manual  An introduction to the BASIC Stamp module, Board of Education, and

HomeWork Board  How to set up your BASIC Stamp hardware  How to test your software and hardware  How to write and run a PBASIC program  Using the DEBUG and END commands, CR control character, and DEC formatter.

Page 20 · Robotics with the Boe-Bot

 A brief introduction to ASCII code  How to disconnect the power to your Board of Education or HomeWork Board

when you’re done

Questions

1. What device will be the brain of your Boe-Bot? 2. When the BASIC Stamp sends a character to your PC/laptop, what type of

numbers are used to send the message through the programming cable? 3. What is the name of the window that displays messages sent from the BASIC

Stamp to your PC/laptop? 4. What PBASIC commands did you learn in this chapter?

Exercises

1. Explain what the asterisk does in this command: DEBUG DEC 7 * 11

2. Guess what the Debug Terminal would display if you ran this command: DEBUG DEC 7 + 11

3. There is a problem with these two commands. When you run the code, the numbers they display are stuck together so that it looks like one large number instead of two small ones. Modify these two commands so that the answers appear on different lines in the Debug Terminal. DEBUG DEC 7 * 11 DEBUG DEC 7 + 11

Projects

1. Use DEBUG to display the solution to the math problem: 1 + 2 + 3 + 4. 2. Save FirstProgramYourTurn.bs2 under another name. If you were to place the

DEBUG command shown below on the line just before the END command in the program, what other lines could you delete and still have it work the same? Modify the copy of the program to test your hypothesis (your prediction of what will happen). DEBUG "What's 7 X 11?", CR, "The answer is: ", DEC 7 * 11

Your Boe-Bot’s Brain · Page 21

Solutions

Q1. A BASIC Stamp 2 microcontroller module. Q2. Binary numbers, that is, 0’s and 1’s. Q3. The Debug Terminal. Q4. DEBUG and END E1. It multiplies the two operands 7 and 11, resulting in a product of 77. The asterisk

is the multiply operator. E2. The Debug Terminal would display: 18 E3. To fix the problem, add a carriage return using the CR control character and a

comma. DEBUG DEC 7 * 11 DEBUG CR, DEC 7 + 11

P1. Here is a program to display a solution to the math problem: 1+2+3+4. ' What's a Microcontroller - Ch01Prj01_Add1234.bs2 '{$STAMP BS2} '{$PBASIC 2.5} DEBUG "What's 1+2+3+4?" DEBUG CR, "The answer is: " DEBUG DEC 1+2+3+4 END

P2. The last three DEBUG lines can be deleted. An additional CR is needed after the

"Hello" message. ' What's a Microcontroller - Ch01Prj02_ FirstProgramYourTurn.bs2 ' BASIC Stamp sends message to Debug Terminal. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Hello, it's me, your BASIC Stamp!", CR DEBUG "What's 7 X 11?", CR, "The answer is: ", DEC 7 * 11 END

The output from the Debug Terminal is: Hello, it's me, your BASIC Stamp! What's 7 X 11? The answer is: 77

Page 22 · Robotics with the Boe-Bot

This output is the same as it was with the previous code. This is an example of using commas to output a lot of information, using only one DEBUG command with multiple elements in it.

Your Boe-Bot’s Servo Motors · Page 23

Chapter 2: Your Boe-Bot’s Servo Motors This chapter will guide you through connecting, adjusting, and testing the Boe-Bot’s motors. In order to do that, you will need to understand certain PBASIC commands and programming techniques that will control the direction, speed, and duration of servo motions. Therefore, Activities #1, #2, and #5 will introduce you to these programming tools, and then Activities #3, #4, and #6 will show you how to apply them to the servos. Since precise servo control is key to the Boe-Bot’s performance, completing these activities before mounting the servos into the Boe-Bot chassis is both important and necessary!

INTRODUCING THE CONTINUOUS ROTATION SERVO

The Parallax Continuous Rotation servos shown in Figure 2-1 are the motors that will make the Boe-Bot’s wheels turn. This figure points out the servos’ external parts. Many of these parts will be referred to as you go through the instructions in this and the next chapter.

Figure 2-1 Parallax Continuous Rotation Servo

Note: You might find it useful to bookmark this page so that you can refer back to it later.

Cable for

power and

control signal

Access hole for center adjusting feedback potentiometer

Control horn

Phillips screw

Mounting Flange

Mounting Flange

Label should read

“Continuous Rotation”

Case contains motor, circuits,

and gears

Plug for RC servo connection ports on Board of Education

Page 24 · Robotics with the Boe-Bot

Standard Servos vs. Continuous Rotation Servos: Standard servos are designed to receive electronic signals that tell them what position to hold. These servos control the positions of radio controlled airplane flaps, boat rudders, and car steering. Continuous rotation servos receive the same electronic signals, but instead of holding certain positions, they turn at certain speeds and directions. Continuous rotation servos are ideal for controlling wheels and pulleys.

Servo Control Horn - 4-point Star vs. Round: It doesn’t make a difference. So long as it is labeled “continuous rotation” it’s the servo for your Boe-Bot. You will be removing the control horn with a wheel.

ACTIVITY #1: BUILDING AND TESTING THE LED CIRCUIT

Controlling a servo motor’s speed and direction involves a program that makes the BASIC Stamp send the same message, over and over again. The message has to repeat itself around 50 times per second for the servo to maintain its speed and direction. This activity has a few PBASIC example programs that demonstrate how to repeat the same message over and over again and control the timing of the message.

Displaying Messages at Human Speeds

You can use the PAUSE command to tell the BASIC Stamp to wait for a while before executing the next command.

PAUSE Duration

The number that you put to the right of the PAUSE command is called the Duration argument, and it’s the value that tells the BASIC Stamp how long it should wait before moving on to the next command. The units for the Duration argument are thousandths of a second (ms). So, if you want to wait for one second, use a value of 1000. Here’s how the command should look:

PAUSE 1000

If you want to wait for twice as long, try: PAUSE 2000

Your Boe-Bot’s Servo Motors · Page 25

A second is abbreviated “s.” In this text, when you see 1 s, it means one second.

A millisecond is one thousandth of a second, and it is abbreviated “ms.” The command PAUSE 1000 delays the program for 1000 ms, which is 1000/1000 of a second, which is one second, or 1 s. Got it?

Example Program: TimedMessages.bs2

There are lots of different ways to use the PAUSE command. This example program uses PAUSE to delay between printing messages that tell you how much time has elapsed. The program should wait one second before it sends the “One second elapsed…” message and another two seconds before it displays the “Three seconds elapsed . . . ” message.  If you have a Board of Education, move the 3-postion switch from position-0 to

position-1.  If you have a HomeWork Board, reconnect the 9 V battery to the battery clip.  Enter the program below into the BASIC Stamp Editor.  Save the program under the name TimedMessages.bs2.  Run the program, and then watch for the delay between messages.

' Robotics with the Boe-Bot - TimedMessages.bs2 ' Show how the PAUSE command can be used to display messages at human speeds. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Start timer..." PAUSE 1000 DEBUG CR, "One second elapsed..." PAUSE 2000 DEBUG CR, "Three seconds elapsed..." DEBUG CR, "Done." END

From here onward, the three instructions that came before this program will be phrased like this:

 Enter, save, and run TimedMessages.bs2.

Page 26 · Robotics with the Boe-Bot

Your Turn – Different Pause Durations

You can change the delay between messages by changing the PAUSE commands’ Duration arguments.  Try changing the PAUSE Duration arguments from 1000 and 2000 to 5000 and

10000, for example: DEBUG "Start timer..." PAUSE 5000 DEBUG CR, "Five seconds elapsed..." PAUSE 10000 DEBUG CR, "Fifteen seconds elapsed..."

 Run the modified program.  Also try it again with numbers like 40 and 100 for the Duration arguments;

they’ll go pretty fast.  The longest possible Duration argument is 65535. If you've got a minute to

spare, try PAUSE 60000.

Over and Over Again

One of the best things about both computers and microcontrollers is that they never complain about doing the same boring things over and over again. You can place your commands between the words DO and LOOP if you want them executed over and over again. For example, let’s say you want to print a message repeating once every second. Simply place your DEBUG and PAUSE commands between the words DO and LOOP like this:

DO DEBUG "Hello!", CR PAUSE 1000 LOOP

Example Program: HelloOnceEverySecond.bs2

 Enter, save, and run HelloOnceEverySecond.bs2.  Verify that the “Hello!” message is printed once every second.

Your Boe-Bot’s Servo Motors · Page 27

' Robotics with the Boe-Bot - HelloOnceEverySecond.bs2 ' Display a message once every second. ' {$STAMP BS2} ' {$PBASIC 2.5} DO DEBUG "Hello!", CR PAUSE 1000 LOOP

Your Turn – A Different Message

You can modify your program so that part of it executes once, and another part executes over an over again.  Modify the program so that the commands look like this:

DEBUG "Hello!" DO DEBUG "!" PAUSE 1000 LOOP

 Run it and see what happens! Did you anticipate the result?

ACTIVITY #2: TRACKING TIME AND REPEATING ACTIONS WITH A CIRCUIT

In this activity, you will build circuits that emit light that will allow you to “see” the kind of signals that are used to control the Boe-Bot’s servo motors.

What’s a Microcontroller? This activity contains selected excerpts from the What’s a Microcontroller? Student Guide.

 Even if you are familiar with this material from What’s a Microcontroller?, don’t skip this activity.

In the second half of this activity, you will examine the signals that control your servos and timing diagrams in a different light than they were presented in What’s a Microcontroller? Bonus! The components in your Boe-Bot kit can be used to complete many of the activities in What’s a Microcontroller? Go www.paralllax.com/go/WAM for a complete list, and to download the text.

Page 28 · Robotics with the Boe-Bot

Introducing the LED and Resistor

A resistor is a component that “resists” the flow of electricity. This flow of electricity is called current. Each resistor has a value that tells how strongly it resists current flow. This resistance value is called the ohm, and the sign for the ohm is the Greek letter omega: Ω. The resistor you will be working with in this activity is the 470 Ω resistor shown in Figure 2-2. The resistor has two wires (called leads and pronounced “leeds”), one coming out of each end. There is a ceramic case between the two leads, and it’s the part that resists current flow. Most circuit diagrams that show resistors use the symbol on the left with the squiggly lines to tell the person building the circuit that he or she must use a 470 Ω resistor. This is called a schematic symbol. The drawing on the right is a part drawing used in some beginner level Stamps in Class texts to help you build circuits.

470  Yellow

Violet Brown

Gold Silver or Blank

Figure 2-2 470 Ω Resistor Part Drawing Schematic symbol (left) and Part Drawing (right)

The colored stripes indicate resistance values. See Appendix B: Resistor Color Codes and Breadboarding Rules on page 293 for information on how to determine a resistor's value from the colored stripes on its ceramic case.

A diode is a one-way current valve, and a light-emitting diode (LED) emits light when current passes through it. Unlike the color codes on a resistor, the color of the LED usually just tells you what color it will glow when current passes through it. The important markings on an LED are contained in its shape. Since an LED is a one-way current valve, you have to make sure to connect it the right way, or it won’t work as intended. Figure 2-3 shows an LED’s schematic symbol and part drawing. An LED has two terminals. One is called the anode, and the other is called the cathode. In this activity, you will have to build the LED into a circuit, and you will have to pay attention and make sure the anode and cathode leads are connected to the circuit properly. On the part drawing, the anode lead is labeled with the plus-sign (+). On the schematic symbol, the anode is the wide part of the triangle. In this part drawing, the cathode lead is the pin

Your Boe-Bot’s Servo Motors · Page 29

labeled with a minus-sign (-), and on the schematic symbol, the cathode is the line across the point of the triangle.

+ _

LED

Figure 2-3 LED Part Drawing and Schematic Symbol Part drawing (above) and schematic symbol (below) The LED part drawings in later pictures will have a + next to the anode leg.

When you start building your circuit, make sure to check it against the schematic symbol and part drawing. If you look closely at the LED’s plastic case in the part drawing, it’s mostly round, but there is a small flat spot right near one of the leads that that tells you it’s the cathode. Also note that the LED’s leads are different lengths. In this text, the anode will be shown with a (+) sign and the cathode will be shown with a (–) sign.

Always check the LED’s plastic case. Usually, the longer lead is connected to the LED’s anode, and the shorter lead is connected to its cathode. But sometimes the leads have been clipped to the same length, or a manufacturer does not follow this convention. Therefore, it is best to always look for the flat spot on the case. If you plug an LED in backwards, it will not hurt it, but it will not light up.

LED Test Circuit Parts

(2) LEDs – Red (2) Resistors, 470 Ω (yellow-violet-brown)

Always disconnect power to your board before building or modifying circuits! For the Board of Education, set the 3-position switch to position-0. For the BASIC Stamp HomeWork Board, disconnect the 9 V battery from the battery clip. Always double-check your circuit for errors before reconnecting power.

Page 30 · Robotics with the Boe-Bot

LED Test Circuits

If you completed the What’s a Microcontroller? text, you are no doubt very familiar with the circuit shown in Figure 2-4. The left side of this figure shows the circuit schematic, and the right side shows a wiring diagram example of the circuit built on your board’s prototyping area.  Build the circuit shown in Figure 2-4.  Make sure that the shorter pins on each LED (the cathodes) are plugged into

black sockets labeled Vss.  Make sure the longer pins (the anodes, marked with a  in the wiring diagram)

are connected to the white breadboard sockets exactly as shown.

P12

P13

Vss Vss

LEDLED

470 

470 

P15 P14

P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0

P13 P12

X2

X3

Vdd VssVin +

+

Figure 2-4 Two LEDs Connected to BASIC Stamp I/O Pins P13 and P12 Schematic (left) and wiring diagram (right)

What's an I/O pin? I/O stands for input/output. The BASIC Stamp 2 has 24 pins, 16 of which are I/O pins. In this text, you will program the BASIC Stamp to use I/O pins as outputs to make LED lights turn on/off, control the speed and direction the Parallax Continuous Rotation servos turn, make tones with a speaker, and prepare sensors to detect light and objects. You will also program the BASIC Stamp to use I/O pins as inputs to monitor sensors that indicate mechanical contact, light level, objects in the Boe-Bot's path, and even their distance.

New to building circuits? See Appendix B: Resistor Color Codes and Breadboarding Rules on page 293.

Your Boe-Bot’s Servo Motors · Page 31

Figure 2-5 shows what you will program the BASIC Stamp to do to the LED circuit. Imagine that you have a 5 volt (5 V) battery. Although a 5 V battery is not common, the Board of Education has a device called a voltage regulator that supplies the BASIC Stamp with the equivalent of a 5 V battery. When you connect a circuit to Vss, it’s like connecting the circuit to the negative terminal of the 5 V battery. When you connect the other end of the circuit to Vdd, it’s like connecting it to the positive terminal of a 5 V battery.

-

-

- -

-

-

-

-

-

-

-

-

-

-

-

- +

_

- -

+

+

-

- - - + +

+

- - - + +

+

- - +

+

-

N

NNN

+ =

N N

N

+

_ -

+

- - - + +

+

- - - + +

+

- - +

NNN

+

N N

N

Vdd

Vss

5 V

Vdd

Vss

5 V

Figure 2-5 Current and Electron Flow

Volts is abbreviated V. That means 5 volts is abbreviated 5 V. When you apply voltage to a circuit, it’s like applying electrical pressure.

Current refers to the rate at which electrons pass through a circuit. You will often see measurements of current expressed in amps, which is abbreviated A. The amount of current an electric motor draws is often measured in amps, for example 2 A, 5 A, etc. However, the currents you will use in the Board of Education are measured in thousandths of an amp, or milliamps. For example, 10.3 mA passes through the circuit in Figure 2-5.

When these connections are made, 5 V of electrical pressure is applied to the circuit causing electrons to flow through and the LED to emit light. As soon as you disconnect the resistor lead from the battery’s positive terminal, the current stops flowing, and the LED stops emitting light. You can take it one step further by connecting the resistor lead to Vss, which has the same result. This is the action you will program the BASIC Stamp to do to make the LED turn on (emit light) and off (not emit light).

Page 32 · Robotics with the Boe-Bot

Programs that Control the LED Test Circuits

The HIGH and LOW commands can be used to make the BASIC Stamp connect an LED alternately to Vdd and Vss. The Pin argument is a number between 0 and 15 that tells the BASIC Stamp which I/O pin to connect to Vdd or Vss.

HIGH Pin LOW Pin

For example, if you use the command: HIGH 13

...it tells the BASIC Stamp to connect I/O pin P13 to Vdd, which turns the LED on. Likewise, if you use the command

LOW 13

...it tells the BASIC Stamp to connect I/O pin P13 to Vss, which turns the LED off. Let’s try this out.

Example Program: HighLowLed.bs2

 Reconnect power to your board.  Enter, save, and run HighLowLed.bs2.  Verify that the LED circuit connected to P13 is turning on and off, once every

second. ' Robotics with the Boe-Bot – HighLowLed.bs2 ' Turn the LED connected to P13 on/off once every second. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "The LED connected to Pin 13 is blinking!" DO HIGH 13 PAUSE 500 LOW 13 PAUSE 500 LOOP

Your Boe-Bot’s Servo Motors · Page 33

How HighLowLed.bs2 Works

Figure 2-6 shows how the BASIC Stamp can connect an LED circuit alternately to Vdd and Vss. When it’s connected to Vdd, the LED emits light. When it’s connected to Vss, the LED does not emit light. The command HIGH 13 instructs the BASIC Stamp to connect P13 to Vdd. The command PAUSE 500 instructs the BASIC Stamp to leave the circuit in that state for 500 ms. The command LOW 13 instructs the BASIC Stamp to connect the LED to Vss. Again, the command PAUSE 500 instructs the BASIC Stamp to leave it in that state for another 500 ms. Since these commands are placed between DO and LOOP, they execute over and over again.

SOUT

SIN

ATN

VSS

P0

P1

P2

P3

P4

P5

P6

P7

VIN

VSS

RES

VDD (+5V)

P15

P14

P13

P12

P11

P10

P9

P8

24

23

22

21

20

19

18

17

16

15

14

13

1

2

3

4

5

6

7

8

9

10

11

12

BS2-IC

BS2

Vdd

Vss

SOUT

SIN

ATN

VSS

P0

P1

P2

P3

P4

P5

P6

P7

VIN

VSS

RES

VDD (+5V)

P15

P14

P13

P12

P11

P10

P9

P8

24

23

22

21

20

19

18

17

16

15

14

13

1

2

3

4

5

6

7

8

9

10

11

12

BS2-IC

BS2

Vdd

Vss

Figure 2-6 BASIC Stamp Switching The BASIC Stamp can be programmed to internally connect the LED circuit’s input to Vdd or Vss.

A Diagnostic Test for your Computer

A very few computers, such as some laptops, will halt the PBASIC program after the first time through a DO...LOOP instruction. These computers have a non-standard serial port design. By placing a DEBUG command the program LedOnOff.bs2, the open Debug Terminal prevents this from possibly happening. You will next re-run this program without the DEBUG command to see if your computer has this non-standard serial port problem. It is not likely, but it would be important for you to know.  Open HighLowLed.bs2.  Delete the entire DEBUG instruction.  Run the modified program while you observe your LED.

If the LED blinks on and off continuously, just as it did when you ran the original program with the DEBUG command, your computer will not have this problem.

Page 34 · Robotics with the Boe-Bot

If the LED blinked on and off only once and then stopped, you have a computer with a non-standard serial port design. If you disconnect the programming cable from your board and press the Reset button, the BASIC Stamp will run the program properly without freezing. In programs you write yourself, you should add a single command:

DEBUG "Program Running!"

...right after the compiler directives. This will open the Debug Terminal and keep the COM port open. This will prevent your programs from freezing after one pass through the DO…LOOP, or any of the other looping commands you will be learning in later chapters. You will see this command in some of the example programs that would not otherwise need a DEBUG instruction. So, you should be able to run all of the remaining programs in this book even if your computer failed the diagnostic test.

Introducing the Timing Diagram

A timing diagram is a graph that relates high (Vdd) and low (Vss) signals to time. In Figure 2-7, time increases from left to right, and high and low signals align with either Vdd (5 V) or Vss (0 V). This timing diagram shows you a 1000 ms slice of the high/low signal you just experimented with. The line of dots (. . .) to the right of the signal is one way of indicating that the signal repeats itself.

Vdd (5 V)

Vss (0 V)

500 ms

1000 ms

500 ms

Figure 2-7 Timing Diagram for HighLowLed.bs2 The LED on/off states are shown above the timing diagram.

Your Boe-Bot’s Servo Motors · Page 35

Your Turn – Blink the Other LED

Blinking the other LED (connected to P12) is a simple matter of changing the Pin argument in the HIGH and LOW commands and re-running the program.  Modify the program so that the commands look like this:

DO HIGH 12 PAUSE 500 LOW 12 PAUSE 500 LOOP

 Run the modified program and verify that it makes the other LED blink on/off. You can also make both LEDs blink at the same time.  Modify the program so that the commands look like this:

DO HIGH 12 HIGH 13 PAUSE 500 LOW 12 LOW 13 PAUSE 500 LOOP

 Run the modified program and verify that it makes both LEDs blink on and off at roughly the same time.

You can modify the program again to make one LEDs blink alternately on/off, and you can also change the rates that the LEDs blink by adjusting the PAUSE command’s Duration argument higher or lower.  Try it!

Page 36 · Robotics with the Boe-Bot

Viewing a Servo Control Signal with an LED

The high and low signals you will program the BASIC Stamp to send to the servo motors must last for very precise amounts of time. That’s because the servo motors measure the amount of time the signal stays high, and use it as an instruction for where to turn. For accurate servo motor control, the time these signals stay high must be much more precise than you can get with a HIGH and a PAUSE command. You can only change the PAUSE command’s Duration argument by 1 ms (remember, that’s 1/1000 of a second) at a time. There’s a different command called PULSOUT that can deliver high signals for precise amounts of time. These amounts of time are values you use in the Duration argument, and they are measured in units that are two millionths of a second!

PULSOUT Pin, Duration A microsecond is a millionth of a second. It’s abbreviated µs. Be careful when you write this value, it’s not the letter ‘u’ from our alphabet; it’s the Greek letter mu ‘µ’. For example, 8 microseconds is abbreviated 8 µs. You can send a HIGH signal that turns the P13 LED on for 2 µs (that’s two millionths of a second) by using this command:

PULSOUT 13, 1

This command would turn the LED on for 4 µs: PULSOUT 13, 2

This command sends a high signal that you can actually view: PULSOUT 13, 65000

How long does the LED circuit connected to P13 stay on when you send this pulse? Let’s figure it out. The time it stays on is 65000 times 2 µs. That’s:

s13.0

s000002.065000

s265000Duration

   

...which is still pretty fast, thirteen hundredths of a second.

Your Boe-Bot’s Servo Motors · Page 37

The largest value you can use in a PULSOUT Duration argument is 65535.

Example Program: PulseP13Led.bs2

This timing diagram in Figure 2-8 shows the pulse train you are about to send to the LED with this new program. This time, the high signal lasts for 0.13 seconds, and the low signal lasts for 2 seconds. This is 100 times slower than the signal that the servo will need to control its motion.

Vdd (5 V)

Vss (0 V)

0.13 s 0.13 s

2.0 s

Figure 2-8 Timing Diagram for PulseP13Led.bs2

 Enter, save, and run PulseP13Led.bs2.  Verify that the LED circuit connected to P13 pulses for about thirteen

hundredths of a second, once every two seconds. ' Robotics with the Boe-Bot – PulseP13Led.bs2 ' Send a 0.13 second pulse to the LED circuit connected to P13 every 2 s. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" DO PULSOUT 13, 65000 PAUSE 2000 LOOP

Page 38 · Robotics with the Boe-Bot

Example Program: PulseBothLeds.bs2

This example program sends a pulse to the LED connected to P13, and then it sends a pulse to the LED connected to P12 as shown in Figure 2-9. After that, it pauses for two seconds.

Figure 2-9 Timing Diagram for PulseBothLeds.bs2 The LEDs emit light for 0.13 second while the signal is high.

The voltages (Vdd and Vss) in this timing diagram are not labeled. With the BASIC Stamp, it is understood that the high signal is 5 V (Vdd) and the low signal is 0 V (Vss).

This is a common practice in documents that explain the timing of high and low signals. Often there are one or more of these documents for each component inside the circuit an engineer is designing. The engineers who created the BASIC Stamp had to comb through many of these kinds of documents looking for information needed to help make decisions while designing the product.

Sometimes the times are also left out, or just shown with a label, like thigh and tlow. Then, the desired time values for thigh and tlow are listed in a table somewhere after the timing diagram. This concept is discussed in more detail in Basic Analog and Digital, another Parallax Stamps in Class Student Guide.

 Enter, save, and run PulseBothLeds.bs2.  Verify that both LED circuits simultaneously pulse for about thirteen hundredths

of a second, once every two seconds.

0.13 s 0.13 s

P12

0.13 s 0.13 s

2.26 s

P13

Your Boe-Bot’s Servo Motors · Page 39

' Robotics with the Boe-Bot – PulseBothLeds.bs2 ' Send a 0.13 second pulse to P13 and P12 every 2 seconds. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" DO PULSOUT 13, 65000 PULSOUT 12, 65000 PAUSE 2000 LOOP

Your Turn – Viewing the Full Speed Servo Signal

Remember the servo signal is 100 times as fast as the program you just ran. First, let’s try running the program ten times as fast. That means divide all the Duration arguments (PULSOUT and PAUSE) by 10.  Modify the program so that the commands look like this:

DO PULSOUT 13, 6500 PULSOUT 12, 6500 PAUSE 200 LOOP

 Run it and verify that it makes the LEDs blink ten times as fast. Now, let’s try 100 times as fast (one hundredth of the duration). Instead of appearing to flicker, the LED will just appear to be not as bright as it would when you send it a simple high signal. That’s because the LED is flashing on and off so quickly and for such brief periods of time that the human eye cannot detect the actual on/off flicker, just a change in brightness.  Modify the program so that the commands look like this:

DO PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 LOOP

Page 40 · Robotics with the Boe-Bot

 Run the modified program and verify that it makes both LEDs about the same brightness.

 Try substituting 850 in the Duration argument for the P13 PULSOUT command. DO PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 LOOP

 Run the modified program and verify that the P13 LED now appears slightly brighter than the P12 LED. You may have to cup your hands around the LEDs and peek inside to see the difference. They differ because the amount of time the P13 LED stays on is longer than the amount of time the P12 LED stays on.

 Try substituting 750 in the Duration argument for both the PULSOUT commands.

DO PULSOUT 13, 750 PULSOUT 12, 750 PAUSE 20 LOOP

 Run the modified program and verify that the brightness of both LEDs is the same again. It may not be obvious, but the brightness level is between those given by Duration arguments of 650 and 850.

ACTIVITY #3: CONNECTING THE SERVO MOTORS

In this activity, you will build a circuit that connects the servo to a power supply and a BASIC Stamp I/O pin. The LED circuits you developed in the last activity will be used later to monitor the signals the BASIC Stamp sends to the servos to control their motion.

Parts for Connecting the Servos

(2) Parallax Continuous Rotation servos (2) Built and tested LED circuits from the previous activity

Your Boe-Bot’s Servo Motors · Page 41

Finding the Connection Instructions for Your Carrier Board

There are different revisions of the Board of Education and BASIC Stamp HomeWork Board. Furthermore, there are several variations to the Board of Education, based on programming interface. In Chapter 1, you used the BASIC Stamp Editor Help file to determine the type and revision of your board, and special instructions for older boards. The instructions in this book were written to support the boards that were current at the time of writing, and previous compatible revisions:

 Board of Education Serial - Rev C or higher  Board of Education USB - Rev A or higher  BASIC Stamp HomeWork Board Serial - Rev C or higher

 Examine the labeling on your carrier board and make note of the type and the

revision.  For older boards, check the BASIC Stamp Editor Help for notes specific to your

board.

(916) 624-8333 www.parallaxinc.com www.stampsinclass.com

Rev B

X3

Vdd VssVin

Board of Education © 2000-2003

P3 P2 P1 P0

X2

Rev C

Rev B

Black Red

X3

Vdd VssVin X4 X5

15 14 13 12

STAMPS CLASS in

Vdd VssVR1

5

X2

X3 nc

Rev A

Figure 2-10 BASIC Stamp Switching The BASIC Stamp can be programmed to internally connect the LED circuit’s input to Vdd or Vss.

 If your board is one of the type and revisions listed above, go to one of the

following pages to continue:

 Board of Education: go to page 42.  HomeWork Board: go to page 45.

Page 42 · Robotics with the Boe-Bot

Connecting the Servos to the Board of Education

 Turn off the power by setting the 3-position switch on your Board of Education to position-0 (see Figure 2-11).

Reset

0 1 2

Figure 2-11 Turn Off Power

Figure 2-12 shows the servo header on the Board of Education. This board features a jumper that you can use to connect the servo’s power supply to either Vin or Vdd. To move it, you have to pull it upwards and off the pair of pins it rests on, then push it onto the pair of pins you want it to rest on.  If you are using the 6 V battery pack, make sure the jumper between the servo

ports on the Board of Education is set to Vin as shown on the left of Figure 2-12.

About Rechargeable Batteries. The Boe-Bot requires 6 V, easily obtained from 4 AA 1.5 V batteries. Alkaline AA batteries are 1.5 V. However, many rechargeable AA batteries supply only 1.2 V, giving a total of 4.8 V, which is not enough to power the BASIC Stamp and Boe- Bot. If you cannot find 1.5 V rechargeable batteries, you may use the inexpensive Boe-Boost (#30078) to add a 5

th 1.2 V rechargeable battery, bringing the total back to 6 V.

 If you are using a 7.5 V, 1000 mA center positive DC supply, set the jumper to

Vdd as shown on the right side of Figure 2-12.

CAUTION – Misuse of AC powered DC supplies can damage your servos.

If you are inexperienced with DC supplies, consider sticking with the 6 V battery pack that comes with the Boe-Bot.

Use only supplies with DC output voltage ratings between 6 and 7.5 V, and current output ratings of 800 mA or more.

Only use a DC supply that is equipped with the same kind of plug as the Boe-Bot battery pack (2.1 mm, center-positive).

Your Boe-Bot’s Servo Motors · Page 43

Black Red

X4 X5

15 14 13 12Vdd

Vin

Select Vin if you are using the battery pack that comes with the Boe-Bot kits.

Select Vdd if you are using a DC supply that plugs into an AC outlet (AC adapter).

Black Red

X4 X5

15 14 13 12Vdd

Vin

Figure 2-12 Selecting Your Servo Ports’ Power Supply on the Board of Education

All examples and instructions in this book will use the battery pack. Figure 2-13 shows the schematic of the circuit you will build on the Board of Education. The jumper is set to Vin.  Connect your servos to your Board of Education as shown in Figure 2-13.

Vin

Vss

P13 White Red Black

Vin

Vss

P12 White Red Black

White Red Black

Black Red

X4 X5

15 14 13 12Vdd

White Red

Black

Figure 2-13 Servo Connections for the Board of Education

How do I tell which servo is connected to P13 and which servo is connected to P12? You just plugged your servos into headers with numbers above them. If the number above the header where the servo is plugged in is 13, it means the servo is connected to P13. If the number is 12, it means it’s connected to P12.

 When you are done assembling the system, it should resemble Figure 2-14

(LED circuits not shown).

Page 44 · Robotics with the Boe-Bot

Figure 2-14 Board of Education with Servos and Battery Pack Connected

 If you removed the LED circuits after Activity #2, make sure to rebuild them as

shown in Figure 2-15. They will be your servo signal monitoring circuits.

P12

P13

Vss Vss

LEDLED

470 

470 

P15 P14

P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0

P13 P12

X2

X3

Vdd VssVin +

+

Figure 2-15 LED Servo Signal Monitor Circuit

Disconnecting Power for the Board of Education

Never leave the power connected to your system when you are not working on it.

 To disconnect power from your Board of Education, move the 3-position switch to position-0.

 Move on to Activity #4: Centering the Servos on page 49.

Your Boe-Bot’s Servo Motors · Page 45

Connecting the Servos to the BASIC Stamp HomeWork Board

If you are connecting your servos to a BASIC Stamp HomeWork Board, you will need the parts listed below and shown in Figure 2-16:

Parts List:

(1) Battery pack with tinned leads (not included, see Appendix A) (2) Parallax Continuous Rotation Servos (2) 3-pin male-male headers (not included, see Appendix A) (4) Jumper wires (4) AA batteries – 1.5 V alkaline (2) Built and tested LED circuits from the previous activity

Figure 2-16 Servo Centering Parts for the HomeWork Board

Figure 2-17 shows a schematic of the servo circuits on the HomeWork Board. Before you start building this circuit, make sure that power is disconnected from the BASIC Stamp HomeWork Board.  The 9 V battery should be disconnected from the battery clip, and the battery

pack with tinned leads should not have any batteries loaded.

Page 46 · Robotics with the Boe-Bot

Vbp

Vss

P12 White Red Black

Vbp

Vss

P13 White Red Black

Figure 2-17 Servo Connection Schematic for the BASIC Stamp HomeWork Board Note: Vbp stands for Voltage Battery Pack. See the i-box below.

 Remove the two LED/resistor circuits, and save the parts.  Build the servo ports shown on the left side of Figure 2-18.  Double-check to make sure the black wire with the white stripe is connected to

Vbp, and the solid black wire should be connected to Vss.  Double-check to make sure that all the connections for P13, Vbp, Vss, Vbp

(another one), and P12 all exactly match the wiring diagram.  Connect the servo plugs to the male headers as shown in Figure 2-18, on the

right side of the figure.  Double-check to make sure the servo wire colors match the legend in the figure.

Vbp stands for Voltage battery pack. It refers to the 6 VDC supplied by the four 1.5 V batteries. This is brought directly to the breadboard to power the servos for Boe-Bots built with the HomeWork Board. Your BASIC Stamp is still powered by the 9 V battery.

About Rechargeable Batteries. The Boe-Bot requires 6 V, easily obtained from 4 AA 1.5 V batteries. Alkaline AA batteries are 1.5 V. However, many rechargeable AA batteries supply only 1.2 V, giving a total of 4.8 V, which is not enough to power the BASIC Stamp and Boe- Bot. If you cannot find 1.5 V rechargeable batteries, you may use the inexpensive Boe-Boost (#30078) to add a 5

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Financial Analyst
Quality Assignments
Best Coursework Help
WRITING LAND
Smart Homework Helper
Exam Attempter
Writer Writer Name Offer Chat
Financial Analyst

ONLINE

Financial Analyst

I find your project quite stimulating and related to my profession. I can surely contribute you with your project.

$32 Chat With Writer
Quality Assignments

ONLINE

Quality Assignments

I am a PhD writer with 10 years of experience. I will be delivering high-quality, plagiarism-free work to you in the minimum amount of time. Waiting for your message.

$42 Chat With Writer
Best Coursework Help

ONLINE

Best Coursework Help

Being a Ph.D. in the Business field, I have been doing academic writing for the past 7 years and have a good command over writing research papers, essay, dissertations and all kinds of academic writing and proofreading.

$26 Chat With Writer
WRITING LAND

ONLINE

WRITING LAND

I have worked on wide variety of research papers including; Analytical research paper, Argumentative research paper, Interpretative research, experimental research etc.

$16 Chat With Writer
Smart Homework Helper

ONLINE

Smart Homework Helper

I will provide you with the well organized and well research papers from different primary and secondary sources will write the content that will support your points.

$30 Chat With Writer
Exam Attempter

ONLINE

Exam Attempter

I am an experienced researcher here with master education. After reading your posting, I feel, you need an expert research writer to complete your project.Thank You

$31 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

100 pair copper cable - Enron bankruptcy case study - Do starfish have organs - Corn pone opinions answers - Discussion 2 WK 3 SOCW 6443: The Role of Mental Health Professionals in the Initial Stages of Psychopharmacological Intervention - Asynchronous sample rate converter - Clipsal c bus training - Angelas ashes chapter 12 - How does emilia die in othello - Video streaming industry five forces analysis - Swot analysis - Selected comparative financial statements of korbin company follow - Modern database management 13th edition - Oedipus rex oracle's prophecy quote - Physical Security Plan for a IT company - Angle of elevation and depression examples - Surface to volume ratio - Crewe and nantwich u3a - That his virtues will plead - Manning company issued 10000 shares - Asme b31 1 2018 pdf free download - Gopro be a hero marketing campaign - Debido al estrés, mario (comenzar) a consumir alcohol en exceso. - Colleges prepare for life freeman hrabowski - Food as thought resisting the moralization of eating - Which of the following estimates at a - Generalized Anxiety Disorder - Determination of amount of acetic acid in vinegar - Hhmi org biointeractive virus explorer - Models and theories of planned change - The outcasts of poker flat analysis - Hollywood reporter media kit - How to increase days of working capital in capsim - Quality dimensions worksheet - Write 3 as an improper fraction - Cisco esa ordering guide 2016 - Theory - Brad is testing whether school is more enjoyable - Advanced persistent threats are ________ - Is night by elie wiesel fiction - Analysis of the other wes moore - Re french caledonia travel - Difference between intramodal and intermodal transportation - Geopolotics - Write a Audit report and Do a powerpoint presentation - Research Paper - Global Giant Corporation case analysis - Scottish national flying club - Process cost summary - Harvesting purple sprouting broccoli - Average velocity of graph - Persuasive speech - Nursing - Latisha assignment.....1 page dye by 15 hprs only - Scheriproct ointment bayer plc - Explain the evolutionary relationship between the fin of a fish - Research paper - The lorelei poem by heinrich heine - Strategic Management and Strategic Competitiveness - Arranger of holidays crossword climber - Https://www.thenutracafe.com/es/keto-360-slim/ - Statistics Final report - Gayatri mantra in finger - Probationary period evaluation template - Theory of ferrous phosphate syrup - Warehoousing - Visio track changes - The dapper dons partnership was formed - Assessment Plan - Controlling metaphor - Marketing questions - Crown napkin folding procedure - Cambridge o level islamiyat - Girl code episodes watch online - Academic referencing tool latrobe - What is business explain its features - Cultural relativism and universal human rights by carolyn fluehr lobban - Artifact that embodies ethical values - Church on the rock ocho rios - Federal public service mobility and transport - Hypothesis for caffeine and heart rate - Everyday use by alice walker discussion questions and answers - Www bplans com bakery business plan - Global supply chain management simulation v2 answers - Elements of film powerpoint - Cafs hsc past papers - Construction closeout documents list - Conflict resolution in nursing scenarios - Frankston special development school - Mortgage discharge form westpac - John q movie character analysis - Importance of organisational behaviour pdf - The metric system worksheet answers - Assignment - 10ks of personal branding pdf - Http www dfs ny gov insurance elec license req htm - O2 arena vehicle management system - Hazardous area classification chart download - Tic tac toe java program code - Elizabeth college parent portal