To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 2542
2541  |  2543
Subject: 
Re: IR Port as Proximity detector.
Newsgroups: 
lugnet.robotics
Date: 
Fri, 8 Jan 1999 08:21:48 GMT
Reply-To: 
nospam-dcchen@AVOIDSPAMpacbell.net-nospam
Viewed: 
1545 times
  
Oops, noticed a coding error, the line that says:
     level = Input(1);
Should read:
     level = IN_2;
For better readability.  The original version works b/c IN_2 is #defined
already as Input(1); but the latter is more readable.

I have used this threshold/proximity detection to trigger back up and
turn in a random direction task/subroutine.  It works pretty good.

Will try to have the robot back up a bit, turn first left, then right
and then go whichever direction is all clear.  This could be a good
technique to make maze solving robots via the "right turn" rule.

Will upload NQC code as it develops.

Dave

Old code follows:

/*
* Ping
* ===========
* Reads light level into level, transmitts it out via SendMessage.
*
* Mapping:
*   OUT_A: empty
*   OUT_B: empty
*   OUT_C: empty
*    IN_1: empty
*    IN_2: light sensor
*    IN_3: empty
*
*/

#define THRESHOLD 70

int level;

task Ping

{
  while(true)
  {
    level = Input(1); <Correction, should read: level = IN_2
    if(level > THRESHOLD)
      PlaySound(1);
    SendMessage(level);
  }
}

task main
{
  // Set up the sensors
  Sensor(IN_2,IN_CFG(STYPE_LIGHT, SMODE_PERCENT));

  // Start Tasks
  start Ping;
}

This has the RCX sending infrared pulses out constantly, if the
reflected pulse is > THRESHOLD (arbitrary values, see below), then it
beeps.

THRESHOLD values I have found to cause beeps when Light Sensor is within
the following distances to a wall painted white (flat wall indoor
paint).  Your milage may vary depending on ambient light.

Threshold:      75      70      60      55-

Range:          6"      4"      3"      Triggers constantly at with the
                                        ambient light.

Perhaps a routine to adjust for Threshold = average ambient level + 20
would work?

Whoever's idea this was, it was a brilliant one.  Now you have an IR
object detector/range detector to use along with your 2 touch sensors.
I can now use the touch sensors for side collision detection and IR
sensor for front.

Next, use a 3rd motor for side to side scanning of objects...

Dave Chen
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics

--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



Message has 1 Reply:
  Re: IR Port as Proximity detector.
 
(...) You are only making IR light with the transmitter, why do you send the value of level? Why not just a constant? (26 years ago, 8-Jan-99, to lugnet.robotics)

Message is in Reply To:
  Re: IR Port as Proximity detector.
 
David ..... Thanks for sharing ... it's a great idea!!! - - - Nick - - - (...) (26 years ago, 8-Jan-99, to lugnet.robotics)

13 Messages in This Thread:







Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR