Subject:
|
Re: IR Port as Proximity detector.
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Fri, 8 Jan 1999 19:56:37 GMT
|
Original-From:
|
Simen Svale Skogsrud <simen@mop.^NoSpam^no>
|
Viewed:
|
1371 times
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
David Chen wrote:
> I am going to try checking for large jumps in absolute values. Also
> will try a smaller duty cycle, let's say 5-10% to save on battery life
> and to allow for IR Tower incoming transmissions.
I have now a good working explorer bot using a combination of IR-proximity
detection and bumpers. I had to work a while to get the proximity detection
totally reliable though.
I have a global variable called IN_PROXIMITY that I treat as a virtual
sensor. I have then written a small "driver task" that constantly polls the
light sensor and checs for changes larger than 100 units. This is done
seven times and the largest change gathered during this time (that is >100)
is used as the sensor value and assigned to IN_PROXIMITY.
This works almost perfectly. To account for the rare sampling cycle where
no spikes is gathered even though the bot is facing a wall I do not reset
the sensor value imediately. If no IR reflection was sensed IN_PROXIMITY is
set to exactly 100, and not before a second sampling sequence has passed
with no reflections is the sensor value really reset to 0. This works
completely reliable for my small bot.
This is my "driver"
variables:
proxsamp - a counter that counts down the number of samples that will be
made
until IN_PROXIMITY should be updated
maxprox - largest fluctuation gathered in this sampling sequence
oldluxsample, newluxsample - the former and current RAW sensor reading
proxisamples - constant, number of samples to gather each cycle
task proximitydriver
{
newluxsample = IN_2;
proxsamp = 0;
while (true)
{
proxsamp -= 1;
maxprox = 0;
SendMessage(255);
oldluxsample = newluxsample;
newluxsample = IN_2;
oldluxsample -= newluxsample;
if (oldluxsample<0)
{
oldluxsample *= -1;
}
if (oldluxsample>100)
{
if (oldluxsample>maxprox)
{
maxprox = oldluxsample;
}
}
if (proxsamp < 0)
{
if (maxprox == 0)
{
if (IN_PROXIMITY > 100)
{
IN_PROXIMITY = 100;
}
else
{
IN_PROXIMITY = maxprox;
}
}
else
{
IN_PROXIMITY = maxprox;
}
proxsamp = proxisamples;
maxprox = 0;
}
}
}
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics
|
|
1 Message in This Thread: ![You are here](/news/here.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|