28125 Parallax Inc, 28125 Datasheet

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
Robotics with the Boe-Bot
Student Guide
VERSION 2.2

Related parts for 28125

28125 Summary of contents

Page 1

Robotics with the Boe-Bot Student Guide VERSION 2.2 ...

Page 2

... Parallax products, and the user may recover from the student only the cost of duplication. This text is available in printed format from Parallax Inc. Because we print the text in volume, the consumer price is often less than typical retail duplication charges. ...

Page 3

... Parallax products. Parallax Inc. is also not responsible for any personal damage, including that to life and health, resulting from use of any of our products. You take full responsibility for your BASIC Stamp application, no matter how life-threatening it may be ...

Page 4

...

Page 5

Preface.........................................................................................................................5 Foreword.........................................................................................................................5 Audience .........................................................................................................................6 Support and Discussion Groups .....................................................................................6 The Stamps in Class Curriculum ....................................................................................7 Foreign Translations .......................................................................................................8 Special Contributors .......................................................................................................8 Chapter 1: Your Boe-Bot’s Brain ..............................................................................1 Hardware and Software ..................................................................................................2 Activity #1: Getting the Software.....................................................................................4 Activity #2: Installing the ...

Page 6

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 .......................................................................................................165 Activity #1: Building and Testing the Whiskers ...........................................................166 Activity #2: Field Testing ...

Page 7

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

Page 8

...

Page 9

... Its name comes from the Board of Education mounted on its wheeled chassis. An example of a Boe-Bot with an infrared obstacle detection circuit built on the Board of Education solderless prototyping area is shown in Figure P-1. The mechanical principles, example ® carrier board that is Figure P-1 Parallax Inc’s Boe-Bot™ Autonomous Wheeled Robot. ...

Page 10

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

Page 11

... Student Guides is highly recommended. “Applied Sensors”, Student Guide, Version 1.3, Parallax Inc., 2003 “Basic Analog and Digital”, Student Guide, Version 1.3, Parallax Inc., 2004 “Process Control”, Student Guide, Version 2.0, Parallax Inc., 2004 More Robotics Kits: ...

Page 12

... 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., 2004 “ ...

Page 13

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

Page 14

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

Page 15

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 microcontroller brain are shown in Figure 1-1. The BASIC Stamp ...

Page 16

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

Page 17

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

Page 18

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

Page 19

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

Page 20

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

Page 21

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

Page 22

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. Other free downloads at the Parallax web site include: • This text and ...

Page 23

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. √ Click the + next to the BASIC ...

Page 24

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

Page 25

If you located the software on the Parallax CD, click the Install button shown in Figure 1-13. √ When the BASIC Stamp Editor…InstallShield Wizard window opens, click the Next button shown in Figure 1-14. Figure 1-12 Download Complete Window ...

Page 26

Select Typical for your setup type as shown in Figure 1-15. √ Click the Next button. √ When the InstallShield Wizard tells you it is “Ready to Install the Program”, click the Install button shown in Figure 1-16. √ ...

Page 27

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 can be programmed. After making these ...

Page 28

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

Page 29

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. Required Hardware (1) Strip of four rubber feet (1) Battery pack (1) BASIC Stamp ...

Page 30

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

Page 31

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

Page 32

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

Page 33

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

Page 34

Power Reset ® BASIC Stamp HomeWork Board Figure 1-30 shows the BASIC Stamp HomeWork Board connected to its battery power supply and serial programming cable. The green Pwr light does not come on when you connect the battery. It ...

Page 35

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. The Windows Start Menu can also be used to run the BASIC ...

Page 36

To make sure your BASIC Stamp is communicating with your computer, click the Run menu, then select Identify. An Identification window similar to the one shown in Figure 1-33 will appear. The example in the figure shows that a ...

Page 37

