Xref: lugnet.com lugnet.robotics:2538 Newsgroups: lugnet.robotics Path: lugnet.com!lugnet From: David Chen X-Real-Life-Name: David Chen Subject: IR Port as Proximity detector. Content-Type: text/plain; charset=us-ascii Reply-To: nospam-dcchen@pacbell.net-nospam Content-Transfer-Encoding: 7bit Organization: None Message-ID: <3695A26F.4C2B@pacbell.net-nospam> X-Mailer: Mozilla 3.01 (Win95; I) Mime-Version: 1.0 X-Nntp-Posting-Host: ppp-207-104-67-148.rvsd01.pacbell.net Date: Fri, 8 Jan 1999 06:15:11 GMT Lines: 74 Someone (Can't remember who, so unfortunately unable to give credit for the idea appropriately) posted the fact that the IR port used as a emitter coupled with the Light Sensor unit as the reciever can be used as a IR proximity sensor. Seemed like a good idea. Had not heard of it done before on this news group. Thought I'd give it a try. NQC code as follows for a test program called Ping. /* * 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); 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