background image

 

 

 

 28

 

6.

 

Identify the gearbox housing, as shown in Figure 4.5.  

 

 

Figure 4.5 

7.

 

Twist the gearbox housing parts apart, so they match Figure 4.6. Notice which housing parts are 
considered “left” and “right.” 

 

 

 

 

 

Figure 4.6

 

Right 
Side 

Left 

Side 

Содержание Pi-Bot v2.00

Страница 1: ...V2 0 User Manual A uniquely designed complete robot kit to get you started in building and programming ...

Страница 2: ... to C Programming 15 The Basic Arduino Program 15 Constants and Variables 16 Control Statements 19 Chapter 4 Assembling Your Gearbox 25 Identification of the Gearbox Parts 25 Assembly of the Gearbox 30 Chapter 5 Building Your Basic Pi Bot 43 Mounting the Gearbox 44 Installing Your Switch 45 Setting Up Your Caster Wheel 47 Assembling Your Tires 49 Mounting the STEM Board Microcontroller 51 Setting ...

Страница 3: ...s well as high schools and colleges worldwide What is the Pi Bot The Pi Bot kit is a multidisciplinary robotics experience intended for high school and college aged students and above It includes an introduction to mechanical electrical and computer science engineering What makes Version 2 0 special We have upgraded our Pi Bot Some of our main updates includes Extra wires Streamlined choice of fas...

Страница 4: ... Bot from start to finish Make sure to take your time and read through each lesson carefully Pictures are included with every step for clarity This manual is for the Version 2 0 Pi Bot which has minor changes from the Version 1 5 Accompanying video tutorials can be found at http www stemcenterusa com pi bot tutorials Before starting the assembly of your Pi Bot please check to make sure all necessa...

Страница 5: ...crete values which are zero 0 or one 1 The notation based on these two numbers is known as the Binary system Electricity The movement of electrons can be described by the analogy below The flow of water from one tank to another is a good analogy for an electrical circuit and the mathematical relationship between voltage resistance and current See Figure 1 1 o Force The difference in water levels v...

Страница 6: ...it Resistor converts electrical energy into heat Resistance is measured in units of ohms Ω and named after George Ohm whose law Ohm s Law defines the fundamental relationship between Voltage measured in Volts V Current measured in amperes A Resistance measured in ohms Ω A resistor s rating can be identified by its color bands Refer to Figure 1 2 below Figure 1 2 Courtesy of DigiKey ...

Страница 7: ...Current I Ampere Voltage V Volt Resistance R Ohm Circuit Symbols Below are basic circuit symbols that you should familiarize yourself with as shown in Figure 1 4 Figure 1 4 Be able to draw a circuit diagram for each circuit you create using the above symbols Figure 1 3 ...

Страница 8: ...al contacts Each contact in a row is electronically the same See Figure 1 5 below for various breadboard sizes Figure 1 5 Each row is electrically the same Figure 1 6 shows the back disassembled view of the breadboard where you can clearly see the rows This means the voltage at any point along each row is the same Figure 1 6 Lighting up an LED ...

Страница 9: ...the power supply to drop the voltage A simple LED circuit is shown in Figure 1 7 Figure 1 7 Building a Basic Circuit The same circuit diagram is shown in Figure 1 8 but with the actual components Compare this to the symbols in Figure 1 7 Figure 1 8 Understanding circuits is extremely important when wiring your Pi Bot Wire your own LED circuit like the one in Figure 1 7 and Figure 1 8 You will have...

Страница 10: ... you have a basic understanding of the C programming language as described in Lesson 3 Introduction to C Programming After completing this lesson you should be familiar with the digital I O ports the analog digital converter ADC and the pulse width modulator PWM The Arduino Board 1 The STEM Board microprocessor and its features are shown in Figure 2 1 The functionality of your STEM Board microproc...

Страница 11: ...thing looks good enter and run the program led_01 ino as shown in Figure 2 2 The LED on your STEM Board microprocessor for channel 13 as shown in Figure 2 2 should be flashing Figure 2 2 Program led_01 ino 3 As before the program consists of two separate functions setup and loop a Note In the setup function digital pin 13 is defined to an output pin Again the loop function is the main program The ...

