|
Page 1 of 1
|
[ 4 posts ] |
|
Using Multiple IR Sensors
| Author |
Message |
|
grendel
Rookie
Joined: Mon Feb 18, 2013 6:16 am Posts: 5
|
 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 |
|
 |
|
Robo5009
Rookie
Joined: Tue Feb 19, 2013 4:11 pm Posts: 7
|
 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 |
|
 |
|
grendel
Rookie
Joined: Mon Feb 18, 2013 6:16 am Posts: 5
|
 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 |
|
 |
|
Robo5009
Rookie
Joined: Tue Feb 19, 2013 4:11 pm Posts: 7
|
 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): Kinda made this in 1 min so hopefully it works. Hope it helps, Team 5009
|
| Wed Feb 20, 2013 5:13 pm |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 5 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
|
|