Your First Program The example programs that you will type into the BASIC Stamp Editor and download to the BASIC Stamp will always be shown with a gray background. Here is an example: Example Program: HelloBoeBot.bs2 ' Robotics with the ...

Page 38

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

Page 39

HelloBoeBot.bs2 Entered into the BASIC Stamp Editor Figure 1-37 √ Save your work by clicking File and selecting Save , (shown in Figure 1-38). √ Enter the name HelloBoeBot.bs2 into the File name field near the bottom of the Save ...

Page 40

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

Page 41

Press and release the Reset button. Did you see a second “Hello…” message appear in the Debug Terminal? The BASIC Stamp Editor has shortcuts for most common tasks. For example, to run a program, you can press the ‘Ctrl’ ...

Page 42

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

Page 43

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

Page 44

Your Debug Terminal should now resemble Figure 1-44. Where did my Debug Terminal go? Sometimes the Debug Terminal gets hidden behind the BASIC Stamp Editor window. You can bring it back to the front by using the Run menu as ...

Page 45

Using the BASIC Stamp Editor’s Help √ In the BASIC Stamp Editor, Click Help , then select Index as shown in Figure 1- 46. √ Type into the field labeled Type in the keyword to find : (shown in Figure ...

Page 46

Click the Search tab, and run a search for the word √ Repeat this process for the Getting and Using the BASIC Stamp Manual The BASIC Stamp Manual is available for free download from the Parallax web site, and ...

Page 47

Briefly look over the BASIC Stamp Manual explanation of the √ Count the number of example programs in the there? Your Turn √ Use the BASIC Stamp Manual index to look up the √ Look up the command in ...

Page 48

Example Program – AsciiName.bs2 √ Enter and run AsciiName.bs2. Remember to use the toolbar icons to place Compiler Directives into your programs! Use the diagonal green electronic chip icon '{$STAMP BS2} - Use the gear icon labeled 2.5. '{$PBASIC 2.5} ...

Page 49

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

Page 50

P10 P11 Sout Vin P13 P12 Sin Vss P14 P15 ATN Rst Vin Vdd Vss Vdd X1 P0 P15 P1 P14 U1 P2 P13 P3 P12 P4 P11 Reset P5 P10 www.stampsinclass.com Do ...

Page 51

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

Page 52

Modify these two commands so that the answers appear on different lines in the Debug Terminal. DEBUG DEC DEBUG DEC Projects 1. Write a program that uses a problem: ...

Page 53

Solutions Q1. The BASIC Stamp 2 microcontroller module. Q2. Binary numbers. Q3. The Debug Terminal. Q4. and . DEBUG END E1. – This command is used to send a message from the BASIC Stamp to the DEBUG PC. The information ...

Page 54

P3. The last three lines can be deleted. An additional DEBUG "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 ...

Page 55

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

Page 56

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

Page 57

Example Program: TimedMessages.bs2 There are lots of different ways to use the to delay between printing messages that tell you how much time has elapsed. The PAUSE program should wait one second before it sends the “One second elapsed…” message ...

Page 58

Try changing the PAUSE Duration 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 ...

Page 59

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

Page 60

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

Page 61

LED When you start building your circuit, make sure to check it against the schematic symbol and part drawing. If you look closely at the LED’s plastic case in the part drawing, it’s mostly round, but there is a small ...

Page 62

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

Page 63

Figure 2-5 shows what you will program the BASIC Stamp the LED circuit. Imagine that you have a 5 volt (5 V) battery. Although battery is not common, the Board of Education has a ...

Page 64

Programs that Control the LED Test Circuits The and commands can be used to make the BASIC Stamp connect an LED HIGH LOW alternately to Vdd and Vss. The the BASIC Stamp which I/O pin to connect to Vdd or ...

Page 65

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

Page 66

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

Page 67

Your Turn – Blink the Other LED Blinking the other LED (connected to P12 simple matter of changing the argument in the and commands and re-running the program. HIGH LOW √ Modify the program so that the commands ...

Page 68

HIGH command’s argument (remember, that’s 1/1000 of a second Duration time. There’s ...

Page 69

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

Page 70

P13 0.13 s P12 The voltages (Vdd and Vss) in this timing diagram are not labeled. With the BASIC Stamp understood that the high signal (Vdd) and the low signal ...

Page 71

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

Page 72

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

Page 73

Examine the labeling on your carrier board and figure out whether you have a BASIC Stamp HomeWork Board Rev Board of Education Rev (916) 624-8333 P0 www.parallaxinc.com Rev B ...

Page 74

When you are done 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 ...

Page 75

Vdd Red Black X4 X5 Vin Select Vin if you are using the battery pack that comes with the Boe-Bot kits. All examples and instructions in this book will use the battery pack. Figure 2-13 shows ...

Page 76

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. P13 Ω 470 P12 470 Ω LED Vss Vss Disconnecting Power – ...

Page 77

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

Page 78

Vbp White P13 Red Black Vss Vbp White P12 Red Black 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 ...

Page 79

Solid Black Black wire with Wire (916) 624-8333 white stripe Rev B www.parallaxinc.com www.stampsinclass.com Vdd Vin Vss X3 P15 P14 P13 P13 Vbp P12 Vss P11 Vbp P10 P12 P9 P8 Port connections Your setup will then resemble Figure 2-19. ...

Page 80

P13 470 Ω P12 470 Ω LED Vss Vss √ 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. Disconnecting Power – Special ...

Page 81

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

Page 82

You can also figure out what the argument has you know how long you want the pulse to last. Just divide 2 µs into the time you want the pulse to last. With ...

Page 83

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

Page 84

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

Page 85

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

Page 86

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 example of an operator. You ...

Page 87

VAR These commands are examples of initializing variables to values that you determine. After these two commands are executed, store 2000. value = 500 anotherValue = 2000 These commands help you see what each variable stores after you initialize ...

Page 88

DEBUG "value = ", SDEC value Display values again √ Run the modified program and verify that Counting and Controlling Repetitions The most convenient way to control the number of times a piece ...

Page 89

FOR myCounter = 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 √ Modify the loop ...

Page 90

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

Page 91

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

Page 92

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

Page 93

DEBUG "Program Running!" DO PULSOUT 12, 850 PAUSE 20 LOOP Your Turn – P13Clockwise.bs2 √ Modify the command’s PULSOUT connected to P13 turn counterclockwise. Example Program: ServosP13CcwP12Cw.bs2 You can use two commands to make both servos turn at the same ...

Page 94

Your Turn – Adjusting the Speed and Direction There are four different combinations of 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 ...

Page 95

Table 2-1: PULSOUT Duration Combinations Durations Description P13 P12 Full speed, P13 servo 850 650 counterclockwise, P12 servo clockwise. 650 850 850 850 650 650 750 850 650 750 Both servos should stay still because of the centering 750 750 ...

Page 96

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

Page 97

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

Page 98

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

Page 99

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

Page 100

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 command makes the program stop for brief or long periods of PAUSE time, depending ...

Page 101

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 command that makes the BASIC Stamp do nothing for 10 PAUSE seconds. 2. Modify this ...

Page 102

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

Page 103

PULSOUT 12, 650 PULSOUT 14, 650 PAUSE 20 LOOP 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 ...

Page 104

DEBUG "Program Running!" counter VAR Word FOR counter = 1 TO 120 PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT FOR counter = 1 TO 124 PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 NEXT FOR counter = 1 ...

Page 105

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

Page 106

Mounting the Topside Hardware √ Start by gathering this list of parts. √ Then, follow the accompanying instructions. Parts List: See Figure 3-2. (1) Boe-Bot chassis (4) 1″ Standoffs (4) Pan head screws, 1/4″ 4-40 (1) Rubber grommet, 13/32″ Figure ...

Page 107

Boe-Bot Parts - The parts for the Boe-Bot are either included in the Boe-Bot full kit combination of the Board of Education Full Kit and Robotics Parts Kit. See Appendix E: Boe-Bot Parts Lists for more information. ...

Page 108

Phillips Control screw horn 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 ...

Page 109

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

Page 110

For use with the Board of Education 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 ...

Page 111

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 Instructions: ...

Page 112

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

Page 113

With the Board of Education Rev C 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 ...

Page 114

White White Red Red Black Black Vdd Red Black Board of Education Rev C Figure 3-11 shows the Boe-Bot chassis with their respective boards attached. √ Set the board on the four standoffs ...

Page 115

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. With Board of Education Rev C ACTIVITY ...

Page 116

Left Back 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, ...

Page 117

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

Page 118

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

Page 119

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 servo connected to P13 instead of the servo connected ...

Page 120

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

Page 121

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

Page 122

Build the circuit shown in Figure 3-17 and Figure 3-18 Servos Vdd Red Black X4 X5 Vdd Vin Vss X3 P15 P14 P13 P12 P11 P10 ...

Page 123

Programming the Start/Reset Indicator The next example program tests the piezospeaker. It uses the precisely timed high/low signals to a speaker. Here is the FREQOUT Pin, Duration, Freq1 {,Freq2} Here’s an example of a command that’s used in the next ...

Page 124

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

Page 125

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

Page 126

Using the DEBUGIN Command By now, you are probably familiar with the 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 ...

Page 127

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

Page 128

FOR counter = 1 TO 244 PULSOUT 12, pulseWidth PULSOUT 13, pulseWidthComp PAUSE 20 NEXT LOOP How TestServoSpeed.bs2 Works Three variables are declared, counter and commands, and DEBUGIN PULSOUT used in a second command. PULSOUT counter VAR pulseWidth VAR pulseWidthComp ...

Page 129

If you enter a pulse width of 700, examples. They will all add up to 1500. pulseWidthComp = 1500 - pulseWidth A loop that runs for 6 seconds sends pulses to the right (P12) servo. The FOR…NEXT value ...

Page 130

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

Page 131

Since the servo turns for 6 seconds, you can multiply this value 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. √ ...

Page 132

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

Page 133

Exercises 1. Write a command that makes a tone that sounds different from the reset FREQOUT detect tone to signify the end of a program. 2. Write a command that makes a tone (different from beginning or FREQOUT ending tones) ...

Page 134

Solutions Q1. Symptoms include erratic behavior such as going in unexpected directions or doing a confused dance. Q2. A command at the beginning of all Boe-Bot programs causes the FREQOUT piezospeaker to play a tone. This tone will therefore occur ...

Page 135

FREQOUT 4, 2000, 3000 FOR counter = 1 TO 122 PULSOUT 12, 650 PAUSE 20 NEXT FOR counter = PULSOUT 12, 750 PAUSE 20 NEXT FOR counter = 1 TO 122 PULSOUT 12, 850 PAUSE 20 NEXT ...

Page 136

PULSOUT 13, ltPulseWidth PULSOUT 12, rtPulseWidth PAUSE 20 NEXT LOOP Note: This project is best tested with the Boe-Bot's wheels propped up. ' Left servo motion ' Right servo motion ...

Page 137

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

Page 138

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

Page 139

EndValue 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, ...

Page 140

This loop sends 122 sets of pulses to the servos, one each to P13 and P12, FOR…NEXT pausing for 20 ms after each set and then returning to the top of the loop. FOR counter = 1 TO 122 PULSOUT ...

Page 141

Moving Backward, Rotating, and Pivoting All it takes to get other motions out of your Boe-Bot are different combinations of the arguments. For example, these two PULSOUT Duration to make your Boe-Bot go backwards: PULSOUT 13, 650 PULSOUT 12, 850 ...

Page 142

PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT PAUSE 200 FOR counter = PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 NEXT PAUSE 200 FOR counter = PULSOUT 13, 850 PULSOUT 12, 850 ...

Page 143

PULSOUT 13, 850 PULSOUT 12, 750 These are the commands for pivoting backwards and to the right. PULSOUT PULSOUT 13, 650 PULSOUT 12, 750 Finally, these are the commands for pivoting backwards and to the left. PULSOUT PULSOUT 13, 750 ...

Page 144

Change the of the EndValue ' 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 FOR counter ...

Page 145

It will probably take several tries to get the right value. Let’s say that your first guess is that will do the trick, but it turns out not to be enough because the Boe- PULSOUT 12,663 Bot is still turning ...

Page 146

PULSOUT 12, 650 PAUSE 20 NEXT Let’s say that the Boe-Bot turns just a bit more than 90° (1 full circle). Try , or maybe even counter = enough, increase the run time of the ...

Page 147

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

Page 148

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. Figure 4-3: Measuring Boe-Bot Distance ...

Page 149

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

Page 150

This is the number you will have to use for your pulses = × p ulses . ...

Page 151

Boe Bot dis tan ce = × p ulses − Boe Bot speed √ 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 ...

Page 152

VAR FOR pulseCount = 1 TO 100 PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 - pulseCount PAUSE 20 NEXT Recall from Chapter 2, Activity #5 that higher number to a lower number. You can use this to ramp ...

Page 153

NEXT ' Continue forward for 75 pulses. FOR pulseCount = PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT ' Ramp down from going forward to a full stop. FOR pulseCount = 100 TO 1 PULSOUT 13, ...

Page 154

Ramp up right rotate. FOR pulseCount = PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 + pulseCount PAUSE 20 NEXT ' Ramp down right rotate FOR pulseCount = PULSOUT 13, 750 + pulseCount ...

Page 155

Figure 4-5 shows part of a PBASIC program that contains a subroutine call and a subroutine. The subroutine call is the subroutine is everything from the Here’s how it works. When the program gets to the it looks for the ...

Page 156

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

Page 157

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

Page 158

PAUSE 200 RETURN Backward: FOR counter = PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT RETURN You should recognize the pattern of movement your Boe-Bot makes the same one made by ForwardLeftRightBackward.bs2. Clearly there ...

Page 159

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 VAR Word pulseLeft VAR Word pulseRight VAR Word pulseCount ...

Page 160

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

Page 161

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

Page 162

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. repeating long ...

Page 163

In this case, it causes the (condition) “Q” is read from EEPROM. A ... ... statement can be used to select a variable and evaluate it SELECT CASE ENDSELECT on a case-by-case basis and ...

Page 164

FREQOUT 4, 2000, 3000 ' -----[ Main Routine ]------------------------------------------------------- DO UNTIL (instruction = "Q") READ address, instruction address = address + 1 SELECT instruction CASE "F": GOSUB Forward CASE "B": GOSUB Backward CASE "L": GOSUB Left_Turn CASE "R": GOSUB Right_Turn ...

Page 165

Subroutine – Right_Turn ]-------------------------------------------- Right_Turn: FOR pulseCount = PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT RETURN Did your Boe-Bot drive in a rectangle, going forward on the first two sides and backwards on ...

Page 166

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 directive. This program stored a total of 10 characters in EEPROM. ...

Page 167

Example Program – EepromNavigationWithWordValues.bs2 This next example program looks complicated at first, but 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 ...

Page 168

LOOP UNTIL (pulseCount = 0) The first time through the loop, retrieve a value of 64 from the first address at the variable. The second pulseCount address specified by the Pulses_Left The third command retrieves a value of 650 from ...

Page 169

VAR Word ' -----[ EEPROM Data ]-------------------------------------------------------- ' addressOffset 0 Pulses_Count DATA Word 64, Pulses_Left DATA Word 850, Word 650, Word 850, Word 650 Pulses_Right DATA Word 650, Word 650, Word 850, Word 850 ' -----[ Initialization ]----------------------------------------------------- FREQOUT ...

Page 170

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

Page 171

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 commands’ arguments. How far the maneuver goes is determined PULSOUT ...

Page 172

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 directive can store values in ...

Page 173

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

Page 174

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

Page 175

PULSOUT 12, 850 PAUSE 20 NEXT FOR counter = PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT FOR counter = PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT E3. FOR counter = ...

Page 176

P1. P13 P12 Description 850 650 Full Speed P13 CCW, P12 CW 650 850 Full Speed P13 CW, P12 CCW 850 850 Full Speed P13 CCW, P12 CCW 650 650 Full Speed P13 CW, P12 CW 750 850 P13 Stopped ...

Page 177

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

Page 178

...

Page 179

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

Page 180

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

Page 181

Parts List: (2) Whisker wires 7 (2) / ″ pan head 4-40 8 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) Building ...

Page 182

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

Page 183

Figure 5-5: Whisker Wiring Diagram for the Board of Education To Servos Vdd Red Black X4 X5 Vdd Vss Vin X3 P15 P14 P13 P12 P11 P10 ...

Page 184

Figure 5-6: Whisker Wiring Diagram for the HomeWork Board To Servos (916) 624-8333 Rev B www.parallax.com www.stampsinclass.com Vdd Vin Vss X3 P15 P14 P13 P12 P11 P10 HomeWork ...

Page 185

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, single- pole, single-throw switch. The reason the whiskers are connected to ...

Page 186

How do you get the BASIC Stamp to tell you whether it’s reading Because the circuit is connected to P7, this value will appear in a variable named called an input register. Input ...

Page 187

DEBUG "WHISKER STATES", CR, "Left Right", CR, "------ ------" DO DEBUG CRSRXY "P5 = ", BIN1 IN5, " ", BIN1 IN7 PAUSE 50 LOOP √ Note the values displayed in the Debug Terminal; ...

Page 188

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

Page 189

Figure 5-10: Whisker Plus LED Wiring Diagram for the Board of Education To Servos Vdd Red Black X4 X5 Vdd Vss Vin X3 P15 P14 P13 P12 P11 P10 ...

Page 190

Figure 5-11: Whisker Plus LED Wiring Diagram for the HomeWork Board To Servos (916) 624-8333 Rev B www.parallax.com www.stampsinclass.com Vdd Vin Vss X3 P15 P14 P13 P12 P11 P10 ...

Page 191

Programming the LED Whisker Testing Circuits √ Reconnect power to your board. √ Save TestWhiskers.bs2 as TestWhiskersWithLeds.bs2. √ Insert these two ... IF THEN commands. IF (IN7 = 0) THEN HIGH 1 ELSE LOW 1 ENDIF IF (IN5 = 0) ...

Page 192

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

Page 193

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

Page 194

PAUSE 20 NEXT RETURN Turn_Right: FOR pulseCount = PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT RETURN Back_Up: FOR pulseCount = PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT RETURN How Roaming ...

Page 195

The , , and Turn_Left Turn_Right the subroutine has a twist. It just sends one pulse, then returns. This is Forward_Pulse really important, because it means the Boe-Bot can check its whiskers between each forward pulse. That means the Boe-Bot ...

Page 196

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 statement in RoamingWithWhiskers.bs2 to make the Boe- IF…THEN Bot broadcast its maneuver using the LED indicators. ...

Page 197

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 alternate whisker contacts in the next program. Example Program: EscapingCorners.bs2 This program will ...

Page 198

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

Page 199

PULSOUT 12, 650 PAUSE 20 NEXT RETURN Turn_Right: FOR pulseCount = PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT RETURN Back_Up: FOR pulseCount = PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT ...

Page 200

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

Related keywords