View unanswered posts | View active topics It is currently Tue Nov 25, 2014 8:49 pm






Reply to topic  [ 8 posts ] 
Re: IRSeeker distance approxiamation 
Author Message
Rookie

Joined: Wed May 30, 2007 4:33 am
Posts: 2
Location: Wooster, OH
Post Re: IRSeeker distance approxiamation
Hi recently purchased an Ir Seeker and IR ball However I am in the middle of project using the ball and IrSeeker for a school project, but i can't figure out how to to get the approximate distance from the ball using the address specified for the IRSeeker using robotC to program . Please any example code or help would be gladly appreciated.
Each address stores a signal, these are:
0x43, 0x44, 0x45, 0x46, 0x47.


Mon Feb 25, 2008 6:01 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
If you want someone to respond then you need to provide more information. Whose product is the "IR Seeker" and which "IR Ball". I'm assuming these are for Robocup Jr competition but don't really know. It would be good if you included web hyperlink to product datasheets and then someone might look up and provide you insight.


Wed Feb 27, 2008 10:40 am
Profile
Rookie

Joined: Wed May 30, 2007 4:33 am
Posts: 2
Location: Wooster, OH
Post 
I'm Sorry. I'm not using it for Robocup Jr. But as a beacon for the robot to find it goal location while traversing a room autonomously and so the nxt will need to know how close it is to the ball to terminate and return that it found the ball. I am using both the hitechnic IRSeeker and IRball.
The link for the info on the IRSeeker can be found here:
http://www.hitechnic.com/index.html?lan ... t=d23.html
and the ball :
http://www.hitechnic.com/


Wed Feb 27, 2008 11:13 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
Do you have a program that will read the six sensor values from the IR sensor. This is simply an I2C read program of six consecutive bytes and can be adapted from any of several samples found in the ROBOTC distribution.

You'll probably want a background task that is periodically polling the IR Sensor on a 10 to 20 millisecond basis.

ONce you've got the six sensor values then you need to figure out which is the "brightest" (i.e. has the highest value -- presumably high values and not low values indicate bright).

There are five sensors. If one is highest value then "direction" is 1, 3, 5, 7, 9 corresponding to the appropriate sensor. If two sensors have the same value then direction is the in-between values of 2, 4, 6, 8.

Hope this helps. Let me know how you make out.

You should learn how to use the ROBOTC "I2C Test" screen. You'll find it very useful in figuring out all of above. You can set it up to continuously poll the IR Seeker and display the six sensor values on a PC screen with rapid update.


Wed Feb 27, 2008 11:26 am
Profile
Rookie

Joined: Wed May 07, 2008 7:07 am
Posts: 3
Post Re: IRSeeker distance approxiamation
I'm also having problems with the HiTechnic IRSeeker. I have run tests with the I2C Test screen and sent it a message to get back type, manufacturer and version which works without issue.

I have also tried the following messages:

"02 42" which are meant to bring back the direction and "02 43 44 45 46 47" to bring back the 5 bytes for the signal strength.

I am getting readings from the first 3 bytes but do not get values in the last 3 bytes.

I am using v1.10. Is this an issue with the sensor or RobotC or Me?

I also see a similar issue when retrieving the values programmatically through the I2C calls.

#define MsgSize 6 // The length of the message you want the NXT to write to the i2c bus
#define DeviceAddress 0x02 // The i2c address of the sensor. With NXT it is usually 0x02
#define DataLocationPtr 0x42 // The address of the Register to start reading from
#define sensorPort S1 // Port the sensor is connected to on the NXT

task main()
{

typedef struct{
byte nMsgSize;
byte nDeviceAddress;
byte nDataLocationPtr;
} TI2C_Output;

SensorType[sensorPort] = sensorI2CCustomStd;
wait10Msec(5);
nI2CBytesReady[sensorPort]=0;
while(nI2CStatus[sensorPort]== STAT_COMM_PENDING)
wait1Msec(2);

byte replyMessage[MsgSize];

TI2C_Output sOutput;

nxtDisplayTextLine(0, " HiTechnic");
nxtDisplayTextLine(1, " IRSeeker Test");

while(true)
{
nI2CBytesReady[sensorPort] = 0;

sOutput.nMsgSize = MsgSize;
sOutput.nDeviceAddress = DeviceAddress;
sOutput.nDataLocationPtr = DataLocationPtr;

// send the message we have just created to the I2C interface on port "sensorPort"
sendI2CMsg(sensorPort, sOutput.nMsgSize, sizeof(replyMessage));

// wait for the I2C interface to become ready
while (nI2CStatus[sensorPort] == STAT_COMM_PENDING)
wait1Msec(2);

// If there is no error on the port get the data
if (nI2CStatus[sensorPort] == NO_ERR)
{
// read the sensor data from the I2C interface
readI2CReply(sensorPort, replyMessage[0], sizeof(replyMessage));

// get the sensor data from the buffer
int direction = (replyMessage[0] & 0x00FF); // Direction data
int st1 = (replyMessage[1] & 0x00FF); // Sensor 1 signal strength
int st2 = (replyMessage[2] & 0x00FF); // Sensor 2 signal strength
int st3 = (replyMessage[3] & 0x00FF); // Sensor 3 signal strength
int st4 = (replyMessage[4] & 0x00FF); // Sensor 4 signal strength
int st5 = (replyMessage[5] & 0x00FF); // Sensor 5 signal strength

//Display the sensor data on the NXT screen
nxtDisplayTextLine(2, "Port: %d", (int)sensorPort+1); //display Port Sensor is connected to
nxtDisplayTextLine(3, "Dir: %d", direction); //display direction data
nxtDisplayTextLine(4, "s1: %d / s2: %d", st1, st2); //Sensor 1 and 2 signal strength
nxtDisplayTextLine(5, "S3: %d / s4: %d", st3, st4); //Sensor 3 and 4 signal strength
nxtDisplayTextLine(6, "s5: %d", st5); //Sensor 5 signal strength
wait1Msec(125);
}
else
{ //Error on port
PlayTone(5000, 1000);
nxtDisplayTextLine(2, "ERROR ON I2C");
nxtDisplayTextLine(3, "INTERFACE");
}
}
}


Wed May 07, 2008 7:33 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 614
Post 
There have been improvements to the I2C handling in the latest version of ROBOTC... download the 1.30 BETA and see if you're having the same issue as it may have been fixed between 1.10 and 1.30.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Wed May 07, 2008 10:02 am
Profile
Rookie

Joined: Wed May 07, 2008 7:07 am
Posts: 3
Post Re: IRSeeker distance approxiamation
I tried the new version 1.3Beta.

The I2C Test screen is different to that in the help. There is no I2C Custom selection in the menu for sensor type, no Trace All Activity checkbox, etc.

I chosen Digital In as the type and set up the messages just to get version "02 00", Manufacturer "02 08" and Type "02 10". All bringing back 8 bytes. I have the NXT turned on an no program running. I get "Not configured as I2C" in the each reply field.

If I download the program above and set it running I do get results back in the I2C Test screen but I also semi regularly get a reply in one of the reply fields that reads "I2C Read Timed Out".

The program above still produces output the same as with version 1.10 with only partial results.


Mon May 12, 2008 6:58 am
Profile
Rookie

Joined: Wed May 07, 2008 7:07 am
Posts: 3
Post Re: IRSeeker distance approxiamation
Is there any update on this issue with the HiTechnic IC2 sensors and RobotC 1.10 and 1.30.


Mon May 19, 2008 7:43 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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.