Страница 12: ...predefined constants to make our programs easier to read For example pin 13 represents the board LED for our robot We can make a global definition that Board_LED is 13 as shown in Figure 2 3 3 Beginner programmers are hesitant to use long descriptive variables Typing Board_LED is more time consuming than typing 13 but program led_02 ino is much easier to understand than led_01 ino They do the exac...

Страница 13: ...ies with the LED as shown in Figure 2 4 3 Ohm s Law is used to determine the current flow through the circuits I 𝑉 𝑅 or V IR or R 𝑉 𝐼 V the voltage across the component I the current flowing through the component R the resistance of the circuit 4 In circuitry ohms is a unit of electrical resistance and is represented by the symbol Ω 5 In our case the LED will be connected on a digital I O pin whic...

Страница 14: ...iates from breadboards as protoboards typically require soldering while breadboard do not 2 A diagram of the breadboard layout is shown in Figure 2 5 Figure 2 5 3 Your mini breadboard has 170 connections arranged in groups of give as shown in Figure 2 5 Any five connections within each group are electrically joined 4 To connect the circuit shown in Figure 2 4 to the STEM Board see Figure 2 6 Figur...

Страница 15: ...the communication speed of the serial port on the Arduino to 9600 baud This will allow the Arduino to communicate with the serial monitor on the PC The after the name setup is the parameter list passed to the function Since there are no parameters being passed to the function the list is empty However the after the name is still required Following the function name is a at the opening and a matchi...

Страница 16: ...rocessor will not see it during the wait time The void loop is the main function and it must be in every Arduino code that you write It is the entry point for your code The loop function is executed continuously that is when the program reaches the end of the loop function denoted by the last the Arduino goes back to the top the of the loop function and begins execution again Exercise 1 After you ...

Страница 17: ...nt var2 DEC Serial print var3 Serial print var3 DEC Serial print var4 Serial print var4 DEC Serial print var5 Serial print var5 DEC Serial print var6 Serial println var6 DEC var3 var4 var5 var6 true Serial print var1 Serial print var1 DEC Serial print var2 Serial print var2 DEC Serial print var3 Serial print var3 DEC Serial print var4 Serial print var4 DEC Serial print var5 Serial print var5 DEC S...

Страница 18: ...are executed The purpose of the program is simply to print the values of each variable then increment the variables using the command and print the values again 9 Repeat the loop every 1 second Make sure that you open the serial monitor after the program is completely downloaded As you can see the constants var1 and var2 do not change 10 For fun try to change their values in the code and see what ...

Страница 19: ...r statement c do while statement 2 The form of the if statement is as follows 3 Note that both the else if and else statements are optional if logical test statements are executed if logical true else if logical statements are executed if the first logical is false and the second logical is true else statements are executed if none of the above logical are true This is the default condition ...

Страница 20: ...e values are equal and false if the values are not equal 6 Take a few minutes to change the value of var1 in the example to see what happens to the value of var2 Does the output make sense 7 The logical operators are a test if equal b test if not equal c test if less than d test if greater than e test if less than or equal to f test if greater than or equal to void setup Serial begin 9600 void loo...

Страница 21: ...ments Does it make sense void setup Serial begin 9600 void loop int var1 var1 3 Serial print var1 Serial print var1 DEC if var1 1 Serial println is equal to 1 else if var1 1 Serial println is less than 1 else if var1 4 Serial println is less than or equal to 4 else Serial println unknown delay 1000 Figure 3 4 Program Fourth ino ...

Страница 22: ...the for statement is given by 3 Let s jump into the example shown in Figure 3 5 Figure 3 5 Program Fifth ino 4 In the program Fifth pde the for statement is used to loop a set of statements ten times You should notice several items a The variable var1 is typed and initialized in the int var1 0 statement b The variable count is typed and initialized to 0 in the for statement hence its scope is limi...

Страница 23: ...if the number is less than 5 equal to 5 or greater than 5 Figure 3 6 Program Sixth ino Exercise 3 1 Write a program based on the Sixth pde to compute and print the number from 0 to 10 together with the factorial of the number The output of the program should look like this The factorial of 0 is 1 The factorial of 1 is 1 The factorial of 2 is 2 The factorial of 3 is 6 etc void setup Serial begin 96...

Страница 24: ...dvanced Exercise 1 Modify the program to count from 5 to 5 For the negative numbers the program should state the factorial could be computed Congratulations on completing your Introduction to C programming ...

Страница 25: ...ur gearbox which will power your Pi Bot The Tamiya Double Gearbox comes with various gearbox options We have identified option C as the most efficient gearbox for the Pi Bot Identification of the Gearbox Parts 1 Your Pi Bot comes in a specially designed package Locate and open the box for the Double Gearbox kit You should have three bags of parts and a gearbox housing as shown in Figure 4 1 Figure...

Страница 26: ...oth shafts approximately 28mm in length Two 2 brass gear hubs 7mm in length Two 2 4mm spacers One 1 hex wrench One 1 tube of grease One 1 package containing o Six 6 self tapping screws approximately 17mm in length o Two 2 tapping screws approximately 8mm in length o Two 2 screws and nuts o Nine 9 brass eyelets o Three 3 grub screws set screws o Two 2 motor purple pinion gears ...

Страница 27: ...ee 3 blue 2 step gears One 1 yellow final gear Two 1 yellow long spacers and two short spacers spaces are attached as seen in the top yellow part of Figure 1 3 4 Use Figure 4 4 to help you recognize the different types of gears Figure 4 4 5 Open the second bag of gears and verify its contents The bags should be identical ...

Страница 28: ...ify the gearbox housing as shown in Figure 4 5 Figure 4 5 7 Twist the gearbox housing parts apart so they match Figure 4 6 Notice which housing parts are considered left and right Figure 4 6 Right Side Left Side ...

Страница 29: ...29 8 Organize the parts for ease of assembly It is recommend to have a large open table space to avoid losing any small parts Identify that all parts are present as shown in Figure 4 7 Figure 4 7 ...

Страница 30: ...ures 4 9 and 4 10 There should be 3mm of exposed shaft from the flanged side of each bushing Once you have made both pieces set them aside temporarily Figure 4 9 Figure 4 10 3 Locate the right side of the housing 4 Place a gear hub on each of the hex shafts approximately 18mm from the end and secure with a grub screw Do no over tighten the grub screw this will be adjusted later on See Figures 4 11...

Страница 31: ...d to seal the tube later on 6 Place two eyelets into the inside center holes of the right side of the housing as shown in Figure 4 13 Figure 4 13 7 Carefully apply a small amount of grease to the hex shaft next to both sides of the gear hub as shown in Figure 4 14 Figure 4 14 ...

Страница 32: ...er end of the hex shaft into the rear eyelet as shown in Figure 4 15 Figure 4 15 9 Locate the smooth shaft assembly which was built in step 1 and apply a small amount of grease to the 3mm end as shown in Figure 4 16 Figure 4 16 ...

Страница 33: ...g eyelet on the gearbox housing as shown in Figure 4 17 Figure 4 17 11 Insert a yellow final gear onto the hex shaft such that the hub of the gear enclosed the gear hub Look carefully at Figure 4 18 and identify how the gear hub is enclosed Figure 4 18 ...

Страница 34: ... Do not apply grease to the outside portion of the hex shaft This is where the wheel will be attached b You may need to squeeze the tube to get the grease out from the bottom Figure 4 19 13 Place a blue 2 step gear onto the smooth shaft such that the small diameter gear mates with the yellow final gear as shown in Figure 4 20 Figure 4 20 ...

Страница 35: ...tes with the larger diameter gear from the first blue 2 step gear as shown in Figure 4 21 Figure 4 21 15 Place the yellow crown gear on the smooth shaft such that the small diameter gear mates with the larger diameter gear of the second blue 2 step gear as shown in Figure 4 22 Figure 4 22 ...

Страница 36: ...3 17 Take 2 eyelets and place one on the smooth shaft and one on the hex shaft as shown in Figure 4 24 Figure 4 24 18 Holding the gear assembly carefully so that the shafts are vertical attach the center section of the gearbox housing to the gear assembly as shown in Figures 4 25 and 4 26 ...

Страница 37: ...elf tapping screws to hold the assembly together as shown in Figure 4 27 The screws should be tightened and snug a Note There are 4 holes but only 3 screws inserted The front lower hole is for alignment only Inserting a screw into this location will damage the housing b Caution Do no over tighten the screws Figure 4 27 20 Congrats the right side of your gear housing is now finished 21 Repeat steps...

Страница 38: ...orrectly If so then locate and insert three 17mm self tapping screws to hold the assembly together as shown in Figure 4 29 The screws should be tightened and snug a Caution If the housing sides are not meshing together do not force them Follow step 23 to fix the housing Figure 4 29 ...

Страница 39: ... this will damage the housing Instead while holding the two parts together use the hex wrench to loosen the left side Grub screw See Figures 4 31 and 4 32 This will allow the two parts to mate properly Continue to hold the two housing parts together then tighten the Grub screws Figure 4 30 Figure 4 31 Figure 4 32 ...

Страница 40: ... Figure 4 33 25 Attach a purple pinion gear on to each of the two motor shafts as shown in Figure 4 34 Do not push on the motor body Support the opposite end of the shaft as shown in Figure 4 35 Your motors should look like Figure 4 36 Figure 4 34 Figure 4 35 ...

Страница 41: ...ing sure that the electrical contacts face outward See Figures 4 37 and 4 38 a Note Wires have already been soldered to your motors Place the motors so that the blues and whites are aligned as shown in Figure 4 38 Notice how the blue wires are on the top Figure 4 37 Figure 4 38 ...

Страница 42: ...4 40 28 Lastly apply grease to all of the gears as shown in Figure 4 41 Figure 4 41 Note You will have some leftover parts after your assembly This is okay Keep these spare parts in a bag for future projects Congratulations your gearbox assembly is complete You may test your completed gearbox with a 3 volt power source ...

Страница 43: ... by the countersink holes You can also identify the top side by the additional switch hole on the right side of the chassis Orient your chassis as show below with countersunk holes facing up Figure 5 1 2 Mount the breadboard to the lower left section of the body as shown in Figure 5 2 The breadboard should be approximated 3mm from the edge a Note The breadboard in the figure is white Your breadboa...

Страница 44: ... gearbox will be mounted to the underside of the chassis as shown in Figure 5 3 Notice how the motors point to the rear of the body Figure 5 3 5 Now mount the gearbox by using the two lower center countersink holes as shown in Figure 5 4 a Note Use your pliers to hold the nut as you tighten your screw The head of your screw should fit snugly into the countersink hole Figure 5 4 ...

Страница 45: ...the OFF position This is when the lever is pointing away from the side with empty terminal as shown below Figure 5 5 7 Install the switch such that the toggle is on the top of the body and the wires are on the underside of the chassis as shown in Figure 5 6 One nut and the flat washer should be installed on the top of the switch One nut and the locking washer should be on the underside of the chas...

Страница 46: ... terminal blocks When mounting the screws the eyelets of the switch wires should be captive as shown in Figure 5 7 Figure 5 7 9 Figure 5 8 depicts the screws pointing up through the top side of your Pi Bot s body This will later be used to power the gearbox during testing Figure 5 8 ...

Страница 47: ...from the clear component as shown in Figure 5 10 Figure 5 9 Figure 5 10 11 Assemble the front caster using the provided screws and nuts as shown in Figure 5 11 Notice we use the large spacer to make the Pi Bot level Figure 5 11 12 Locate two 2 3 4 inch nylon spacers and four 4 4 40 x 3 8 screws and assemble them as shown in Figure 5 12 ...

Страница 48: ...s through the hole above the caster Figure 5 13 14 Now we will install the 1 standoffs for the front line sensor Locate the two remaining countersunk holes on your Pi Bot chassis 15 Mount two 1 inch standoff spacers using two 2 flat head 4 40 x 3 8 screws as shown in Figure 5 14 Do not mount the line sensor at this time ...

