Robotics with the Boe-Bot Student Guide VERSION 2.
WARRANTY Parallax Inc. 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 Inc. 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.
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 Inc.
Table of Contents · Page i Table of Contents Preface.........................................................................................................................5 Foreword.........................................................................................................................5 Audience .........................................................................................................................6 Support and Discussion Groups ...........................................
Page ii · Robotics with the Boe-Bot Activity #5: Simplify Navigation with Subroutines .......................................................140 Activity #6: Building Complex Maneuvers in EEPROM ..............................................146 Summary ....................................................................................................................157 Chapter 5: Tactile Navigation with Whiskers ...................................................... 165 Tactile Navigation ...............
Table of Contents · Page iii Appendix E: Boe-Bot Parts Lists ..........................................................................317 Appendix F: Balancing Photoresistors ................................................................321 Appendix G: Tuning IR Distance Detection .........................................................329 Appendix H: Boe-Bot Navigation Contests .........................................................335 Index ..........................................................
Preface · Page v Preface FOREWORD 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.
Page vi · Robotics with the Boe-Bot 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, 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.
Preface · Page vii Educational Sales: sales@parallax.com Contact our Sales Team for information about educational discount pricing and classroom packs for our Stamps in Class kits and other selected products. Technical Support: support@parallax.com Contact our Tech Support Team for general questions regarding the set-up and use of any of our hardware or software products. THE STAMPS IN CLASS CURRICULUM This text can be successfully completed with no prerequisites.
Page viii · Robotics with the Boe-Bot Educational Project Kits: Elements of Digital Logic, Understanding Signals and Experiments with Renewable Energy focus more closely on topics in electronics, while StampWorks provides a variety of projects that are useful to hobbyists, inventors and product designers interested in trying a variety of projects. “Elements of Digital Logic”, Student Guide, Version 1.0, Parallax Inc., 2003 “Experiments with Renewable Energy”, Student Guide, Version 1.0, Parallax Inc.
Preface · Page ix Figure P-2 Original Boe-Bot Prototype Andrew Lindsay, Parallax Chief Roboticist, has since rewritten this text and its activities with three goals in mind. First, to support all activities in the text with carefully written “how to” instructions. Second, to expose the reader and student to new circuit, programming, engineering, and robotic concepts in each chapter.
Page x · Robotics with the Boe-Bot If you have suggestions, think you found a mistake, or would like to contribute an activity or chapter to forthcoming Robotics with the Boe-Bot versions or More Robotics with the Boe-Bot texts, contact us at stampsinclass@parallax.com. Subscribe and stay tuned to the StampsInClass Yahoo! Group for the latest in free hardware offers for Robotics with the Boe-Bot contributions. See the WEB SITE AND DISCUSSION LISTS section on the page before the Table of Contents.
Chapter 1: Your Boe-Bot’s Brain · Page 1 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® 2 module on a Boe-Bot™ robot.
Page 2 · 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.
Chapter 1: Your Boe-Bot’s Brain · Page 3 Both this text and What’s a Microcontroller? contain instructions for getting started with BASIC Stamp hardware and software in Chapter 1. These instructions are almost identical. Introducing the BASIC Stamp and Board of Education A BASIC Stamp 2 module and a Board of Education® carrier board are shown in Figure 1-2. As mentioned earlier, a BASIC Stamp module is like a very small computer. This very small computer plugs into the Board of Education carrier board.
Page 4 · Robotics with the Boe-Bot Figure 1-3 BASIC Stamp® HomeWork Board™ project platform. What’s the difference? Using a Board of Education carrier board and BASIC Stamp module gives you additional features such as headers for plugging in servo motors, control over the type of power supply the servos receive, and a handy, 3-position switch you can use to control what parts of the system receive power. The BASIC Stamp 2 module is removable, and can be replaced.
Chapter 1: Your Boe-Bot’s Brain · Page 5 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 more recent than April 2003. In a Hurry? Get your copy of the BASIC Stamp Windows Editor version 2.
Page 6 · Robotics with the Boe-Bot Figure 1-4 The Parallax Web Site: www.parallax.com √ √ When you get to the BASIC Stamp Software page, find a BASIC Stamp Windows Editor download with a version number of 2.0 or higher. Click the Download icon. In Figure 1-5, the Download icon looks like a file folder to the right of the description: “BASIC Stamp Windows Editor Version 2.0 Beta 1 (6MB)”.
Chapter 1: Your Boe-Bot’s Brain · Page 7 Figure 1-6 File Download Window Figure 1-7 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. Figure 1-7 Save As Window Selecting a place to save the file √ Wait while the BASIC Stamp Editor installation program downloads (shown in Figure 1-8).
Page 8 · Robotics with the Boe-Bot Figure 1-8 Download Progress Window √ When the download is complete, leave the window shown in Figure 1-9 open while you skip to the next section - Activity #2: Installing the Software. Figure 1-9 Download Complete Window Go to Activity #2: Installing the Software.
Chapter 1: Your Boe-Bot’s Brain · Page 9 √ √ If the Welcome application does not automatically run, double-click My Computer, then double-click your CD drive, and then double-click Welcome. Click the Software link shown in Figure 1-10. Figure 1-10 The Parallax CD Browser √ √ √ √ Click the + next to the BASIC Stamps folder shown in Figure 1-11. Click the + next to the Windows folder. Click the floppy diskette icon labeled “Stamp 2/2e/2sx/2p/2pe (stampw.exe)”.
Page 10 · Robotics with the Boe-Bot Figure 1-11 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 month or two old, you will probably have the most up-to-date material.
Chapter 1: Your Boe-Bot’s Brain · Page 11 Figure 1-12 Download Complete Window If you skipped here from the “Downloading the Software from the Internet” section, click the Open button now. √ If you located the software on the Parallax CD, click the Install button shown in Figure 1-13. Figure 1-13 The Parallax CD Browser Install button located near bottom of window. √ When the BASIC Stamp Editor…InstallShield Wizard window opens, click the Next button shown in Figure 1-14.
Page 12 · Robotics with the Boe-Bot √ √ Select Typical for your setup type as shown in Figure 1-15. Click the Next button. Figure 1-15 Setup Type √ When the InstallShield Wizard tells you it is “Ready to Install the Program”, click the Install button shown in Figure 1-16. Figure 1-16 Ready to Install Click the Install button. √ When the InstallShield Wizard window tells you “InstallShield Wizard Completed” as shown in Figure 1-17, click Finish.
Chapter 1: Your Boe-Bot’s Brain · Page 13 Figure 1-17 InstallShield Wizard Completed ACTIVITY #3: SETTING UP THE HARDWARE AND TESTING THE SYSTEM The BASIC Stamp needs to be connected to power for it to run. It also needs to be connected to a PC so it can be programmed. After making these connections, you can use the BASIC Stamp Editor to test the system. This activity will show you how.
Page 14 · Robotics with the Boe-Bot √ If you are using a USB to Serial Adapter, follow the hardware and software installation instructions that are supplied with the product. FTDI’s US232B/LC USB to Serial Adapter: At the time of this writing, the US232B/LC USB to Serial Adapter made by Future Technology Devices International is the recommended adapter for use with Parallax products.
Chapter 1: Your Boe-Bot’s Brain · Page 15 Board of Education Connection Instructions If you have a BASIC Stamp and Board of Education, Figure 1-20 shows the hardware you will need to get started.
Page 16 · Robotics with the Boe-Bot Figure 1-21 Rubber Feet (left) Affixed to Underside of the Board of Education (right) The Board of Education Rev C has a 3-position switch (see Figure 1-22). Position-0 is for turning the power to the Board of Education completely off. Regardless of whether or not you have a battery or power supply connected to the Board of Education Rev C, when the 3-posiiton switch is set to 0, the device is off. √ Set the 3-position switch on the Board of Education to position-0.
Chapter 1: Your Boe-Bot’s Brain · Page 17 Figure 1-23 Battery Pack Polarity indicators on molded plastic (left) and loaded with correct polarity (right). √ If your BASIC Stamp is not already plugged into your Board of Education, insert it into the socket shown in Figure 1-24, step-1. Make sure your BASIC Stamp is right-side-up (as shown in Figure 1-24) before you insert it into the socket! If the BASIC Stamp is plugged into the socket upside-down, it could be damaged when you plug in power.
Page 18 · Robotics with the Boe-Bot √ √ √ Plug the serial cable into the Board of Education as shown in Figure 1-24, step-2. Plug the battery pack into the 6-9 VDC battery jack as shown in Figure 1-24, step-3. Move the 3-position switch from position-0 to position-1 to turn the power on. Figure 1-25 3-position Switch 0 √ 1 2 Set to position-1 to turn the power back on. The green light labeled Pwr on the Board of Education should now be on.
Chapter 1: Your Boe-Bot’s Brain · Page 19 (1) BASIC Stamp HomeWork Board Figure 1-27 Getting Started Hardware for the BASIC Stamp HomeWork Board √ Remove each rubber foot from its adhesive strip and affix it to the underside of the HomeWork Board next to each plated hole at each corner of the board as shown in Figure 1-28, making sure not to cover up the holes. Figure 1-28 Rubber Feet √ Connect the serial cable and battery to the HomeWork Board (Figure 1-29, steps 1 and 2).
Page 20 · Robotics with the Boe-Bot Figure 1-29 HomeWork Board and Serial Cable 1 STAM PS CL ASS (916) 624-8333 www.parallaxinc.com www.stampsinclass.com in Vdd Vin Rev A Vss X3 2 Power Powercell Alkaline Battery Reset P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 Plug the serial cable and 9 V battery into the HomeWork Board. X2 © 2002 BASIC Stamp® HomeWork Board Figure 1-30 shows the BASIC Stamp HomeWork Board connected to its battery power supply and serial programming cable.
Chapter 1: Your Boe-Bot’s Brain · Page 21 Figure 1-30 BASIC Stamp HomeWork Board Ready to Program Testing for Communication √ First, run your BASIC Stamp Editor by double-clicking the shortcut on your desktop. It should look similar to the one shown in Figure 1-31. Figure 1-31 BASIC Stamp Editor Shortcut Look for a shortcut similar to this one on your computer’s desktop. The Windows Start Menu can also be used to run the BASIC Stamp Editor.
Page 22 · Robotics with the Boe-Bot √ To make sure your BASIC Stamp is communicating with your computer, click the Run menu, then select Identify. Figure 1-32 BASIC Stamp Editor An Identification window similar to the one shown in Figure 1-33 will appear. The example in the figure shows that a BASIC Stamp 2 has been detected on COM2. Figure 1-33 Identification Window Example: BASIC Stamp 2 found on COM2.
Chapter 1: Your Boe-Bot’s Brain · Page 23 11 100 10000100 01 10 00 10 1 0 1 10 10101001 0 0 001 000 0 1 1 00 6-9VDC 9 Vdc Battery Figure 1-34 Messages from the BASIC Stamp to Your Computer STA MPS CL A SS in TM 101 0 1 11 00 001 0 1 1 Sout Sin ATN Vss P0 P1 P2 P3 P4 P5 P6 P7 U1 Vin Vss Rst Vdd P15 P14 P13 P12 P11 P10 P9 P8 10 0 www.stampsinclass.
Page 24 · Robotics with the Boe-Bot √ √ Begin by clicking the BS2 icon (the green diagonal chip) on the toolbar, shown highlighted in Figure 1-35. If you hold your cursor over this button, its flyover help description “Stamp Mode: BS2” will appear. Next, click on the gear icon labeled “2.5” shown highlighted in Figure 1-36. Its flyover help description is “PBASIC Language: 2.5”. Figure 1-35 BS2 Icon Figure 1-36 PBASIC 2.
Chapter 1: Your Boe-Bot’s Brain · Page 25 Figure 1-37 √ HelloBoeBot.bs2 Entered into the BASIC Stamp Editor Save your work by clicking File and selecting Save, (shown in Figure 1-38). Figure 1-38 Saving the Program HelloBoeBot.bs2 √ √ Enter the name HelloBoeBot.bs2 into the File name field near the bottom of the Save As window as shown in Figure 1-39. Click the Save button.
Page 26 · Robotics with the Boe-Bot Figure 1-39 Entering the File Name The next time you save, the BASIC Stamp Editor will automatically save to the same filename (HelloBoeBot.bs2) unless you tell it to save to a different filename by clicking File and selecting Save As (instead of just Save). √ Click Run, and select Run from the menu that appears (by clicking it) as shown in Figure 1-40. Figure 1-40 Running Your First Program HelloBoeBot.
Chapter 1: Your Boe-Bot’s Brain · Page 27 √ Press and release the Reset button. Did you see a second “Hello…” message appear in the Debug Terminal? Figure 1-41 Debug Terminal The Debug Terminal displays messages sent to the PC/laptop by the BASIC Stamp. The BASIC Stamp Editor has shortcuts for most common tasks. For example, to run a program, you can press the ‘Ctrl’ and ‘R’ keys at the same time to run a program. You can also click the Run button.
Page 28 · Robotics with the Boe-Bot There are several special messages that you can send to the BASIC Stamp Editor by placing them inside comments (to the right of an apostrophe on a given line). These are called compiler directives, and every program in this text will use these two directives: ' {$STAMP BS2} ' {$PBASIC 2.5} The first directive is called the Stamp directive, and it tells the BASIC Stamp Editor that you will be downloading the program to a BASIC Stamp 2.
Chapter 1: Your Boe-Bot’s Brain · Page 29 √ √ A good new name for the file would be HelloBoeBotYourTurn.bs2. Modify the comments at the beginning of the program so that they read: ' Robotics with the Boe-Bot - HelloBoeBotYourTurn.bs2 ' BASIC Stamp does simple math, and sends the results ' to the Debug Terminal.
Page 30 · Robotics with the Boe-Bot Your Debug Terminal should now resemble Figure 1-44. Figure 1-44 Modified HelloBoeBot.bs2 Debug Terminal Output Make sure that when you re-run your program, you get the results you expect. Where did my Debug Terminal go? Sometimes the Debug Terminal gets hidden behind the BASIC Stamp Editor window.
Chapter 1: Your Boe-Bot’s Brain · Page 31 Using the BASIC Stamp Editor’s Help √ In the BASIC Stamp Editor, Click Help, then select Index as shown in Figure 146. Figure 1-46 Selecting Index from the Help Menu √ √ Type DEBUG into the field labeled Type in the keyword to find: (shown in Figure 147). When the word DEBUG appears in the list below the field you are typing in, double-click it, then click the Display button.
Page 32 · Robotics with the Boe-Bot √ √ Click the Search tab, and run a search for the word DEBUG. Repeat this process for the END command. Getting and Using the BASIC Stamp Manual The BASIC Stamp Manual is available for free download from the Parallax web site, and it’s also included on the Parallax CD. It can also be purchased as a bound and printed manual. Downloading the BASIC Stamp Manual from the Parallax Web Site √ √ √ √ Using a web browser, go to www.parallax.com.
Chapter 1: Your Boe-Bot’s Brain · Page 33 √ √ Briefly look over the BASIC Stamp Manual explanation of the DEBUG command. Count the number of example programs in the DEBUG section. How many are there? Figure 1-49 Reviewing the DEBUG Command in the BASIC Stamp Manual Your Turn √ √ Use the BASIC Stamp Manual index to look up the DEBUG command. Look up the END command in the BASIC Stamp Manual.
Page 34 · Robotics with the Boe-Bot Example Program – AsciiName.bs2 √ Enter and run AsciiName.bs2. Remember to use the toolbar icons to place Compiler Directives into your programs! '{$STAMP BS2} - Use the diagonal green electronic chip icon. '{$PBASIC 2.5} - Use the gear icon labeled 2.5. You can see a picture of these icons again on page 24. ' Robotics with the Boe-Bot - AsciiName.bs2 ' Use ASCII code in a DEBUG command to display the words BASIC Stamp 2. ' {$STAMP BS2} ' {$PBASIC 2.
Chapter 1: Your Boe-Bot’s Brain · Page 35 √ √ √ √ √ Save AsciiRandom.bs2 as YourAsciiName.bs2 Look up the ASCII Chart in the BASIC Stamp Manual. Modify the program to spell your own name. Run the program to see if you spelled your name correctly. If you did, good job, and save your program! ACTIVITY #7: WHEN YOU’RE DONE It’s important to disconnect the power from your BASIC Stamp and Board of Education or HomeWork Board for several reasons.
Page 36 · Robotics with the Boe-Bot Sout Sin ATN Vss P0 P1 P2 P3 P4 P5 P6 P7 U1 Vin Vss Rst Vdd P15 P14 P13 P12 P11 P10 P9 P8 P10 P12 P14 Vdd P11 P13 P10 P15 P9 Vin P8 P7 X1 P6 P5 P4 P3 Reset P2 P1 P0 X2 0 1 2 Board of Education www.stampsinclass.com Figure 1-50 Switching Off the Power for the Board of Education Rev C © 2000-2003 Do not remove the BASIC Stamp from its socket in the Board of Education! Resist any temptation to store your Board of Education and BASIC Stamp separately.
Chapter 1: Your Boe-Bot’s Brain · Page 37 SUMMARY This chapter guided you through the following: • • • • • • • • • • • • An introduction to the BASIC Stamp 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 An introduction to the BASIC Stamp, 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 Us
Page 38 · Robotics with the Boe-Bot 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. Write a program that uses a DEBUG instruction to display the solution to the math problem: 1 + 2 + 3 + 4. 2. Predict what you would expect to see if you removed the DEC formatter from this command. Use a PBASIC program to test your prediction. DEBUG DEC 7 * 11 3.
Chapter 1: Your Boe-Bot’s Brain · Page 39 Solutions Q1. The BASIC Stamp 2 microcontroller module. Q2. Binary numbers. Q3. The Debug Terminal. Q4. DEBUG and END. E1. DEBUG – This command is used to send a message from the BASIC Stamp to the PC. The information is displayed on the Debug Terminal. END – This command is used to terminate a PBASIC program and put the BASIC Stamp module into low-power mode. E2. The asterisk multiplies the two operands 7 and 11, resulting in a product of 77.
Page 40 · Robotics with the Boe-Bot P3. The last three DEBUG lines can be deleted. An additional CR is needed after the "Hello" message. ' Robotics with the Boe-Bot – HelloBoeBotCh01Project03.bs2 ' Send message to Debug Terminal and do some math. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Hello, this is a message from your Boe-Bot.", CR DEBUG "What's 7 X 11?", CR, "The answer is: ", DEC 7 * 11 END The output from the Debug Terminal is: Hello, this is a message from your Boe-Bot.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 41 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.
Page 42 · 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 43 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.
Page 44 · Robotics with the Boe-Bot √ 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 45 ' 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.
Page 46 · Robotics with the Boe-Bot 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 47 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. + LED When you start building your circuit, make sure to check it against the schematic symbol and part drawing.
Page 48 · 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 49 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.
Page 50 · 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 51 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.
Page 52 · Robotics with the Boe-Bot 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 53 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.
Page 54 · Robotics with the Boe-Bot 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 55 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. 0.13 s 0.13 s Vdd (5 V) Figure 2-8 Timing Diagram for PulseP13Led.bs2 Vss (0 V) 2.0 s √ √ Enter, save, and run PulseP13Led.bs2.
Page 56 · Robotics with the Boe-Bot 0.13 s 0.13 s P13 Figure 2-9 Timing Diagram for PulseBothLeds.bs2 0.13 s 0.13 s P12 The LEDs emit light for 0.13 seconds while the signal is high. 2.26 s 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 57 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.
Page 58 · Robotics with the Boe-Bot 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 are different because the amount of time the LED connected to P13 stays on is longer than the amount of time the LED connected to P12 stays on.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 59 √ Examine the labeling on your carrier board and figure out whether you have a BASIC Stamp HomeWork Board Rev B or a Board of Education Rev C, B, or A. (916) 624-8333 www.parallaxinc.com www.stampsinclass.
Page 60 · Robotics with the Boe-Bot √ When you are done, go to Activity #4: Centering the Servos on page 66. Connecting the Servos to the Board of Education Rev C √ Turn off the power by setting the 3-position switch on your Board of Education to position-0 (see Figure 2-11). Figure 2-11 Disconnect Power Reset 0 1 2 Figure 2-12 shows the servo header on the Board of Education Rev C. This board features a jumper that you can use to connect the servo’s power supply to either Vin or Vdd.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 61 15 14 Vdd 13 12 Red Black X4 X5 Select Vdd if you are using a DC supply that plugs into an AC outlet (AC adapter). 15 14 Vdd 13 12 Vin Select Vin if you are using the battery pack that comes with the Boe-Bot kits. Red Black X4 Figure 2-12 Selecting Your Servo’s Power Supply on the Board of Education Rev C X5 Vin All examples and instructions in this book will use the battery pack.
Page 62 · 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 63 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 (2) Parallax Continuous Rotation Servos (2) 3-pin male-male headers (4) Jumper wires (4) AA batteries – 1.
Page 64 · Robotics with the Boe-Bot Vbp White Red Black P13 Vss Vbp White Red Black P12 Figure 2-17 Servo Connection Schematic for the BASIC Stamp HomeWork Board. Vss √ √ √ √ √ √ 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.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 65 Black wire with white stripe(916) 624-8333 www.parallaxinc.com www.stampsinclass.com Vdd Vin Solid Black Wire (916) 624-8333 www.parallaxinc.com www.stampsinclass.com Rev B Vdd Vss Vss X3 X3 P15 P14 P13 P12 P11 P10 P9 P8 Vin Å Å Å Å Å P13 Vbp Vss Vbp P12 Port connections P15 P14 P13 P12 P11 P10 P9 P8 Å Å Å Å Å White Red Black Red White Servo connections by wire color Your setup will then resemble Figure 2-19.
Page 66 · Robotics with the Boe-Bot (916) 624-8333 www.parallaxinc.com www.stampsinclass.com Vdd X3 P13 470 Ω P12 470 Ω LED Vss LED Vss Vin + Rev B Vss Vss + Figure 2-20 LED Servo Signal Monitor Circuit P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 © 2002 HomeWork Board √ When all your connections are made and double-checked, load the battery pack with batteries and reconnect the 9 V battery to the HomeWork Board’s battery clip.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 67 turning. You will then use a screwdriver to adjust them so that they stay still. This is called centering the servos. After the adjustment, you will test the servos to make sure they are functioning properly. The test programs will send signals that make the servos turn clockwise and counterclockwise at various speeds. Servo Tools and Parts The Parallax screwdriver shown in Figure 2-21 is the only extra tool you will need for this activity.
Page 68 · Robotics with the Boe-Bot the pulse will last. You can also figure out what the PULSOUT command's Duration argument has to be if you know how long you want the pulse to last. Just divide 2 µs into the time you want the pulse to last. With this calculation: Duration argument = Pulse duration 0.0015 s = 750 2 µs 0.000002 s we now know that the command for a 1.5 ms pulse to P12 will be PULSOUT 12, 750.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 69 ' P12 for manual centering. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" DO PULSOUT 12, 750 PAUSE 20 LOOP If the servo has not yet been centered, its horn will start turning, and you will be able to hear the motor inside making a whining noise. √ If the servo is not yet centered, use a screwdriver to gently adjust the potentiometer in the servo as shown in Figure 2-24.
Page 70 · Robotics with the Boe-Bot √ If the servo does not turn, skip to the Your Turn section on page 70 so that you can test and center the other servo that’s connected to P13. What's a Potentiometer? A potentiometer is kind of like an adjustable resistor. The resistance of a potentiometer is adjusted with a moving part. On some potentiometers, this moving part is a knob or a sliding bar, others have sockets that can be adjusted with screwdrivers.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 71 ACTIVITY #5: HOW TO STORE VALUES AND COUNT This activity introduces variables, which are used in PBASIC programs to store values. Boe-Bot programs later in this book will rely heavily on variables. The most important thing about being able to store values is that the program can use them to count. As soon as your program can count, it can both control and keep track of the number of times something happens.
Page 72 · Robotics with the Boe-Bot Default Value - If you do not initialize a variable, the program will automatically start by storing the number zero in that variable. That’s called the variable's default value. The “=” sign in value = 500 is an example of an operator. You can use other operators to do math with variables. Here are a couple of multiplication examples: value = 10 * value anotherValue = 2 * value Example Program: VariablesAndSimpleMath.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 73 anotherValue VAR Word These commands are examples of initializing variables to values that you determine. After these two commands are executed, value will store 500, and anotherValue will store 2000. value = 500 anotherValue = 2000 ' Initialize variables These DEBUG commands help you see what each variable stores after you initialize them.
Page 74 · Robotics with the Boe-Bot value = value - anotherValue ' Answer = -1500 DEBUG "value = ", SDEC value, CR ' Display values again √ Run the modified program and verify that value changes from 500 to -1500. Counting and Controlling Repetitions The most convenient way to control the number of times a piece of code is executed is with a FOR…NEXT loop. Here is the syntax: FOR Counter = StartValue TO EndValue {STEP StepValue}…NEXT The three-dots ...
Chapter 2: Your Boe-Bot’s Servo Motors · Page 75 FOR myCounter = 1 TO 10 DEBUG ? myCounter PAUSE 500 NEXT DEBUG CR, "All done!" END Your Turn – Different Start and End Values and Counting in Steps You can use different values for the StartValue and EndValue arguments. √ Modify the FOR…NEXT loop so it looks like this: FOR myCounter = 21 TO 9 DEBUG ? myCounter PAUSE 500 NEXT √ Run the modified program.
Page 76 · Robotics with the Boe-Bot This is an example of subsystem testing. Subsystem testing is a worthwhile habit to develop, because it isn’t any fun to take a robot back apart just to fix a problem that you could have otherwise caught before putting it together! Subsystem testing is the practice of testing the individual components before they go into the larger device. It’s a valuable strategy that can help you win robotics contests.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 77 You can use ServoP13Clockwise.bs2 to send this pulse train to the servo connected to P13. Example Program: ServoP13Clockwise.bs2 Your entire system, including servos should be connected to power for this activity. √ √ √ √ If you have a Board of Education Rev C, set the 3-position switch to position-2. This connects power to the servo ports in addition to the position-1 power to the BASIC Stamp, Vdd, Vin, and Vss.
Page 78 · Robotics with the Boe-Bot √ Run the program and verify that the servo connected to P12 is now rotating between 50 and 60 RPM clockwise. ' Robotics with the Boe-Bot – ServoP12Clockwise.bs2 ' Run the servo connected to P12 at full speed clockwise. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" DO PULSOUT 12, 650 PAUSE 20 LOOP Example Program: ServoP12Counterclockwise.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 79 DEBUG "Program Running!" DO PULSOUT 12, 850 PAUSE 20 LOOP Your Turn – P13Clockwise.bs2 √ Modify the PULSOUT command’s Pin argument so that it makes the servo connected to P13 turn counterclockwise. Example Program: ServosP13CcwP12Cw.bs2 You can use two PULSOUT commands to make both servos turn at the same time. You can also make them turn in opposite directions. √ √ Enter, save, and run ServosP13CcwP12Cw.bs2.
Page 80 · Robotics with the Boe-Bot Your Turn – Adjusting the Speed and Direction There are four different combinations of PULSOUT Duration arguments that will be used repeatedly when programming your Boe-Bot’s motion in the upcoming chapters. ServosP13CcwP12Cw.bs2 sends one of these combinations, 850 to P13 and 650 to P12. By testing several possible combinations and filling in the Description column of Table 2-1, you will become familiar with them and build a reference for yourself.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 81 Table 2-1: PULSOUT Duration Combinations Durations P13 P12 Description 850 650 Full speed, P13 servo counterclockwise, P12 servo clockwise. 650 850 850 850 650 650 750 850 650 750 750 750 760 740 770 730 850 700 800 650 Both servos should stay still because of the centering adjustments you made in Activity #4.
Page 82 · Robotics with the Boe-Bot FOR…NEXT to Control Servo Run Time Hopefully, by now you fully understand that pulse width controls the speed and direction of a Parallax Continuous Rotation servo. It’s a pretty simple way to control motor speed and direction. There is also a simple way to control the amount of time a motor runs, and that’s with a FOR…NEXT loop.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 83 ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" counter VAR Byte FOR counter = 1 TO 100 PULSOUT 13, 850 PAUSE 20 NEXT FOR counter = 1 TO 200 PULSOUT 12, 850 PAUSE 20 NEXT END Let’s say you want to run both servos, the P13 servo at a pulse width of 850 and the P12 servo at a pulse width of 650. Now, each time through the loop, it will take: 1.7ms 1.3 ms 20 ms 1.6 ms --------24.
Page 84 · Robotics with the Boe-Bot Example Program: BothServosThreeSeconds.bs2 Here’s an example of making the servos turn in one direction for three seconds, then reversing their direction. √ Enter, save, and run BothServosThreeSeconds.bs2. ' Robotics with the Boe-Bot - BothServosThreeSeconds.bs2 ' Run both servos in opposite directions for three seconds, then reverse ' the direction of both servos and run another three seconds. ' {$STAMP BS2} ' {$PBASIC 2.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 85 √ Remember to disconnect power from your system (board and servos) when you are done. That means setting the 3-posisiton switch to position-0 if you have a Board of Education Rev C. If you have a HomeWork Board, disconnect the 9 V battery from the battery clip and remove one battery from the battery pack. TIP – To measure the run time, press and hold the Reset button on your Board of Education (or BASIC Stamp HomeWork Board).
Page 86 · Robotics with the Boe-Bot SUMMARY This chapter guided you through connecting, adjusting, and testing the Parallax Continuous Rotation servos. Along the way, a variety of PBASIC commands were introduced. The PAUSE command makes the program stop for brief or long periods of time, depending on the Duration argument you use. DO…LOOP makes repeating a single or group of PBASIC commands over and over again efficient.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 87 PBASIC commands? What are the command and argument that you can adjust to control a continuous rotation servo’s speed and direction? Exercises 1. Write a PAUSE command that makes the BASIC Stamp do nothing for 10 seconds. 2. Modify this FOR…NEXT loop so that it counts from 6 to 24 in steps of 3. Also, write the variable declaration you will need to make this program work. FOR counter = 9 TO 21 DEBUG ? counter PAUSE 500 NEXT Projects 1.
Page 88 · Robotics with the Boe-Bot Solutions Q1. Instead of holding a certain position like a standard servo, the Parallax Continuous Rotation servos turn a certain direction at a certain speed. Q2. A millisecond lasts one thousandth of a second. Millisecond is abbreviated "ms". Q3. The DO…LOOP command is used to make other PBASIC commands execute over and over. Q4. HIGH connects I/O pin to Vdd, LOW connects I/O pin to Vss. Q5. The variable sizes are bit, nib, byte, and word.
Chapter 2: Your Boe-Bot’s Servo Motors · Page 89 PULSOUT 12, 650 PULSOUT 14, 650 PAUSE 20 LOOP ' P12 servo clockwise ' P14 LED lights dimly P2. First, calculate the number of loops needed to get the servos to run for three seconds, for each combination of rotation. As given on page 79, the code overhead is 1.6 ms. Four combinations (1,2,3,4). Each combination: Determine PULSOUT Duration arguments: 1. Both counterclockwise: 12, 850 and 13, 850 2. Both clockwise: 12, 650 and 13, 650 3.
Page 90 · Robotics with the Boe-Bot DEBUG "Program Running!" counter VAR Word FOR counter = 1 TO 120 PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT ' Loop for three seconds ' P13 servo counterclockwise ' P12 servo counterclockwise FOR counter = 1 TO 124 PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 NEXT ' Loop for three seconds ' P13 servo clockwise ' P12 servo clockwise FOR counter = 1 TO 122 PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT ' Loop for three seconds ' P13 servo clockwise ' P12 servo counter
Chapter 3: Assemble and Test Your Boe-Bot · Page 91 Chapter 3: Assemble and Test Your Boe-Bot This chapter contains instructions for building and testing your Boe-Bot. It’s especially important to complete the testing portion before moving on to the next chapter. By doing so, you can help avoid a number of common mistakes that lead to mystifying Boe-Bot behavior in later chapters.
Page 92 · Robotics with the Boe-Bot Figure 3-1 Boe-Bot Assembly Tools Mounting the Topside Hardware √ √ Start by gathering this list of parts. Then, follow the accompanying instructions. Parts List: Instructions: See Figure 3-2. √ (1) (4) (4) (1) √ Boe-Bot chassis 1″ Standoffs Pan head screws, 1/4″ 4-40 Rubber grommet, 13/32″ √ Insert the 13/32″ rubber grommet into the hole in the center of the Boe-Bot chassis.
Chapter 3: Assemble and Test Your Boe-Bot · Page 93 Figure 3-2 Chassis and Topside Hardware Parts (left); assembled (right). Boe-Bot Parts - The parts for the Boe-Bot are either included in the Boe-Bot full kit or in a combination of the Board of Education Full Kit and Robotics Parts Kit. See Appendix E: Boe-Bot Parts Lists for more information. Removing the Servo Horns √ √ √ Disconnect the power from your BASIC Stamp and servos. Remove all of the AA batteries from the battery pack.
Page 94 · Robotics with the Boe-Bot Figure 3-3 Servo Control Horn Removal Phillips screw Control horn Parts (left); after following instructions (right). Output shaft Stop! √ Before this next step, you must have completed these activities from Chapter 2: Your Boe-Bot’s Servo Motors • • Activity #3: Connecting the Servo Motors Activity #4: Centering the Servos Mounting the Servos on the Chassis Parts List: See Figure 3-4.
Chapter 3: Assemble and Test Your Boe-Bot · Page 95 Figure 3-4 Mounting the Servos on the Chassis Parts (left); assembled (right). Mounting the Battery Pack Figure 3-5 shows two different sets of parts. Use the parts on the left if you have a Board of Education, and the parts on the right if you have a HomeWork Board. Parts List for Boe-Bot with a Board of Education Rev C: Parts List for Boe-Bot with a HomeWork Board: See Figure 3-5 (left side). See Figure 3-5 (right side).
Page 96 · Robotics with the Boe-Bot Figure 3-5 Battery Pack Mounting Hardware For use with the Board of Education For use with the HomeWork Board Instructions: √ √ √ √ √ Use the flathead screws and nuts to attach the battery pack to underside of the Boe-Bot chassis as shown on the left side of Figure 3-6. Make sure to insert the screws through the battery pack, then tighten down the nuts on the topside of the chassis.
Chapter 3: Assemble and Test Your Boe-Bot · Page 97 Figure 3-6 Battery Pack Installed Bottom view (left); top view (right). Mounting the Wheels Parts List: (1) Partially assembled Boe-Bot (not shown) (1) 1/16″ Cotter pin (1) Tail wheel ball (2) Rubber band tires (2) Plastic machined wheels (2) Screws that were saved in the Removing the Servo Horns step Figure 3-7 Wheel Hardware Instructions: The left side of Figure 3-8 shows the Boe-Bot’s tail wheel mounted on the chassis.
Page 98 · Robotics with the Boe-Bot √ √ Each plastic wheel has a recess that fits on a servo output shaft. Press each plastic wheel onto a servo output shaft making sure the shaft lines up with and sinks into the recess. Use the machine screws that you saved when you removed the servo horns to attach the wheels to the servo output shafts. Figure 3-8 Mounting the Wheels Tail wheels (left); drive wheels (right).
Chapter 3: Assemble and Test Your Boe-Bot · Page 99 Figure 3-9 Boe-Bot Chassis and Boards With the Board of Education Rev C With the HomeWork Board Figure 3-10 shows the servo ports reconnected for both the Board of Education Rev C (left side) and the HomeWork Board (right side). √ √ Reconnect the servos to the servo headers. Make sure to connect the plug labeled ‘L’ to the P13 port and the plug labeled ‘R’ to the P12 port.
Page 100 · Robotics with the Boe-Bot White Red Black White Stripe White Red Black (916) 624-8333 www.parallaxinc.com www.stampsinclass.com 15 14 Vdd 13 12 Vdd Red Black X4 X5 On Board of Education Rev C Vin Solid Black Rev B Vss X3 P15 P14 P13 P12 P11 P10 P9 P8 Figure 3-10 Servo Ports Reconnected Å Å Å Å Å P13 - White Vbp - Red Vss - Black Vbp - Red P12 - White Board of Education Rev C (left) HomeWork Board (right).
Chapter 3: Assemble and Test Your Boe-Bot · Page 101 √ √ From the underside of the chassis, pull any excess servo and battery cable through the hole with the rubber grommet. Tuck the excess cable lengths between the servos and the chassis. Figure 3-12 Assembled Boe-Bots With Board of Education Rev C With HomeWork Board ACTIVITY #2: RE-TEST THE SERVOS In this activity, you will test to make sure that the electrical connections between your board and the servos are correct.
Page 102 · Robotics with the Boe-Bot Left Front Back Figure 3-13 Your Boe-Bot robot’s Front, Back, Left, and Right Right Testing the Right Wheel The next example program will test the servo connected to the right wheel, shown in Figure 3-14. The program will make this wheel turn clockwise for three seconds, then stop for one second, then turn counterclockwise for three seconds.
Chapter 3: Assemble and Test Your Boe-Bot · Page 103 √ √ If the right wheel/servo does not behave as predicted, see the Servo Trouble Shooting section. It comes right after RightServoTest.bs2. If the right wheel/servo does behave properly, then move on to the Your Turn section, where you will test the left wheel. ' Robotics with the Boe-Bot - RightServoTest.bs2 ' Right servo turns clockwise three seconds, stops 1 second, then ' counterclockwise three seconds. ' {$STAMP BS2} ' {$PBASIC 2.
Page 104 · Robotics with the Boe-Bot Servo Trouble Shooting: Here is a list of some common symptoms and how to fix them. The servo doesn’t turn at all. √ √ √ √ If you are using a Board of Education Rev C, make sure the 3-position switch is set to position-2. You can then re-run the program by pressing and releasing the Reset button. If you are using a BASIC Stamp HomeWork Board, make sure the battery pack has batteries. Double-check your servo connections using Figure 3-10 on page 100 as a guide.
Chapter 3: Assemble and Test Your Boe-Bot · Page 105 Your Turn – Testing the Left Wheel Now, it’s time to run the same test on the left wheel as shown in Figure 3-15. This involves modifying RightServoTest.bs2 so that the PULSOUT commands are sent to the servo connected to P13 instead of the servo connected to P12. All you have to do is change the three PULSOUT commands so that they read PULSOUT 13 instead of PULSOUT 12.
Page 106 · Robotics with the Boe-Bot When the supply voltage comes back above 5.2 V, the BASIC Stamp starts running again, but not at the same place in the program. Instead, it starts from the beginning of the program. This is actually the same thing that happens when you unplug power and plug it back in, and it’s also the same thing that happens if you press and release the Reset button on your board.
Chapter 3: Assemble and Test Your Boe-Bot · Page 107 Figure 3-16 Piezospeaker What’s frequency? It’s the measurement of how often something occurs in a given amount of time. What’s a piezoelectric element and how can it make sound? It’s a crystal that changes shape slightly when voltage is applied to it. By applying high and low voltages to a piezoelectric crystal at a rapid rate, it causes the piezoelectric crystal to rapidly change shape. The result is vibration.
Page 108 · Robotics with the Boe-Bot √ Build the circuit shown in Figure 3-17 and Figure 3-18. P4 Figure 3-17 Program Start/Reset Indicator Circuit Vss To Servos To Servos 15 14 Vdd 13 12 (916) 624-8333 Rev B www.parallax.com www.stampsinclass.
Chapter 3: Assemble and Test Your Boe-Bot · Page 109 Programming the Start/Reset Indicator The next example program tests the piezospeaker. It uses the FREQOUT command to send precisely timed high/low signals to a speaker. Here is the FREQOUT command’s syntax: FREQOUT Pin, Duration, Freq1 {,Freq2} Here’s an example of a FREQOUT command that’s used in the next example program. FREQOUT 4, 2000, 3000 The Pin argument is 4, meaning that the high/low signals will be sent to I/O pin P4.
Page 110 · Robotics with the Boe-Bot √ √ √ If you did not hear a tone, check your wiring and code for errors. Repeat until you get an audible tone from your speaker. If you did hear an audible tone, try simulating the brownout condition by pressing and releasing the Reset button on your board. Verify that the piezospeaker makes a clearly audible tone after each reset. Also try disconnecting and reconnecting your battery supply, and verify that this results in the reset warning tone as well.
Chapter 3: Assemble and Test Your Boe-Bot · Page 111 An initialization routine is comprised of all the commands necessary to get a device or program up and running. It often includes setting certain variable values, beeping noises, and for more complex devices, self testing and calibration. √ √ √ Open HelloOnceEverySecond.bs2. Copy the FREQOUT command from StartResetIndicator.bs2 into HelloOnceEverySecond.bs2 above the DO…LOOP section.
Page 112 · Robotics with the Boe-Bot Using the DEBUGIN Command By now, you are probably familiar with the DEBUG command and how it can be used to send messages from the BASIC Stamp to the Debug Terminal. The place the messages are viewed is called the Receive windowpane because it's the place where messages received from the BASIC Stamp are displayed. The Debug Terminal also has a Transmit windowpane, which allows you to send information to your BASIC Stamp while a program is running.
Chapter 3: Assemble and Test Your Boe-Bot · Page 113 When the servo is done turning, you will be prompted to enter another value. √ √ Type 850 and then press the Enter key. Verify that the servo turns full speed counterclockwise. Try measuring the wheel's rotational speed in RPM (revolutions per minute) for a range of pulse widths between 650 and 850. Here's how: √ √ √ √ ' ' ' ' Place a mark on the wheel so that you can see how far it turns in 6 seconds.
Page 114 · Robotics with the Boe-Bot FOR counter = 1 TO 244 PULSOUT 12, pulseWidth PULSOUT 13, pulseWidthComp PAUSE 20 NEXT LOOP How TestServoSpeed.bs2 Works Three variables are declared, counter for the FOR…NEXT loop, pulseWidth for the DEBUGIN and PULSOUT commands, and pulseWidthComp which stores a value that is used in a second PULSOUT command. counter VAR pulseWidth VAR pulseWidthComp VAR Word Word Word The FREQOUT command is used to signal that the program has started.
Chapter 3: Assemble and Test Your Boe-Bot · Page 115 be 650. If you enter a pulse width of 700, pulseWidthComp will be 800. Try a few other examples. They will all add up to 1500. pulseWidthComp = 1500 - pulseWidth A FOR…NEXT loop that runs for 6 seconds sends pulses to the right (P12) servo. The pulseWidthComp value is sent to the left (P13) servo, making it turn in the opposite direction.
Page 116 · Robotics with the Boe-Bot You can use Table 3-1 to record the data for your own transfer curve. Keep in mind that the example program is controlling the right wheel with the values you enter. The left wheel turns in the opposite direction. Table 3-1: Pulse Width and RPM for Parallax Servo Pulse Width (ms) Rotational Velocity (RPM) Pulse Width (ms) Rotational Velocity (RPM) Pulse Width (ms) Rotational Velocity (RPM) Pulse Width (ms) 1.300 1.400 1.500 1.600 1.310 1.410 1.510 1.
Chapter 3: Assemble and Test Your Boe-Bot · Page 117 Since the servo turns for 6 seconds, you can multiply this value by 10 to get revolutions per minute (RPM). √ √ √ √ √ √ √ Multiply this value by 10 and enter the result into Table 3-1 next to the 1.3 ms entry. Enter the value 655. Count how many turns the wheel made. Multiply this value by 10 and enter the result into Table 3-1 next to the 1.31 ms entry. Keep increasing your durations by 5 (0.01 ms) until you are up to 850 (1.7 ms).
Page 118 · Robotics with the Boe-Bot SUMMARY This chapter covered Boe-Bot assembly and testing. This involved mechanical assembly, such as connecting the various moving parts to the Boe-Bot chassis. It also involved circuit assembly, connecting the servos and piezospeaker. The testing involved retesting the servos after they were disconnected to build the Boe-Bot. The concept of brownout was introduced along with what this condition does to a program running on the BASIC Stamp.
Chapter 3: Assemble and Test Your Boe-Bot · Page 119 Exercises 1. Write a FREQOUT command that makes a tone that sounds different from the reset detect tone to signify the end of a program. 2. Write a FREQOUT command that makes a tone (different from beginning or ending tones) that signifies an intermediate step in a program has been completed. Try a value with a 100 ms duration at a 4 kHz frequency. Projects 1. Modify RightServoTest.bs2 so that it makes a tone signifying the test is complete. 2.
Page 120 · Robotics with the Boe-Bot Solutions Q1. Symptoms include erratic behavior such as going in unexpected directions or doing a confused dance. Q2. A FREQOUT command at the beginning of all Boe-Bot programs causes the piezospeaker to play a tone. This tone will therefore occur every time an accidental reset happens due to brownout conditions. Q3. A reset is when the power is interrupted and the BASIC Stamp program starts running again from the beginning of the program. Q4.
Chapter 3: Assemble and Test Your Boe-Bot · Page 121 FREQOUT 4, 2000, 3000 ' Signal start of program. FOR counter = 1 TO 122 PULSOUT 12, 650 PAUSE 20 NEXT ' Clockwise just under 3 seconds. FOR counter = 1 TO 40 PULSOUT 12, 750 PAUSE 20 NEXT ' Stop one second. FOR counter = 1 TO 122 PULSOUT 12, 850 PAUSE 20 NEXT ' Counterclockwise three seconds. FREQOUT 4, 500, 3500 ' Signal end of program END P2. To solve this problem, TestServoSpeed.
Page 122 · Robotics with the Boe-Bot PULSOUT 13, ltPulseWidth PULSOUT 12, rtPulseWidth PAUSE 20 NEXT ' Left servo motion ' Right servo motion LOOP Note: This project is best tested with the Boe-Bot's wheels propped up.
Chapter 4: Boe-Bot Navigation · Page 123 Chapter 4: Boe-Bot Navigation The Boe-Bot can be programmed to perform a variety of maneuvers. The maneuvers and programming techniques introduced in this chapter will be reused in later chapters. The only difference is that in this chapter, the Boe-Bot will blindly perform the maneuvers. In later chapters, the Boe-Bot will perform similar maneuvers in response to conditions it detects with its sensors.
Page 124 · Robotics with the Boe-Bot Left Turn Figure 4-1 Your Boe-Bot and Driving Directions Backward Forward Right Turn Moving Forward Here’s a funny thing: to make the Boe-Bot go forward, the Boe-Bot’s left wheel has to turn counterclockwise, but its right wheel has to turn clockwise. If you haven’t already grasped this, take a look at Figure 4-2 and see if you can convince yourself that it’s true. Viewed from the left, the wheel has to turn counterclockwise for the Boe-Bot to move forward.
Chapter 4: Boe-Bot Navigation · Page 125 the same amount of time, the EndValue argument also controls the time the servo runs. Here’s an example program that will make the Boe-Bot roll forward for about three seconds. Example Program: BoeBotForwardThreeSeconds.bs2 √ √ Make sure power is connected to the BASIC Stamp and servos. Enter, save, and run BoeBotForwardThreeSeconds.bs2. ' Robotics with the Boe-Bot - BoeBotForwardThreeSeconds.bs2 ' Make the Boe-Bot roll forward for three seconds.
Page 126 · Robotics with the Boe-Bot This FOR…NEXT loop sends 122 sets of pulses to the servos, one each to P13 and P12, pausing for 20 ms after each set and then returning to the top of the loop. FOR counter = 1 TO 122 PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT PULSOUT 13, 850 causes the left servo to rotate counterclockwise while PULSOUT 12, 650 causes the right servo to rotate clockwise. Therefore, both wheels will be turning toward the front end of the Boe-Bot, causing it to drive forward.
Chapter 4: Boe-Bot Navigation · Page 127 Moving Backward, Rotating, and Pivoting All it takes to get other motions out of your Boe-Bot are different combinations of the PULSOUT Duration arguments.
Page 128 · Robotics with the Boe-Bot PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT PAUSE 200 FOR counter = 1 TO 24 ' Rotate left - about 1/4 turn PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 NEXT PAUSE 200 FOR counter = 1 TO 24 ' Rotate right - about 1/4 turn PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT PAUSE 200 FOR counter = 1 TO 64 ' Backward PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT END Your Turn - Pivoting You can make the Boe-Bot turn by pivoting around one wheel.
Chapter 4: Boe-Bot Navigation · Page 129 PULSOUT 13, 850 PULSOUT 12, 750 These are the PULSOUT commands for pivoting backwards and to the right. PULSOUT 13, 650 PULSOUT 12, 750 Finally, these are the PULSOUT commands for pivoting backwards and to the left. PULSOUT 13, 750 PULSOUT 12, 850 √ √ √ √ √ Save ForwardLeftRightBackward.bs2 as PivotTests.bs2. Substitute the PULSOUT commands just discussed in place of the forward, left, right, and backward routines.
Page 130 · Robotics with the Boe-Bot √ Change the EndValue of the FOR counter from 122 to 407, so it reads like this: ' Robotics with the Boe-Bot - BoeBotForwardTenSeconds.bs2 ' Make the Boe-Bot roll forward for ten seconds. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" counter VAR Word FREQOUT 4, 2000, 3000 ' Signal program start/reset. FOR counter = 1 TO 407 ' Number of pulses – run time. PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 ' Left servo full speed ccw.
Chapter 4: Boe-Bot Navigation · Page 131 It will probably take several tries to get the right value. Let’s say that your first guess is that PULSOUT 12,663 will do the trick, but it turns out not to be enough because the BoeBot is still turning slightly to the left. So try PULSOUT 12,670. Maybe that overcorrects, and it turns out that PULSOUT 12,665 gets it exactly right. This is called an iterative process, meaning a process that takes repeated tries and refinements to get to the right value.
Page 132 · Robotics with the Boe-Bot PULSOUT 12, 650 PAUSE 20 NEXT Let’s say that the Boe-Bot turns just a bit more than 90° (1/4 of a full circle). Try FOR counter = 1 TO 23, or maybe even FOR counter = 1 TO 22. If it doesn’t turn far enough, increase the run time of the rotation by increasing the FOR…NEXT loop’s EndValue argument to whatever value it takes to complete the quarter turn.
Chapter 4: Boe-Bot Navigation · Page 133 Perhaps when you got a little older, and learned division in school, you started watching the road signs to see how far it was to the destination city. Next, you checked the speedometer in your car. By dividing the speed into the distance, you got a pretty good estimate of the time it would take to get there. You may not have been thinking in these exact terms, but here is the equation you were using.
Page 134 · Robotics with the Boe-Bot √ √ Place your Boe-Bot next to a ruler as shown in Figure 4-3. Make sure to line up the point where the wheel touches the ground with the 0 in/cm mark on the ruler.
Chapter 4: Boe-Bot Navigation · Page 135 NEXT END You can also think about the distance you just recorded as your Boe-Bot’s speed, in units per second. Let’s say that your Boe-Bot traveled 9 in (23 cm). Since it took one second for your Boe-Bot to travel that far, it means your Boe-Bot travels at around 9 in/s (23 cm/s). Now, you can figure out how many seconds your Boe-Bot has to travel to go a particular distance.
Page 136 · Robotics with the Boe-Bot you can use these values to calculate how many pulses to send to the servos. This is the number you will have to use for your FOR…NEXT loop's EndValue argument. 40.65 pulses s = 90.24... pulses ≈ 90 pulses pulses = 2.22 s × The calculations in this example took two steps. First, figure out how long the servos have to run to make the Boe-Bot travel a certain distance, then figure out how many pulses it takes to make the servos run for that long.
Chapter 4: Boe-Bot Navigation · Page 137 pulses = √ √ Boe − Bot dis tan ce 40.65 pulses × Boe − Bot speed s Modify BoeBotForwardOneSecond.bs2 so that it delivers the number of pulses you determined for your distance. Run the program and test to see how close you got. This technique has sources of error. The activity you just completed does not take into account the fact that it took a certain number of pulses for the Boe-Bot to get up to full speed.
Page 138 · Robotics with the Boe-Bot pulseCount VAR Word FOR pulseCount = 1 TO 100 1, 2, 3, …100 PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 - pulseCount PAUSE 20 Figure 4-4 Ramping Example NEXT Recall from Chapter 2, Activity #5 that FOR…NEXT loops can also count downward from a higher number to a lower number. You can use this to ramp the speed back down again by using FOR pulseCount = 100 TO 1. Here is an example program that uses FOR…NEXT loops to ramp up to full speed, then ramp back down.
Chapter 4: Boe-Bot Navigation · Page 139 NEXT ' Continue forward for 75 pulses. FOR pulseCount = 1 TO 75 PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT ' ' ' ' Loop sends 75 forward pulses. 1.7 ms pulse to left servo. 1.3 ms pulse to right servo. Pause for 20 ms. ' Ramp down from going forward to a full stop. FOR pulseCount = 100 TO 1 PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 - pulseCount PAUSE 20 NEXT END ' ' ' ' Loop ramps down for 100 pulses. Pulse = 1.5 ms + pulseCount. Pulse = 1.
Page 140 · Robotics with the Boe-Bot ' Ramp up right rotate. FOR pulseCount = 0 TO 30 PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 + pulseCount PAUSE 20 NEXT ' Ramp down right rotate FOR pulseCount = 30 TO 0 PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 + pulseCount PAUSE 20 NEXT √ √ Open ForwardLeftRightBackward.bs2 from Activity #1, and save it as ForwardLeftRightBackwardRamping.bs2. Modify the new program so your Boe-Bot will ramp into and out of each maneuver.
Chapter 4: Boe-Bot Navigation · Page 141 Figure 4-5 shows part of a PBASIC program that contains a subroutine call and a subroutine. The subroutine call is the GOSUB My_Subroutine command. The actual subroutine is everything from the My_Subroutine: label through the RETURN command. Here’s how it works. When the program gets to the GOSUB My_Subroutine command, it looks for the My_Subroutine: label. As shown by arrow (1), the program jumps to the My_Subroutine: label and starts executing commands.
Page 142 · Robotics with the Boe-Bot DEBUG "Command in subroutine", CR PAUSE 1000 RETURN √ Watch your Debug Terminal, and press the Reset button a few times. You should get the same set of three messages in the right order each time. Here’s an example program that has two subroutines. One subroutine makes a high pitched tone while the other makes a low pitched tone. The commands between DO and LOOP call each of the subroutines in turn. Try this program and note the effect.
Chapter 4: Boe-Bot Navigation · Page 143 Example Program – MovementsWithSubroutines.bs2 √ Enter, save, and run MovementsWithSubroutines.bs2. Hint: you can use the Edit menu in the BASIC Stamp Editor to copy and paste code blocks from one program to another. ' Robotics with the Boe-Bot - MovementsWithSubroutines.bs2 ' Make forward, left, right, and backward movements in reusable subroutines. ' {$STAMP BS2} ' {$PBASIC 2.
Page 144 · Robotics with the Boe-Bot PAUSE 200 RETURN Backward: FOR counter = 1 TO 64 PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT RETURN You should recognize the pattern of movement your Boe-Bot makes; it is the same one made by ForwardLeftRightBackward.bs2. Clearly there are many different ways to structure a program that will result in the same movements. A third approach is given in the example below. Example Program – MovementsWithVariablesAndOneSubroutine.
Chapter 4: Boe-Bot Navigation · Page 145 √ Enter, save, and run MovementWithVariablesAndOneSubroutine.bs2. ' Robotics with the Boe-Bot - MovementWithVariablesAndOneSubroutine.bs2 ' Make a navigation routine that accepts parameters. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" counter pulseLeft pulseRight pulseCount VAR VAR VAR VAR Word Word Word Byte FREQOUT 4, 2000, 3000 ' Signal program start/reset.
Page 146 · Robotics with the Boe-Bot colons function the same as a carriage return to separate each PBASIC instruction. Using colons this way allows all of the new variable values for a given maneuver to be stored together, and on the same line as the subroutine call. Your Turn Here is your "dead reckoning" contest mentioned earlier. √ Modify MovementWithVariablesAndOneSubroutine.bs2 to make your Boe-Bot drive in a square, facing forwards on the first two sides and backwards on the second two sides.
Chapter 4: Boe-Bot Navigation · Page 147 You can view the contents of the BASIC Stamp’s EEPROM in the BASIC Stamp Editor by clicking Run and selecting Memory Map. Figure 4-6 shows the Memory Map for MovementsWithSubroutines.bs2. Note the condensed EEPROM Map on the left side of the figure. This shaded area in the small box at the bottom shows the amount of EEPROM that MovementsWithSubroutines.bs2 occupies. The memory map images shown in this activity were taken from the BASIC Stamp Editor v2.1.
Page 148 · Robotics with the Boe-Bot familiar code blocks in subroutines for each basic maneuver. Each maneuver is given a one-letter code as a reference. Long lists of these code letters can be stored in EEPROM and then read and decoded during program execution. This avoids the tedium of repeating long lists of subroutines, or having to change the variables before each GOSUB command. This programming approach requires some new PBASIC instructions: the DATA directive, and READ and SELECT...CASE...
Chapter 4: Boe-Bot Navigation · Page 149 while a certain condition exists. Our example program will use DO…LOOP UNTIL (condition). In this case, it causes the DO…LOOP to keep repeating until the character “Q” is read from EEPROM. A SELECT...CASE...ENDSELECT statement can be used to select a variable and evaluate it on a case-by-case basis and execute code blocks accordingly.
Page 150 · Robotics with the Boe-Bot FREQOUT 4, 2000, 3000 ' Signal program start/reset. ' -----[ Main Routine ]------------------------------------------------------DO UNTIL (instruction = "Q") READ address, instruction address = address + 1 ' Data at address in instruction. ' Add 1 to address for next read.
Chapter 4: Boe-Bot Navigation · Page 151 ' -----[ Subroutine – Right_Turn ]-------------------------------------------Right_Turn: FOR pulseCount = 1 TO 24 PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT RETURN ' ' ' ' ' right turn subroutine. Send 24 right rotate pulses. 1.7 ms pulse to left servo. 1.7 ms pulse to right servo. Pause for 20 ms. ' Return to Main Routine section.
Page 152 · Robotics with the Boe-Bot Now the direction instructions will appear in a more familiar format shown in Figure 4-8. Instead of ASCII codes, they appear as the actual characters you recorded using the DATA directive. Figure 4-8 Close-up of the Detailed EEPROM Map after Display ASCII Box is Checked This program stored a total of 10 characters in EEPROM. These ten characters were accessed by the READ command’s address variable.
Chapter 4: Boe-Bot Navigation · Page 153 Example Program – EepromNavigationWithWordValues.bs2 This next example program looks complicated at first, but it is a very efficient way to design programs for custom Boe-Bot choreography. This example program uses EEPROM data storage, but does not use subroutines. Instead, a single code block is used, with variables in place of the FOR...NEXT loop's EndValue and PULSOUT Duration arguments. By default, the DATA directive stores bytes of information in EEPROM.
Page 154 · Robotics with the Boe-Bot LOOP UNTIL (pulseCount = 0) The first time through the loop, addressOffset = 0. The first READ command will retrieve a value of 64 from the first address at the Pulses_Count label, and place it in the pulseCount variable. The second READ command retrieves a value of 850 from the first address specified by the Pulses_Left label, and places it in the pulseLeft variable.
Chapter 4: Boe-Bot Navigation · Page 155 pulseLeft VAR Word ' -----[ EEPROM Data ]-------------------------------------------------------' addressOffset Pulses_Count DATA Pulses_Left DATA Pulses_Right DATA 0 Word 64, Word 850, Word 650, 2 Word 24, Word 650, Word 650, 4 Word 24, Word 850, Word 850, 6 8 Word 64, Word 0 Word 650 Word 850 ' -----[ Initialization ]----------------------------------------------------FREQOUT 4, 2000, 3000 ' Signal program start/reset.
Page 156 · Robotics with the Boe-Bot Word 740, Word 715, Word 700, Word 650, Word 750 Pulses_Right DATA Word 650, Word 700, Word 715, Word 740, Word 750, Word 760, Word 785, Word 800, Word 850, Word 750 √ √ √ √ Make a table with three rows, one for each DATA directive, and a column for each Boe-Bot maneuver you want to make, plus one for the Word 0 item in the Pulses_Count row. Use the table to plan out your Boe-Bot choreography, filling in the FOR...
Chapter 4: Boe-Bot Navigation · Page 157 SUMMARY This chapter introduced the basic Boe-Bot maneuvers: forward, backward, rotating in place to turn to the right or left, and pivoting. The type of maneuver is determined by the PULSOUT commands’ Duration arguments. How far the maneuver goes is determined by the FOR…NEXT loop’s StartValue and EndValue arguments. Chapter 2 included a hardware adjustment, physically centering the Boe-Bot’s servos with a screwdriver.
Page 158 · Robotics with the Boe-Bot The BASIC Stamp’s EEPROM stores the program it runs, but you can take advantage of any unused portion of the program to store values. This is a great way to store custom navigation routines. The DATA directive can store values in EEPROM. Bytes are stored by default, but adding the Word modifier to each data item allows you to store values up to 65535 in two bytes’ worth of EEPROM memory space. You can read values back out of EEPROM using the READ command.
Chapter 4: Boe-Bot Navigation · Page 159 2. Let’s say that you tested your servos and discovered that it takes 48 pulses to make a 180° turn with right-rotate. With this information, write routines to make the Boe-Bot perform 30, 45, and 60 degree turns. 3. Write a routine that makes the Boe-Bot go straight forward, then ramp in and out of a pivoting turn, and then continue straight forward. Projects 1. It is time to fill in column 3 of Table 2-1: PULSOUT Duration Combinations on page 81.
Page 160 · Robotics with the Boe-Bot Solutions Q1. Left wheel counterclockwise, right wheel clockwise. Q2. The right wheel is turning clockwise (forward), and the left wheel is not moving. PULSOUT 13, 750 PULSOUT 12, 650 Q3. You can slow down the right wheel to correct a veer to the left. The PULSOUT command for the right wheel needs to be adjusted. PULSOUT 12, 650 Adjust the 650 to something closer to 750 to slow the wheel down. PULSOUT 12, 663 Q4.
Chapter 4: Boe-Bot Navigation · Page 161 PULSOUT 12, 850 PAUSE 20 NEXT E3.
Page 162 · Robotics with the Boe-Bot P1.
Chapter 4: Boe-Bot Navigation · Page 163 match your Boe-Bot and particular surface. For a triangle pattern, the Boe-Bot must travel 1 meter/yard forward, then make a 120 degree turn. This should be repeated three times for the three sides of the triangle. You may have to adjust the pulseCount EndValue in the Right_Rotate120 subroutine to get a precise 120 degree turn. ' Robotics with the Boe-Bot - Chapter 4 - Triangle.bs2 ' Boe-Bot navigates triangle shape with 1 yard sides.
Chapter 5: Tactile Navigation with Whiskers · Page 165 Chapter 5: Tactile Navigation with Whiskers Many types of robotic machinery rely on a variety of tactile switches. For example, a tactile switch may detect when a robotic arm has encountered an object. The robot can be programmed to pick up the object and place it elsewhere. Factories use tactile switches to count objects on a production line, and also for aligning objects during industrial processes.
Page 166 · Robotics with the Boe-Bot Figure 5-1 Boe-Bot with Whiskers ACTIVITY #1: BUILDING AND TESTING THE WHISKERS Before moving on to programs that make the Boe-Bot navigate based on what it can touch, it’s essential to build and test the whiskers first. This activity will guide you through building and testing the whiskers. Whisker Circuit and Assembly √ √ Gather the whiskers hardware shown in Figure 5-2. Disconnect power from your board and servos.
Chapter 5: Tactile Navigation with Whiskers · Page 167 Parts List: (2) Whisker wires (2) 7/8″ pan head 4-40 Phillips screws (2) ½″ round spacer (2) Nylon washers – size #4 (2) 3-pin m/m headers (2) Resistors, 220 Ω (red-red-brown) (2) Resistors, 10 kΩ (brown-black-orange) Figure 5-2 Whiskers Hardware Building the Whiskers √ √ √ √ √ √ Remove the two front screws that hold your board to the front standoffs. Refer to Figure 5-3 while following the remaining instructions.
Page 168 · Robotics with the Boe-Bot The next step is add the whiskers circuit shown in Figure 5-4 to the piezospeaker and servo circuits you built and tested in Chapter 2 and Chapter 3. √ √ √ If you have a Board of Education, build the whiskers circuit shown in Figure 5-4 using the wiring diagram in Figure 5-5 on page 169 as a reference. If you have a HomeWork Board, build the whiskers circuit shown in Figure 5-4 using the wiring diagram in Figure 5-6 on page 170 as a reference.
Chapter 5: Tactile Navigation with Whiskers · Page 169 Figure 5-5: Whisker Wiring Diagram for the Board of Education Left Whisker To Servos 15 14 Vdd 13 12 Red Black X4 Vdd X5 Vin Vss X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 + Board of Education Rev C © 2000-2003 Right Whisker Use the 220 Ω resistors (red-red-brown color codes) to connect P5 and P7 to their corresponding 3-pin headers.
Page 170 · Robotics with the Boe-Bot Figure 5-6: Whisker Wiring Diagram for the HomeWork Board Left Whisker To Servos (916) 624-8333 Rev B www.parallax.com www.stampsinclass.com Vdd Vin Vss X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 + HomeWork Board Right Whisker Use the 220 Ω resistors (red-red-brown-color codes) to connect P5 and P7 to their corresponding 3-pin headers. Use the 10 kΩ resistors (brown-black-orange color codes) to connect Vdd to each 3-pin header.
Chapter 5: Tactile Navigation with Whiskers · Page 171 Testing the Whiskers Take a second look at the whiskers schematic (Figure 5-7). Each whisker is both the mechanical extension and the ground electrical connection of a normally open, singlepole, single-throw switch. The reason the whiskers are connected to ground (Vss) is because the plated holes at the outer edge of the board are all connected to Vss. This is true for both the Board of Education and the BASIC Stamp HomeWork Board.
Page 172 · Robotics with the Boe-Bot How do you get the BASIC Stamp to tell you whether it’s reading a 1 or 0? Because the circuit is connected to P7, this 1 or 0 value will appear in a variable named IN7. IN7 is called an input register. Input register variables are built-in and do not have to be declared in the beginning of your program. You can see the value this variable is storing by using the command DEBUG BIN1 IN7.
Chapter 5: Tactile Navigation with Whiskers · Page 173 ' {$PBASIC 2.5} ' PBASIC directive. DEBUG "WHISKER STATES", CR, "Left Right", CR, "-----------" DO DEBUG CRSRXY, 0, 3, "P5 = ", BIN1 IN5, " P7 = ", BIN1 IN7 PAUSE 50 LOOP √ √ √ √ √ √ Note the values displayed in the Debug Terminal; it should display that both P7 and P5 are equal to 1. Check Figure 5-5 on page 169 (or Figure 5-6 on page 170) so you know which whisker is the “left whisker” and which whisker is the “right whisker”.
Page 174 · Robotics with the Boe-Bot ACTIVITY #2: FIELD TESTING THE WHISKERS Assume that you may have to test the whiskers at some later time away from a computer. Since the Debug Terminal won’t be available, what can you do? One solution would be to program the BASIC Stamp so that it sends an output signal that corresponds to the input signal it’s receiving. This can be done with a pair of LED circuits and a program that turns the LEDs on and off based on the whisker inputs.
Chapter 5: Tactile Navigation with Whiskers · Page 175 Figure 5-10: Whisker Plus LED Wiring Diagram for the Board of Education This lead is the anode. To Servos Left Whisker 15 14 Vdd 13 12 Red Black X4 Vdd X5 Vin Vss X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 Flat spot on plastic case indicates cathode. + Board of Education Rev C © 2000-2003 This lead is the anode.
Page 176 · Robotics with the Boe-Bot Figure 5-11: Whisker Plus LED Wiring Diagram for the HomeWork Board The anode connects to the 220 Ω resistor. To Servos Left Whisker (916) 624-8333 Rev B www.parallax.com www.stampsinclass.com Vdd Vin Vss X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 + Flat spot on plastic case indicates cathode HomeWork Board The anode connects to the 220 Ω resistor.
Chapter 5: Tactile Navigation with Whiskers · Page 177 Programming the LED Whisker Testing Circuits √ √ √ Reconnect power to your board. Save TestWhiskers.bs2 as TestWhiskersWithLeds.bs2. Insert these two IF...THEN statements between the PAUSE 50 and LOOP commands. IF (IN7 = 0) THEN HIGH 1 ELSE LOW 1 ENDIF IF (IN5 = 0) THEN HIGH 10 ELSE LOW 10 ENDIF These are called IF…THEN statements, and they will be more fully introduced in the next activity. These statements are used to make decisions in PBASIC.
Page 178 · Robotics with the Boe-Bot Programming the Boe-Bot to Navigate Based on Whisker Inputs This next program makes the Boe-Bot go forward until it encounters an obstacle. In this case, the Boe-Bot knows when it encounters an obstacle by bumping into it with one or both of its whiskers. As soon as the obstacle is detected by the whiskers, the navigation routines and subroutines developed in Chapter 4 will make the Boe-Bot back up and turn.
Chapter 5: Tactile Navigation with Whiskers · Page 179 √ Try letting the Boe-Bot roam. When it contacts obstacles in its path, it should back up, turn, and then roam in a new direction. ' -----[ Title ]-------------------------------------------------------------' Robotics with the Boe-Bot - RoamingWithWhiskers.bs2 ' Boe-Bot uses whiskers to detect objects, and navigates around them. ' {$STAMP BS2} ' {$PBASIC 2.5} ' Stamp directive. ' PBASIC directive.
Page 180 · Robotics with the Boe-Bot PAUSE 20 NEXT RETURN Turn_Right: FOR pulseCount = 0 TO 20 PULSOUT 13, 850 PULSOUT 12, 850 ' Right turn, about 90-degrees. PAUSE 20 NEXT RETURN Back_Up: FOR pulseCount = 0 TO 40 PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT RETURN ' Back up. How Roaming with Whiskers Works The IF...THEN statements in the Main Routine section first check the whiskers for any states that require attention.
Chapter 5: Tactile Navigation with Whiskers · Page 181 The Turn_Left, Turn_Right, and Back_Up subroutines should look fairly familiar, but the Forward_Pulse subroutine has a twist. It just sends one pulse, then returns. This is really important, because it means the Boe-Bot can check its whiskers between each forward pulse. That means the Boe-Bot checks for obstacles roughly 40 times per second as it travels forward.
Page 182 · Robotics with the Boe-Bot GOSUB Turn_Right ELSEIF (IN7 = 0) THEN HIGH 1 GOSUB Back_Up GOSUB Turn_Left ELSE LOW 10 LOW 1 GOSUB Forward_Pulse ENDIF √ Modify the IF…THEN statement in RoamingWithWhiskers.bs2 to make the BoeBot broadcast its maneuver using the LED indicators. ACTIVITY #4: ARTIFICIAL INTELLIGENCE AND DECIDING WHEN YOU’RE STUCK You may have noticed that the Boe-Bot gets stuck in corners. As the Boe-Bot enters the corner, its whisker touches the wall on the left, so it turns right.
Chapter 5: Tactile Navigation with Whiskers · Page 183 Commands for both condition2 and condition1 ELSE Commands for condition1 but not condition2 ENDIF ELSE Commands for not condition1 ENDIF There is an example of nested IF…THEN statements in the routine that detects consecutive alternate whisker contacts in the next program. Example Program: EscapingCorners.
Page 184 · Robotics with the Boe-Bot DO ' --- Detect Consecutive Alternate Corners -----------------------' See the "How EscapingCorners.bs2 Works" section that follows this program. IF (IN7 <> IN5) THEN IF (old7 <> IN7) AND (old5 <> IN5) THEN counter = counter + 1 old7 = IN7 old5 = IN5 IF (counter > 4) THEN counter = 1 GOSUB Back_Up GOSUB Turn_Left GOSUB Turn_Left ENDIF ELSE counter = 1 ENDIF ENDIF ' --- ' ' ' ' ' ' ' ' One or other is pressed. Different from previous. Alternate whisker count + 1.
Chapter 5: Tactile Navigation with Whiskers · Page 185 PULSOUT 12, 650 PAUSE 20 NEXT RETURN Turn_Right: FOR pulseCount = 0 TO 20 PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT RETURN ' Right turn, about 90-degrees. Back_Up: FOR pulseCount = 0 TO 40 PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT RETURN ' Back up. How EscapingCorners.bs2 Works Since this program is a modified version of RoamingWithWhiskers.bs2, only new features related to detecting and escaping corners are discussed here.
Page 186 · Robotics with the Boe-Bot counter = 1 old7 = 0 old5 = 1 Now we get to the Detect Consecutive Alternate Corners section. The first thing we want to check for is if one or the other whisker is pressed. A simple way to do this is to ask “is IN7 different from IN5?” In PBASIC, we can use the not-equal operator <> in an IF statement: IF (IN7 <> IN5) THEN If it is indeed one whisker that is pressed, the next thing to check for is whether or not it’s the exact opposite pattern as the previous time.
Chapter 5: Tactile Navigation with Whiskers · Page 187 ELSE counter = 1 This ENDIF statement ends the decision making process for the IF (old7 <> IN7) AND (old5 <> IN5) THEN statement. ENDIF ENDIF The remainder of the program is the same as before. Your Turn One of the IF...THEN statements in EscapingCorners.bs2 checks to see if counter has reached 4. √ √ Try increasing the value to 5 and 6 and note the effect. Try also reducing the value and see if it has any effect on normal roaming.
Page 188 · Robotics with the Boe-Bot SUMMARY In this chapter, instead of navigating from a pre-programmed list, the Boe-Bot was programmed to navigate based on sensory inputs. The sensory inputs used in this chapter were whiskers, which served as normally open contact switches. When properly wired, these switches can show one voltage (5 V) at the switch’s contact point when it’s open, and a different voltage (0 V) when it’s closed.
Chapter 5: Tactile Navigation with Whiskers · Page 189 Exercises 1. Write a DEBUG command for TestWhiskers.bs2 that updates each whisker state on a new line. Adjust the PAUSE command so that it is 250 instead of 50. 2. Using RoamingWithWhiskers.bs2 as a reference, write a Turn_Away subroutine that calls the Back_Up subroutine once and the Turn_Left subroutine twice. Write down the modifications you will have to make to the Main Routine section of RoamingWithWhiskers.bs2. Projects 1.
Page 190 · Robotics with the Boe-Bot Solutions Q1. A tactile switch. Q2. Zero (0) volts, resulting in Binary zero (0) at the input register. IN8 = 0 when whisker is pressed. IN8 = 1 when whisker is not pressed. Q3. IN7 = 1 means the right whisker is not pressed. IN7 = 0 means the right whisker is pressed. IN5 = 1 means the left whisker is not pressed. IN5 = 0 means the left whisker is pressed. Q4. The GOSUB command performs the actual jump. The IF...
Chapter 5: Tactile Navigation with Whiskers · Page 191 To modify the Main Routine, replace the three GOSUB commands under the first IF condition with this single line: GOSUB Turn_Away P1. The key to solving this problem is to write a statement that makes a beep with the required parameters: FREQOUT 4, 100, 4000 ' 4kHz beep for 100ms This statement must be added to the Main Routine in the appropriate places, as shown below. The rest of the program is unchanged.
Page 192 · Robotics with the Boe-Bot ' Robotics with the Boe-Bot - CirclingWithWhiskerInput.bs2 ' Move in 1 yard circle, increase/decrease radius in response ' to whisker presses, one whisker increases, one decreases. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" ' Stamp directive. ' PBASIC directive.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 193 Chapter 6: Light Sensitive Navigation with Photoresistors Light has many applications in robotics and industrial control. Some examples include sensing the edge of a roll of fabric in the textile industry, determining when to activate streetlights at different times of the year, when to take a picture, or when to deliver water to a crop of plants. There are many different light sensors that serve unique functions.
Page 194 · Robotics with the Boe-Bot A photoresistor is a light-dependent resistor (LDR) that covers the spectral sensitivity similar to that of the human eye. In other words, the kind of light that your eye detects is the same kind of light that affects the photoresistor’s resistance. The active elements of these photoresistors are made of Cadmium Sulfide (CdS). Light enters into the semiconductor layer applied to a ceramic substrate and produces free charge carriers.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 195 Vdd Vdd P6 Figure 6-2 Schematic – First Light Detection Circuit P3 220 Ω 220 Ω 2 kΩ 2 kΩ Vss Vss To Servos To Servos 15 14 Vdd 13 12 (916) 624-8333 www.parallax.com www.stampsinclass.
Page 196 · Robotics with the Boe-Bot How the Photoresistor Circuit Works A BASIC Stamp I/O pin can function as an output or an input. As an output, the I/O pin can send a high (5 V) or low (0 V) signal. Up to this point, high and low signals have been used to turn LED circuits on and off, control servos, and send tones to a speaker. A BASIC Stamp I/O pin can also function as an input. As an input, the I/O pin does not apply any voltage to the circuit it is connected to.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 197 Vdd R Vo Figure 6-4 Schematic – Voltage Divider Circuit 2 kΩ Vss When resistors are connected end-to-end as shown in Figure 6-4 they are connected in series, and they can be referred to as series resistors. When two resistors are connected in series to set a voltage at Vo, the circuit is called a voltage divider. In this circuit, the value of Vo can be anywhere between Vdd and Vss.
Page 198 · Robotics with the Boe-Bot Example Program: TestPhotoresistorsDividers.bs2 This example program is TestWhiskers.bs2 adapted to the photoresistor dividers. Instead of monitoring P5 and P7 as we did with the whiskers, we are now monitoring P3 and P6, which are connected to the photoresistor divider circuits. This program should display a value of 1 on both sides in a well-lit room. When you cast a shadow over one or both of the photoresistors, their corresponding values should change to 0.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 199 Photoresistor Divider Troubleshooting General things to verify: √ √ √ Check your wiring and program for errors. Make sure that each component is firmly plugged into its socket. Check the color codes on your resistors. The resistors that connect between Vss and the photoresistors should be 2 kΩ (red-black-red). The resistors connecting P6 and P3 to the photoresistors should be 220 Ω (red-red-brown).
Page 200 · Robotics with the Boe-Bot ACTIVITY #2: ROAM AND AVOID SHADOWS LIKE OBJECTS Since the photoresistor dividers behave similarly to whiskers, it’s worth examining what’s involved in adapting RoamingWithWhiskers.bs2 so that it functions with the photoresistor dividers. Adapting RoamingWithWhiskers.bs2 for the Photoresistor Dividers All you really have to do is adjust the IF…THEN statements so that they monitor IN6 and IN3, instead of IN7 and IN5. Figure 6-5 demonstrates how to make these changes.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 201 Casting shadows over both photoresistors at the same time can be difficult. When the Boe-Bot is going forward, it is checking the photoresistors around 40 times/second. You will have to move quickly to cast a shadow over both photoresistors between pulses. It helps to move your hand rapidly from no shade to full shade to trigger both photoresistors at once.
Page 202 · Robotics with the Boe-Bot ELSE GOSUB Forward_Pulse ENDIF ' Neither photoresistor detects ' shadow, apply a forward pulse. LOOP ' -----[ Subroutines ]-------------------------------------------------------Forward_Pulse: PULSOUT 12,650 PULSOUT 13,850 PAUSE 20 RETURN ' Send a single forward pulse. Turn_Left: FOR pulseCount = 0 TO 20 PULSOUT 12, 650 PULSOUT 13, 650 PAUSE 20 NEXT RETURN ' Left turn, about 90-degrees.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 203 Figure 6-6: Modify RoamingWithPhotoresistorDividers.bs2 ' Excerpt from ' RoamingWithPhotoresistor ' Dividers.bs2 ' Modified excerpt from ' RoamingWithPhotoresistor ' Dividers.
Page 204 · Robotics with the Boe-Bot Boe-Bot should move forward. If you cast a shadow over one of the photoresistors, the Boe-Bot should turn in the direction of the photoresistor that senses the shadow. √ √ √ Enter, save, and run ShadowGuidedBoeBot.bs2. Use your hand to cast shadows over the photoresistor dividers. Study this program carefully and make sure you understand how it works. It is very short, yet very powerful. ' Robotics with the Boe-Bot - ShadowGuidedBoeBot.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 205 Your Turn – Condensing the Program This program does not need the ELSE condition or the two PULSOUT commands that follow. If you deliver no pulses, the Boe-Bot will sit still, just as it should when you deliver pulses using 750 for the PULSOUT Duration argument. √ Try deleting (or commenting) this code block. √ √ Run the modified program.
Page 206 · Robotics with the Boe-Bot Common capacitance measurements are: • • • Microfarads: Nanofarads: Picofarads: (millionths of a Farad), abbreviated µF (billionths of a Farad), abbreviated nF (trillionths of a Farad), abbreviated pF -6 1 µF = 1×10 F -9 1 nF = 1×10 F -12 1 pF = 1×10 F The 103 on the 0.01 µF capacitor’s case is a measurement picofarads or (pF). 103 is 10, with three zeros added, which is 10,000. Here is how to relate 103 to 0.01 µF. 3 10,000 is 10 × 10 .
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 207 P6 220 Ω 0.01 µF Figure 6-8 Schematic - Two Photoresistor RC Circuits Vss P3 220 Ω 0.01 µF For measurement of resistance that varies with light. Vss To Servos To Servos 15 14 Vdd 13 12 (916) 624-8333 www.parallax.com www.stampsinclass.
Page 208 · Robotics with the Boe-Bot About RC Decay Time and the Photoresistor Circuit Think of a capacitor in the circuit shown in Figure 6-10 as a tiny rechargeable battery. When P6 sends the high signal, it essentially charges this capacitor-battery by applying 5 V to it. After a few ms, the capacitor charges up to almost 5 V. If the BASIC Stamp program then changes the I/O pin so that it just quietly listens, the capacitor loses its charge through the photoresistor.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 209 RCTIME. The RCTIME command is designed to measure RC decay time on a circuit like the one in Figure 6-10. Here is the syntax for the RCTIME command: RCTIME Pin, State, Duration The Pin argument is the number of the I/O pin that you want to measure. For example, if you want to measure P6, the Pin argument should be 6. The State argument can either be 1 or 0. It should be 1 if the voltage across the capacitor starts above 1.
Page 210 · Robotics with the Boe-Bot √ √ Cast a shadow over the photoresistor connected to P6 and verify that the time measurement gets larger as the environment gets darker. Point the photoresistor’s light collecting surface directly at an overhead light, or shine flashlight directly at it. The time measurement should get very small. It should then get larger as you gradually direct the photoresistor further away from the light source.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 211 Extra Equipment (1) Flashlight Adjust Sensors to Search for Flashlight Beam This activity works best if the photoresistors’ light-collecting surfaces are pointing ahead at separate points on the ground about 2 in (5.1 cm) in front of the Boe-Bot. √ Point the light collecting surfaces of your photoresistors at the surface in front of the Boe-Bot as shown in Figure 6-11.
Page 212 · Robotics with the Boe-Bot Testing Sensor Response to Flashlight Beam Before you can program the Boe-Bot to turn towards a flashlight beam, you have to know the difference between light readings with and without the flashlight beam shining in the Boe-Bot’s path. Example Program: TestBothPhotoresistors.bs2 √ √ √ √ √ Enter, save, and run TestBothPhotoresistors.bs2. Place the Boe-Bot on the surface where it is to follow the flashlight beam.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 213 PAUSE 3 RCTIME 6,1,timeLeft HIGH 3 PAUSE 3 RCTIME 3,1,timeRight ' Right RC time measurement. DEBUG CRSRXY, 0, 3, DEC5 timeLeft, " ", DEC5 timeRight ' Display measurements. PAUSE 100 LOOP Your Turn √ √ Try facing the Boe-Bot in different directions, and repeat your measurements. For better results, you can average your measurements for "flashlight on" and "flashlight off" and replace the values in Table 6-1 with your average values.
Page 214 · Robotics with the Boe-Bot Constants can even be used to calculate other constants. Here is an example of two constants, named LeftThreshold and RightThreshold that are calculated using the four constants just discussed. The LeftThreshold and RightThreshold constants are used in the program to figure out whether or not the flashlight beam has been detected.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 215 √ √ √ √ √ √ √ Substitute your timeRight measurement with no flashlight beam in place of the value 114 in the RightAmbient CON directive. Substitute your timeLeft measurement with focused flashlight beam in place of the value 20 in the LeftBright CON directive. Substitute your timeRight measurement with focused flashlight beam in place of the value 22 in the RightBright CON directive. Reconnect power to your board and servos.
Page 216 · Robotics with the Boe-Bot FREQOUT 4, 2000, 3000 ' -----[ Main Routine ]------------------------------------------------------DO GOSUB Test_Photoresistors GOSUB Navigate LOOP ' -----[ Subroutine - Test_Photoresistors ]----------------------------------Test_Photoresistors: HIGH 6 PAUSE 3 RCTIME 6,1,timeLeft ' Left RC time measurement. HIGH 3 PAUSE 3 RCTIME 3,1,timeRight ' Right RC time measurement.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 217 How FlashlightControlledBoeBot.bs2 Works These are the four constant declarations that you used with your own values from Table 6-1. LeftAmbient RightAmbient LeftBright RightBright CON CON CON CON 108 114 20 22 Now that the four constants have been declared, the next two lines average and scale the values to come up with threshold values for the program.
Page 218 · Robotics with the Boe-Bot This is the subroutine that performs the RCTIME measurements on both photoresistor RC circuits. The measurement for the left circuit is stored in the timeLeft variable, and the measurement for the right circuit is stored in the timeRight variable.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 219 PAUSE 20 RETURN Your Turn – Adjusting the Performance and Changing the Behavior You can adjust the program’s performance by adjusting the scale factor term in this constant declaration: ' Average LeftThreshold CON RightThreshold CON Scale factor LeftBright + LeftAmbient / 2 * 5 / 8 RightBright + RightAmbient / 2 * 5 / 8 If you change the scale factor from 5/8 to 1/2, it will make the Boe-Bot less sensitive to the flashlight, which
Page 220 · Robotics with the Boe-Bot √ Point the light collecting surfaces of your photoresistors upward and outward shown in Figure 6-12.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 221 PULSOUT PULSOUT ELSE PULSOUT PULSOUT ENDIF 13, 650 12, 650 ' Go forward. 13, 850 12, 650 Here is another code block that works a little better. This code block fixes the turning back and forth problem under certain conditions. The timeLeft variable now has to be larger than timeRight by a margin of 15 before the Boe-Bot will apply a left pulse.
Page 222 · Robotics with the Boe-Bot average = timeRight + timeLeft / 2 difference = average / 6 Now, the difference variable can be used in this IF…THEN statement, and it will be a large value when the lighting is low, and a small value when the lighting is bright. IF (timeLeft > timeRight + difference) THEN ' Turn right. PULSOUT 13, 850 PULSOUT 12, 850 ELSEIF (timeRight > timeLeft + difference) THEN ' Turn left. PULSOUT 13, 650 PULSOUT 12, 650 ELSE ' Go forward.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 223 √ Also try placing your Boe-Bot in a room that is poorly lit, but that has light streaming in through a doorway from an adjacent brightly lit room or hallway. See if the Boe-Bot can successfully find its way out the door. ' -----[ Title ]-------------------------------------------------------------' Robotics with the Boe-Bot - RoamingTowardTheLight.bs2 ' Boe-Bot roams, and turns away from dark areas in favor of brighter areas.
Page 224 · Robotics with the Boe-Bot ' -----[ Subroutine - Average_And_Difference ]-------------------------------Average_And_Difference: average = timeRight + timeLeft / 2 difference = average / 6 RETURN ' -----[ Subroutine - Navigate ]---------------------------------------------Navigate: ' Shadow significantly stronger on left detector, turn right. IF (timeLeft > timeRight + difference) THEN PULSOUT 13, 850 PULSOUT 12, 850 ' Shadow significantly stronger on right detector, turn left.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 225 √ √ √ Instead of the value 6, try dividing the average variable by the values 3, 4, 5, 7, and 9. Run the program and test the Boe-Bot’s ability to exit a dark room with each denominator value. Decide what the optimum denominator value is.
Page 226 · Robotics with the Boe-Bot difference = difference / Denominator RETURN There is a better way though. √ Leave the Average_And_Difference routine like this: Average_And_Difference: average = timeRight + timeLeft / 2 difference = average / Denominator RETURN √ Next, make this change in the variable declarations: Figure 6-13: Modify RoamingTowardTheLight.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 227 SUMMARY This chapter focused on measuring differences in light intensity and programming the Boe-Bot to act on these differences. A pair of cadmium sulfide (CdS) photoresistors were used to measure differences in visible light. The CdS photoresistors were first connected to resistors to form voltage dividers, and the BASIC Stamp monitored the voltage at the connection between the photoresistor and the fixed resistor.
Page 228 · Robotics with the Boe-Bot 2. Does an I/O pin have any effect on the circuit when it’s set to input? What causes the input register for an I/O pin to hold a 1 or 0 when it’s set to input? 3. What does threshold voltage mean? What’s the threshold voltage of a BASIC Stamp I/O pin? 4. Referring to Figure 6-4 on page 197, what causes Vo to rise above or fall below a BASIC Stamp I/O pin’s threshold voltage? What is it about the circuit that causes Vo to change value? 5.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 229 the program work than the photoresistor divider techniques. Also, make sure this obstacle course is in a uniformly lit area. Bright sunlight from windows, and shadows cast by onlookers can make the demonstration fail. 2. If you succeeded with project 1, experiment with confining the Boe-Bot so that it can only roam in a space that is enclosed by black sheets of paper.
Page 230 · Robotics with the Boe-Bot Solutions Q1. The resistance is small, a few ohms, if the light is bright. The resistance is large, around 50 kΩ, in dim light. For light levels between bright and dim, its resistance will be somewhere between the bright and dim values. Q2. No. The I/O pin just quietly listens without any actual effect on the circuit. The value of the applied voltage causes the input register to change what it stores. If the applied voltage is less than 1.4 volts it stores a 0.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 231 E2. a) Vo = 1.4 V R = (5 * (2000/Vo)) – 2000 = (5 * (2000/1.4)) – 2000 = (5 * 1428.57) – 2000 = 7142.86 – 2000 = 5142.86 = 5143 Ohm When Vo = 1.4V, R = 5143 Ω b) Vo = 1.0 V R = (5 * (2000/1)) – 2000 = (5 * 2000) – 2000 = (10000) – 2000 = 8000 = 8 kOhm When Vo = 1.4V, R = 8 kΩ c) Vo = 3.0 V R = (5 * (2000/3.0)) – 2000 = (5 * 666.67) – 2000 = 3333.33 – 2000 = 1333.33 = 1333 Ohm When Vo = 1.4V, R = 1333 Ω E3.
Page 232 · Robotics with the Boe-Bot ' -----[ Title ]---------------------------------------------------------' Robotics with the Boe-Bot - TestBlackWhiteLogic.bs2 ' Calculate whether Boe-Bot is over black or white surface, and print. ' {$STAMP BS2} ' {$PBASIC 2.5} ' Stamp directive ' PBASIC directive.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 233 "FlashlightControlledBoeBot.bs2" and "RoamingTowardTheLight.bs2". A sample solution is shown below. ' -----[ Title ]------------------------------------------------------' Robotics with the Boe-Bot - AvoidBlackSpots.bs2 ' Boe-Bot avoids black pieces of paper. ' {$STAMP BS2} ' {$PBASIC 2.5} ' Stamp directive ' PBASIC directive.
Page 234 · Robotics with the Boe-Bot ' Both detect black paper, back up and make a noise IF (timeLeft > LeftAvg) AND (timeRight > RightAvg) THEN PULSOUT 13, 650 PULSOUT 12, 850 FREQOUT 4, 20, 4400 ' Beep instead of pause ' Left detects black paper, turn away to right, make a noise ELSEIF (timeLeft > LeftAvg) THEN PULSOUT 13, 850 PULSOUT 12, 850 FREQOUT 4, 20, 2200 ' Right detects black paper, turn away to left, make a noise ELSEIF (timeRight > RightAvg) THEN PULSOUT 13, 650 PULSOUT 12, 650 FREQOUT 4, 20, 3
Chapter 7: Navigating with Infrared Headlights · Page 235 Chapter 7: Navigating with Infrared Headlights Today's hottest products seem to have one thing in common: wireless communication. Personal organizers beam data into desktop computers, and wireless remotes let us channel surf. Many remote controls and PDA’s use signals in the infrared frequency range to communicate, below the visible light spectrum.
Page 236 · Robotics with the Boe-Bot Infrared Headlights The infrared object detection system we’ll build on the Boe-Bot is like a car’s headlights in several respects. When the light from a car’s headlights reflects off obstacles, your eyes detect the obstacles and your brain processes them and makes your body guide the car accordingly. The Boe-Bot uses infrared LEDs for headlights as shown in Figure 7-1.
Chapter 7: Navigating with Infrared Headlights · Page 237 Some fluorescent lights do generate signals that can be detected by the IR detectors. These lights can cause problems for your Boe-Bot’s infrared headlights. One of the things you will do in this chapter is develop an infrared interference “sniffer” that you can use to test the fluorescent lights near your Boe-Bot courses.
Page 238 · Robotics with the Boe-Bot One IR pair (IR LED and detector) is mounted on each corner of the breadboard. Figure 7-4 shows the IR headlights circuit as a schematic and Figure 7-5 shows the circuit as a wiring diagram. √ √ Disconnect power from your board and servos. Build the circuit shown by the schematic in Figure 7-4, using the wiring diagram for your board in Figure 7-5 as a reference for parts placement.
Chapter 7: Navigating with Infrared Headlights · Page 239 To Servos To Servos 15 14 Vdd 13 12 X4 Vdd X5 Vin Vdd Vss anode leads + Board of Education Rev C © 2000-2003 Vin Vss X3 X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 Figure 7-5 Wiring Diagrams for Infrared Emitter and Receiver Circuits (916) 624-8333 Rev B www.parallax.com www.stampsinclass.
Page 240 · Robotics with the Boe-Bot FREQOUT Command - Fundamentals and Harmonics The fundamental frequency is the value of the Freq1 argument when it’s at or below 32768. For example, when you use the command FREQOUT 4, 2000, 3000, the fundamental frequency is 3000 Hz. That's the intended sound, but there is also a harmonic sound that accompanies it. This harmonic is a much higher frequency that the human ear can detect, in the neighborhood of 62.5 kHz.
Chapter 7: Navigating with Infrared Headlights · Page 241 ' {$PBASIC 2.5} irDetectLeft VAR Bit DO FREQOUT 8, 1, 38500 irDetectLeft = IN9 DEBUG HOME, "irDetectLeft = ", BIN1 irDetectLeft PAUSE 100 LOOP √ √ √ √ √ Leave the Boe-Bot connected to the serial cable, because you will be using the Debug Terminal to test your IR pair. Place an object, such as your hand or a sheet of paper, about an inch from the left IR pair, in the manner shown in Figure 7-1 on page 236.
Page 242 · Robotics with the Boe-Bot √ √ √ √ √ Change the DEBUG statement, title and comments to refer to the right IR pair. Change the variable name from irDetectLeft to irDetectRight. You will need to do this in four places in the program. Change the FREQOUT command’s Pin argument from 8 to 2. Change the input register monitored by the irDetectRight variable from IN9 to IN0.
Chapter 7: Navigating with Infrared Headlights · Page 243 P1 P10 220 Ω 220 Ω Figure 7-6 Left and Right Indicator LEDs Red LED Red LED Vss Vss Left IR Pair Right IR Pair To Servos To Servos 15 14 Vdd 13 12 Anode leads Anode leads Red Black X4 Vdd X5 Vin + Board of Education Rev C Vdd Vin Vss X3 Vss X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 (916) 624-8333 Rev B www.parallax.com www.stampsinclass.
Page 244 · Robotics with the Boe-Bot √ √ √ Verify that the speaker makes a clear, audible tone while the Debug Terminal displays “Testing piezospeaker…”. Use the Debug Terminal to verify that the BASIC Stamp still receives a zero from each IR detector when an object is placed in front of it. Verify that the LED next to each detector emits light when the detector detects an object. If one or both of the LEDs appear not to work, check your wiring and your program.
Chapter 7: Navigating with Infrared Headlights · Page 245 LOW 1 ENDIF DEBUG CRSRXY, 2, 3, BIN1 irDetectLeft, CRSRXY, 9, 3, BIN1 irDetectRight PAUSE 100 LOOP Your Turn – Remote Testing and Range Testing You can now use your LED detectors to take your Boe-Bot and test your IR detectors on objects that might not otherwise be in reach of your computer’s serial cable. √ √ Unplug your Boe-Bot from the serial cable, and take your Boe-Bot to a variety of objects and test the range of the IR detectors.
Page 246 · Robotics with the Boe-Bot Example Program – IrInterferenceSniffer.bs2 √ √ Enter, save, and run IrInterferenceSniffer.bs2. Test to make sure the Boe-Bot sounds the alarm when it detects IR interference. You can do this with a separate Boe-Bot that’s running TestIrPairsAndIndicators.bs2. If you don’t have a second Boe-Bot, just use a handheld remote for a TV, VCR, CD/DVD player, or projector. Simply point the remote at the Boe-Bot and press a button.
Chapter 7: Navigating with Infrared Headlights · Page 247 ACTIVITY #3: INFRARED DETECTION RANGE ADJUSTMENTS You may have noticed that brighter car headlights (or a brighter flashlight) can be used to see objects that are further away when it’s dark. By making the Boe-Bot’s infrared LED headlights brighter, you can also increase its detection range. By resisting electric current less, a smaller resistor allows more current to flow through an LED.
Page 248 · Robotics with the Boe-Bot The command STOP is used here rather than END, since END would put the BASIC Stamp into low power mode. Your Turn – Testing LED Brightness Remember to disconnect power before you make changes to a circuit. Remember also that the same program will run again when you reconnect power, so you can pick up right where you left off with each test. √ √ √ √ √ √ √ Note how brightly the LED in the circuit connected to P1 is glowing with the 220 Ω resistor.
Chapter 7: Navigating with Infrared Headlights · Page 249 √ √ √ Repeat with 2 kΩ resistors. Repeat with 470 Ω resistors. Repeat with 220 Ω resistors. Table 7-2: Detection Distance vs. Resistance IR LED Series Resistance, (Ω) Maximum Detection Distance, Circle one: ( in / cm ) 4700 2000 1000 470 220 √ √ Before moving on to the next activity, restore your IR pairs to their original configuration (with 1 kΩ resistors in series with each IR LED).
Page 250 · Robotics with the Boe-Bot irDetectLeft = IN9 The IF…THEN statements were modified so that they look at the variables that store the IR pair detections instead of the whisker inputs. IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN GOSUB Back_Up GOSUB Turn_Left GOSUB Turn_Left ELSEIF (irDetectLeft = 0) THEN GOSUB Back_Up GOSUB Turn_Right ELSEIF (irDetectRight = 0) THEN GOSUB Back_Up GOSUB Turn_Left ELSE GOSUB Forward_Pulse ENDIF Example Program – RoamingWithIr.
Chapter 7: Navigating with Infrared Headlights · Page 251 FREQOUT 4, 2000, 3000 ' Signal program start/reset. ' -----[ Main Routine ]------------------------------------------------------DO FREQOUT 8, 1, 38500 irDetectLeft = IN9 ' Store IR detection values in ' bit variables.
Page 252 · Robotics with the Boe-Bot Back_Up: FOR pulseCount = 0 TO 40 PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT RETURN ' Back up. Your Turn √ Modify RoamingWithIr.bs2 so that the IR pairs are checked in a subroutine. ACTIVITY #5: HIGH PERFORMANCE IR NAVIGATION The style of pre-programmed maneuvers that were used in the previous activity were fine for whiskers, but are unnecessarily slow when using the IR LEDs and detectors.
Chapter 7: Navigating with Infrared Headlights · Page 253 irDetectRight pulseLeft pulseRight VAR VAR VAR Bit Word Word FREQOUT 4, 2000, 3000 ' Signal program start/reset. DO ' Main Routine FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 irDetectRight = IN0 ' Check IR Detectors ' Decide how to navigate.
Page 254 · Robotics with the Boe-Bot command’s worth of time, the IR detector will return to the not detected (1 state), regardless of whether or not it detected an object. FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 irDetectRight = IN0 In the IF…THEN statements, instead of delivering pulses or calling navigation routines, this program sets variable values that will be used in PULSOUT commands’ Duration arguments.
Chapter 7: Navigating with Infrared Headlights · Page 255 ACTIVITY #6: THE DROP-OFF DETECTOR Up until now, the Boe-Bot has mainly been programmed to take evasive maneuvers when an object is detected. There are also applications where the Boe-Bot must take evasive action when an object is not detected. For example, if the Boe-Bot is roaming on a table, its IR detectors might be looking down at the table surface as shown in Figure 7-8.
Page 256 · Robotics with the Boe-Bot √ √ √ √ √ Build a course similar to the electrical tape delimited course shown in Figure 79. Use at least three strips of electrical tape, edge to edge with no paper visible between the strips. Replace your 1 kΩ resistors with 2 kΩ resistors (red-black-red) to connect P2 to its IR LED and P8 to its IR LED. We want the Boe-Bot to be nearsighted for this activity. Reconnect power to your board. Run the program IrInterferenceSniffer.
Chapter 7: Navigating with Infrared Headlights · Page 257 22” (56 cm) 22” (56 cm) Figure 7-9 Electrical Tape Outline Simulates Tabletop Edge If you try a tabletop after success with the electrical tape course: √ Remember to follow the same steps you followed before running the Boe-Bot in the electrical tape delimited course! Make sure to be the spotter for your Boe-Bot.
Page 258 · Robotics with the Boe-Bot A second feature of a program for turning away from drop-offs is adjustable distance. You may want your Boe-Bot to only take one pulse forward between checking the detectors, but as soon as a drop-off is detected, you may want your Boe-Bot to take several pulses worth of turn before checking the detectors again. Just because you are taking multiple pulses in an evasive maneuver, it doesn’t mean you have to return to whiskers-style navigation.
Chapter 7: Navigating with Infrared Headlights · Page 259 FREQOUT 4, 2000, 3000 ' Signal program start/reset. DO ' Main Routine. FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 irDetectRight = IN0 ' Check IR detectors. ' Decide navigation. IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN pulseCount = 1 ' Both detected, pulseLeft = 850 ' one pulse forward. pulseRight = 650 ELSEIF (irDetectRight = 1) THEN ' Right not detected, pulseCount = 10 ' 10 pulses left.
Page 260 · Robotics with the Boe-Bot pulseCount VAR Byte The IF…THEN statements now set the value of pulseCount as well as the values of pulseRight and pulseLeft. If both detectors can see the table, take one cautious pulse forward. IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN pulseCount = 1 pulseLeft = 850 pulseRight = 650 Else, if the right IR detector does not see the tabletop, rotate left 10 pulses.
Chapter 7: Navigating with Infrared Headlights · Page 261 NEXT Your Turn You can experiment with setting different pulseLeft, pulseRight, and pulseCount values inside the IF…THEN statement. For example, if the Boe-Bot doesn’t turn as far, it may actually track the edge of the electrical tape delimited course. Pivoting backward instead of rotating in place may also lead to some interesting behaviors. √ √ Modify AvoidTableEdge.
Page 262 · Robotics with the Boe-Bot SUMMARY This chapter covered a unique technique for infrared object detection that uses the infrared LED found in common handheld remotes, and the infrared detector found in TVs, CD/DVD players, and other appliances that are controlled by these remotes. By shining infrared into the Boe-Bot’s path and looking for its reflection, object detection can be accomplished without physically contacting the object. Infrared LED circuits are used to send a 38.
Chapter 7: Navigating with Infrared Headlights · Page 263 Exercises 1. Modify a line of code in IrInterferenceSniffer.bs2 so that it only monitors one of the IR LED/detector pairs. 2. Explain the function of pulseCount in AvoidTableEdge.bs2. How does this relate to your answer to Exercise 3? Projects 1. Design a Boe-Bot application that sits still until you wave your and in front of it, then it starts roaming. 2. Design a Boe-Bot application that slowly rotates in place until it detects an object.
Page 264 · Robotics with the Boe-Bot Solutions Q1. 38.5 kHz is the frequency of the harmonic. Its fundamental frequency = 65536 – 38500 = 27036 Hz. The signals are sent for 1 millisecond, and the IR LED must be connected to I/O Pin 2. Q2. The command which stores the detector's output in a variable. For example, irDetectLeft = IN9. Q3. A low signal means IR at 38.5 kHz was detected, thus, an object was detected. A high signal means no IR at 38.5kHz was detected, so, no object. Q4.
Chapter 7: Navigating with Infrared Headlights · Page 265 ' -----[ Main Routine ]-----------------------------------------------Main: ' Loop until something is detected DO GOSUB Check_IRs LOOP UNTIL (irDetectLeft = 0) OR (irDetectRight = 0) ' Now start roaming -- this code from FastIrRoaming.
Page 266 · Robotics with the Boe-Bot detectors read "no object" for brief moments, but this is not reason enough to give up the chase. ' Robotics with the Boe-Bot - SumoBoeBot.bs2 ' Search for object, lock onto it and push it. ' {$STAMP BS2} ' {$PBASIC 2.
Chapter 7: Navigating with Infrared Headlights · Page 267 ENDIF ' its position. PULSOUT 13,pulseLeft PULSOUT 12,pulseRight PAUSE 15 ' Apply the pulse. ' 5 ms for detectors ' Check IRs again in case object is moving GOSUB Check_IRs LOOP ' -----[ Subroutines ] -----------------------------------------------Check_IRs: FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 IrDetectRight = IN0 RETURN ' Check IR Detectors P3. The key to solving this problem is to combine "FastIrRoaming.
Page 268 · Robotics with the Boe-Bot ' -----[ Subroutines ] -----------------------------------------------Sniff: IF (IN0 = 0) OR (IN9 = 0) THEN FOR counter = 1 TO 5 HIGH 1 HIGH 10 FREQOUT 4, 50, 4000 LOW 1 LOW 10 PAUSE 20 NEXT ENDIF RETURN Roam: FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 irDetectRight = IN0 ' From IrInterferenceSniffer.bs2 ' Beep 5 times ' and flash LEDs ' From FastIrRoaming.bs2 ' Check IR Detectors ' Decide how to navigate.
Chapter 8: Robot Control with Distance Detection · Page 269 Chapter 8: Robot Control with Distance Detection In Chapter 7, we used the infrared sensors to detect whether an object is in the Boe-Bot’s way without actually touching it. Wouldn’t it be nice to also know how far away the object is? This is usually a task for sonar, which sends a pulse of sound out and records how long it takes for the echo to come back.
Page 270 · Robotics with the Boe-Bot Figure 8-1 Filter Sensitivity Depends on Carrier Frequency Another way to think about it is that the most sensitive frequency will detect the objects that are the farthest away, while less sensitive frequencies can only be used to detect closer objects. This makes distance detection simple. Pick 5 frequencies, then test them from most sensitive to least sensitive. Try at the most sensitive frequency first.
Chapter 8: Robot Control with Distance Detection · Page 271 Figure 8-2: Frequencies and Zones for the Boe-Bot Object 15 14 Vd d 13 12 Red Black X4 Vdd X5 Vin Vs s X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 Zone 0 41500 Hz + Zone 1 40500 Hz Zone 2 Zone 3 39500 Hz 38250 Hz Zone 4 37500 Hz Boar d of Education © 20 00 -2 00 3 Zone 5 No Detection at any Frequency You might be wondering why the value of zone 4 is 37.5 kHz and not 38.5 kHz.
Page 272 · Robotics with the Boe-Bot FREQOUT 8,1, irFrequency irDetect = IN9 ' Commands not shown... NEXT The first time through the FOR…NEXT loop, freqSelect is 0, so the LOOKUP command places the value 37500 in the irFrequency variable. Since irFrequency contains 37500 after the LOOKUP command, the FREQOUT command sends that frequency to the IR LED connected to P8. As in the previous chapter, the value of IN9 is then saved in the irDetect variable.
Chapter 8: Robot Control with Distance Detection · Page 273 Figure 8-3 Testing Distance Detection Output Examples Keep in mind that these distance measurements are relative and not necessarily precise or evenly spaced. However, they will give the Boe-Bot a good enough sense of object distance for following, tracking, and other activities. √ √ √ √ Enter, save, and run TestLeftFrequencySweep.bs2. Use a sheet of paper or card facing the IR LED/detector to test the distance detection.
Page 274 · Robotics with the Boe-Bot ' -----[ Variables ]---------------------------------------------------------freqSelect irFrequency irDetect distance VAR VAR VAR VAR Nib Word Bit Nib ' -----[ Initialization ]----------------------------------------------------DEBUG CLS, " "FREQUENCY "--------- OBJECT", CR, DETECTED", CR, --------" ' -----[ Main Routine ]------------------------------------------------------DO distance = 0 FOR freqSelect = 0 TO 4 LOOKUP freqSelect,[37500,38250,39500,40500,41500],
Chapter 8: Robot Control with Distance Detection · Page 275 so that they read FREQOUT 2,1, irFrequency irDetect = IN0 √ √ Modify TestLeftFrequencySweep.bs2 for testing the distance measurement of the right IR LED/detector pair. Run the program and verify that this pair can measure a similar distance. Displaying Both Distances It’s useful at times to have a quick program you can run to test both the Boe-Bot’s distance detectors at the same time.
Page 276 · Robotics with the Boe-Bot DO GOSUB Get_Distances GOSUB Display_Distances LOOP ' -----[ Subroutine – Get_Distances ]----------------------------------------Get_Distances: distanceLeft = 0 distanceRight = 0 FOR freqSelect = 0 TO 4 LOOKUP freqSelect,[37500,38250,39500,40500,41500], irFrequency FREQOUT 8,1,irFrequency irDetectLeft = IN9 distanceLeft = distanceLeft + irDetectLeft FREQOUT 2,1,irFrequency irDetectRight = IN0 distanceRight = distanceRight + irDetectRight PAUSE 100 NEXT RETURN ' -----[ S
Chapter 8: Robot Control with Distance Detection · Page 277 ACTIVITY #2: BOE-BOT SHADOW VEHICLE For one Boe-Bot to follow another, the Boe-Bot that follows, a.k.a. the shadow vehicle, has to know how far ahead the lead vehicle is. If the shadow vehicle is lagging behind, it has to detect this and speed up. If the shadow vehicle is too close to the lead vehicle, it has to detect this as well and slow down.
Page 278 · Robotics with the Boe-Bot Center pulse width 750 Error = -2 Kp X error 35 X -2 + - Output adjust -70 + + Right servo output 680 Measured right distance = 4 Figure 8-4 Proportional Control Block Diagram for Right Servo and IR LED and Detector Pair System Let’s take a closer look at the numbers in Figure 8-4 to learn how proportional control works. This particular example is for the right IR LED/detector and right servo.
Chapter 8: Robot Control with Distance Detection · Page 279 Output adjust Right servo output = = = = = = = 2–4 error × Kp –2 × 35 – 70 Output adjust + Center pulse width – 70 + 750 680 By making some substitutions, the three equations above can be reduced to this one, which will give you the same result.
Page 280 · Robotics with the Boe-Bot Center pulse width 750 Error = -2 Kp X error -35 X -2 + - Output adjust +70 + + Left servo output 820 Measured left distance = 4 Figure 8-5 Proportional Control Block Diagram for Left Servo and IR LED and Detector Pair System Programming the Boe-Bot Shadow Vehicle Remember that the equation for the right servo’s output was: Right servo output = (Right distance set point – Measured right distance) × Kp + Center pulse width Here is an example of solving this s
Chapter 8: Robot Control with Distance Detection · Page 281 The left servo is different because Kp for that system is -35 pulseLeft = 2 - distanceLeft * (-35) + 750 Since the values -35, 35, 2, and 750 all have names, it’s definitely a good place for some constant declarations. Kpl Kpr SetPoint CenterPulse CON CON CON CON -35 35 2 750 With these constant declarations in the program, you can use the name Kpl in place of 35, Kpr in place of 35, SetPoint in place of 2, and CenterPulse in place of 750.
Page 282 · Robotics with the Boe-Bot √ Move the sheet of paper too close to the Boe-Bot, and it should back up, away from the paper. ' -----[ Title ]-------------------------------------------------------------' Robotics with the Boe-Bot - FollowingBoeBot.bs2 ' Boe-Bot adjusts its position to keep objects it detects in zone 2. ' {$STAMP BS2} ' {$PBASIC 2.5} ' Stamp directive. ' PBASIC directive.
Chapter 8: Robot Control with Distance Detection · Page 283 Get_Ir_Distances: distanceLeft = 0 distanceRight = 0 FOR freqSelect = 0 TO 4 LOOKUP freqSelect,[37500,38250,39500,40500,41500], irFrequency FREQOUT 8,1,irFrequency irDetectLeft = IN9 distanceLeft = distanceLeft + irDetectLeft FREQOUT 2,1,irFrequency irDetectRight = IN0 distanceRight = distanceRight + irDetectRight NEXT RETURN ' -----[ Subroutine – Get Pulse ]--------------------------------------------Send_Pulse: PULSOUT 13,pulseLeft PULSOUT 12,pu
Page 284 · Robotics with the Boe-Bot The next two lines of code implement the proportional control calculations for each servo. ' Calculate proportional output. pulseLeft = SetPoint - distanceLeft * Kpl + CenterPulse pulseRight = SetPoint - distanceRight * Kpr + CenterPulse Now that the pulseLeft and pulseRight calculations are done, the Send_Pulse subroutine can be called.
Chapter 8: Robot Control with Distance Detection · Page 285 Figure 8-6 Lead Boe-Bot (left) and Shadow BoeBot (right) √ √ √ √ √ √ √ If you are part of a class, mount paper panels on the tail and both sides of the lead Boe-Bot as shown in Figure 8-6. If you are not part of a class (and only have one Boe-Bot) the shadow vehicle will follow a piece of paper or your hand just as well as it follows a lead BoeBot.
Page 286 · Robotics with the Boe-Bot You can adjust the set points and proportionality constants to change the shadow BoeBot’s behavior. Use your hand or a piece of paper to lead the shadow Boe-Bot while doing these exercises: √ Try running FollowingBoeBot.bs2 using values of Kpr and Kpl constants, ranging from 15 to 50. Note the difference in how responsive the Boe-Bot is when following an object. Try making adjustments to the value of the SetPoint constant. Try values from 0 to 4.
Chapter 8: Robot Control with Distance Detection · Page 287 Materials Required (1) Sheet of poster board – Approximate dimensions: 22 X 28 in (56 X 71 cm) (1) Roll of Black Vinyl Electrical Tape – ¾” (19 mm) wide. √ Use your poster board and electrical tape to build the course shown in Figure 87. Testing the Stripe √ Point your IR pairs downward and outward as shown in Figure 8-8 (Figure 7-8 from page 255 repeated here for convenience).
Page 288 · Robotics with the Boe-Bot 15 1 4 6- 9VD C V dd R ed Bl ack STA i nC MPS LAS S TM 1 S out Sn i AT N V ss P0 P1 P2 P3 P4 P5 P6 P7 U1 Vn i V ss R st V dd P 15 P 14 P 13 P 12 P 11 P 10 P9 P8 w w w . st a mps i nc al ss .
Chapter 8: Robot Control with Distance Detection · Page 289 Figure 8-11 Test for High Zone Number – Side View Electrical Tape Trouble Shooting the Electrical Tape Course If you are unable to get a high zone value when the IR detectors are focused on the electrical tape, take a separate piece of paper, and make a stripe that’s four strips wide instead of three. If the zone numbers are still low, make sure that you are using 2 kΩ resistors (red-black-red) in series with your IR LEDs. You can also try a 4.
Page 290 · Robotics with the Boe-Bot for the pair that is now over the electrical tape should increase to 4 or 5. Keep in mind that if you move the Boe-Bot toward its left, the right detectors should increase in value, and if you move the Boe-Bot toward its right, the left detectors should show the higher value. √ Adjust your IR LED/detector pairs until the Boe-Bot passes this last test. Then you will be ready to try following the stripe.
Chapter 8: Robot Control with Distance Detection · Page 291 √ √ √ Change Kpr from 35 to -35. Run the program (shown below). Place your Boe-Bot at the “Start” location shown in Figure 8-13. The Boe-Bot should wait there until you place your hand in front of its IR pairs. It will then roll forward. When it clears the starting stripe, take your hand away, and it should start tracking the stripe. When it sees the “Finish” stripe, it should stop and wait there.
Page 292 · Robotics with the Boe-Bot Kpr SetPoint CenterPulse CON CON CON -35 3 750 ' Change from 35 to -35 ' Change from 2 to 3.
Chapter 8: Robot Control with Distance Detection · Page 293 ' -----[ Subroutine - Get Pulse ]--------------------------------------------Send_Pulse: PULSOUT 13,pulseLeft PULSOUT 12,pulseRight PAUSE 5 RETURN Your Turn – Stripe Following Contest You can turn this into a contest with the lowest course time winning, provided the BoeBot faithfully waits at the “Start” and “Finish” stripes. You can make up other courses too. For best performance, experiment with different SetPoint, Kpl, and Kpr values.
Page 294 · Robotics with the Boe-Bot SUMMARY Frequency sweep was introduced as a way of determining distance using the Boe-Bot’s IR LED and detector. FREQOUT was used to send IR signals at frequencies ranging from 37.5 kHz (most sensitive) to 41.5 kHz (least sensitive). The distance was determined by tracking which frequencies caused the IR detector to report that an object was detected and which did not.
Chapter 8: Robot Control with Distance Detection · Page 295 4. What PBASIC directive do you use to declare a constant? How would you give the number 100 the name “BoilingPoint”? Exercises 1. List the sensitivity of the IR detector for each kHz frequency shown in Figure 81. 2. Write a segment of code that does the frequency sweep for just four frequencies instead of five. 3. Make a condensed checklist for the tests that should be performed to ensure faithful stripe following. Projects P1.
Page 296 · Robotics with the Boe-Bot Questions Q1. The relative sensitivity at 35 kHz is 30%. For 36 kHz, it's 50% Q2. When index = 4, prime = 11 index = 0, prime = 2 index = 1, prime = 3 index = 2, prime = 5 index = 7, prime = 19 Q3. Expressions are evaluated left to right. To override, use parentheses to change the order. Q4. Use the CON directive. BoilingPoint CON 100 E1. Frequency (kHz): 34 35 36 37 38 39 40 41 42 Sensitivity : 14% 30% 50% 76% 100% 80% 55% 35% 16% E2.
Chapter 8: Robot Control with Distance Detection · Page 297 intersection is a 3-way or 4-way intersection, the Boe-Bot will arbitrarily turn in the direction that black is first detected. A constant, Turn90Degree, is provided to tune the 90 degree turn. Some audible and visual indicators are included, which aid in troubleshooting and understanding what the Boe-Bot is seeing and deciding, as well as adding a bit of personality and fun.
Page 298 · Robotics with the Boe-Bot GOSUB Update_LEDs ' Indicate white/black line ' Calculate proportional output and move accordingly.
Chapter 8: Robot Control with Distance Detection · Page 299 PAUSE 20 NEXT ENDIF ' That's it. At this point the Boe-Bot should have turned 90 degrees ' to follow the intersection. Continue following the black line. RETURN Check_For_Intersection: ' Keep track of no. of pulses vs the forward pulses. If there are less ' than 30 forward pulses per total of 60 pulses, robot is likely stuck ' at an intersection.
Page 300 · Robotics with the Boe-Bot PULSOUT 12, 750 PAUSE 20 RETURN Get_Ir_Distances: ' Read both IR pairs and calculate the distance. Black line gives 4-5 ' reading. White surface give 0-1 reading.
Appendix A: PC to BASIC Stamp Communication Trouble-Shooting · Page 301 Appendix A: PC to BASIC Stamp Communication Trouble-Shooting Here is a list of things to try to quickly fix any difficulties getting the BASIC Stamp Editor to communicate with your BASIC Stamp: √ √ √ √ √ If you are using a Board of Education Rev C, make sure the power switch is set to position-1. Rule out dead batteries and incorrect or malfunctioning power supplies by using a new 9 V battery or four new 1.
Page 302 · Robotics with the Boe-Bot Figure A-1 Identification Window Example: BASIC Stamp 2 not found on COM ports. If you know the number of the COM port, but it does not appear in the Identification Window: √ √ √ √ Use the Edit Port List button to add that COM port. When you return to the Identification window, click the Refresh button to find out if the BASIC Stamp 2 is now detected. Close the Identification window. In the BASIC Stamp Editor, Click Edit and select Preferences.
Appendix A: PC to BASIC Stamp Communication Trouble-Shooting · Page 303 √ √ √ √ √ If you are using a serial port (no USB to serial adaptor), make a note of the COM ports listed. If one or more of these COM ports do not appear in your BASIC Stamp Editor's list, make a note of the numbers for each COM port that doesn't appear in the list now. If you are using an FTDI USB to Serial adaptor, look for the COM port that reads FTDI USB to Serial COM… Repeat the Run → Identify test.
Page 304 · Robotics with the Boe-Bot √ √ √ √ √ Select the COM port that was noted by the Run → Identify test. Select → Port Settings → Advanced. Uncheck the box labeled “Use FIFO Buffers” then click OK. Click OK as needed to close each window and return to the BASIC Stamp Editor. Try downloading a program once more. Windows® XP: √ √ √ √ √ √ √ √ √ Click on your computer desktop’s Start button. Select Control Panel → Printers and Other Hardware. In the See Also box select System.
Appendix B: BASIC Stamp and Carrier Board Components and Features · Page 305 Appendix B: BASIC Stamp and Carrier Board Components and Features The BASIC STAMP® 2 Microcontroller Module Figure B-1 shows a close-up of the BASIC Stamp® 2 microcontroller module. Its major components and their functions are indicated by labels.
Page 306 · Robotics with the Boe-Bot The Board of Education® Rev C Carrier Board The Board of Education® Rev C carrier board for BASIC Stamp® 24-pin microcontroller modules is shown in Figure B-2. Its major components and their functions are indicated by labels.
Appendix B: BASIC Stamp and Carrier Board Components and Features · Page 307 The BASIC Stamp® HomeWork Board™ Project Platform The BASIC Stamp® HomeWork Board™ project platform is shown in Figure B-3. Its major components and their functions are indicated by labels.
Page 308 · Robotics with the Boe-Bot The Board of Education® Rev B Carrier Board Figure B-4 shows the Board of Education® Rev B carrier board for BASIC Stamp® 24pin microcontroller modules. Its major components and their functions are indicated by labels.
Appendix C: Resistor Color Codes · Page 309 Appendix C: Resistor Color Codes Resistors like the ones we are using in this student guide have colored stripes that tell you what their resistance values are. There is a different color combination for each resistance value. For example, the color code for the 470 Ω resistor is yellow-violetbrown. There may be a fourth stripe that indicates the resistor’s tolerance.
Page 310 · Robotics with the Boe-Bot • Third stripe is brown. Since brown is 1, it means add one zero to the right of the first two digits. Yellow-Violet-Brown = 4-7-0.
Appendix D: Breadboarding Rules · Page 311 Appendix D: Breadboarding Rules Look at your Board of Education or HomeWork Board. The white square with lots of holes, or sockets, in it is called a solderless breadboard. This breadboard, combined with the black strips of sockets along two of its sides, is called the prototyping area (shown in Figure D-1). The example circuits in this text are built by plugging components such as resistors, LEDs, speakers, and sensors into these small sockets.
Page 312 · Robotics with the Boe-Bot connected by lines on a schematic, the line indicates that an electrical connection is made. Lines can also be used to connect components to voltage supplies. Vdd, Vin, and Vss all have symbols. Vss corresponds to the negative terminal of the battery supply for the Board of Education or BASIC Stamp HomeWork Board. Vin is the battery’s positive terminal, and Vdd is regulated to +5 volts.
Appendix D: Breadboarding Rules · Page 313 Vdd X3 Vdd 470 Ω LED Vss P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 Vin Vss + Figure D-3 Example Schematic and Wiring Diagram Schematic (left) and wiring diagram (right) Figure D-4 shows a second example of a schematic and wiring diagram. This schematic shows P14 connected to one end of a resistor, with the other end connected to the + terminal of an LED, and the – terminal of the LED is connected to Vss.
Page 314 · Robotics with the Boe-Bot Vdd X3 P14 470 Ω LED Vss P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 Vin Vss + Figure D-4 Example Schematic and Wiring Diagram Schematic (left) and wiring diagram (right) Here is a more complex example that involves two additional parts, a photoresistor and a capacitor. The schematic symbols and part drawings for these components are shown in Figure D-5. Figure D-5 Part Drawings and Schematic Symbols 0.
Appendix D: Breadboarding Rules · Page 315 the prototyping area (Figure D-7). In the schematic, the other lead of the resistor is connected to not one, but two other component terminals. A terminal from the photoresistor and capacitor both share this connection. On the breadboard, the other resistor lead is plugged into one of the rows of 5 sockets. This row also has leads from the capacitor and photoresistor plugged into it.
Page 316 · Robotics with the Boe-Bot Vdd Vin Vss X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 Figure D-7 Resistor, Photoresistor, and Capacitor Wiring Diagram Keep in mind that the wiring diagrams presented here as solutions to the schematics are not the ONLY solutions to those schematics. For example, Figure D-8 shows another solution to the schematic just discussed. Follow the connections and convince yourself that it does satisfy the schematic.
Appendix E: Boe-Bot Parts Lists · Page 317 Appendix E: Boe-Bot Parts Lists To complete the activities in this text, you will need a complete Boe-Bot and the electronic components necessary to build the example circuits. There are several options for ordering these items from Parallax, which are described on the following pages. All of the information in this appendix was current at the time of printing.
Page 318 · Robotics with the Boe-Bot Robotics with the Boe Bot Parts Kit If you already have a Board of Education and BASIC Stamp, you may purchase the Robotics with the Boe-Bot Parts kit, with or without the printed text Robotics with the Boe-Bot Student Guide.
Appendix E: Boe-Bot Parts Lists · Page 319 Building a Boe-Bot with a HomeWork Board If you already have a BASIC Stamp HomeWork Board that you wish to use with a Boe Bot, you will need the Robotics with the Boe-Bot Parts kit and these additional items: (2) 3-pin male/male headers, #451-00303 (1) Tinned-lead battery pack, #753-00001 Boe-Bot Hardware Pack All of the Boe-Bot hardware parts can be purchased individually, as found in our on-line Robot Component Shop if you find you need a replacement part.
Page 320 · Robotics with the Boe-Bot Board of Education Kits Almost all of the titles in the Stamps in Class curriculum feature different hardware and component packages that depend on the BASIC Stamp and Board of Education as a core. The Board of Education can be purchased separately or in its own kit, as listed in Table E-4 below.
Appendix F: Balancing Photoresistors · Page 321 Appendix F: Balancing Photoresistors In this appendix, you will test the photoresistors to find out if they respond similarly to the same incident light levels. If the measurements they report are different for the same incident light levels, you can modify your programs to scale the values reported by your photoresistors.
Page 322 · Robotics with the Boe-Bot √ √ Cup your hand over the photoresistors, making sure that you are casting equal shade over both. For best results, the measurements should be in the 200 to 400 range. Record the values of both time measurements in the second row of Table F-1.
Appendix F: Balancing Photoresistors · Page 323 Calibrating Using a Linear Approximation The photoresistor is often referred to as a non-linear device. In other words, if it returns one measurement at one brightness, that doesn’t mean that the measurement will be five times as large when the light is five times as bright. The math is more complicated and involves logarithms.
Page 324 · Robotics with the Boe-Bot y2 = mx2 + b − ( y1 = mx1 + b ) −−−−−−−−−−−−− ( y2 − y1 ) = m( x2 − x1 ) m= ( y2 − y1 ) ( x2 − x1 ) Once you’ve solved for m, you can plug m back into either of the two y = mx + b equations you started with to get b.
Appendix F: Balancing Photoresistors · Page 325 Now, we know how to correct the timeLeft variable so that it reports values similar to the timeRight variable in this narrow range of light levels: y = mx + b y = 1.37 x + 7 timeLeft( adjusted ) = 1.37 × timeLeft + 7 A Linear Equation in PBASIC In most programming languages for PCs, this equation could be entered as-is. The BASIC Stamp is a very tiny processor compared to a PC. Because of this, it takes an extra step to multiply by a fractional value.
Page 326 · Robotics with the Boe-Bot √ √ Calculate the values of m you will use with the */ operator by multiplying m by 256. Substitute your value of m and b in this line of code from BalancePhtoresistors.bs2: timeLeft = (timeLeft */ 351) + 7 √ √ √ √ √ √ Enter, save, and run your adjusted version of BalancePhotoresistors.bs2. Expose both photoresistors to the same light level. Verify that the “after” values are similar and corrected for differences in the “before” values.
Appendix F: Balancing Photoresistors · Page 327 DEC5 timeRight, " Before" timeLeft = (timeLeft */ 351) + 7 DEBUG CRSRXY, 0, 5, DEC5 timeLeft, " ", DEC5 timeRight, " After" PAUSE 200 LOOP ' Display measurements.
Appendix G: Tuning IR Distance Detection · Page 329 Appendix G: Tuning IR Distance Detection Finding the Right Frequency Sweep Values Fine tuning the Boe-Bot’s distance detection involves determining which frequency is most reliable for each zone for each IR pair. Note: This appendix features a method of determining the best frequencies for determining given distances using spreadsheets. This activity takes time and patience, and is only recommended if your distance sensing is severely out of calibration.
Page 330 · Robotics with the Boe-Bot ' -----[ Initialization ]----------------------------------------------------DEBUG CLS, "Click transmit windowpane,", CR, "then press enter to begin", CR, "frequency sweep...
Appendix G: Tuning IR Distance Detection · Page 331 Figure G-1 Debug of Frequency Data The BASIC Stamp has been programmed to make the Debug Terminal display a “Yes” if an object was detected and a “No” if an object was not detected. Figure G-1 shows that the left sensor’s region of good signal response is between 36500 and 42500.
Page 332 · Robotics with the Boe-Bot √ Modify the FOR...NEXT loop in Program Listing FrequencySweep.bs2 so that it steps in increments of 250 and includes the upper and lower limits of both detectors. Based on the data in the example shown in Figure G-1, the start, end, and step values of the FOR...NEXT loop would be modified as follows: FOR irFrequency = 36500 to 42500 STEP 250 √ √ √ √ √ √ √ √ Re-run your modified FrequencySweep.bs2, and press Enter again.
Appendix G: Tuning IR Distance Detection · Page 333 √ readings at a particular frequency. Note this frequency as a reliable measurement for the dividing line between Zone 0 and Zone 1. At each of the remaining five distances, find a frequency for which the output values have just become stable. For example, at 15 cm, three different frequencies might show five ”Yes” readings. If you look back to the 17.5 cm mark, two of these frequencies were stable, but the other was not.
Appendix H: Boe-Bot Navigation Contests · Page 335 Appendix H: Boe-Bot Navigation Contests If you're planning a competition for autonomous robots, these rules are provided courtesy of Seattle Robotics Society. CONTEST#1: ROBOT FLOOR EXERCISE Purpose The floor exercise competition is intended to give robot inventors an opportunity to show off their robots or other technical contraptions. Rules The rules for this competition are quite simple.
Page 336 · Robotics with the Boe-Bot Maximum Time to Complete Course Four minutes. Example Course All measurements in the example course are approximate. There is a solid line dividing Area "A" from Area "T" at position "F.” This indicates where the course ends. The line is black, approximately 2.25 inches wide and spaced approximately two feet from the walls. All curves have a radius of at least one foot and at most three feet. The walls are 3 1/2 inches high and surround the course.
Appendix H: Boe-Bot Navigation Contests · Page 337 Scoring Each contestant’s score is calculated by taking the time needed to complete the course (in seconds) minus 10% for each "accomplishment." The contestant with the lowest score wins. Table H-1: Line Following Scoring Accomplished Percent Deducted Stops in area A after reaching B and C 10% Does not touch any walls 10% Starts on command 10% ("Starts on command" means the robot starts with an external, non-tactile command.
Page 338 · Robotics with the Boe-Bot conditions. The maze is a classical two-dimensional proper maze: there is a single path from the start to the finish and there are no islands in the maze. Both the entrance and exit are located on outside walls. Proper mazes can be solved by following either the left wall or the right wall. The maze is carefully designed so that there is no advantage if you follow the left wall or the right wall.
Index · Page 339 Index -*- */, 325 -<- <>, 186 -…- …, 52 -3- 3-position switch, 16 3-position switch, 35 -9- 90° turns, 132 -A- alarm circuit, 107 American Standard Code for Information Interchange, 33, 151 amps, 49 anode, 46 artificial intelligence, 182 ASCII, 33, 151 -B- backwards motion, 127 ballast, 242 band pass frequency, 236 Basic Analog and Digital, 56 BASIC Stamp components, 305 insertion, 17 low power mode, 28 preventing damage, 36 BASIC Stamp Editor Identification window, 22 Identify, 3
Page 340 · Robotics with the Boe-Bot disconnect power, 36 Board of Education Rev B, 59 components, 308 Board of Education Rev C connecting power, 16 disconnect power, 35 breadboard.
Index · Page 341 Detailed EEPROM Map, 151 disconnect power, 35 distance calculation, 133 DO WHILE, 148 DO...
Page 342 · Robotics with the Boe-Bot Index argument, 271 Industrial Control, 277 infrared detector, 237 infrared interference, 242 infrared led, 237 infrared spectrum, 235 initialize, 72 input register, 172 integral control, 277 IR interference, 236 -J- jumper, 60 -K- kilohertz, 109 Kp, 278 -L- label subroutine, 141 LDR, 194 lead vehicle, 277 LED, 46 LED light shield assembly, 237 light dependent resistor, 193 light emitting diode, 46 anode, 46 cathode, 46 schematic symbol, 46 terminals, 46 linear app
Index · Page 343 piezoelectric speaker, 106 resistor, 46 PAUSE, 42 Duration argument, 42 PBASIC, 1 variables, 71 PBASIC commands DEBUG, 28 DEBUGIN, 112 DO WHILE, 148 DO...
Page 344 · Robotics with the Boe-Bot programs saving, 26, 27 proportional constant, 278 proportional control, 277 prototyping area input/output pins, 311 prototyping areas socket, 311 PULSOUT, 54 Duration argument, 54 -R- RADAR, 235 RAM, 146 ramping, 137 random access memory, 146 RC decay time, 208 RCTIME, 209 Duration argument, 209 Pin argument, 209 State argument, 209 READ, 148 Reset button, 28 Reset button, 26 resistor, 45 color code, 309 leads, 46 light dependent resistor, 193 series resistors, 1
Index · Page 345 standoffs, 92, 100, 167 start/reset indicator, 106 StartValue, 74 STEP StepValue, 75 stepValue, 75 STOP, 248 straightening the trajectory, 130 subroutine call, 140, 141 subroutine label, 141 subroutines, 140 summing junction, 278 -T- tactile switches, 165 tail wheel, 97 threshold voltage, 197 timing diagram, 52, 56 tokens, 146 tolerance, 309 tones, 106 tools required, 91 transfer curve, 115 Transmit windowpane, 111 troubleshooting BASIC Stamp to PC communication, 301 electrical tape cours
Parts and quantities in the various Boe-Bot Robot kits are subject to change without notice. Parts may differ from what is shown in this picture. Please contact stampsinclsss@parallax.com if you have any questions about your kit.