background image

Chapter 4: Infrared Object Detection · Page 41   

SUMOBOT MOTION CONTROL 

The next task is to link the SumoBot robot’s ability to "see" with the motors so that an 
object – the opponent – can be tracked.   Load and run program 4.2 to see a 
demonstration of linking IR object control to the SumoBot motors. 
 

' SumoBot_4.2_IR_Scan.BS2 
' {$STAMP BS2} 
' {$PBASIC 2.5} 
 
' -----[ I/O Definitions ]------------------------------------------------- 
 
LMotor          PIN     13                      ' left servo motor 
RMotor          PIN     12                      ' right servo motor 
 
LfIrOut         PIN     4                       ' left IR LED output 
LfIrIn          PIN     11                      ' left IR sensor input 
RtIrOut         PIN     15                      ' right IR LED output 
RtIrIn          PIN     14                      ' right IR sensor input 
 
' -----[ Constants ]------------------------------------------------------- 
 
LFwdFast        CON     1000                    ' left motor fwd; fast 
LFwdSlow        CON      800                    ' left motor fwd; slow 
LStop           CON      750                    ' left motor stop 
LRevSlow        CON      700                    ' left motor rev; slow 
LRevFast        CON      500                    ' left motor rev; fast 
 
RFwdFast        CON      500                    ' right motor fwd; fast 
RFwdSlow        CON      700                    ' right motor fwd; slow 
RStop           CON      750                    ' right motor stop 
RRevSlow        CON      800                    ' right motor rev; slow 
RRevFast        CON     1000                    ' right motor rev; fast 
 
' -----[ Variables ]------------------------------------------------------- 
 
irBits          VAR     Nib                     ' storage for IR target data 
irLeft          VAR     irBits.BIT1 
irRight         VAR     irBits.BIT0 
lastIr          VAR     Nib                     ' info from last reading 
 
pulses          VAR     Byte                    ' counter for motor control 
 
' -----[ Initialization ]-------------------------------------------------- 
 
Reset: 
  LOW LMotor                                    ' initialize motor outputs 
  LOW RMotor 
 
' -----[ Program Code ]---------------------------------------------------- 

Содержание Boe-Bot

Страница 1: ...SumoBot Mini Sumo Robotics Assembly Documentation and Programming VERSION 2 1...

Страница 2: ...Parallax copyrights legally punishable according to Federal copyright or intellectual property laws Any duplication of this documentation for commercial uses is expressly prohibited by Parallax Inc BA...

Страница 3: ...llax provides editable Word documents to our translating partners and attempts to time the translations to coordinate with our publications Robotics Designed exclusively for Parallax robots this forum...

Страница 4: ......

Страница 5: ...ervo Works 11 Time Measurement and Voltage Levels 11 SumoBot Motion Test 16 Challenge Yourself 21 Chapter 3 SumoBot Sensors and Border Detection 23 Line Sensor Theory 23 Our First Operational Sumo Pro...

Страница 6: ...Page vi SumoBot Mini Sumo Robotics Appendix B Standard Mini Sumo Competition Rules 55 Appendix C Mini Sumo Ring 65 Appendix D SumoBot PCB Schematic 67...

Страница 7: ...ler version about half the size and weight of the lightweight class to be used as a robot Sumo demonstrator The result of their work was a very small Sumo robot that measured just 8 cm by 8 cm and mas...

Страница 8: ...ssed in an introductory format designed to impart a conceptual understanding along with some hands on experience Those who intend to delve further into industrial technology electronics or robotics ar...

Страница 9: ...Preface Page ix...

Страница 10: ......

Страница 11: ...bles as well state oriented design A well designed program means you can easily tune the software for the right mechanical control in just a few places rather than rewriting your entire program A surf...

Страница 12: ...EQUIRED A Parallax screwdriver is included in your kit You may find a pair of needle nose pliers and a wire stripper to be useful not included ABOUT PARTS IN THE SUMOBOT KIT Appendix A includes a part...

Страница 13: ...s and nuts The screws will be countersunk into the battery pack when tightened and should be out of the way of the batteries Step 2 Install the Servo Motors Parts Required 2 Parallax Continuous Rotati...

Страница 14: ...s SumoBot chassis Using a 4 40 3 8 pan head machine screw attach each stand off to the rear of the SumoBot chassis Step 4 Install the Front SumoBot PCB Stand offs Parts Required 2 5 8 round standoffs...

Страница 15: ...holes on the SumoBot chassis Secure the rear side of the SumoBot PCB to the 5 8 standoffs with two 3 8 pan head machine screws Holding the chassis upside down place a nylon washer onto the end of eac...

Страница 16: ...wheel onto the servo splines Secure each wheel with the small black Phillips head screw Step 8 Mount the Scoop Parts Required SumoBot scoop 2 4 40 1 4 long pan head machine screws 2 4 40 nuts SumoBot...

Страница 17: ...enter chassis slot Step 10 Install the QTI Line Sensors Parts Required 2 QTI line sensors 2 4 40 1 4 long pan head machine screws SumoBot chassis Using two 4 40 1 4 pan head machine screws attach the...

Страница 18: ...ine Sensor X4 Right QTI Line Sensor Connect the battery pack wires to SumoBot PCB connector X1 The battery pack s white striped lead connects to the terminal Note Previous versions of the SumoBot PCB...

Страница 19: ...position power switch The state of each position is shown below The three position switch has a middle position that powers the entire circuit except the servos A complete schematic of the SumoBot PCB...

Страница 20: ......

Страница 21: ...also has internal mechanical linkages for position feedback so that the electronic circuit that controls the DC motor inside the servo knows where to turn to in response to a pulse train SumoBot motio...

Страница 22: ...atteries and it is connected to the positive terminal of the battery pack Vdd is regulated to 5 volts by the SumoBot PCB s onboard voltage regulator and it will be used with Vss to supply power to cir...

Страница 23: ...e pulses Negative pulses would involve a resting state that s high with pulses that drop low The ideal pause between servo pulses is 20 milliseconds but can be anything between 10 and 40 milliseconds...

Страница 24: ...nough to cause an excessive load on the BASIC Stamp s regulator circuitry causing it to reset or behave erratically For Mini Sumo competition precise speed control is not a requirement The goal is to...

Страница 25: ...de Main DO PULSOUT LMotor LStop stop left PULSOUT RMotor RStop stop right PAUSE 20 LOOP END Move the SumoBot power switch to position 2 and then download the code using the Run command from the Run me...

Страница 26: ...me to test the SumoBot for essential motion control Load the following program into the BASIC Stamp Editor and then download it to the SumoBot SumoBot_2 2_Motor_Test BS2 STAMP BS2 PBASIC 2 5 I O Defin...

Страница 27: ...utputs LOW RMotor PAUSE 2000 time to disconnect cable Program Code Main FOR pulses 1 TO 65 fwd slow 12 inches PULSOUT LMotor LFwdSlow PULSOUT RMotor RFwdSlow PAUSE 20 NEXT FOR pulses 1 TO 30 pivot 90...

Страница 28: ...This program code starts as well coded programs do by defining connection and value constants used in the program This methodology creates programs that are easier to read maintain and debug In the ca...

Страница 29: ...tructed using a FOR NEXT control loop to give the motors enough time to perform the actual movements You may notice that the SumoBot does not move precisely as the code dictates that it should Do not...

Страница 30: ...Mini Sumo Robotics Figure 2 6 BASIC Stamp Editor with SumoBot_ 2 2_Motor_Test BS2 Note The figure above shows the edit window set to split pane mode so that two sections of the program may be viewed...

Страница 31: ...that your SumoBot travels straight at low and high speeds 2 Determine the proper loop count to cause the SumoBot to turn 30 degrees 45 degrees and 90 degrees 3 Using the information in 2 above see if...

Страница 32: ......

Страница 33: ...very low when the QTI is over the white border Tawara the reflectivity is very high and will cause a different reading from the sensor Figure 3 1 shows the schematic for the Parallax QTI line sensor F...

Страница 34: ...value When the QTI is positioned over the white border line the current flow through the phototransistor is high so the capacitor charge time is fast and RCTIME returns a small value Load and run pro...

Страница 35: ...capacitor is fully discharged RCTIME makes the R line an input and allows the capacitor to begin to charge the plate connected to the R line will move toward Vss While the capacitor is charging the R...

Страница 36: ...called from any point in the program The routine should also be developed to return either a True 1 or False 0 value if the QTI is over the Sumo ring border To see this in action load and run program...

Страница 37: ...vate sensors HIGH RLinePwr HIGH LLineIn discharge caps HIGH RLineIn PAUSE 1 RCTIME LLineIn 1 lLine read left sensor RCTIME RLineIn 1 rLine read right sensor LOW LLinePwr deactivate sensors LOW RLinePw...

Страница 38: ...er the index value of 1 is moved into lbLeft We could use an IF THEN ELSE coding technique to accomplish the same thing Left_Conv IF lLine 1000 THEN lbLeft 0 ELSE lbLeft 1 ENDIF As you can see using L...

Страница 39: ...N Spin_Left IF lineBits 10 THEN Spin_Right IF lineBits 11 THEN About_Face and accomplishes the same objective With simple programs like this one using SELECT CASE is a clean solution As programs grow...

Страница 40: ...left line sensor power LLineIn PIN 9 left line sensor input RLinePwr PIN 7 right line sensor power RLineIn PIN 8 right line sensor input StartLED PIN 0 display start delay Constants LFwdFast CON 1000...

Страница 41: ...motor control temp VAR Byte EEPROM Data RunStatus DATA 00 run status Initialization Reset READ RunStatus temp read current status temp temp invert status WRITE RunStatus temp save for next reset IF te...

Страница 42: ...OTO Main END Subroutines Read_Line_Sensors HIGH LLinePwr activate sensors HIGH RLinePwr HIGH LLineIn discharge caps HIGH RLineIn PAUSE 1 RCTIME LLineIn 1 lLine read left sensor RCTIME RLineIn 1 rLine...

Страница 43: ...not start until five seconds after the command is given by the judge This code is very simple it lights the LED to show that the SumoBot is preparing to start and inserts a five second PAUSE At the en...

Страница 44: ...Page 34 SumoBot Mini Sumo Robotics CHALLENGE YOURSELF 1 Experiment with the Spin_Left and Spin_Right routines so that the SumoBot generally moves toward the center after touching the border...

Страница 45: ...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 accor...

Страница 46: ...the 555 timer circuit is more complex and less functional than the circuit we will use in this and the next chapter For example the method of IR detection introduced here can be used for distance dete...

Страница 47: ...he protective shell standoff and shield The purpose of this assembly is to prevent stray IR from falling directly onto the detector and causing a false positive reading Figure 4 1 IR LED Standoff and...

Страница 48: ...that the 220 resistors are already built into the SumoBot PCB just plug in the IR emitters and your SumoBot will be ready When aligning the IR emitter headlights it s a good idea to angle them slight...

Страница 49: ...rmal output state when it sees no IR signal is high logic 1 When the IR detector sees the 38 5 kHz harmonic sent by the IR LED its output will drop from high to low logic 0 Of course if the IR does no...

Страница 50: ...n object or not If it bounces off an object and is seen by the IR detector the IR detector sends a low signal to I O pin LfIrIn Otherwise the IR detector sends a high signal to LfIrIn The bitwise inve...

Страница 51: ...15 right IR LED output RtIrIn PIN 14 right IR sensor input Constants LFwdFast CON 1000 left motor fwd fast LFwdSlow CON 800 left motor fwd slow LStop CON 750 left motor stop LRevSlow CON 700 left moto...

Страница 52: ...in left slow DEBUG HOME Scan Left CLREOL PULSOUT LMotor LRevSlow PULSOUT RMotor RFwdSlow PAUSE 20 GOTO Main Follow_Right spin right fast DEBUG HOME Follow Right CLREOL PULSOUT LMotor LFwdFast PULSOUT...

Страница 53: ...s detected the SumoBot will go into scanning mode The code at Scan will look for the opponent in the last known direction held in the variable lastIr When a target is detected the SumoBot will move qu...

Страница 54: ......

Страница 55: ...tition The program in this chapter brings all the SumoBot robot s systems together and adds some intelligent control Start by adding a piezo speaker as shown in Figures 5 1 and 5 2 then load and run p...

Страница 56: ...LFwdFast CON 1000 left motor fwd fast LFwdSlow CON 800 left motor fwd slow LStop CON 750 left motor stop LRevSlow CON 700 left motor rev slow LRevFast CON 500 left motor rev fast RFwdFast CON 500 rig...