Страница 49: ...e set as displayed in Figure 5 15 Figure 5 15 17 Assemble the wheels as shown in Figure 5 16 a The wheel hubs should be attached to maximize the wheel base In other words insert the screws into the deeper side of each wheel and the nuts into the more shallow side ...

Страница 50: ...https www youtube com watch v mWdVtPwpJ8M Figure 5 16 18 The Pi Bot with correctly installed wheels are depicted in Figures 5 17 a Note Do no force the wheels all the way in Keep a reasonable clearance between the tires and the body Figure 5 17 ...

Страница 51: ...18 a Four 4 1 nylon b Clear plastic microprocessor mounting board c Four 4 4 40 x 1 2 screws d Four 4 4 40 x 3 8 screws Figure 5 18 20 Attach four 4 1 2 nylon standoffs to the bottom of the microprocessor mounting board using four 4 4 40 x 3 8 screws as shown in Figure 5 19 a Note You will need to peel off the brown layer from the microprocessor mounting board Figure 5 19 ...

Страница 52: ...Figures 5 20 and 5 21 a Note There is only one configuration that allows the STEM Board to fit onto the mounting plate Figure 5 20 Figure 5 21 22 Locate the clear battery pack rails there should be two wider ones and two thinner ones Next get four 4 4 40 x 1 2 screws See Figure 5 22 a Note You will have to peel off the brown layer from the rails ...

Страница 53: ...icker rail is on top This creates a notch for the battery pack slider Pay careful attention to Figure 5 23 to see how the rails are oriented Use the 1 2 screws to mount the entire STEM Board and rails together a Note You will need to insert the screws from the underside of the chassis Figure 5 23 ...

Страница 54: ...in Step 22 Locate the following items as shown in Figure 5 24 a The three AA battery pack carrier b Clear plastic battery slide c One Velcro set Figure 5 24 25 Peel off the brown layer from the plastic battery slide Then place a piece of Velcro on the battery pack and battery slide as shown in Figure 5 25 Figure 5 25 ...

Страница 55: ...rneath the STEM board mount You may need to loosen or tighten the underside screws to lock the battery slide in place See Figure 5 26 for the inserted battery pack slide Figure 5 26 27 Locate your 9V battery case and one Velcro set as shown in Figure 5 27 Figure 5 27 ...

Страница 56: ... one of the Pi Bot chassis Refer to Figure 5 28 for the placement of the Velcro a Note The battery case should have the switch facing upwards Figure 5 28 Congratulations You have completed the assembly of the Basic Pi Bot Your Pi Bot should look similar to Figure 5 29 ...

Страница 57: ...57 Figure 5 29 Now that your Basic Pi Bot is complete we are now ready for the most exciting part making your Pi Bot move The next lesson will go over the motor wiring ...

Страница 58: ...tive red jumper wire with a tab from your bag of wires as shown in Figure 6 1 Figure 6 1 2 Attach the jumper wire tab to the right switch terminal secure it with a nut Then attach the positive red wire from the battery pack to the left switch terminal secure it with a nut See Figure 6 2 Figure 6 2 3 Figure 6 3 depicts the motor H bridge controller Get familiar with the pin configurations ...

Страница 59: ...e solder pads will be used to orient the controller on the breadboard When installing the controller in the breadboard make sure the solder pads are on the right side of the body as shown in Figure 6 4 Figure 6 3 4 Place the motor controller in the breadboard as shown in Figure 6 4 Figure 6 4 ...

Страница 60: ...u have not done so already We have labeled our motor wires with L and R to make the wiring more clear See Figure 6 5 Figure 6 5 Basic Motor Wiring Schematic 6 Review the Figure 6 6 schematic to get familiar with the wiring and motor controller pins Figure 6 6 ...

Страница 61: ...tive red wire from the right power switch terminal to motor controller pin 15 See the schematic in Figure 6 6 and Figure 6 7 Figure 6 7 8 Locate four 4 white male male wires and one 1 black male male wire as shown in Figure 6 8 Figure 6 8 ...

