a little assistance
Archiver
Posts: 46,084
Hi all!
Here is a program that I have running on my bot for collision avoidance.
The problenm I have with it is that the halls in the school where I
will be using this are bad to echo. The three sonars ping sequentially
about 150ms apart and from what I can tell, the sonars are picking up
the echoes from each other and getting false triggering. This makes the
bot erratic when traversing the halls.
Example:
scenario 1
left sonar fires and gets satisfied (recieves an echo)
center sonar fires and gets an echo but it may be the ping from the left
sonar that was echoing down the hall so it thinks there is an obstacle
in close range. Bot puts on the brakes. . .
scenario 2
center sonar fires and determines there is nothing in the way so the
right sonar fires and recieves an echo which may be the echo from center
echoing back from down the hall and it thinks there is a wall or
obstacle on the right so it veers left. There was no obstacle on the right.
Following is the entire code for the program.
Anyone who can assist or help me write it to be more stable, or just
give suggestions, I would appreciate it!
Thanks
Doug Simpson
Code follows. . .
*****************************************
'Triple Sonar, Dual Motor Robot Vision and Guidance System
'For Basic Stamp 2sx only.
'Forward motor control only at this time. Strictly collision avoidance.
'No other functions at this time
'declaration of constants
pingl con 15 'Sets ping output left on pin 15
pingc con 14 'Sets ping output center on pin 14
pingr con 13 'Sets ping output right on pin13
retl con 10 'Sets echo input left on pin 10
retc con 9 'Sets echo input center on pin 9
retr con 8 'Sets echo input right on pin 8
ena con 11 'Sets output to enable (power to sonars) on 11
serv con 12 'Sets servo output on pin 12
ir con 7 'Sets infrared detect input on pin 7
timel var word 'variable for the rctime on left sonar
timec var word 'variable for the rctime on center sonar
timer var word 'variable for the rctime on right sonar
inchesl var byte 'variable for inches left
inchesc var byte 'variable for inches canter
inchesr var byte 'variable for inches right
inchl var byte 'variable for inches left for direction sensing
inchr var byte 'variable for inches right for direction sensing
vector var word 'variable for the location of the sonar servo
check var byte 'variable for
vcheck var byte 'variable for
stiml var word 'variable for directional determination
stimr var word 'variable for directional determination
stimc var word 'variable for collision avoidance
inchc var byte 'converted inches for collision avoidance
rot var word 'rotational variable
rot = 500 'sets duration of rotation - 500 is roughly 1/2 second
vector = 1800 'sets the servo to center DO NOT CHANGE
start:
output ena
output pingl
output pingc
output pingr
output serv
input retl
input retc
input retr
input ir
low pingl 'turn pingl off
low pingc 'turn pingc off
low pingr 'turn pingr off
high ena 'high turns off power to the sonar modules
gosub center 'jump to servo center routine
tping:
low ena 'turn power on
pause 5 'wait a tad
high pingl 'execute a ping
pulsout 0,1500 'wait 1.2ms (dummy line)
rctime retl,0,timel 'now, wait for echo pulse
timel = timel*2
inchesl = timel/375+11 'convert time in microseconds to inches
'could be done just on the timel, timec and timer data but
'easier to set the distances in inches than miliseconds
low pingl 'turn ping off
pause 50
high pingc 'same as above only on center sonar
pulsout 0,1500 'starts the rctime timer in the Stamp
rctime retc,0,timec 'to get the time in microseconds
timec = timec*2
inchesc = timec/375+11 'do some math to determine inches (approximate)
low pingc 'turn ping off
pause 50
high pingr 'same as above only on right sonar
pulsout 0,1500
rctime retr,0,timer
timer = timer*2
inchesr = timer/375+11
low pingr
high ena 'turn power off
pause 150 'wait a bit 'sonars must be powered off between pings and
'this delay assures ample time to discharge the
'filters on the sonar modules
display:
if inchesc <60 then sonar 'if inches on center are less than 60 then jump to
label sonar
if inchesc >60 then free 'if inches on center are greater than 60 then jump to
label free
sonar:
low 1:low 2:low 3:low 4 'stop motors
pause 2000
vector = 2700 'sets servo vector for directional determination DO NOT CHANGE
gosub seek 'jump to label seek
free:
'debug dec inchesl, " inches left ",dec inchesc, " inches center ",dec inchesr,
" inches right ",cr
if inchesl >50 and inchesr >50 then forward 'no errors
if inchesl <50 and inchesr >50 then veerr 'something close on left - veer right
if inchesl >50 and inchesr <50 then veerl 'something close on right - veer left
if inchesl <50 and inchesr <50 then sonar 'something close on both - examine
with servo seek
'goto tping 'ping again (unneeded line - left for revision history)
seek: 'routine to determine direction of least obstacles
low ena 'extra ping to make sure the <40 on center is actually an inanimate
object
pause 5 'and not a person or other moving object
high pingc
pulsout 0,1500
rctime retc,0,stimc
stimc = stimc*2
inchc = stimc/375+11
low pingc
high ena
''debug dec inchesc, " inches ",cr
pause 200
if inchc >60 then tping 'if center obstacle is cleared, continue on forward -
if not, determine
'path of least obstacles
vector = 2700 'servo vector right to ping for obstacle DO NOT CHANGE
for vcheck = 1 to 50 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
low ena 'ping for obstacle
pause 5
high pingc
pulsout 0,1500
rctime retc,0,stimr
stimr = stimr*2
inchr = stimr/375+11
low pingc
high ena
'debug dec inchesr, " inches right ",cr
pause 150
vector = 700 'servo vector left to ping for obstacle DO NOT CHANGE
for vcheck = 1 to 50 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
low ena 'ping for obstacle
pause 5
high pingc
pulsout 0,1500
rctime retc,0,stiml
stiml = stiml*2
inchl = stiml/375+11
low pingc
high ena
'debug dec inchesl, " inches left ",cr
pause 150
center: 'Center servo centering routine
for vcheck = 1 to 50 'DO NOT CHANGE
vector = 1650 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
if inchl < inchr then rotr 'if obstacle is closer on the left, then rotate right
if inchr < inchl then rotl 'if obstacle is closer on the right, then rotate left
rotr:
'debug " rotate right ",cr,cr
high 1: low 2:low 3:low 4 'Turns on left motor forward to rotate right
pause rot 'sets the rotate -on- delay
goto rotf
rotl:
'debug " rotate left ",cr,cr
low 1:low 2:low 3:high 4 'Turns on right motor forward to rotate left
pause rot
goto rotf
rotf:
low 1:low 2:low 3:low 4 'turns off motors
pause 500 'wait a bit for coastdown (no braking implemented yet)
return
forward: 'run motors forward
high 1:high 4
'debug " forward ",cr
goto tping 'return to start of main routine
veerr: 'run left forward motor only
high 1:low 4
'debug " veerr ",cr
goto tping
veerl: 'run right forward motor only
'debug " veerl ",cr
low 1:high 4
goto tping
Here is a program that I have running on my bot for collision avoidance.
The problenm I have with it is that the halls in the school where I
will be using this are bad to echo. The three sonars ping sequentially
about 150ms apart and from what I can tell, the sonars are picking up
the echoes from each other and getting false triggering. This makes the
bot erratic when traversing the halls.
Example:
scenario 1
left sonar fires and gets satisfied (recieves an echo)
center sonar fires and gets an echo but it may be the ping from the left
sonar that was echoing down the hall so it thinks there is an obstacle
in close range. Bot puts on the brakes. . .
scenario 2
center sonar fires and determines there is nothing in the way so the
right sonar fires and recieves an echo which may be the echo from center
echoing back from down the hall and it thinks there is a wall or
obstacle on the right so it veers left. There was no obstacle on the right.
Following is the entire code for the program.
Anyone who can assist or help me write it to be more stable, or just
give suggestions, I would appreciate it!
Thanks
Doug Simpson
Code follows. . .
*****************************************
'Triple Sonar, Dual Motor Robot Vision and Guidance System
'For Basic Stamp 2sx only.
'Forward motor control only at this time. Strictly collision avoidance.
'No other functions at this time
'declaration of constants
pingl con 15 'Sets ping output left on pin 15
pingc con 14 'Sets ping output center on pin 14
pingr con 13 'Sets ping output right on pin13
retl con 10 'Sets echo input left on pin 10
retc con 9 'Sets echo input center on pin 9
retr con 8 'Sets echo input right on pin 8
ena con 11 'Sets output to enable (power to sonars) on 11
serv con 12 'Sets servo output on pin 12
ir con 7 'Sets infrared detect input on pin 7
timel var word 'variable for the rctime on left sonar
timec var word 'variable for the rctime on center sonar
timer var word 'variable for the rctime on right sonar
inchesl var byte 'variable for inches left
inchesc var byte 'variable for inches canter
inchesr var byte 'variable for inches right
inchl var byte 'variable for inches left for direction sensing
inchr var byte 'variable for inches right for direction sensing
vector var word 'variable for the location of the sonar servo
check var byte 'variable for
vcheck var byte 'variable for
stiml var word 'variable for directional determination
stimr var word 'variable for directional determination
stimc var word 'variable for collision avoidance
inchc var byte 'converted inches for collision avoidance
rot var word 'rotational variable
rot = 500 'sets duration of rotation - 500 is roughly 1/2 second
vector = 1800 'sets the servo to center DO NOT CHANGE
start:
output ena
output pingl
output pingc
output pingr
output serv
input retl
input retc
input retr
input ir
low pingl 'turn pingl off
low pingc 'turn pingc off
low pingr 'turn pingr off
high ena 'high turns off power to the sonar modules
gosub center 'jump to servo center routine
tping:
low ena 'turn power on
pause 5 'wait a tad
high pingl 'execute a ping
pulsout 0,1500 'wait 1.2ms (dummy line)
rctime retl,0,timel 'now, wait for echo pulse
timel = timel*2
inchesl = timel/375+11 'convert time in microseconds to inches
'could be done just on the timel, timec and timer data but
'easier to set the distances in inches than miliseconds
low pingl 'turn ping off
pause 50
high pingc 'same as above only on center sonar
pulsout 0,1500 'starts the rctime timer in the Stamp
rctime retc,0,timec 'to get the time in microseconds
timec = timec*2
inchesc = timec/375+11 'do some math to determine inches (approximate)
low pingc 'turn ping off
pause 50
high pingr 'same as above only on right sonar
pulsout 0,1500
rctime retr,0,timer
timer = timer*2
inchesr = timer/375+11
low pingr
high ena 'turn power off
pause 150 'wait a bit 'sonars must be powered off between pings and
'this delay assures ample time to discharge the
'filters on the sonar modules
display:
if inchesc <60 then sonar 'if inches on center are less than 60 then jump to
label sonar
if inchesc >60 then free 'if inches on center are greater than 60 then jump to
label free
sonar:
low 1:low 2:low 3:low 4 'stop motors
pause 2000
vector = 2700 'sets servo vector for directional determination DO NOT CHANGE
gosub seek 'jump to label seek
free:
'debug dec inchesl, " inches left ",dec inchesc, " inches center ",dec inchesr,
" inches right ",cr
if inchesl >50 and inchesr >50 then forward 'no errors
if inchesl <50 and inchesr >50 then veerr 'something close on left - veer right
if inchesl >50 and inchesr <50 then veerl 'something close on right - veer left
if inchesl <50 and inchesr <50 then sonar 'something close on both - examine
with servo seek
'goto tping 'ping again (unneeded line - left for revision history)
seek: 'routine to determine direction of least obstacles
low ena 'extra ping to make sure the <40 on center is actually an inanimate
object
pause 5 'and not a person or other moving object
high pingc
pulsout 0,1500
rctime retc,0,stimc
stimc = stimc*2
inchc = stimc/375+11
low pingc
high ena
''debug dec inchesc, " inches ",cr
pause 200
if inchc >60 then tping 'if center obstacle is cleared, continue on forward -
if not, determine
'path of least obstacles
vector = 2700 'servo vector right to ping for obstacle DO NOT CHANGE
for vcheck = 1 to 50 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
low ena 'ping for obstacle
pause 5
high pingc
pulsout 0,1500
rctime retc,0,stimr
stimr = stimr*2
inchr = stimr/375+11
low pingc
high ena
'debug dec inchesr, " inches right ",cr
pause 150
vector = 700 'servo vector left to ping for obstacle DO NOT CHANGE
for vcheck = 1 to 50 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
low ena 'ping for obstacle
pause 5
high pingc
pulsout 0,1500
rctime retc,0,stiml
stiml = stiml*2
inchl = stiml/375+11
low pingc
high ena
'debug dec inchesl, " inches left ",cr
pause 150
center: 'Center servo centering routine
for vcheck = 1 to 50 'DO NOT CHANGE
vector = 1650 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
if inchl < inchr then rotr 'if obstacle is closer on the left, then rotate right
if inchr < inchl then rotl 'if obstacle is closer on the right, then rotate left
rotr:
'debug " rotate right ",cr,cr
high 1: low 2:low 3:low 4 'Turns on left motor forward to rotate right
pause rot 'sets the rotate -on- delay
goto rotf
rotl:
'debug " rotate left ",cr,cr
low 1:low 2:low 3:high 4 'Turns on right motor forward to rotate left
pause rot
goto rotf
rotf:
low 1:low 2:low 3:low 4 'turns off motors
pause 500 'wait a bit for coastdown (no braking implemented yet)
return
forward: 'run motors forward
high 1:high 4
'debug " forward ",cr
goto tping 'return to start of main routine
veerr: 'run left forward motor only
high 1:low 4
'debug " veerr ",cr
goto tping
veerl: 'run right forward motor only
'debug " veerl ",cr
low 1:high 4
goto tping
Comments
seconds apart may be far to close together for the environment (hallway is
an echo chamber) and the speed (slow) which a robot would normally want to
navigate in a hallway presumably with human pedestrian traffic. You could
get by with fewer pings with built in pauses in your code after each ping
command. If you can't control the ping rate, would it be feasible to turn
the sonar on and off to accomplish this? Ask the manufacturer if there is a
resistor or cap you can place somewhere to reduce the ping rate(simple
hardware fix unless its super miniaturized). Could you desensitize your
"ears" with a sort of earmuff, how about giving your "ears" external sound
absorbing tubes, giving them directional filtering?
Original Message
From: Doug Simpson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=RR4bL1_57BBrEBpJ34-Xsa39mPPilYoCjHRGdQXDuvZxTUF863kMTjQDFVQ6T12bcO9eYetqQIzZ]veewee77@a...[/url
Sent: Saturday, July 19, 2003 1:18 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] a little assistance
Hi all!
Here is a program that I have running on my bot for collision avoidance.
The problenm I have with it is that the halls in the school where I
will be using this are bad to echo. The three sonars ping sequentially
about 150ms apart and from what I can tell, the sonars are picking up
the echoes from each other and getting false triggering. This makes the
bot erratic when traversing the halls.
Example:
scenario 1
left sonar fires and gets satisfied (recieves an echo)
center sonar fires and gets an echo but it may be the ping from the left
sonar that was echoing down the hall so it thinks there is an obstacle
in close range. Bot puts on the brakes. . .
scenario 2
center sonar fires and determines there is nothing in the way so the
right sonar fires and recieves an echo which may be the echo from center
echoing back from down the hall and it thinks there is a wall or
obstacle on the right so it veers left. There was no obstacle on the right.
Following is the entire code for the program.
Anyone who can assist or help me write it to be more stable, or just
give suggestions, I would appreciate it!
Thanks
Doug Simpson
Code follows. . .
*****************************************
'Triple Sonar, Dual Motor Robot Vision and Guidance System
'For Basic Stamp 2sx only.
'Forward motor control only at this time. Strictly collision avoidance.
'No other functions at this time
'declaration of constants
pingl con 15 'Sets ping output left on pin 15
pingc con 14 'Sets ping output center on pin 14
pingr con 13 'Sets ping output right on pin13
retl con 10 'Sets echo input left on pin 10
retc con 9 'Sets echo input center on pin 9
retr con 8 'Sets echo input right on pin 8
ena con 11 'Sets output to enable (power to sonars) on 11
serv con 12 'Sets servo output on pin 12
ir con 7 'Sets infrared detect input on pin 7
timel var word 'variable for the rctime on left sonar
timec var word 'variable for the rctime on center sonar
timer var word 'variable for the rctime on right sonar
inchesl var byte 'variable for inches left
inchesc var byte 'variable for inches canter
inchesr var byte 'variable for inches right
inchl var byte 'variable for inches left for direction sensing
inchr var byte 'variable for inches right for direction sensing
vector var word 'variable for the location of the sonar servo
check var byte 'variable for
vcheck var byte 'variable for
stiml var word 'variable for directional determination
stimr var word 'variable for directional determination
stimc var word 'variable for collision avoidance
inchc var byte 'converted inches for collision avoidance
rot var word 'rotational variable
rot = 500 'sets duration of rotation - 500 is roughly 1/2 second
vector = 1800 'sets the servo to center DO NOT CHANGE
start:
output ena
output pingl
output pingc
output pingr
output serv
input retl
input retc
input retr
input ir
low pingl 'turn pingl off
low pingc 'turn pingc off
low pingr 'turn pingr off
high ena 'high turns off power to the sonar modules
gosub center 'jump to servo center routine
tping:
low ena 'turn power on
pause 5 'wait a tad
high pingl 'execute a ping
pulsout 0,1500 'wait 1.2ms (dummy line)
rctime retl,0,timel 'now, wait for echo pulse
timel = timel*2
inchesl = timel/375+11 'convert time in microseconds to inches
'could be done just on the timel, timec and timer data but
'easier to set the distances in inches than miliseconds
low pingl 'turn ping off
pause 50
high pingc 'same as above only on center sonar
pulsout 0,1500 'starts the rctime timer in the Stamp
rctime retc,0,timec 'to get the time in microseconds
timec = timec*2
inchesc = timec/375+11 'do some math to determine inches (approximate)
low pingc 'turn ping off
pause 50
high pingr 'same as above only on right sonar
pulsout 0,1500
rctime retr,0,timer
timer = timer*2
inchesr = timer/375+11
low pingr
high ena 'turn power off
pause 150 'wait a bit 'sonars must be powered off between pings and
'this delay assures ample time to discharge the
'filters on the sonar modules
display:
if inchesc <60 then sonar 'if inches on center are less than 60 then jump to
label sonar
if inchesc >60 then free 'if inches on center are greater than 60 then jump
to label free
sonar:
low 1:low 2:low 3:low 4 'stop motors
pause 2000
vector = 2700 'sets servo vector for directional determination DO NOT
CHANGE
gosub seek 'jump to label seek
free:
'debug dec inchesl, " inches left ",dec inchesc, " inches center ",dec
inchesr, " inches right ",cr
if inchesl >50 and inchesr >50 then forward 'no errors
if inchesl <50 and inchesr >50 then veerr 'something close on left - veer
right
if inchesl >50 and inchesr <50 then veerl 'something close on right - veer
left
if inchesl <50 and inchesr <50 then sonar 'something close on both -
examine with servo seek
'goto tping 'ping again (unneeded line - left for revision history)
seek: 'routine to determine direction of least obstacles
low ena 'extra ping to make sure the <40 on center is actually an
inanimate object
pause 5 'and not a person or other moving object
high pingc
pulsout 0,1500
rctime retc,0,stimc
stimc = stimc*2
inchc = stimc/375+11
low pingc
high ena
''debug dec inchesc, " inches ",cr
pause 200
if inchc >60 then tping 'if center obstacle is cleared, continue on
forward - if not, determine
'path of least obstacles
vector = 2700 'servo vector right to ping for obstacle DO NOT CHANGE
for vcheck = 1 to 50 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
low ena 'ping for obstacle
pause 5
high pingc
pulsout 0,1500
rctime retc,0,stimr
stimr = stimr*2
inchr = stimr/375+11
low pingc
high ena
'debug dec inchesr, " inches right ",cr
pause 150
vector = 700 'servo vector left to ping for obstacle DO NOT CHANGE
for vcheck = 1 to 50 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
low ena 'ping for obstacle
pause 5
high pingc
pulsout 0,1500
rctime retc,0,stiml
stiml = stiml*2
inchl = stiml/375+11
low pingc
high ena
'debug dec inchesl, " inches left ",cr
pause 150
center: 'Center servo centering routine
for vcheck = 1 to 50 'DO NOT CHANGE
vector = 1650 'DO NOT CHANGE
pulsout serv,vector 'DO NOT CHANGE
pause 20 'DO NOT CHANGE
next 'DO NOT CHANGE
if inchl < inchr then rotr 'if obstacle is closer on the left, then rotate
right
if inchr < inchl then rotl 'if obstacle is closer on the right, then rotate
left
rotr:
'debug " rotate right ",cr,cr
high 1: low 2:low 3:low 4 'Turns on left motor forward to rotate right
pause rot 'sets the rotate -on- delay
goto rotf
rotl:
'debug " rotate left ",cr,cr
low 1:low 2:low 3:high 4 'Turns on right motor forward to rotate left
pause rot
goto rotf
rotf:
low 1:low 2:low 3:low 4 'turns off motors
pause 500 'wait a bit for coastdown (no braking implemented yet)
return
forward: 'run motors forward
high 1:high 4
'debug " forward ",cr
goto tping 'return to start of main routine
veerr: 'run left forward motor only
high 1:low 4
'debug " veerr ",cr
goto tping
veerl: 'run right forward motor only
'debug " veerl ",cr
low 1:high 4
goto tping
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
different 'ping's. Clearly the echo-ness of your
hallway means you need more time to let the
echo's die. Try 100 mSec, or 200 mSec and
see what happens.
--- In basicstamps@yahoogroups.com, Doug Simpson <veewee77@a...>
wrote:
> Hi all!
>
> Here is a program that I have running on my bot for collision
avoidance.
> The problenm I have with it is that the halls in the school where
I
> will be using this are bad to echo. The three sonars ping
sequentially
> about 150ms apart and from what I can tell, the sonars are picking
up
> the echoes from each other and getting false triggering. This
makes the
> bot erratic when traversing the halls.
>
> Example:
> scenario 1
> left sonar fires and gets satisfied (recieves an echo)
>
> center sonar fires and gets an echo but it may be the ping from the
left
> sonar that was echoing down the hall so it thinks there is an
obstacle
> in close range. Bot puts on the brakes. . .
>
> scenario 2
> center sonar fires and determines there is nothing in the way so
the
> right sonar fires and recieves an echo which may be the echo from
center
> echoing back from down the hall and it thinks there is a wall or
> obstacle on the right so it veers left. There was no obstacle on
the right.
>
> Following is the entire code for the program.
> Anyone who can assist or help me write it to be more stable, or
just
> give suggestions, I would appreciate it!
>
> Thanks
>
> Doug Simpson
>
> Code follows. . .
> *****************************************
>
> 'Triple Sonar, Dual Motor Robot Vision and Guidance System
>
> 'For Basic Stamp 2sx only.
>
> 'Forward motor control only at this time. Strictly collision
avoidance.
>
> 'No other functions at this time
>
>
> 'declaration of constants
>
>
> pingl con 15 'Sets ping output left on pin
15
>
> pingc con 14 'Sets ping output center on
pin 14
>
> pingr con 13 'Sets ping output right on
pin13
>
> retl con 10 'Sets echo input left on pin
10
>
> retc con 9 'Sets echo input center on
pin 9
>
> retr con 8 'Sets echo input right on pin
8
>
> ena con 11 'Sets output to enable (power
to sonars) on 11
>
> serv con 12 'Sets servo output on pin 12
>
> ir con 7 'Sets infrared detect input
on pin 7
>
> timel var word 'variable for the rctime on
left sonar
>
> timec var word 'variable for the rctime on
center sonar
>
> timer var word 'variable for the rctime on
right sonar
>
> inchesl var byte 'variable for inches left
>
> inchesc var byte 'variable for inches canter
>
> inchesr var byte 'variable for inches right
>
> inchl var byte 'variable for inches left for
direction sensing
>
> inchr var byte 'variable for inches right
for direction sensing
>
> vector var word 'variable for the location of
the sonar servo
>
> check var byte 'variable for
>
> vcheck var byte 'variable for
>
> stiml var word 'variable for directional
determination
>
> stimr var word 'variable for directional
determination
>
> stimc var word 'variable for collision
avoidance
>
> inchc var byte 'converted inches for
collision avoidance
>
> rot var word 'rotational variable
>
> rot = 500 'sets duration of rotation -
500 is roughly 1/2 second
>
> vector = 1800 'sets the servo to center DO NOT
CHANGE
>
>
> start:
>
>
> output ena
>
> output pingl
>
> output pingc
>
> output pingr
>
> output serv
>
> input retl
>
> input retc
>
> input retr
>
> input ir
>
>
> low pingl 'turn pingl off
>
> low pingc 'turn pingc off
>
> low pingr 'turn pingr off
>
> high ena 'high turns off power to the
sonar modules
>
> gosub center 'jump to servo center routine
>
>
> tping:
>
>
> low ena 'turn power on
>
> pause 5 'wait a tad
>
> high pingl 'execute a ping
>
> pulsout 0,1500 'wait 1.2ms (dummy line)
>
> rctime retl,0,timel 'now, wait for echo pulse
>
> timel = timel*2
>
> inchesl = timel/375+11 'convert time in microseconds
to inches
>
> 'could be done just on the
timel, timec and timer data but
>
> 'easier to set the distances
in inches than miliseconds
>
>
> low pingl 'turn ping off
>
> pause 50
>
>
> high pingc 'same as above only on center
sonar
>
> pulsout 0,1500 'starts the rctime timer in
the Stamp
>
> rctime retc,0,timec 'to get the time in microseconds
>
> timec = timec*2
>
> inchesc = timec/375+11 'do some math to determine
inches (approximate)
>
> low pingc 'turn ping off
>
> pause 50
>
>
> high pingr 'same as above only on right
sonar
>
> pulsout 0,1500
>
> rctime retr,0,timer
>
> timer = timer*2
>
> inchesr = timer/375+11
>
> low pingr
>
>
> high ena 'turn power off
>
> pause 150 'wait a bit 'sonars must
be powered off between pings and
>
> 'this delay assures ample
time to discharge the
>
> 'filters on the sonar modules
>
>
> display:
>
> if inchesc <60 then sonar 'if inches on center are less than 60
then jump to label sonar
>
> if inchesc >60 then free 'if inches on center are greater than
60 then jump to label free
>
>
> sonar:
>
> low 1:low 2:low 3:low 4 'stop motors
>
> pause 2000
>
>
> vector = 2700 'sets servo vector for directional
determination DO NOT CHANGE
>
> gosub seek 'jump to label seek
>
> free:
>
> 'debug dec inchesl, " inches left ",dec inchesc, " inches
center ",dec inchesr, " inches right ",cr
>
>
> if inchesl >50 and inchesr >50 then forward 'no errors
>
> if inchesl <50 and inchesr >50 then veerr 'something
close on left - veer right
>
> if inchesl >50 and inchesr <50 then veerl 'something
close on right - veer left
>
> if inchesl <50 and inchesr <50 then sonar 'something
close on both - examine with servo seek
>
>
> 'goto tping 'ping again (unneeded line -
left for revision history)
>
>
> seek: 'routine to determine
direction of least obstacles
>
>
> low ena 'extra ping to make sure the
<40 on center is actually an inanimate object
>
> pause 5 'and not a person or other
moving object
>
> high pingc
>
> pulsout 0,1500
>
> rctime retc,0,stimc
>
> stimc = stimc*2
>
> inchc = stimc/375+11
>
> low pingc
>
> high ena
>
> ''debug dec inchesc, " inches ",cr
>
> pause 200
>
>
> if inchc >60 then tping 'if center obstacle is
cleared, continue on forward - if not, determine
>
> 'path of least obstacles
>
>
> vector = 2700 'servo vector right to ping for
obstacle DO NOT CHANGE
>
> for vcheck = 1 to 50 'DO NOT CHANGE
>
> pulsout serv,vector 'DO NOT CHANGE
>
> pause 20 'DO NOT CHANGE
>
> next 'DO NOT CHANGE
>
> low ena 'ping for obstacle
>
> pause 5
>
> high pingc
>
> pulsout 0,1500
>
> rctime retc,0,stimr
>
> stimr = stimr*2
>
> inchr = stimr/375+11
>
> low pingc
>
> high ena
>
> 'debug dec inchesr, " inches right ",cr
>
>
> pause 150
>
>
> vector = 700 'servo vector left to ping for
obstacle DO NOT CHANGE
>
> for vcheck = 1 to 50 'DO NOT CHANGE
>
> pulsout serv,vector 'DO NOT CHANGE
>
> pause 20 'DO NOT CHANGE
>
> next 'DO NOT CHANGE
>
> low ena 'ping for obstacle
>
> pause 5
>
> high pingc
>
> pulsout 0,1500
>
> rctime retc,0,stiml
>
> stiml = stiml*2
>
> inchl = stiml/375+11
>
> low pingc
>
> high ena
>
> 'debug dec inchesl, " inches left ",cr
>
>
> pause 150
>
>
>
>
> center: 'Center servo centering
routine
>
> for vcheck = 1 to 50 'DO NOT CHANGE
>
> vector = 1650 'DO NOT CHANGE
>
> pulsout serv,vector 'DO NOT CHANGE
>
> pause 20 'DO NOT CHANGE
>
> next 'DO NOT CHANGE
>
>
> if inchl < inchr then rotr 'if obstacle is closer on the left,
then rotate right
>
> if inchr < inchl then rotl 'if obstacle is closer on the right,
then rotate left
>
>
> rotr:
>
> 'debug " rotate right ",cr,cr
>
> high 1: low 2:low 3:low 4 'Turns on left motor forward to
rotate right
>
> pause rot 'sets the rotate -on- delay
>
> goto rotf
>
>
> rotl:
>
> 'debug " rotate left ",cr,cr
>
> low 1:low 2:low 3:high 4 'Turns on right motor forward to
rotate left
>
>
> pause rot
>
> goto rotf
>
>
> rotf:
>
> low 1:low 2:low 3:low 4 'turns off motors
>
> pause 500 'wait a bit for coastdown (no
braking implemented yet)
>
> return
>
>
> forward: 'run motors forward
>
> high 1:high 4
>
> 'debug " forward ",cr
>
> goto tping 'return to start of main
routine
>
>
> veerr: 'run left forward motor only
>
> high 1:low 4
>
> 'debug " veerr ",cr
>
> goto tping
>
>
> veerl: 'run right forward motor only
>
> 'debug " veerl ",cr
>
> low 1:high 4
>
> goto tping
electric wheelchair and moves at a better than a fast walk pace and the
more delay in object detection the more likely it is to run over something.
Thanks for the input, though. . .
Allan Lane wrote:
>An obvious solution: delay more than 50 mSec between
>different 'ping's. Clearly the echo-ness of your
>hallway means you need more time to let the
>echo's die. Try 100 mSec, or 200 mSec and
>see what happens.
>
>--- In basicstamps@yahoogroups.com, Doug Simpson <veewee77@a...>
>wrote:
>
>
>>Hi all!
>>
>>Here is a program that I have running on my bot for collision
>>
>>
>avoidance.
>
>
>> The problenm I have with it is that the halls in the school where
>>
>>
>I
>
>
>>will be using this are bad to echo. The three sonars ping
>>
>>
>sequentially
>
>
>>about 150ms apart and from what I can tell, the sonars are picking
>>
>>
>up
>
>
>>the echoes from each other and getting false triggering. This
>>
>>
>makes the
>
>
>>bot erratic when traversing the halls.
>>
>>Example:
>>scenario 1
>>left sonar fires and gets satisfied (recieves an echo)
>>
>>center sonar fires and gets an echo but it may be the ping from the
>>
>>
>left
>
>
>>sonar that was echoing down the hall so it thinks there is an
>>
>>
>obstacle
>
>
>>in close range. Bot puts on the brakes. . .
>>
>>scenario 2
>>center sonar fires and determines there is nothing in the way so
>>
>>
>the
>
>
>>right sonar fires and recieves an echo which may be the echo from
>>
>>
>center
>
>
>>echoing back from down the hall and it thinks there is a wall or
>>obstacle on the right so it veers left. There was no obstacle on
>>
>>
>the right.
>
>
>>Following is the entire code for the program.
>>Anyone who can assist or help me write it to be more stable, or
>>
>>
>just
>
>
>>give suggestions, I would appreciate it!
>>
>>Thanks
>>
>>Doug Simpson
>>
>>Code follows. . .
>>*****************************************
>>
>>'Triple Sonar, Dual Motor Robot Vision and Guidance System
>>
>>'For Basic Stamp 2sx only.
>>
>>'Forward motor control only at this time. Strictly collision
>>
>>
>avoidance.
>
>
>>'No other functions at this time
>>
>>
>>'declaration of constants
>>
>>
>>pingl con 15 'Sets ping output left on pin
>>
>>
>15
>
>
>>pingc con 14 'Sets ping output center on
>>
>>
>pin 14
>
>
>>pingr con 13 'Sets ping output right on
>>
>>
>pin13
>
>
>>retl con 10 'Sets echo input left on pin
>>
>>
>10
>
>
>>retc con 9 'Sets echo input center on
>>
>>
>pin 9
>
>
>>retr con 8 'Sets echo input right on pin
>>
>>
>8
>
>
>>ena con 11 'Sets output to enable (power
>>
>>
>to sonars) on 11
>
>
>>serv con 12 'Sets servo output on pin 12
>>
>>ir con 7 'Sets infrared detect input
>>
>>
>on pin 7
>
>
>>timel var word 'variable for the rctime on
>>
>>
>left sonar
>
>
>>timec var word 'variable for the rctime on
>>
>>
>center sonar
>
>
>>timer var word 'variable for the rctime on
>>
>>
>right sonar
>
>
>>inchesl var byte 'variable for inches left
>>
>>inchesc var byte 'variable for inches canter
>>
>>inchesr var byte 'variable for inches right
>>
>>inchl var byte 'variable for inches left for
>>
>>
>direction sensing
>
>
>>inchr var byte 'variable for inches right
>>
>>
>for direction sensing
>
>
>>vector var word 'variable for the location of
>>
>>
>the sonar servo
>
>
>>check var byte 'variable for
>>
>>vcheck var byte 'variable for
>>
>>stiml var word 'variable for directional
>>
>>
>determination
>
>
>>stimr var word 'variable for directional
>>
>>
>determination
>
>
>>stimc var word 'variable for collision
>>
>>
>avoidance
>
>
>>inchc var byte 'converted inches for
>>
>>
>collision avoidance
>
>
>>rot var word 'rotational variable
>>
>>rot = 500 'sets duration of rotation -
>>
>>
>500 is roughly 1/2 second
>
>
>>vector = 1800 'sets the servo to center DO NOT
>>
>>
>CHANGE
>
>
>>start:
>>
>>
>>output ena
>>
>>output pingl
>>
>>output pingc
>>
>>output pingr
>>
>>output serv
>>
>>input retl
>>
>>input retc
>>
>>input retr
>>
>>input ir
>>
>>
>>low pingl 'turn pingl off
>>
>>low pingc 'turn pingc off
>>
>>low pingr 'turn pingr off
>>
>>high ena 'high turns off power to the
>>
>>
>sonar modules
>
>
>>gosub center 'jump to servo center routine
>>
>>
>>tping:
>>
>>
>>low ena 'turn power on
>>
>>pause 5 'wait a tad
>>
>>high pingl 'execute a ping
>>
>>pulsout 0,1500 'wait 1.2ms (dummy line)
>>
>>rctime retl,0,timel 'now, wait for echo pulse
>>
>>timel = timel*2
>>
>>inchesl = timel/375+11 'convert time in microseconds
>>
>>
>to inches
>
>
>> 'could be done just on the
>>
>>
>timel, timec and timer data but
>
>
>> 'easier to set the distances
>>
>>
>in inches than miliseconds
>
>
>>low pingl 'turn ping off
>>
>>pause 50
>>
>>
>>high pingc 'same as above only on center
>>
>>
>sonar
>
>
>>pulsout 0,1500 'starts the rctime timer in
>>
>>
>the Stamp
>
>
>>rctime retc,0,timec 'to get the time in microseconds
>>
>>timec = timec*2
>>
>>inchesc = timec/375+11 'do some math to determine
>>
>>
>inches (approximate)
>
>
>>low pingc 'turn ping off
>>
>>pause 50
>>
>>
>>high pingr 'same as above only on right
>>
>>
>sonar
>
>
>>pulsout 0,1500
>>
>>rctime retr,0,timer
>>
>>timer = timer*2
>>
>>inchesr = timer/375+11
>>
>>low pingr
>>
>>
>>high ena 'turn power off
>>
>>pause 150 'wait a bit 'sonars must
>>
>>
>be powered off between pings and
>
>
>> 'this delay assures ample
>>
>>
>time to discharge the
>
>
>> 'filters on the sonar modules
>>
>>
>>display:
>>
>>if inchesc <60 then sonar 'if inches on center are less than 60
>>
>>
>then jump to label sonar
>
>
>>if inchesc >60 then free 'if inches on center are greater than
>>
>>
>60 then jump to label free
>
>
>>sonar:
>>
>>low 1:low 2:low 3:low 4 'stop motors
>>
>>pause 2000
>>
>>
>>vector = 2700 'sets servo vector for directional
>>
>>
>determination DO NOT CHANGE
>
>
>>gosub seek 'jump to label seek
>>
>>free:
>>
>>'debug dec inchesl, " inches left ",dec inchesc, " inches
>>
>>
>center ",dec inchesr, " inches right ",cr
>
>
>>if inchesl >50 and inchesr >50 then forward 'no errors
>>
>>if inchesl <50 and inchesr >50 then veerr 'something
>>
>>
>close on left - veer right
>
>
>>if inchesl >50 and inchesr <50 then veerl 'something
>>
>>
>close on right - veer left
>
>
>>if inchesl <50 and inchesr <50 then sonar 'something
>>
>>
>close on both - examine with servo seek
>
>
>>'goto tping 'ping again (unneeded line -
>>
>>
>left for revision history)
>
>
>>seek: 'routine to determine
>>
>>
>direction of least obstacles
>
>
>>low ena 'extra ping to make sure the
>>
>>
><40 on center is actually an inanimate object
>
>
>>pause 5 'and not a person or other
>>
>>
>moving object
>
>
>>high pingc
>>
>>pulsout 0,1500
>>
>>rctime retc,0,stimc
>>
>>stimc = stimc*2
>>
>>inchc = stimc/375+11
>>
>>low pingc
>>
>>high ena
>>
>>''debug dec inchesc, " inches ",cr
>>
>>pause 200
>>
>>
>>if inchc >60 then tping 'if center obstacle is
>>
>>
>cleared, continue on forward - if not, determine
>
>
>> 'path of least obstacles
>>
>>
>>vector = 2700 'servo vector right to ping for
>>
>>
>obstacle DO NOT CHANGE
>
>
>>for vcheck = 1 to 50 'DO NOT CHANGE
>>
>>pulsout serv,vector 'DO NOT CHANGE
>>
>>pause 20 'DO NOT CHANGE
>>
>>next 'DO NOT CHANGE
>>
>>low ena 'ping for obstacle
>>
>>pause 5
>>
>>high pingc
>>
>>pulsout 0,1500
>>
>>rctime retc,0,stimr
>>
>>stimr = stimr*2
>>
>>inchr = stimr/375+11
>>
>>low pingc
>>
>>high ena
>>
>>'debug dec inchesr, " inches right ",cr
>>
>>
>>pause 150
>>
>>
>>vector = 700 'servo vector left to ping for
>>
>>
>obstacle DO NOT CHANGE
>
>
>>for vcheck = 1 to 50 'DO NOT CHANGE
>>
>>pulsout serv,vector 'DO NOT CHANGE
>>
>>pause 20 'DO NOT CHANGE
>>
>>next 'DO NOT CHANGE
>>
>>low ena 'ping for obstacle
>>
>>pause 5
>>
>>high pingc
>>
>>pulsout 0,1500
>>
>>rctime retc,0,stiml
>>
>>stiml = stiml*2
>>
>>inchl = stiml/375+11
>>
>>low pingc
>>
>>high ena
>>
>>'debug dec inchesl, " inches left ",cr
>>
>>
>>pause 150
>>
>>
>>
>>
>>center: 'Center servo centering
>>
>>
>routine
>
>
>>for vcheck = 1 to 50 'DO NOT CHANGE
>>
>>vector = 1650 'DO NOT CHANGE
>>
>>pulsout serv,vector 'DO NOT CHANGE
>>
>>pause 20 'DO NOT CHANGE
>>
>>next 'DO NOT CHANGE
>>
>>
>>if inchl < inchr then rotr 'if obstacle is closer on the left,
>>
>>
>then rotate right
>
>
>>if inchr < inchl then rotl 'if obstacle is closer on the right,
>>
>>
>then rotate left
>
>
>>rotr:
>>
>>'debug " rotate right ",cr,cr
>>
>>high 1: low 2:low 3:low 4 'Turns on left motor forward to
>>
>>
>rotate right
>
>
>>pause rot 'sets the rotate -on- delay
>>
>>goto rotf
>>
>>
>>rotl:
>>
>>'debug " rotate left ",cr,cr
>>
>>low 1:low 2:low 3:high 4 'Turns on right motor forward to
>>
>>
>rotate left
>
>
>>pause rot
>>
>>goto rotf
>>
>>
>>rotf:
>>
>>low 1:low 2:low 3:low 4 'turns off motors
>>
>>pause 500 'wait a bit for coastdown (no
>>
>>
>braking implemented yet)
>
>
>>return
>>
>>
>>forward: 'run motors forward
>>
>>high 1:high 4
>>
>>'debug " forward ",cr
>>
>>goto tping 'return to start of main
>>
>>
>routine
>
>
>>veerr: 'run left forward motor only
>>
>>high 1:low 4
>>
>>'debug " veerr ",cr
>>
>>goto tping
>>
>>
>>veerl: 'run right forward motor only
>>
>>'debug " veerl ",cr
>>
>>low 1:high 4
>>
>>goto tping
>>
>>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>
This must be as close to real-time detection as possible since the bot
moves at a better than a fast walk pace. The sooner it detects
obstacles, the sooner it will be able to decide not to run over them.
ds
Bill Katakis wrote:
>I'm not too knowledgeable here but I'll give my 2 cents anyway, :-) 150
>seconds apart may be far to close together for the environment (hallway is
>an echo chamber) and the speed (slow) which a robot would normally want to
>navigate in a hallway presumably with human pedestrian traffic. You could
>get by with fewer pings with built in pauses in your code after each ping
>command. If you can't control the ping rate, would it be feasible to turn
>the sonar on and off to accomplish this? Ask the manufacturer if there is a
>resistor or cap you can place somewhere to reduce the ping rate(simple
>hardware fix unless its super miniaturized). Could you desensitize your
>"ears" with a sort of earmuff, how about giving your "ears" external sound
>absorbing tubes, giving them directional filtering?
>
>
Original Message
>From: Doug Simpson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=4lBg9MuGRr66hU-_awAKM4cp_rOLcRYYNoZ_VJdp9quknLfp_k0SHoxhTQGoMNwqYGqgUCPzGUnAZ-x42MY]veewee77@a...[/url
>Sent: Saturday, July 19, 2003 1:18 AM
>To: basicstamps@yahoogroups.com
>Subject: [noparse][[/noparse]basicstamps] a little assistance
>
>
>Hi all!
>
>Here is a program that I have running on my bot for collision avoidance.
> The problenm I have with it is that the halls in the school where I
>will be using this are bad to echo. The three sonars ping sequentially
>about 150ms apart and from what I can tell, the sonars are picking up
>the echoes from each other and getting false triggering. This makes the
>bot erratic when traversing the halls.
>
>Example:
>scenario 1
>left sonar fires and gets satisfied (recieves an echo)
>
>center sonar fires and gets an echo but it may be the ping from the left
>sonar that was echoing down the hall so it thinks there is an obstacle
>in close range. Bot puts on the brakes. . .
>
>scenario 2
>center sonar fires and determines there is nothing in the way so the
>right sonar fires and recieves an echo which may be the echo from center
>echoing back from down the hall and it thinks there is a wall or
>obstacle on the right so it veers left. There was no obstacle on the right.
>
>Following is the entire code for the program.
>Anyone who can assist or help me write it to be more stable, or just
>give suggestions, I would appreciate it!
>
>Thanks
>
>Doug Simpson
>
>Code follows. . .
>*****************************************
>
>'Triple Sonar, Dual Motor Robot Vision and Guidance System
>
>'For Basic Stamp 2sx only.
>
>'Forward motor control only at this time. Strictly collision avoidance.
>
>'No other functions at this time
>
>
>'declaration of constants
>
>
>pingl con 15 'Sets ping output left on pin 15
>
>pingc con 14 'Sets ping output center on pin 14
>
>pingr con 13 'Sets ping output right on pin13
>
>retl con 10 'Sets echo input left on pin 10
>
>retc con 9 'Sets echo input center on pin 9
>
>retr con 8 'Sets echo input right on pin 8
>
>ena con 11 'Sets output to enable (power to sonars) on 11
>
>serv con 12 'Sets servo output on pin 12
>
>ir con 7 'Sets infrared detect input on pin 7
>
>timel var word 'variable for the rctime on left sonar
>
>timec var word 'variable for the rctime on center sonar
>
>timer var word 'variable for the rctime on right sonar
>
>inchesl var byte 'variable for inches left
>
>inchesc var byte 'variable for inches canter
>
>inchesr var byte 'variable for inches right
>
>inchl var byte 'variable for inches left for direction sensing
>
>inchr var byte 'variable for inches right for direction sensing
>
>vector var word 'variable for the location of the sonar servo
>
>check var byte 'variable for
>
>vcheck var byte 'variable for
>
>stiml var word 'variable for directional determination
>
>stimr var word 'variable for directional determination
>
>stimc var word 'variable for collision avoidance
>
>inchc var byte 'converted inches for collision avoidance
>
>rot var word 'rotational variable
>
>rot = 500 'sets duration of rotation - 500 is roughly 1/2 second
>
>vector = 1800 'sets the servo to center DO NOT CHANGE
>
>
>start:
>
>
>output ena
>
>output pingl
>
>output pingc
>
>output pingr
>
>output serv
>
>input retl
>
>input retc
>
>input retr
>
>input ir
>
>
>low pingl 'turn pingl off
>
>low pingc 'turn pingc off
>
>low pingr 'turn pingr off
>
>high ena 'high turns off power to the sonar modules
>
>gosub center 'jump to servo center routine
>
>
>tping:
>
>
>low ena 'turn power on
>
>pause 5 'wait a tad
>
>high pingl 'execute a ping
>
>pulsout 0,1500 'wait 1.2ms (dummy line)
>
>rctime retl,0,timel 'now, wait for echo pulse
>
>timel = timel*2
>
>inchesl = timel/375+11 'convert time in microseconds to inches
>
> 'could be done just on the timel, timec and timer data but
>
> 'easier to set the distances in inches than miliseconds
>
>
>low pingl 'turn ping off
>
>pause 50
>
>
>high pingc 'same as above only on center sonar
>
>pulsout 0,1500 'starts the rctime timer in the Stamp
>
>rctime retc,0,timec 'to get the time in microseconds
>
>timec = timec*2
>
>inchesc = timec/375+11 'do some math to determine inches (approximate)
>
>low pingc 'turn ping off
>
>pause 50
>
>
>high pingr 'same as above only on right sonar
>
>pulsout 0,1500
>
>rctime retr,0,timer
>
>timer = timer*2
>
>inchesr = timer/375+11
>
>low pingr
>
>
>high ena 'turn power off
>
>pause 150 'wait a bit 'sonars must be powered off between pings and
>
> 'this delay assures ample time to discharge the
>
> 'filters on the sonar modules
>
>
>display:
>
>if inchesc <60 then sonar 'if inches on center are less than 60 then jump to
>label sonar
>
>if inchesc >60 then free 'if inches on center are greater than 60 then jump
>to label free
>
>
>sonar:
>
>low 1:low 2:low 3:low 4 'stop motors
>
>pause 2000
>
>
>vector = 2700 'sets servo vector for directional determination DO NOT
>CHANGE
>
>gosub seek 'jump to label seek
>
>free:
>
>'debug dec inchesl, " inches left ",dec inchesc, " inches center ",dec
>inchesr, " inches right ",cr
>
>
>if inchesl >50 and inchesr >50 then forward 'no errors
>
>if inchesl <50 and inchesr >50 then veerr 'something close on left - veer
>right
>
>if inchesl >50 and inchesr <50 then veerl 'something close on right - veer
>left
>
>if inchesl <50 and inchesr <50 then sonar 'something close on both -
>examine with servo seek
>
>
>'goto tping 'ping again (unneeded line - left for revision history)
>
>
>seek: 'routine to determine direction of least obstacles
>
>
>low ena 'extra ping to make sure the <40 on center is actually an
>inanimate object
>
>pause 5 'and not a person or other moving object
>
>high pingc
>
>pulsout 0,1500
>
>rctime retc,0,stimc
>
>stimc = stimc*2
>
>inchc = stimc/375+11
>
>low pingc
>
>high ena
>
>''debug dec inchesc, " inches ",cr
>
>pause 200
>
>
>if inchc >60 then tping 'if center obstacle is cleared, continue on
>forward - if not, determine
>
> 'path of least obstacles
>
>
>vector = 2700 'servo vector right to ping for obstacle DO NOT CHANGE
>
>for vcheck = 1 to 50 'DO NOT CHANGE
>
>pulsout serv,vector 'DO NOT CHANGE
>
>pause 20 'DO NOT CHANGE
>
>next 'DO NOT CHANGE
>
>low ena 'ping for obstacle
>
>pause 5
>
>high pingc
>
>pulsout 0,1500
>
>rctime retc,0,stimr
>
>stimr = stimr*2
>
>inchr = stimr/375+11
>
>low pingc
>
>high ena
>
>'debug dec inchesr, " inches right ",cr
>
>
>pause 150
>
>
>vector = 700 'servo vector left to ping for obstacle DO NOT CHANGE
>
>for vcheck = 1 to 50 'DO NOT CHANGE
>
>pulsout serv,vector 'DO NOT CHANGE
>
>pause 20 'DO NOT CHANGE
>
>next 'DO NOT CHANGE
>
>low ena 'ping for obstacle
>
>pause 5
>
>high pingc
>
>pulsout 0,1500
>
>rctime retc,0,stiml
>
>stiml = stiml*2
>
>inchl = stiml/375+11
>
>low pingc
>
>high ena
>
>'debug dec inchesl, " inches left ",cr
>
>
>pause 150
>
>
>
>
>center: 'Center servo centering routine
>
>for vcheck = 1 to 50 'DO NOT CHANGE
>
>vector = 1650 'DO NOT CHANGE
>
>pulsout serv,vector 'DO NOT CHANGE
>
>pause 20 'DO NOT CHANGE
>
>next 'DO NOT CHANGE
>
>
>if inchl < inchr then rotr 'if obstacle is closer on the left, then rotate
>right
>
>if inchr < inchl then rotl 'if obstacle is closer on the right, then rotate
>left
>
>
>rotr:
>
>'debug " rotate right ",cr,cr
>
>high 1: low 2:low 3:low 4 'Turns on left motor forward to rotate right
>
>pause rot 'sets the rotate -on- delay
>
>goto rotf
>
>
>rotl:
>
>'debug " rotate left ",cr,cr
>
>low 1:low 2:low 3:high 4 'Turns on right motor forward to rotate left
>
>
>pause rot
>
>goto rotf
>
>
>rotf:
>
>low 1:low 2:low 3:low 4 'turns off motors
>
>pause 500 'wait a bit for coastdown (no braking implemented yet)
>
>return
>
>
>forward: 'run motors forward
>
>high 1:high 4
>
>'debug " forward ",cr
>
>goto tping 'return to start of main routine
>
>
>veerr: 'run left forward motor only
>
>high 1:low 4
>
>'debug " veerr ",cr
>
>goto tping
>
>
>veerl: 'run right forward motor only
>
>'debug " veerl ",cr
>
>low 1:high 4
>
>goto tping
>
>
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and
>Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>
have the ability to change the ping *tone* to something different, i.e.
Left sonar ping freq = 45khz
center sonar ping freq= 55khz
right sonar ping freq = 65khz
Or maybe change the order of the ping polling to Right side, then left
side then center then small pause, repeat.
Seems the best way would be to isolate the sonar modules in some way.
Maybe send out a different waveform with each one? (r=square c=triangle
l=sawtooth?) I'm just "typing out loud" so to speak. [noparse]:)[/noparse]
Since I don't know as much about the environment and the hardware, it
takes a bit of guessing. Ok, here's another idea, mount the sensors at
different altitudes? Right side low, center high left low? Maybe
supplement the obstical detection with some IR reflection sensors? This
would allow you to ping the sonar, then check the IR for bounce, then
ping the next sonar and then poll the next IR device. Maybe this would
give the echos time to die or drop below a threshold of detection.
Ok... I think I'm out of ideas... [noparse]:)[/noparse]
Vern
--
Vern Graner CNE/CNA/SSE | "If the network is down, then you're
Senior Systems Engineer | obviously incompetent so why are we
Texas Information Services | paying you? Of course, if the network
vern@t... www.txis.com | is up, then we obviously don't need
Cell 507-7851 Desk 328-8947 | you, so why are we paying you?" VLG
Doug Simpson said:
> Thanks for the input.
> This must be as close to real-time detection as possible since the bot
> moves at a better than a fast walk pace. The sooner it detects
> obstacles, the sooner it will be able to decide not to run over them.
>
> ds
> Bill Katakis wrote:
>
>>I'm not too knowledgeable here but I'll give my 2 cents anyway, :-)
>> 150 seconds apart may be far to close together for the environment
>> (hallway is an echo chamber) and the speed (slow) which a robot would
>> normally want to navigate in a hallway presumably with human
>> pedestrian traffic. You could get by with fewer pings with built in
>> pauses in your code after each ping command. If you can't control the
>> ping rate, would it be feasible to turn the sonar on and off to
>> accomplish this? Ask the manufacturer if there is a resistor or cap
>> you can place somewhere to reduce the ping rate(simple hardware fix
>> unless its super miniaturized). Could you desensitize your "ears"
>> with a sort of earmuff, how about giving your "ears" external sound
>> absorbing tubes, giving them directional filtering?
>>
>>
Original Message
>>From: Doug Simpson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=XQAISzxka4O9GYlSxZA9ZPEWZr_-gJwwWGkO-a-REl5lQvH2OyE16LOyTg9e8FaLOsjAdPXsFLO9lQ]veewee77@a...[/url
>>Sent: Saturday, July 19, 2003 1:18 AM
>>To: basicstamps@yahoogroups.com
>>Subject: [noparse][[/noparse]basicstamps] a little assistance
>>
>>
>>Hi all!
>>
>>Here is a program that I have running on my bot for collision
>> avoidance.
>> The problenm I have with it is that the halls in the school where I
>>will be using this are bad to echo. The three sonars ping
>> sequentially about 150ms apart and from what I can tell, the sonars
>> are picking up the echoes from each other and getting false
>> triggering. This makes the bot erratic when traversing the halls.
>>
>>Example:
>>scenario 1
>>left sonar fires and gets satisfied (recieves an echo)
>>
>>center sonar fires and gets an echo but it may be the ping from the
>> left sonar that was echoing down the hall so it thinks there is an
>> obstacle in close range. Bot puts on the brakes. . .
>>
>>scenario 2
>>center sonar fires and determines there is nothing in the way so the
>> right sonar fires and recieves an echo which may be the echo from
>> center echoing back from down the hall and it thinks there is a wall
>> or
>>obstacle on the right so it veers left. There was no obstacle on the
>> right.
>>
>>Following is the entire code for the program.
>>Anyone who can assist or help me write it to be more stable, or just
>> give suggestions, I would appreciate it!
>>
>>Thanks
>>
>>Doug Simpson
>>
>>Code follows. . .
>>*****************************************
>>
>>'Triple Sonar, Dual Motor Robot Vision and Guidance System
>>
>>'For Basic Stamp 2sx only.
>>
>>'Forward motor control only at this time. Strictly collision
>> avoidance.
>>
>>'No other functions at this time
>>
>>
>>'declaration of constants
>>
>>
>>pingl con 15 'Sets ping output left on pin 15
>>
>>pingc con 14 'Sets ping output center on pin 14
>>
>>pingr con 13 'Sets ping output right on pin13
>>
>>retl con 10 'Sets echo input left on pin 10
>>
>>retc con 9 'Sets echo input center on pin 9
>>
>>retr con 8 'Sets echo input right on pin 8
>>
>>ena con 11 'Sets output to enable (power to sonars) on 11
>>
>>serv con 12 'Sets servo output on pin 12
>>
>>ir con 7 'Sets infrared detect input on pin 7
>>
>>timel var word 'variable for the rctime on left sonar
>>
>>timec var word 'variable for the rctime on center sonar
>>
>>timer var word 'variable for the rctime on right sonar
>>
>>inchesl var byte 'variable for inches left
>>
>>inchesc var byte 'variable for inches canter
>>
>>inchesr var byte 'variable for inches right
>>
>>inchl var byte 'variable for inches left for direction sensing
>>
>>inchr var byte 'variable for inches right for direction sensing
>>
>>vector var word 'variable for the location of the sonar servo
>>
>>check var byte 'variable for
>>
>>vcheck var byte 'variable for
>>
>>stiml var word 'variable for directional determination
>>
>>stimr var word 'variable for directional determination
>>
>>stimc var word 'variable for collision avoidance
>>
>>inchc var byte 'converted inches for collision avoidance
>>
>>rot var word 'rotational variable
>>
>>rot = 500 'sets duration of rotation - 500 is roughly 1/2 second
>>
>>vector = 1800 'sets the servo to center DO NOT CHANGE
>>
>>
>>start:
>>
>>
>>output ena
>>
>>output pingl
>>
>>output pingc
>>
>>output pingr
>>
>>output serv
>>
>>input retl
>>
>>input retc
>>
>>input retr
>>
>>input ir
>>
>>
>>low pingl 'turn pingl off
>>
>>low pingc 'turn pingc off
>>
>>low pingr 'turn pingr off
>>
>>high ena 'high turns off power to the sonar modules
>>
>>gosub center 'jump to servo center routine
>>
>>
>>tping:
>>
>>
>>low ena 'turn power on
>>
>>pause 5 'wait a tad
>>
>>high pingl 'execute a ping
>>
>>pulsout 0,1500 'wait 1.2ms (dummy line)
>>
>>rctime retl,0,timel 'now, wait for echo pulse
>>
>>timel = timel*2
>>
>>inchesl = timel/375+11 'convert time in microseconds to inches
>>
>> 'could be done just on the timel, timec and timer data but
>>
>> 'easier to set the distances in inches than miliseconds
>>
>>
>>low pingl 'turn ping off
>>
>>pause 50
>>
>>
>>high pingc 'same as above only on center sonar
>>
>>pulsout 0,1500 'starts the rctime timer in the Stamp
>>
>>rctime retc,0,timec 'to get the time in microseconds
>>
>>timec = timec*2
>>
>>inchesc = timec/375+11 'do some math to determine inches
>> (approximate)
>>
>>low pingc 'turn ping off
>>
>>pause 50
>>
>>
>>high pingr 'same as above only on right sonar
>>
>>pulsout 0,1500
>>
>>rctime retr,0,timer
>>
>>timer = timer*2
>>
>>inchesr = timer/375+11
>>
>>low pingr
>>
>>
>>high ena 'turn power off
>>
>>pause 150 'wait a bit 'sonars must be powered off between pings and
>>
>> 'this delay assures ample time to discharge the
>>
>> 'filters on the sonar modules
>>
>>
>>display:
>>
>>if inchesc <60 then sonar 'if inches on center are less than 60 then
>> jump to label sonar
>>
>>if inchesc >60 then free 'if inches on center are greater than 60 then
>> jump to label free
>>
>>
>>sonar:
>>
>>low 1:low 2:low 3:low 4 'stop motors
>>
>>pause 2000
>>
>>
>>vector = 2700 'sets servo vector for directional determination DO
>> NOT CHANGE
>>
>>gosub seek 'jump to label seek
>>
>>free:
>>
>>'debug dec inchesl, " inches left ",dec inchesc, " inches center ",dec
>> inchesr, " inches right ",cr
>>
>>
>>if inchesl >50 and inchesr >50 then forward 'no errors
>>
>>if inchesl <50 and inchesr >50 then veerr 'something close on left -
>> veer right
>>
>>if inchesl >50 and inchesr <50 then veerl 'something close on right -
>> veer left
>>
>>if inchesl <50 and inchesr <50 then sonar 'something close on both -
>> examine with servo seek
>>
>>
>>'goto tping 'ping again (unneeded line - left for revision history)
>>
>>
>>seek: 'routine to determine direction of least obstacles
>>
>>
>>low ena 'extra ping to make sure the <40 on center is actually an
>> inanimate object
>>
>>pause 5 'and not a person or other moving object
>>
>>high pingc
>>
>>pulsout 0,1500
>>
>>rctime retc,0,stimc
>>
>>stimc = stimc*2
>>
>>inchc = stimc/375+11
>>
>>low pingc
>>
>>high ena
>>
>>''debug dec inchesc, " inches ",cr
>>
>>pause 200
>>
>>
>>if inchc >60 then tping 'if center obstacle is cleared, continue on
>> forward - if not, determine
>>
>> 'path of least obstacles
>>
>>
>>vector = 2700 'servo vector right to ping for obstacle DO NOT CHANGE
>>
>>for vcheck = 1 to 50 'DO NOT CHANGE
>>
>>pulsout serv,vector 'DO NOT CHANGE
>>
>>pause 20 'DO NOT CHANGE
>>
>>next 'DO NOT CHANGE
>>
>>low ena 'ping for obstacle
>>
>>pause 5
>>
>>high pingc
>>
>>pulsout 0,1500
>>
>>rctime retc,0,stimr
>>
>>stimr = stimr*2
>>
>>inchr = stimr/375+11
>>
>>low pingc
>>
>>high ena
>>
>>'debug dec inchesr, " inches right ",cr
>>
>>
>>pause 150
>>
>>
>>vector = 700 'servo vector left to ping for obstacle DO NOT CHANGE
>>
>>for vcheck = 1 to 50 'DO NOT CHANGE
>>
>>pulsout serv,vector 'DO NOT CHANGE
>>
>>pause 20 'DO NOT CHANGE
>>
>>next 'DO NOT CHANGE
>>
>>low ena 'ping for obstacle
>>
>>pause 5
>>
>>high pingc
>>
>>pulsout 0,1500
>>
>>rctime retc,0,stiml
>>
>>stiml = stiml*2
>>
>>inchl = stiml/375+11
>>
>>low pingc
>>
>>high ena
>>
>>'debug dec inchesl, " inches left ",cr
>>
>>
>>pause 150
>>
>>
>>
>>
>>center: 'Center servo centering routine
>>
>>for vcheck = 1 to 50 'DO NOT CHANGE
>>
>>vector = 1650 'DO NOT CHANGE
>>
>>pulsout serv,vector 'DO NOT CHANGE
>>
>>pause 20 'DO NOT CHANGE
>>
>>next 'DO NOT CHANGE
>>
>>
>>if inchl < inchr then rotr 'if obstacle is closer on the left, then
>> rotate right
>>
>>if inchr < inchl then rotl 'if obstacle is closer on the right, then
>> rotate left
>>
>>
>>rotr:
>>
>>'debug " rotate right ",cr,cr
>>
>>high 1: low 2:low 3:low 4 'Turns on left motor forward to rotate right
>>
>>pause rot 'sets the rotate -on- delay
>>
>>goto rotf
>>
>>
>>rotl:
>>
>>'debug " rotate left ",cr,cr
>>
>>low 1:low 2:low 3:high 4 'Turns on right motor forward to rotate left
>>
>>
>>pause rot
>>
>>goto rotf
>>
>>
>>rotf:
>>
>>low 1:low 2:low 3:low 4 'turns off motors
>>
>>pause 500 'wait a bit for coastdown (no braking implemented yet)
>>
>>return
>>
>>
>>forward: 'run motors forward
>>
>>high 1:high 4
>>
>>'debug " forward ",cr
>>
>>goto tping 'return to start of main routine
>>
>>
>>veerr: 'run left forward motor only
>>
>>high 1:low 4
>>
>>'debug " veerr ",cr
>>
>>goto tping
>>
>>
>>veerl: 'run right forward motor only
>>
>>'debug " veerl ",cr
>>
>>low 1:high 4
>>
>>goto tping
>>
>>
>>
>>
>>
>>To UNSUBSCRIBE, just send mail to:
>> basicstamps-unsubscribe@yahoogroups.com
>>from the same email address that you subscribed. Text in the Subject
>> and Body of the message will be ignored.
>>
>>
>>Your use of Yahoo! Groups is subject to
>> http://docs.yahoo.com/info/terms/
>>
>>
>>
>>
>>To UNSUBSCRIBE, just send mail to:
>> basicstamps-unsubscribe@yahoogroups.com
>>from the same email address that you subscribed. Text in the Subject
>> and Body of the message will be ignored.
>>
>>
>>Your use of Yahoo! Groups is subject to
>> http://docs.yahoo.com/info/terms/
>>
>>
>>
>>
>>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
Sun 660 cameras. I don't know how to shift the frequency or that would
be the easiest option. Each pings at a different frequency and then
there would be no interference. But I don't think it is changeable easily.
DS
Vernon Graner wrote:
>Would it be possible to stagger the ping frequency? I don't know if you
>have the ability to change the ping *tone* to something different, i.e.
>
>Left sonar ping freq = 45khz
>center sonar ping freq= 55khz
>right sonar ping freq = 65khz
>
>Or maybe change the order of the ping polling to Right side, then left
>side then center then small pause, repeat.
>
>Seems the best way would be to isolate the sonar modules in some way.
>Maybe send out a different waveform with each one? (r=square c=triangle
>l=sawtooth?) I'm just "typing out loud" so to speak. [noparse]:)[/noparse]
>
>Since I don't know as much about the environment and the hardware, it
>takes a bit of guessing. Ok, here's another idea, mount the sensors at
>different altitudes? Right side low, center high left low? Maybe
>supplement the obstical detection with some IR reflection sensors? This
>would allow you to ping the sonar, then check the IR for bounce, then
>ping the next sonar and then poll the next IR device. Maybe this would
>give the echos time to die or drop below a threshold of detection.
>
>
>Ok... I think I'm out of ideas... [noparse]:)[/noparse]
>
>Vern
>
>--
>Vern Graner CNE/CNA/SSE | "If the network is down, then you're
>Senior Systems Engineer | obviously incompetent so why are we
>Texas Information Services | paying you? Of course, if the network
>vern@t... www.txis.com | is up, then we obviously don't need
>Cell 507-7851 Desk 328-8947 | you, so why are we paying you?" VLG
>
>
>
>Doug Simpson said:
>
>
>>Thanks for the input.
>>This must be as close to real-time detection as possible since the bot
>>moves at a better than a fast walk pace. The sooner it detects
>>obstacles, the sooner it will be able to decide not to run over them.
>>
>>ds
>>Bill Katakis wrote:
>>
>>
>>
>>>I'm not too knowledgeable here but I'll give my 2 cents anyway, :-)
>>>150 seconds apart may be far to close together for the environment
>>>(hallway is an echo chamber) and the speed (slow) which a robot would
>>>normally want to navigate in a hallway presumably with human
>>>pedestrian traffic. You could get by with fewer pings with built in
>>>pauses in your code after each ping command. If you can't control the
>>>ping rate, would it be feasible to turn the sonar on and off to
>>>accomplish this? Ask the manufacturer if there is a resistor or cap
>>>you can place somewhere to reduce the ping rate(simple hardware fix
>>>unless its super miniaturized). Could you desensitize your "ears"
>>>with a sort of earmuff, how about giving your "ears" external sound
>>>absorbing tubes, giving them directional filtering?
>>>
>>>
Original Message
>>>From: Doug Simpson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=HNPU4CMdS2TLQ7oNeNxdqtabdcoEUcpSmC3EiC5Zec8_R7CgDZ9faTcBHcQWE_jTrNrkg-jmJ3qn7dDFb08]veewee77@a...[/url
>>>Sent: Saturday, July 19, 2003 1:18 AM
>>>To: basicstamps@yahoogroups.com
>>>Subject: [noparse][[/noparse]basicstamps] a little assistance
>>>
>>>
>>>Hi all!
>>>
>>>Here is a program that I have running on my bot for collision
>>>avoidance.
>>>The problenm I have with it is that the halls in the school where I
>>>will be using this are bad to echo. The three sonars ping
>>>sequentially about 150ms apart and from what I can tell, the sonars
>>>are picking up the echoes from each other and getting false
>>>triggering. This makes the bot erratic when traversing the halls.
>>>
>>>Example:
>>>scenario 1
>>>left sonar fires and gets satisfied (recieves an echo)
>>>
>>>center sonar fires and gets an echo but it may be the ping from the
>>>left sonar that was echoing down the hall so it thinks there is an
>>>obstacle in close range. Bot puts on the brakes. . .
>>>
>>>scenario 2
>>>center sonar fires and determines there is nothing in the way so the
>>>right sonar fires and recieves an echo which may be the echo from
>>>center echoing back from down the hall and it thinks there is a wall
>>>or
>>>obstacle on the right so it veers left. There was no obstacle on the
>>>right.
>>>
>>>Following is the entire code for the program.
>>>Anyone who can assist or help me write it to be more stable, or just
>>>give suggestions, I would appreciate it!
>>>
>>>Thanks
>>>
>>>Doug Simpson
>>>
>>>Code follows. . .
>>>*****************************************
>>>
>>>'Triple Sonar, Dual Motor Robot Vision and Guidance System
>>>
>>>'For Basic Stamp 2sx only.
>>>
>>>'Forward motor control only at this time. Strictly collision
>>>avoidance.
>>>
>>>'No other functions at this time
>>>
>>>
>>>'declaration of constants
>>>
>>>
>>>pingl con 15 'Sets ping output left on pin 15
>>>
>>>pingc con 14 'Sets ping output center on pin 14
>>>
>>>pingr con 13 'Sets ping output right on pin13
>>>
>>>retl con 10 'Sets echo input left on pin 10
>>>
>>>retc con 9 'Sets echo input center on pin 9
>>>
>>>retr con 8 'Sets echo input right on pin 8
>>>
>>>ena con 11 'Sets output to enable (power to sonars) on 11
>>>
>>>serv con 12 'Sets servo output on pin 12
>>>
>>>ir con 7 'Sets infrared detect input on pin 7
>>>
>>>timel var word 'variable for the rctime on left sonar
>>>
>>>timec var word 'variable for the rctime on center sonar
>>>
>>>timer var word 'variable for the rctime on right sonar
>>>
>>>inchesl var byte 'variable for inches left
>>>
>>>inchesc var byte 'variable for inches canter
>>>
>>>inchesr var byte 'variable for inches right
>>>
>>>inchl var byte 'variable for inches left for direction sensing
>>>
>>>inchr var byte 'variable for inches right for direction sensing
>>>
>>>vector var word 'variable for the location of the sonar servo
>>>
>>>check var byte 'variable for
>>>
>>>vcheck var byte 'variable for
>>>
>>>stiml var word 'variable for directional determination
>>>
>>>stimr var word 'variable for directional determination
>>>
>>>stimc var word 'variable for collision avoidance
>>>
>>>inchc var byte 'converted inches for collision avoidance
>>>
>>>rot var word 'rotational variable
>>>
>>>rot = 500 'sets duration of rotation - 500 is roughly 1/2 second
>>>
>>>vector = 1800 'sets the servo to center DO NOT CHANGE
>>>
>>>
>>>start:
>>>
>>>
>>>output ena
>>>
>>>output pingl
>>>
>>>output pingc
>>>
>>>output pingr
>>>
>>>output serv
>>>
>>>input retl
>>>
>>>input retc
>>>
>>>input retr
>>>
>>>input ir
>>>
>>>
>>>low pingl 'turn pingl off
>>>
>>>low pingc 'turn pingc off
>>>
>>>low pingr 'turn pingr off
>>>
>>>high ena 'high turns off power to the sonar modules
>>>
>>>gosub center 'jump to servo center routine
>>>
>>>
>>>tping:
>>>
>>>
>>>low ena 'turn power on
>>>
>>>pause 5 'wait a tad
>>>
>>>high pingl 'execute a ping
>>>
>>>pulsout 0,1500 'wait 1.2ms (dummy line)
>>>
>>>rctime retl,0,timel 'now, wait for echo pulse
>>>
>>>timel = timel*2
>>>
>>>inchesl = timel/375+11 'convert time in microseconds to inches
>>>
>>> 'could be done just on the timel, timec and timer data but
>>>
>>> 'easier to set the distances in inches than miliseconds
>>>
>>>
>>>low pingl 'turn ping off
>>>
>>>pause 50
>>>
>>>
>>>high pingc 'same as above only on center sonar
>>>
>>>pulsout 0,1500 'starts the rctime timer in the Stamp
>>>
>>>rctime retc,0,timec 'to get the time in microseconds
>>>
>>>timec = timec*2
>>>
>>>inchesc = timec/375+11 'do some math to determine inches
>>>(approximate)
>>>
>>>low pingc 'turn ping off
>>>
>>>pause 50
>>>
>>>
>>>high pingr 'same as above only on right sonar
>>>
>>>pulsout 0,1500
>>>
>>>rctime retr,0,timer
>>>
>>>timer = timer*2
>>>
>>>inchesr = timer/375+11
>>>
>>>low pingr
>>>
>>>
>>>high ena 'turn power off
>>>
>>>pause 150 'wait a bit 'sonars must be powered off between pings and
>>>
>>> 'this delay assures ample time to discharge the
>>>
>>> 'filters on the sonar modules
>>>
>>>
>>>display:
>>>
>>>if inchesc <60 then sonar 'if inches on center are less than 60 then
>>>jump to label sonar
>>>
>>>if inchesc >60 then free 'if inches on center are greater than 60 then
>>>jump to label free
>>>
>>>
>>>sonar:
>>>
>>>low 1:low 2:low 3:low 4 'stop motors
>>>
>>>pause 2000
>>>
>>>
>>>vector = 2700 'sets servo vector for directional determination DO
>>>NOT CHANGE
>>>
>>>gosub seek 'jump to label seek
>>>
>>>free:
>>>
>>>'debug dec inchesl, " inches left ",dec inchesc, " inches center ",dec
>>>inchesr, " inches right ",cr
>>>
>>>
>>>if inchesl >50 and inchesr >50 then forward 'no errors
>>>
>>>if inchesl <50 and inchesr >50 then veerr 'something close on left -
>>>veer right
>>>
>>>if inchesl >50 and inchesr <50 then veerl 'something close on right -
>>>veer left
>>>
>>>if inchesl <50 and inchesr <50 then sonar 'something close on both -
>>>examine with servo seek
>>>
>>>
>>>'goto tping 'ping again (unneeded line - left for revision history)
>>>
>>>
>>>seek: 'routine to determine direction of least obstacles
>>>
>>>
>>>low ena 'extra ping to make sure the <40 on center is actually an
>>>inanimate object
>>>
>>>pause 5 'and not a person or other moving object
>>>
>>>high pingc
>>>
>>>pulsout 0,1500
>>>
>>>rctime retc,0,stimc
>>>
>>>stimc = stimc*2
>>>
>>>inchc = stimc/375+11
>>>
>>>low pingc
>>>
>>>high ena
>>>
>>>''debug dec inchesc, " inches ",cr
>>>
>>>pause 200
>>>
>>>
>>>if inchc >60 then tping 'if center obstacle is cleared, continue on
>>>forward - if not, determine
>>>
>>> 'path of least obstacles
>>>
>>>
>>>vector = 2700 'servo vector right to ping for obstacle DO NOT CHANGE
>>>
>>>for vcheck = 1 to 50 'DO NOT CHANGE
>>>
>>>pulsout serv,vector 'DO NOT CHANGE
>>>
>>>pause 20 'DO NOT CHANGE
>>>
>>>next 'DO NOT CHANGE
>>>
>>>low ena 'ping for obstacle
>>>
>>>pause 5
>>>
>>>high pingc
>>>
>>>pulsout 0,1500
>>>
>>>rctime retc,0,stimr
>>>
>>>stimr = stimr*2
>>>
>>>inchr = stimr/375+11
>>>
>>>low pingc
>>>
>>>high ena
>>>
>>>'debug dec inchesr, " inches right ",cr
>>>
>>>
>>>pause 150
>>>
>>>
>>>vector = 700 'servo vector left to ping for obstacle DO NOT CHANGE
>>>
>>>for vcheck = 1 to 50 'DO NOT CHANGE
>>>
>>>pulsout serv,vector 'DO NOT CHANGE
>>>
>>>pause 20 'DO NOT CHANGE
>>>
>>>next 'DO NOT CHANGE
>>>
>>>low ena 'ping for obstacle
>>>
>>>pause 5
>>>
>>>high pingc
>>>
>>>pulsout 0,1500
>>>
>>>rctime retc,0,stiml
>>>
>>>stiml = stiml*2
>>>
>>>inchl = stiml/375+11
>>>
>>>low pingc
>>>
>>>high ena
>>>
>>>'debug dec inchesl, " inches left ",cr
>>>
>>>
>>>pause 150
>>>
>>>
>>>
>>>
>>>center: 'Center servo centering routine
>>>
>>>for vcheck = 1 to 50 'DO NOT CHANGE
>>>
>>>vector = 1650 'DO NOT CHANGE
>>>
>>>pulsout serv,vector 'DO NOT CHANGE
>>>
>>>pause 20 'DO NOT CHANGE
>>>
>>>next 'DO NOT CHANGE
>>>
>>>
>>>if inchl < inchr then rotr 'if obstacle is closer on the left, then
>>>rotate right
>>>
>>>if inchr < inchl then rotl 'if obstacle is closer on the right, then
>>>rotate left
>>>
>>>
>>>rotr:
>>>
>>>'debug " rotate right ",cr,cr
>>>
>>>high 1: low 2:low 3:low 4 'Turns on left motor forward to rotate right
>>>
>>>pause rot 'sets the rotate -on- delay
>>>
>>>goto rotf
>>>
>>>
>>>rotl:
>>>
>>>'debug " rotate left ",cr,cr
>>>
>>>low 1:low 2:low 3:high 4 'Turns on right motor forward to rotate left
>>>
>>>
>>>pause rot
>>>
>>>goto rotf
>>>
>>>
>>>rotf:
>>>
>>>low 1:low 2:low 3:low 4 'turns off motors
>>>
>>>pause 500 'wait a bit for coastdown (no braking implemented yet)
>>>
>>>return
>>>
>>>
>>>forward: 'run motors forward
>>>
>>>high 1:high 4
>>>
>>>'debug " forward ",cr
>>>
>>>goto tping 'return to start of main routine
>>>
>>>
>>>veerr: 'run left forward motor only
>>>
>>>high 1:low 4
>>>
>>>'debug " veerr ",cr
>>>
>>>goto tping
>>>
>>>
>>>veerl: 'run right forward motor only
>>>
>>>'debug " veerl ",cr
>>>
>>>low 1:high 4
>>>
>>>goto tping
>>>
>>>
>>>
>>>
>>>
>>>To UNSUBSCRIBE, just send mail to:
>>> basicstamps-unsubscribe@yahoogroups.com
>>>
>>>
>>>from the same email address that you subscribed. Text in the Subject
>>
>>
>>>and Body of the message will be ignored.
>>>
>>>
>>>Your use of Yahoo! Groups is subject to
>>>http://docs.yahoo.com/info/terms/
>>>
>>>
>>>
>>>
>>>To UNSUBSCRIBE, just send mail to:
>>> basicstamps-unsubscribe@yahoogroups.com
>>>
>>>
>>>from the same email address that you subscribed. Text in the Subject
>>
>>
>>>and Body of the message will be ignored.
>>>
>>>
>>>Your use of Yahoo! Groups is subject to
>>>http://docs.yahoo.com/info/terms/
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>To UNSUBSCRIBE, just send mail to:
>> basicstamps-unsubscribe@yahoogroups.com
>>from the same email address that you subscribed. Text in the Subject
>>and Body of the message will be ignored.
>>
>>
>>Your use of Yahoo! Groups is subject to
>>http://docs.yahoo.com/info/terms/
>>
>>
>
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>
Has anyone raised the subject of beam pattern?
This could be a big factor - from an old Polaroid handbook, I see a 30 deg
(inclusive) front central lobe then 2 pairs of side lobes covering beyond
100 deg. If the receiver gain can be reduced, perhaps the effect of those
wide side lobes could be eliminated.
David Lawrence
www.rhombus-tek.com/microgui.html
Original Message
From: Doug Simpson <veewee77@a...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, July 19, 2003 3:43 PM
Subject: Re: [noparse][[/noparse]basicstamps] a little assistance
> Thanks for the input. The sonars I'm using are salvaged from Polaroid
> Sun 660 cameras. I don't know how to shift the frequency or that would
> be the easiest option. Each pings at a different frequency and then
> there would be no interference. But I don't think it is changeable
easily.
>