Robotics_2.0_EduCourse
Download
Report
Transcript Robotics_2.0_EduCourse
Presentation based on:
“Robotics: with the Boe-Bot"
Parallax, Inc.
www.parallax.com
599 Menlo Drive
Suite 100
Rocklin, CA 95765
1
Copyrights and Trademarks
This documentation is copyright 2004 by Parallax, Inc. By downloading or
obtaining a printed copy of this documentation or software you agree that it is
to be used exclusively with Parallax products. Any other uses are not
permitted and may represent a violation of 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. Duplication for educational use is permitted subject to the
following conditions: Parallax grants the user a conditional right to download,
duplicate, and distribute this text without Parallax's permission. This right is
based on the following conditions: the document, or any portion thereof, may
not be duplicated for commercial use; it may be duplicated only for
educational purposes when used solely in conjunction with Parallax products,
and the user may recover from the student only the cost of duplication.
BASIC Stamp, Stamps in Class, and Board of Education are registered
trademarks of Parallax, Inc. If you decide to use the names BASIC Stamp,
Stamps in Class, and/or Board of Education on your web page or in printed
material, you must state that "BASIC Stamp is a registered trademark of
Parallax, Inc.," "Stamps in Class is a registered trademark of Parallax, Inc.,"
and/or "Board of Education is a registered trademark of Parallax, Inc.,"
respectively, upon the first appearance of the trademark name. Other brand
and product names are trademarks or registered trademarks of their
respective holders.
2
What's New In Robotics
15 14 Vdd 13 12
Red
Black
X4
X5
Vin
New Servos
• Adjustable potentiometer
• Faster, quieter, draw less
power
New Board of Education
• Power Switch
• Jumper
New Wheels and Tires
New Whiskers
New Infrared Emitters
New Text – v2.0
3
Select the Servo Power Supply
New jumper - connects servo power to either
• Vin – Battery Voltage
• Vdd – Regulated 5V supply
Select Vin for use with 4 AA batteries
Pull jumper off pins, then push onto Vin pin
15 14 Vdd 13 12
Red
Black
X4
X5
Vin
4
Center the Boe-Bot Servos
Plug the battery pack into the BOE
• Note the correct polarity
Plug the servos in to the BOE
• Important!! Black wire closest to breadboard!
Turn the switch to Position 1
Enter and Run "CenterServoP12.bs2" pg. 65
Repeat for "CenterServoP13.bs2" pg. 66
5
Center the Boe-Bot Servos
Move the switch to Position 2
If the servos do not stay still, adjust them with
your Parallax screwdriver
• Do not push too hard
• Use the Phillips end
Adjust each servo so it stays completely still
6
Build the Boe-Bot
Build the robot by following instructions
from your manual (pages 85-99)
7
Build the Start/Reset Indicator
Brownout
• Batteries drop below 5.2 V
• Brownout detector circuit resets the
BASIC Stamp
• Program starts over from beginning
Low Battery Indicator
• Add speaker to Boe-Bot
• "Beep" first thing in program
If Boe-Bot beeps during
navigation, must have reset
Thus batteries are low
P4
To Servos
15 14 Vdd 13 12
Red
Black
Vss
X4
Vdd
X5
Vin
Vss
X3
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
X2
+
Board of Education
Rev C
© 2000-2003
8
Test the Low Battery Indicator
Run "StartResetIndicator.bs2"
Test by pressing the Reset button on the BOE
Should beep each time reset
DEBUG CLS, "Beep!!!"
FREQOUT 4, 2000, 3000
' Display while speaker beeps.
' Signal program start/reset.
DO
DEBUG CR, "Waiting for reset…"
PAUSE 500
LOOP
' DO...LOOP
' Display message
' every 0.5 seconds
9
Servo Positioning
Direction
• Determined by the width of the pulse
Distance
• Each pulse causes the servo to rotate a small amount
Speed
• Maximum at 1.3 and 1.7 ms.
• Decreases as approaches 1.5 ms
Pulse Width Direction of Rotation PULSOUT Period
1.3 ms
Clockwise
650
1.5 ms
Stopped
750
1.7 ms
Counter-clockwise
850
10
Controlling Distance
Run "BoeBotForwardThreeSeconds.bs2"
Follow the instructions on p. 118 to make the
Boe-Bot go half as far forward
Add code to make the Boe-Bot go backward,
left, and right, as shown on pages 119-120
FOR counter = 1 TO 122
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT
11
EEPROM Navigation
Run "EEPROMNavigation.bs2" p. 141
Modify the DATA directive to make your own motion
sequence
• DATA
"FFFBBLFFRFFQ"
F = Forward, B = Backward, L = Left, R = Right, Q = Quit
DO
address
instruction
'
'
DATA
VAR
VAR
Byte
Byte
Address: 0123456789
||||||||||
"FLFFRBLBBQ"
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
ENDSELECT
LOOP UNTIL instruction = "Q"
12
Tactile Navigation with Whiskers
Activities:
Building and Testing the Whiskers
• Page 154-165
• See also wiring diagram next slide
13
Build the Whisker Circuit
Left
Whisker
To Servos
15 14 Vdd 13 12
Vdd
Red
Black
X4
Vdd
X5
Vin
10 k
10 k
Right
Whisker
Left
Whisker
Vss
P7
X3
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
X2
Vdd
220
P5
220
+
Vss
Vss
Board of Education
Rev C
© 2000-2003
Right
Whisker
14
Testing the Whiskers
Run "TestWhiskers.bs2" p.160
Press on each whisker and examine the Debug
Terminal output.
Each whisker should display 1 when not
pressed, 0 when pressed.
Position the whisker wires to make good
contact with the headers
DEBUG "WHISKER STATES", CR,
"Left
Right", CR,
"-----------"
DO
DEBUG CRSRXY, 0, 3,
"P5 = ", BIN1 IN5,
"
P7 = ", BIN1 IN7
PAUSE 50
LOOP
15
Navigation With Whiskers
Run "Roaming with Whiskers.bs2"
Compare with pushbuttons exercise from
the previous day
DO
IF (IN5 = 0) AND (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
LOOP
' Both whiskers detect obstacle
' Back up & U-turn (left twice)
' Left whisker contacts
' Back up & turn right
' Right whisker contacts
' Back up & turn left
' Both whiskers 1, no contacts
' Apply a forward pulse
' and check again
16
Navigation with Infrared Headlights
Activities:
Understanding Infrared Object Detection
Building and Testing the IR Circuit
Object Detection and Avoidance
Object Detection and Avoidance in Real-Time
17
Using Infrared Headlights to See the Road
IR reflect off obstacles
IR LED emits light in infrared region (780 nm)
Detector shows "0" if detects IR, "1" otherwise
Detector tuned to 38,500 Hz only
18
Building and testing the IR Pairs
15 14 Vdd 13 12
Vdd
Red
Black
P2
X4
Vdd
1 k
220
Vss
Vss
Vdd
P8
1 k
IR
LED
P0
220
Vss
Vin
Vss
X3
IR
LED
P9
X5
Vss
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
X2
+
Board of Education
Rev C
© 2000-2003
Run "TestLeftIrPair.bs2"
Follow directions on p. 223 to test
right IR pair
19
How the IR Test Program Works
' Robotics with the Boe-Bot - TestLeftIrPair.bs2
' Test IR object detection circuits, IR LED connected to P8
' and detector connected to P9.
' {$STAMP BS2}
' {$PBASIC 2.5}
irDetectLeft
VAR
Bit
DO
FREQOUT 8, 1, 38500
irDetectLeft = IN9
DEBUG HOME, "irDetectLeft = ", BIN1 irDetectLeft
PAUSE 100
LOOP
20
Object Detection and Avoidance
Run "RoamingWithIr.bs2"
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (irDetectLeft = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (irDetectRight = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
Place the Boe-Bot on the floor
Your Boe-Bot should roam around and avoid
objects
21
Fast IR Roaming
Run "FastIRRoaming.bs2"
Again the Boe-Bot should roam around and
avoid objects
Observe: How does this behavior differ from
that of "RoamingWithIr.bs2"?
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 850
ELSEIF (irDetectLeft = 0) THEN
pulseLeft = 850
pulseRight = 850
ELSEIF (irDetectRight = 0) THEN
pulseLeft = 650
pulseRight = 650
ELSE
pulseLeft = 850
pulseRight = 650
ENDIF
22
Understanding Filter Sensitivity
Object
15 14
Vd d
13 12
Red
Black
X4
Vdd
X5
Vin
Vss
X3
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
X2
Zone 0
41500 Hz
+
Board of Education
© 20 00 -2 00 3
Zone 1
40500 Hz
Zone 2
Zone 3
39500 Hz 38250 Hz
Zone 4
37500 Hz
Zone 5
No Detection
at any
Frequency
23
Testing Distance Detection
Run
"TestLeftFrequencySweep.
bs2"
Place the Boe-Bot in front
of some obstacle (Wall,
book, etc)
Observe the readings
change as you move the
Boe-Bot closer to and
further away from the
obstacle
24
Boe-Bot Shadow Vehicle
Follow the detailed instructions on p. 259-260
In summary:
•
•
•
•
Run "FollowingBoeBot.bs2"
Place a sheet of paper in front of your Boe-Bot
Move the paper around
The Boe-Bot should follow the paper at a constant
distance
If the Boe-Bot backs away instead, contact the
instructor for assistance. Your right/left servos
are probably reversed.
25
Boe-Bot Follow-the-Leader
Place sticky notes on the back of
all Boe-Bots
Now select two or three Boe-Bots
from the class to be "Leader" BoeBots
Create "Leader" Boe-Bots by
following the instructions on p.
263
All other Boe-Bots keep the
previous program,
"FollowingBoeBot.bs2"
The "Shadow" Boe-Bots will follow
the "Leader" Boe-Bots
See how many Boe-Bots will follow
in a row, like a train
26
Following a Stripe
Create Stripe-Following Boe-Bots
Follow the instructions on pp. 264-271
Make sure to point IR pairs downward as
detailed in text
15 1 4 V dd 13 1 2
6- 9VD C
9 V dc
B a t t er y
R ed
Bl ack
X4
X5
V dd
V in
VVssss
V ss
X3
P1
P 3 P 15
P 5 P 14
P 7 P 13
P 9 P 12
P 11 P 11
P 13 P 10
P 15 P 9
V in P 8
X1
P7
P6
P5
P4
P3
+
R eset
P2
P1
P0
X2
0 1 2
B o a r d o f E d uc a t i o n
Pw r
R ev C
© 2 000 -2 003
22” (56 cm)
Start
TM
ST
i n AM PS
C LAS S
© 200 0- 200 3
R ev C
1 2
X1
X3
V ss
X3
P1
P 3 P1
P 155
P 5 P1
P 144
P 133
P 7 P1
P 122
P 9 P1
P 111
P 11 P1
P 1 3 P1
P 100
P 1 5 PP99
P8
V i n P8
P7
P7
P6
P6
P5
P5
P4
P4
P3
P3
P2
P2
P1
P1
P0
P0
X2
Pw r
B o a rd o f E d u ca t i o n
+
Vd d
V in
X4
V ss
X5
R ed
B lac k
9Vdc
B a t e ry
6- 9V DC
1514
V dd
1312
P9
P8
R ese t
P 11
P 10
0
P 14
P 13
P 12
Vs s
P0
P2
P4
P6
P8
P1 0
P1 2
P1 4
Vd d
U1
w w w . st a m ps i nc la ss .c om
V in
V ss
R st
V dd
P 15
P 14
P 13
P 12
P 11
P6
P7
P 10
P9
P8
P1
P2
P3
P4
P5
U1
V ss
R st
V dd
P 15
1
S in
AT N
V ss
P0
V ss
P0
P2
P4
P6
P8
P 10
P 12
P 14
V dd
P5
P6
P7
V in
w w w .s t am ps in cl as s. co m
TM
S out
S in
ATN
V ss
P0
P1
P2
P3
P4
S TAM
iC
n
PS
LAS S
1
S out
Finish
28” (70 cm)
27
Focus on Proportional Control
The Boe-Bot will follow a moving object by maintaining a
constant distance from it. The amount of correction is directly
proportional to the error. That is, the Boe-Bot will speed up or
slow down a varying amount, depending on how far away the
object is.
Distance
Reading
Meaning
Left Wheel
PULSOUT
Wheel
Direction
Robot motion
0
Far Away
650
Clockwise
Backward fast
2
Desired
distance
680
Clockwise
Backward slow
5
Very close
750
Stopped
Stopped
820
Counterclockwise
Forward slow
850
Counterclockwise
Forward fast
28
Proportional Control Block Diagram
Center pulse width
750
Output
adjust
+70
Error = -2
Kp X error
-35 X -2
+
-
+
+
Left servo
output
820
Measured left
distance = 4
System
Desired
Distance
Measured
Distance
Boe-Bot is…
What to
do…
Error
Output
Adjustment
Left Servo
Output
Robot Motion
2
4
A bit too close
Go backward
2–4 =
-2
-35 * -2 =
-70
750 + (-70) =
680
Backwards slow
2
5
Much too close
Go backward
2-5 =
-3
-35 * -3 =
-105
750 + (-105)
= 645
Backwards fast
2
1
Much too far
away
Go forward
?
?
?
?
2
2
A bit too far
away
?
?
?
?
?
29
The End
We hope you enjoyed this Educator's Course
Don't hesitate to contact us for any reason!
30