Страница 62: ...6 9 and 6 10 a Ground black male male wire from the STEM Board to motor controller pin 1 b Battery pack negative black wire to motor controller pin 16 Figure 6 9 Figure 6 10 10 Wire the left and right motors to the motor controller as shown in Figure 6 11 ...

Страница 63: ...own in Figure 6 12 The connections between the STEM Board and H Bridge should be as follows a STEM Board Pin 3 will go to H Bridge Pin 3 b STEM Board Pin 5 will go to H Bridge Pin 4 c STEM Board Pin 6 will go to H Bridge Pin 5 d STEM Board Pin 11 will go to H Bridge Pin 6 ...

Страница 64: ... up view of the completed breadboard is shown in Figure 6 13 Figure 6 13 14 Make sure the power switch is turned OFF Remember the power switch is arranged in the OFF position when it is pointing to the rear of your Pi Bot or away from the empty terminal See Figure 6 14 ...

Страница 65: ...om lid 16 Plug the 9V battery into the 9V socket on the STEM Board to test it out Look for the green LED on the STEM Board to turn on a Note Do not turn on the power switch to the motor controller yet Congratulations You have finished wiring your motors and your Pi Bot is now ready for programming ...

Страница 66: ... not connected to the right pins on the STEM Board Once you have determined the robot is running the program correctly you can modify the program to do different tasks Review the following statements to familiarize yourself with the program in Figure 6 15 STEM Board Pins 3 IN1 and 5 In2 control the left motor IN1 and IN2 both cannot be a positive value simultaneously A positive value for IN1 zero ...

Страница 67: ...67 Figure 6 15 ...

Страница 68: ...am shown below in Figure 6 16 is similar to the previous program except now it uses function calls Using function calls makes the program compact You can make function calls as many time as you need without rewriting the same code Test out the new program and try using function calls in future codes Figure 6 16 ...

Страница 69: ...s forward for 5 seconds stop for 2 seconds reverse for 3 seconds and stop indefinitely Exercise 2 Add another function called TURN Have it turn the wheels in opposite directions This will cause your Pi Bot to spin in circles Congratulations You have successfully tested the motion control capabilities of your Pi Bot ...

Страница 70: ...ly known as distance sensors Ultrasonic sensors offer excellent non contact range detection from 2cm to 400 cm or 1 to 13 feet Assembly 1 Locate the ultrasonic sensor LED adapters and ultrasonic mount as shown in Figure 7 1 Figure 7 1 2 LEDs can be attached to the ultrasonic sensor mount using the adapters You should be able to gently push the green and red LEDs through the adapters See Figure 7 2...

Страница 71: ...llow c Echo Green d GND Black Figure 7 3 4 Attach the ultrasonic sensor using four 4 0 80 x 1 2 screws and nuts they come in a separate bag See Figure 7 4 a Caution Do not force the ultrasonic sensor into the mounting bracket Do not overtighten the screws These components are fragile and damage may easily occur Figure 7 4 ...

Страница 72: ...one 1 4 40 x 3 8 screw and nut to mount the ultrasonic assembly on the left side of the body as shown in Figure 7 5 Figure 7 5 6 Route all of the wires underneath the STEM Board as shown in Figure 7 6 Figure 7 6 ...

Страница 73: ...Jumper wires are used to create more pins for power and ground They also help clear the clutter of wires See Figure 7 8 and a close up of 7 9 a Use the red wire as a jumper wire from your STEM Board 5V Pin to the breadboard b Use the black wire as a jumper wire from your STEM Board GND to the breadboard Figure 7 8 ...

Страница 74: ... Green to Pin 4 d GND Black to breadboard GND use the jumper wires you have already set up so that the GND lead connects to the breadboard Wiring the LEDs 4 Now you will need to wires your LEDs As discussed in the Introduction to Electronics and Basic Hardware Programming chapters an LED requires a resistor to drop the voltage Figure 7 10 shows the two 2 330 Ω resistors that you will need Figure 7...

Страница 75: ... Green LED through the dropping resistor to STEM board digital pin 12 as shown in Figure 7 11 a Note White jumper wires are used from Pin 12 and Pin 13 to the dropping resistors Figure 7 11 6 For both LEDs the black leads must connect to GND again use the jumper wires to connect the GND lead to the GND on the breadboard ...

Страница 76: ...omplished with the use of an ultrasonic transmitter and an ultrasonic receiver The sensor emits a chirp using the transmitter and listens for an echo on the receiver The time it takes for the return echo to be detected is proportional to the distance to the object The following program UltraSonicSensorTest is simple and easy to understand Download this program from http www stemcenterusa com pi bo...

Страница 77: ...nicSensorTest Program Now let s use the ultrasonic sensor to control an LED Download the program UltraSonicSensorTestwithLED and run it The RED LED will light whenever the distance to an object is less than 10cm ...

Страница 78: ...78 UltraSonicSensorTestwithLED Program ...

Страница 79: ...o tasks at the same time A program demonstrating the use of interrupt control for the ultrasonic sensor will be available soon Obstacle Avoidance Using the Ultrasonic Sensor In this lesson you will program your Pi Bot to prevent accidents Combining with what we have learned about the ultrasonic sensor and motion control we shall now investigate obstacle avoidance Using the program shown below your...

Страница 80: ...80 ObstacleAvoidance Program ...

Страница 81: ...et s use the ultrasonic sensor to control two LEDs as the robot moves forward and detect an obstacle Download the program ObstacleAvoidancewithLED and run it GREEN LED will be on as the robot moves forward and the RED LED will light up when the robot encounters an obstacle ...

Страница 82: ...82 ObstacleAvoidancewithLED Program ...

Страница 83: ...83 ObstacleAvoidancewithLED Program CONTINUED ...

Страница 84: ...Try different speeds on the two wheels when traveling in reverse Exercise 2 Upon detecting an obstacle have your Pi Bot reverse in different directions For example upon detecting the first obstacle have your Pi Bot reverse while turning to the right The next time it detects an obstacle have your Pi Bot turn to the right ...

Страница 85: ...oing in a straight line turning machine vision line following obstacle avoidance dead reckoning and bar code reading For a day in the life of Kiva Robot take a look at the following video http www youtube com watch v 6KRjuuEVEZs There are several competitions focusing on line following You can use one two three or even more sensors for line following In this lesson we will be using three light sen...

Страница 86: ...r to the nylon spacers See Figure 8 2 a Note Notice the red LEDs are pointed upwards Figure 8 2 3 Figure 8 3 shows the view of the robot from the underside showing the line sensor wiring Figure 8 3 4 Route the wires through the hole on top of the caster wheel ...

Страница 87: ...gure 8 4 shows the wiring diagram of the line sensor array a The diagram also shows connections for the ultrasonic sensor motors and LEDs Figure 8 4 7 Once you have completed the wiring download the program LineFollowingSensorTest from http www stemcenterusa com pi bot downloads 8 Open the serial monitor and run the program Each of the line sensor outputs will be displayed You will see three colum...

Страница 88: ...88 By moving the sensors over a black line you should see the outputs toggle between 0 and 1 If this test is successful you are ready to begin line following LineFollowingSensorTest ...

Страница 89: ... When the line sensor detects black sensor outputs 1 indicating that most of the light is absorbed When the line sensor detects white the sensor output is 0 By using three line sensors your Pi Bot will know whether it is on a black line left and right sensors output 0 and the center sensor outputs 1 to the left of a black line or to the right of a black line 2 Motor control With this information y...

Страница 90: ...90 Download and run the following program LineFollowing Program ...

Страница 91: ...91 LineFollowing Program CONTINUED ...

Страница 92: ...ONTINUED Exercise 1 Write a program to follow a line with just one light sensor use any L C or R Exercise 2 Write a program to follow a line with two light sensors L and R Exercise 3 Compare the performance of all three programs ...

Страница 93: ... are values related to how long your Pi Bot is has been off the line The longer it has been off the line the larger the differential speed is between the wheels to get your Pi Bot back on track In the program N is set to 8 The speed value for each motor is controlled by the ratio of the weighted sum of the side detectors to the center detector This algorithm is very sensitive to the motor voltage ...

Страница 94: ...94 AdvancedLineFollowing Program CONTINUED ...

Страница 95: ...95 AdvancedLineFollowing Program CONTINUED ...

Страница 96: ...96 AdvancedLineFollowing Program CONTINUED ...

Страница 97: ...LineFollowing Program CONTINUED Exercise 4 Advanced Combine the line following with the collision detection Your Pi Bot should follow a black line until an obstacle is placed in front of it at which time it stops ...

Страница 98: ...or USB drive Save the file in the location c Arduino You may need to create this folder before downloading the file Your computer may request that you allow the program to make changes as shown in Figure A 1 If so answer Yes Figure A 1 2 Go to the c Arduino installation directory and run the 1 5 6 r2 windows exe file as shown in Figure A 2 You will be prompted to agree to the license agreement Cli...

Страница 99: ...Figure A 3 4 Select your destination folder and click Install as shown in Figure A 4 Figure A 4 5 After installation is complete you should see the Arduino Setup Completed dialog box as shown in Figure A 5 ...

Страница 100: ...100 Figure A 5 6 Use the Arduino command in the Start menu or click on the icon on the desktop to open the program as shown in Figure A 6 Figure A 6 ...

Страница 101: ... Board into your computer Windows should automatically detect the newly attached device and attempt to find a driver for it If Windows finds and updates the driver skip to the next section Testing the IDE In the likely event that Windows cannot find the appropriate driver follow the following steps 4 Go to the Start Menu and select Devices and Printers as shown in Figure A 7 Figure A 7 ...

Страница 102: ...102 5 Scroll down and double click on the Arduino UNO icon as shown in Figure A 8 Figure A 8 6 In the Arduino UNO dialog box select the Properties tab as shown in Figure A 9 Figure A 9 ...

Страница 103: ...103 7 Next select the Change Settings button as shown in Figure A 10 Figure A 10 8 Select the Update Driver button to update the driver software as shown in Figure A 11 Figure A 11 ...

Страница 104: ...re or browse your computer Choose the second option Browse my computer for driver software as shown in Figure A 12 Figure A 12 10 Use the Browse button and select the location the C Arduino arduino 0022 drivers as shown in Figure A 13 Click Next and Windows should install the correct driver Figure A 13 ...

Страница 105: ...A 14 2 Most but not all of your interfacing with the IDE can be accomplished using the seven action buttons directly below the menus A brief description of each button is useful Button 1 right pointing triangle is used to VERIFY your code which in Arduino language is known as a sketch Use this button to compile convert your code the sketch to Arduino language but not upload your code to the Arduin...

Страница 106: ...y down while selecting the OPEN button the existing sketch is opened in a new IDE Button 5 the SAVE button is used to save the current sketch Use it often Don t lose your work Button 6 the UPLOAD button is used to compile generate the Arduino machine code the current sketch and if no errors result upload it to the Arduino microprocessor If any compiling errors do occur they will be shown in the ou...

Страница 107: ...107 4 Make sure that the IDE is set up for Arduino UNO Using Tools Board select the Arduino UNO as shown in Figure A 15 Figure A 15 ...

Страница 108: ...icking Tools Serial Port as shown in figure A 16 A serial port must be selected It will probably not be port 12 as shown in Figure A 16 If you have multiple ports and the IDE cannot communicate with the STEM Board try changing the ports Figure A 16 6 We are now ready to write our first program ...

Страница 109: ...ut errors a Note This step is not really needed in this case but it helps to understand the functionality of the IDE buttons 10 If so click the UPLOAD button 11 Open a monitor window by clicking the MONITOR button 12 Does it continuously print Hello World If so Congratulations You have successfully run your first Arduino program void setup Your setup code here to run once Serial begin 9600 void lo...

Страница 110: ...Appendix B Complete Pi Bot Wiring Schematic ...

Отзывы: