View unanswered posts | View active topics It is currently Fri Feb 12, 2016 2:42 am

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
How could you find distance with a ir sensor
Author Message
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
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
Rookie

Joined: Thu Sep 13, 2012 8:35 pm
Posts: 3
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
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
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
Rookie

Joined: Tue Feb 19, 2013 4:11 pm
Posts: 8
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
Rookie

Joined: Sun Dec 05, 2010 11:58 am
Posts: 28
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
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
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
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 7 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    2014 Robotics Academy Summer of Learning    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge