+ All Categories
Home > Documents > BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Date post: 12-Feb-2016
Category:
Upload: kaleb
View: 48 times
Download: 0 times
Share this document with a friend
Description:
BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering. Navigating the BOE-BOT with whiskers Reference : For more complete documentation, the following items are available from www.parallax.com or www.tcc.edu/faculty/webpages/PGordy Robotics with the BOEBOT Version 2.2 - PowerPoint PPT Presentation
Popular Tags:
17
1 BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering Navigating the BOE-BOT with whiskers Reference : For more complete documentation, the following items are available from www.parallax.com or www.tcc.edu/faculty/webpages/PGordy Robotics with the BOEBOT Version 2.2 BASIC Stamp Syntax and Reference Manual Version 2.1
Transcript
Page 1: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

1

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Navigating the BOE-BOT with whiskersReference: For more complete documentation, the following items are available from www.parallax.com or www.tcc.edu/faculty/webpages/PGordy • Robotics with the BOEBOT Version 2.2• BASIC Stamp Syntax and Reference Manual Version 2.1

Page 2: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

2

Tactile Navigation with the BOE-BOT(Wall following using whiskers)

The following is an excerpt from Robotics, Version 2.2:

“Many types of robotic machinery rely on a variety of tactile switches. For example, a tactile switch may detect when a robotic arm has encountered an object. The robot can be programmed to pick up the object and place it elsewhere. Factories use tactile switches to count objects on a production line, and also for aligning objects during industrial processes. In this chapter, you will build tactile switches, called whiskers, onto your BOE-BOT and test them. You will then program the BOE-BOT to monitor the state of these switches, and to decide what to do when it encounters an obstacle. The end result will be autonomous navigation by touch.The whiskers are so named because that is what these bumper switches look like, though some argue they look more like antennae. Whiskers give the BOE-BOT the ability to sense the world around it through touch, much like the antennae on an ant or the whiskers on a cat.

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Page 3: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

3

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Whiskers

Page 4: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

4

Adding whiskers to the BOE-BOTIf your BOE-BOT is not already equipped with whiskers, following the instructions shown from Robotics, Version 2.2 to add the whiskers. If your BOE-BOT is equipped with whiskers, skip to the next page.

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Header

Page 5: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

5

Adding a whisker circuit to the BOE-BOTShown below is a circuit to read the status of each whisker. It works as follows: The whiskers are connected to standoffs on the BOE which are connected to ground (Vss). When the BOE-BOT runs into a wall, the whisker touches a “header” on the breadboard which will make a connection to a point in the circuit below (see next page). A whisker hitting a wall is equivalent to closing a switch in the circuit below. In the circuit, if the right whisker hits a wall, it makes a connection to Vss making P7 LOW. If the whiskers is not pressed, P7 remains HIGH. In this way we can tell when each whiskers hits a wall by monitoring the states of P5 and P7.

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Page 6: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

6

Adding a whisker circuit to the BOE-BOTShown below is a circuit to read the status of each whisker. It works as follows: The

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

When the left whisker hits a wall, it is pushed into the header, essentially connecting the header to ground (Vss).

Header

The whisker is connected to the corner of the BOE, which is connected to ground (Vss)

Page 7: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

7

Whisker test circuit It is nice to have a test circuit, so that we can tell if the whiskers are working properly. An easy solution if to add two LED (with series resistors) so that one LED lights when the left whisker hits a wall and the other LED lights when the right whisker hits a wall.

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Page 8: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

8

Final result: Whisker control circuit with LED test circuit.Shown below is the BOE-BOT with the whisker control circuit (see Figure 5-4) and the LED whisker test circuit (see Figure 5-7). You will need to add this circuit to your BOE-BOT.

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Note: Ignore the round, black buzzer and the wire connecting it to P4. We will not be using the buzzer.

Page 9: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

9

Additional PBASIC InstructionsBefore testing the whiskers, a few new PBASIC instructions need to be introduced.

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Inputs to the Basic StampThe BASIC Stamp can easily determine whether an input connected to a pin is HIGH or LOW by checking its value. This is done using:INpin where pin can be 0 through 15

so IN3 will have the value 1 if a HIGH (5V) input is connected to P3 IN4 will have the value 0 if a LOW (0V) input is connected to P4

Page 10: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

10

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Decision structuresMost programming languages support various types of decision structures which allows the program to branch and perform different tasks based on some sort of logical test. A common type of decision structure is the IF .. THEN structure.

IF (Logical Statement) THEN statements so that the program can respond one way when the logical statement is true and another way when it is false. Sometimes this is illustrated with a diagram as shown.

Do this if true Do this if false

LogicalTest

T

F

Page 11: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

11

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

IF .. THEN statement in PBASICIF (Logical Test) THEN Instructions to perform if the test is trueENDIF

Or

IF (Logical Test) THEN Instructions to perform if the test is trueELSE Instructions to perform if the test is falseENDIF

Examples of Logical Tests:X > 2IN3 = 0IN7 <> 0 (not equal)A <= BA+B >= C+D

Example:IF (X < 0) THEN DEBUG “X is negative”ENDIF

Example:IF (IN8 = 0) THEN DEBUG “P8 is LOW”ELSE DEBUG “P8 is HIGH”ENDIF

Page 12: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

12

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Subprograms in PBASICIn order to repeat useful sections of code, subprograms (or subroutines) are often used. Functions are also used for this purpose in other programming languages.

For example, suppose that at several points in a program you wanted to cause an LED connected to P3 to blink on and off ten times. Instead of repeating the instructions several times, they could be placed in a subprogram as shown below.

‘ Main programN VAR BYTEGOSUB Blink ‘Call subroutine BlinkOther instructions….GOSUB Blink ‘Call subroutine BlinkOther instructions….GOSUB Blink ‘Call subroutine BlinkOther instructionsOther instructions….END ‘End of main program‘-----Subroutine Blink is listed below---------Blink:FOR N = 1 TO 10 HIGH 3 PAUSE 500 LOW 3 PAUSE 500NEXTRETURN

Note that three new PBASIC commands were introduced in this example. Discuss each.

GOSUB LabelLabel:RETURN

Page 13: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

13

Testing the whiskersThe program below can be used to test the whiskers. Each time a whiskers is pressed, the input will be detected and an LED will light. It is important to use this test program to be sure that the whiskers are functioning properly before navigation on a track is attempted. This program will be used in Team Assignment #5.

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

DO IF (IN7 = 0) THEN ‘IN7 = 0 when right whisker hits wall HIGH 1 ‘Turn on LED connected to P1 when IN7 = 0 ELSE LOW 1 ‘Turn off LED connected to P1 when IN7 0 ENDIF IF (IN5 = 0) THEN ‘IN5 = 0 when left whisker hits wall HIGH 10 ‘Turn on LED connected to P10 when IN5 = 0 ELSE LOW 10 ‘Turn off LED connected to P10 when IN5 0 ENDIF PAUSE 50 ‘Test whiskers about every 50 msLOOP

Page 14: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

14

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Sample whisker navigation programA whisker navigation program is provided in the BOE-BOT manual that could possibly be used to try to navigate any general maze. If a specific track is to be used, modifications to the program might be made so that it will more efficiently navigate that specific track.The program works as follows:• If neither whisker is pressed, go straight• If the left whisker runs into an obstacle, back up a little bit and turn right 90º• If the right whisker runs into an obstacle, back up a little bit and turn left 90º• If both whiskers run into obstacles, back up a little bit and turn 180º (U-turn)

Video – a video of a BOE-BOT navigating using whiskers based on the sample program described above is available at the following URL:

http://www.parallax.com/dl/mm/video/boebot/whisker.mpg

Page 15: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

15

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

' {$STAMP BS2}' {$PBASIC 2.5}' {$PORT COM1} 'Sample program to navigate with whiskers from Robotics, Version 2.2, pp. 179-180pulseCount VAR Byte 'Loop counter for FOR .. NEXT loopsDO IF (IN5 = 0) AND (IN7 = 0)THEN 'Both whiskers detect obstacle GOSUB Back_Up 'Back up and do U-turn GOSUB Turn_Left GOSUB Turn_Left ELSEIF (IN5 = 0) THEN 'Left whisker detects obstacle GOSUB Back_Up 'Back up and turn right GOSUB Turn_Right ELSEIF (IN7 = 0) THEN 'Right whisker detects obstacle GOSUB Back_Up 'Back up and turn left GOSUB Turn_Left ELSE 'No contact with whiskers GOSUB Forward_Pulse 'Go straight forward ENDIF 'and check againLOOP' ----- Subroutines -------------------------------------------------Forward_Pulse: 'Go straight ahead PULSOUT 13, 850 'Left wheel full speed CCW PULSOUT 12, 650 'Right wheel full speed CW PAUSE 20 RETURN

Turn_Left: 'Turn left about 90 degrees FOR pulseCount = 0 TO 20 PULSOUT 13, 650 'Right wheel full speed CW PULSOUT 12, 650 'Right wheel full speed CW PAUSE 20 NEXT RETURN Turn_Right: 'Turn right about 90 degrees FOR pulseCount = 0 TO 20 PULSOUT 13, 850 'Right wheel full speed CCW PULSOUT 12, 850 'Right wheel full speed CCW PAUSE 20 NEXT RETURN Back_Up: 'Back up a little bit FOR pulseCount = 0 TO 40 PULSOUT 13, 650 'Left wheel full speed CW PULSOUT 12, 850 'Right wheel full speed CCW PAUSE 20 NEXT

RETURN

Sample whisker navigation programThe whisker navigation program from the BOE-BOT manual described on the previous slide is shown below.

Page 16: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

16

Modifying the whisker navigation programThere are many possible approaches to navigation by whiskers. Some approaches might include:

BOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

• Program the BOE-BOT to follow the outside (right) wall. Do this by giving the BOE-BOT a slight bias (drift) to the right. When the right whisker hits the wall, turn left for a short time and then resume the slight bias to the right.

• Same as above except follow the inside (left) wall. This is illustrated on the following slide.

• Change the program as the BOE-BOT proceeds through the course. For example:

– The first three times that both whiskers hit a wall, turn right

– The 4th, 5th, and 6th time that both whiskers hit a wall, turn left

– Turn right for additional times.– Note that it may be necessary to

use a counter to keep track of the walls.

– See the example shown

Counter VAR BYTECounter = 0 ‘Initialize counter to zeroDO IF (IN5 = 0) AND (IN7 = 0)THEN 'Both whiskers detect obstacle Counter = Counter + 1 IF (Counter >=4) AND (Counter <=6) THEN GOSUB Back_Up ‘Back up and turn left GOSUB Turn_Left ELSE GOSUB Back_Up 'Back up and turn right GOSUB Turn_Right ENDIF ELSEIF (IN7 = 0) THEN 'Right whisker detects obstacle GOSUB Back_Up 'Back up and turn left GOSUB Turn_Left ELSE 'No contact with whiskers GOSUB Forward_Pulse 'Go straight forward ENDIF 'and check againLOOP' ----- Subroutines -------------------------------------------------Forward_Pulse: 'Go straight ahead PULSOUT 13, 850 'Left wheel full speed CCW PULSOUT 12, 650 'Right wheel full speed CW PAUSE 20 RETURNEtc …….

Page 17: BOE-BOT Lecture #4      EGR 120 – Introduction to Engineering

17

Possible whisker navigation program – following the outside wallBOE-BOT Lecture #4 EGR 120 – Introduction to Engineering

Path of robot

Place where left whisker hits the

wall

Robot naturally drives slightly to the left and

then corrects right after left whisker hits

the wallAreas of

difficulty?

RightWhisker

Adding angled barriers to

corners may make

navigation easier


Recommended