View unanswered posts | View active topics It is currently Tue May 21, 2013 7:41 pm






Reply to topic  [ 4 posts ] 
Using Multiple IR Sensors 
Author Message
Rookie

Joined: Mon Feb 18, 2013 6:16 am
Posts: 5
Post Using Multiple IR Sensors
I set up my robot to use 2 ir sensors (Hitech 1200) for my autonomous program. Unfortunately, only 1 of them works. I tried swapping out the sensor ports and ir sensors - everything. Is it possible to use multiple IR sensors (successfully) on a robot?


Tue Feb 19, 2013 5:11 am
Profile
Rookie

Joined: Tue Feb 19, 2013 4:11 pm
Posts: 7
Post Re: Using Multiple IR Sensors
In theory, there should be no problem in installing two Hitechnic IR seekers on your robot. It is however possible that you have two different versions of the IR seeker (Hitechnic has a v1 and v2) which would each require seperate drivers and might cause problems when calling driver functions. In order to fix this, you may need to fiddle with the code in the drivers (i.e changing function names or number of parameters) in order to differentiate which driver your calling a function from (since they both probably have identical function names and parameters).


Wed Feb 20, 2013 2:36 pm
Profile
Rookie

Joined: Mon Feb 18, 2013 6:16 am
Posts: 5
Post Re: Using Multiple IR Sensors
Both IR Seekers are v2 so, unfortunately, that doesn't explain the problem. Here is some sample code:

#pragma config(Sensor, S2, IRSeeker, sensorHiTechnicIRSeeker1200)
#pragma config(Sensor, S3, IRSeeker2, sensorHiTechnicIRSeeker1200)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
int IRZone = 0;
int IRZone2 = 0;


while(true)
{
IRZone = SensorValue[IRSeeker];
IRZone2 = SensorValue[IRSeeker2];

// Strafe right //
if(IRZone > 5 && IRZone2 > 5)
{
nxtDisplayTextLine(2, "Strafe Right");

}
else if(IRZone < 5 && IRZone2 < 5)
{
nxtDisplayTextLine(2, "Strafe Left");
}
else
{
nxtDisplayTextLine(2, "'Forward");
}
}
}

One sensor works (IRSeeker), the other doesn't. Swapping out the sensor ports doesn't work or swapping out the sensors themselves. Any ideas?


Wed Feb 20, 2013 3:04 pm
Profile
Rookie

Joined: Tue Feb 19, 2013 4:11 pm
Posts: 7
Post Re: Using Multiple IR Sensors
Not sure why you're using the SensorValue for your IRSeekers. Maybe that's because I defined my IR sensor as I2CCustom. Maybe try something like this (will need the IRSv2 driver):

Code:
int intIrBeaconDir(tsensors link) {
   int intDirDC = HTIRS2readDCDir(link); //Read IRS value
   return intDirDC; //Return the value of IR sensor (emitter direction)
}

task main {

int irZone, irZone2;

  while(true) {
     irZone = intIrBeaconDir(IRSeeker);
     irZone2 = intIrBeaconDir(IRSeeker2);

     nxtDisplayCenteredTextLine(3, "%d %d", irZone, irZone2); //Update display
  }

}


Kinda made this in 1 min so hopefully it works.

Hope it helps,

Team 5009


Wed Feb 20, 2013 5:13 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 3 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.