Subject:
|
The ultimate in IR proximity detection (when calibrated)
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Fri, 29 Jan 1999 07:06:58 GMT
|
Original-From:
|
John Cooper <robots@jpsc.STOPSPAMMERSco.uk>
|
Reply-To:
|
robots@jpsc!StopSpammers!.co.uk
|
Viewed:
|
1193 times
|
| |
| |
We have designed a fast moving Mindstorms robot which tends to hit
things before seeing them using most of the IR proximity detector
implementations published.
I was thinking about the recording of an RCX message by video camera
on Simen Svale Skogsruds web page and tried it myself. I used a
standard VHS camera and when played back, a SendMessage(255) is
usually only visible in one frame, but sometimes visible in two
consecutive frames. From this I gather the pulse lasts just about the
same length as a frame is displayed, or slightkly less. Assuming a
frame rate of 25 per second (UK) this gives an IR pulse of 4 units of
Sleep (aside - why are Sleep units 10ms and Timer units 100ms? it
makes timers useless for anything like this). I wanted to sample the
light sensor only when an IR pulse was being emitted, and need to
sample many times a second to perform collision avoidance.
Some NQC:
#define IDLE 0
#define TRANSMITTING 1
int IN_PROXIMITY, IN_AMBIENT;
int ClockPhase;
int ThisLight;
int LastLight;
int DiffLight;
Sensor(RAW_LIGHT, IN_CFG(STYPE_LIGHT, SMODE_RAW));
IRMode(IR_HI);
start TransmitterClock;
start ProximityDriver;
task TransmitterClock
{
while (true) { //20 per second
SendMessage(255); //takes about 4 100ths of a second
ClockPhase = TRANSMITTING;
Sleep(3); //guaranteed to be shorter than the pulse?
ClockPhase = IDLE;
Sleep(2); //makes a nice round number
}
}
task ProximityDriver
{
while (true) {
while (ClockPhase==IDLE) {
} //while
IN_PROXIMITY = 0;
while (ClockPhase==TRANSMITTING) {
LastLight = ThisLight;
ThisLight = RAW_LIGHT;
DiffLight = LastLight;
DiffLight -= ThisLight; //LastLight-ThisLight
if (DiffLight > THRESHOLD) { //an IR reflection
IN_PROXIMITY += 1;
IN_AMBIENT = LastLight;
} else {
IN_AMBIENT = ThisLight;
}
} //while
} //while
}
IN_PROXIMITY is a count of the number of reflections during an IR
pulse, larger means closer (0 means proceed full speed ahead).
IN_AMBIENT is the raw ambient light (bigger is darker).
I have not yet been able to determine how many times the while
(ClockPhase==TRANSMITTING) loop executes during a pulse, it would be
nice to be able to use Display to put it in the LCD but I haven't
been able to find a way to do this yet.
If anyone can confirm more exactly the length of a SendMessage we'd
be grateful.
--
John & James Cooper, Wallington, UK
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Robotics
|
|
|
|