Страница 57: ...ad_Line_Sensors blackThresh lLine 10 rLine 10 LOW LMotor make more pins outputs LOW RMotor Start_Delay five second delay FOR temp 1 TO 5 HIGH StartLED show active PAUSE 900 INPUT StartLED blink each s...

Страница 58: ...ulses 1 TO 30 turn around PULSOUT LMotor LFwdFast PULSOUT RMotor RRevFast PAUSE 20 NEXT lastIr 00 GOTO Lunge IR Processing Search_For_Opponent GOSUB Read_IR_Sensors If opponent is not in view scan las...

Страница 59: ...t lastIR irBits GOTO Main Lunge locked on go get him FOR pulses 1 TO 25 PULSOUT LMotor LFwdFast PULSOUT RMotor RFwdFast GOSUB Read_Line_Sensors IF lineBits 11 THEN Match_Over in sight we re on the lin...

Страница 60: ...modulate right IR LED irRight RtIrIn read input 1 target RETURN Creep_Forward FOR pulses 1 TO 20 PULSOUT LMotor LFwdSlow PULSOUT RMotor RFwdSlow PAUSE 20 NEXT RETURN HOW IT WORKS After the Reset code...

Страница 61: ...gic previously developed will be used When the border is touched the lastIr variable is cleared so the SumoBot will move toward the center after turning in from the border The Search_For_Opponent rout...

Страница 62: ...ake plenty of fresh batteries to each contest you participate in When fully assembled and loaded with batteries the SumoBot will weigh less than the 500 gram 17 6 oz limit imposed by standard Mini Sum...

Страница 63: ...een LED 1 150 04710 470 ohm resistor 1 4 watt 2 900 00001 Piezo speaker 1 800 00016 Jumper wires bag of 10 1 550 27400 SumoBot Printed Circuit Board with BASIC Stamp 2 1 753 00001 Battery Pack with Ti...

Страница 64: ...Page 54 SumoBot Mini Sumo Robotics 700 00015 Nylon washer 2 Miscellaneous 122 27400 SumoBot Manual 1 800 00003 Serial programming cable 1 27000 Parallax CD 1 700 00064 Parallax Screwdriver 1...

Страница 65: ...dges will decide which team wins A single person can also compete with a Robot Sumo with the same rules that apply to teams Section 2 Requirements for the Ring Area Article 2 Definition of Ring Area T...

Страница 66: ...re tube of 10 cm wide and 10 cm deep A robot can be of any height A robot must not be in such a design that its body will be physically separated into pieces when a match starts The robot with such a...

Страница 67: ...by putting into a robot s body such devices as a jamming device 2 Do not use parts that could break or damage the Ring Do not use parts that are intended to damage the opponent s robot or its operator...

Страница 68: ...was called for or lots were employed Section 5 Match Procedure Article 8 Start With the chief judge s instructions the two teams bow in the Outer Ring For example stand facing each other outside the...

Страница 69: ...e 12 An extended match shall be for 3 minutes if called by the Judge Article 13 The following are not included in the time of the Match 1 The time elapsed after the chief judge announces Yuko and befo...

Страница 70: ...ds with no progress being made If it is not clear if progress is being made or not the Judge can extend the time limit for a clinch or orbiting robots up to 30 seconds 5 2 Both robots move without mak...

Страница 71: ...re than 30 seconds before resuming the match unless the Judge announces a time extension 2 3 Start operating the robot before the chief judge announces the start of the match for remote controlled rob...

Страница 72: ...me should continue in case of injury or accident shall be decided by the judges and the Committee members The decision process shall take no longer than five minutes Article 24 Yuko Given to the Playe...

Страница 73: ...body while the robot is in competition Section 13 Miscellaneous Article 28 Flexibility of Rules As long as the concept and fundamentals of the rules are observed the rules shall be so flexible that t...

Страница 74: ......

Страница 75: ...lose to the official dimension and can be used to create a suitable practice ring Mini Sumo Ring Specifications Diameter 77 cm 30 3 in Height 2 5 cm 1 in Surface Hard Rubber Colors o Ring Black o Shik...

Страница 76: ......

Страница 77: ...Appendix D SumoBot PCB Schematic Page 67 Appendix D SumoBot PCB Schematic...

Страница 78: ...Mouser Electronics Authorized Distributor Click to View Pricing Inventory Delivery Lifecycle Information Parallax 27400 27402 122 27400...

Отзывы: