View unanswered posts | View active topics It is currently Thu Jul 31, 2014 6:10 am






Reply to topic  [ 7 posts ] 
How could you find distance with a ir sensor 
Author Message
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
Post How could you find distance with a ir sensor
I am trying to use the ir seeker to tell when my robot needs to stop. On the hitechnic site it says you can get raw distance with it. How can I convert the values from
Code:
HTIRS2readAllACStrength(Ir, acS1, acS2, acS3, acS4, acS5 );
to actual distance, and use that to tell it when to stop?


Thu Feb 14, 2013 10:02 pm
Profile
Rookie
User avatar

Joined: Thu Sep 13, 2012 8:35 pm
Posts: 3
Post Re: How could you find distance with a ir sensor
Code:
int sampleIR()
{
  int _dirDC = 0;
  int _dirAC = 0;
   int dcS1, dcS2, dcS3, dcS4, dcS5 = 0;
   int acS1, acS2, acS3, acS4, acS5 = 0;
   int irPos = 0;
   int irZone = 0;
  _dirDC = HTIRS2readDCDir(irSensor);
      if (_dirDC < 0)
        return irPos; // I2C read error occurred
      // read the current modulated signal direction
      _dirAC = HTIRS2readACDir(irSensor);
      if (_dirAC < 0)
        return irPos; // I2C read error occurred
      // Read the individual signal strengths of the internal sensors
      // Do this for both unmodulated (DC) and modulated signals (AC)
      if (!HTIRS2readAllDCStrength(irSensor, dcS1, dcS2, dcS3, dcS4, dcS5))
        return irPos;
      if (!HTIRS2readAllACStrength(irSensor, acS1, acS2, acS3, acS4, acS5 ))
        return irPos;
      //displayText(2, "0", dcS1, acS1);
      //displayText(3, "1", dcS2, acS2);
      displayText(4, "2", dcS3, acS3);
      displayText(5, "3", dcS4, acS4);
      displayText(6, "4", dcS5, acS5);
   irPos = acS1;
   irZone = 1;
   if (irPos < acS2)
   {
     irPos = acS2;
     irZone = 2;
   }
   if (irPos < acS3)
   {
     irPos = acS3;
     irZone = 3;
   }
   if (irPos < acS4)
   {
     irPos = acS4;
     irZone = 4;
   }
   if (irPos < acS5)
   {
     irPos = acS5;
     irZone = 5;
   }
   return irZone;
}

This is code my team uses that we found/edited to return a zone. IRPos is not needed put if you know the zone you know the general direction of the beacon.
There is a diagram I believe that comes with the Hitechnic IRSensor that shows the zones and their direction.
Hope this helped!
Sean,
Team 2901


Thu Feb 14, 2013 10:45 pm
Profile
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
Post Re: How could you find distance with a ir sensor
Im trying to find the distance. Also the zone can be found by using _dirAC, so your code is unnecessary.


Fri Feb 15, 2013 4:37 pm
Profile
Rookie

Joined: Tue Feb 19, 2013 4:11 pm
Posts: 8
Post Re: How could you find distance with a ir sensor
The IR Seeker cannot calculate distances, the sensor you are looking for is an ultrasonic sensor. However, this will not locate the infrared beacon.


Wed Feb 20, 2013 6:06 pm
Profile
Rookie

Joined: Sun Dec 05, 2010 11:58 am
Posts: 28
Post Re: How could you find distance with a ir sensor
The IR gives you signal strength or at least sensor strength. This correlates with distance. You have to find how it correlates though.


Wed Feb 27, 2013 11:06 pm
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 137
Post Re: How could you find distance with a ir sensor
I agree that using the IR signal strength to calculate distance is inherently unreliable. External lighting conditions, the battery level of the IR beacon, and other factors contribute to inconsistencies in what sensor value would correlate to what distance.
I have seen students attempt to estimate distances using two IR Seekers and triangulating distance based on the strongest zones on each sensor. This may more consistent, but still not very accurate.


Fri Mar 01, 2013 12:35 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: How could you find distance with a ir sensor
Our team uses two IR seekers to triangulate as well as looking at both signal strength but we found that even with 2 IR seekers, the signal strength doesn't give us reliable reading. So we gave up on it and uses an ultrasonic sensor instead. That works very well.


Sat Mar 02, 2013 5:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.