View unanswered posts | View active topics It is currently Sat Jun 23, 2018 12:54 am






Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
IR Seeker not working? 
Author Message
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post IR Seeker not working?
I'm trying to learn how the IR Seeker works, but when I run my code, the only value displayed on the NXT screen is "38" no matter how far the beacon is from the seeker or what direction the seeker is facing. Is that supposed to happen? I use the NXT Lego Mindstorm and my code is:

#pragma config(Sensor, S1, ir, sensorLightActive)
#pragma config(Motor, motorA, a, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, motorB, b, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, motorC, c, tmotorNXT, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
int irvalue;
while(true)
{
irvalue = SensorValue[ir];
nxtDisplayTextLine(5,"%d",irvalue);
wait1Msec(100);
}
}

Any help is appreciated, thanks in advance.


Thu Nov 13, 2014 7:09 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: IR Seeker not working?
It looks like you have the sensor set as an inactive light sensor. I'm afraid that's why you're getting funky values. By the way, is it the HiTechnic IR seeker that you're using? If so, you need to check the option on the Sensor Management page of the Motor and Sensor Setup window that reads "Allow 3rd Party Sensors from HiTechnic." Then, on the Sensors tab, under Sensor Type, select HiTechnic Sensors-> HiTechnic IRSeeker 1200.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Thu Nov 13, 2014 7:52 pm
Profile
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post Re: IR Seeker not working?
After a lot of testing, the result has changed only slightly. Instead of displaying 38, it now only displays 0 regardless of distance or direction. I am using the HiTechnic IR Seeker and an NXT brick, I'm not sure what version of the IR Seeker it is because it doesn't say anywhere on the part. Here's the code:

#pragma config(Sensor, S1, ir, sensorHiTechnicIRSeeker1200)
#pragma config(Motor, motorA, a, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, motorB, b, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, motorC, c, tmotorNXT, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
int irvalue;
while(true)
{
irvalue = SensorValue[ir];
nxtDisplayTextLine(5,"%d",irvalue);
wait1Msec(100);
}
}

I should mention that the "nxtDisplayTextLine" is appearently a "depreciated function" as RobotC told me with a yellow X marking upon compiling the program, I don't know any other display functions, but does it still work?

Once again help is greatly appreciated and thanks in advance.


Tue Nov 25, 2014 6:31 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: IR Seeker not working?
So, with the nxtDisplayTextLine() thing, it says it's deprecated because in 4.x they've moved to using displayTextLine(), I guess so the command is the same between NXT and EV3. It appears that nxtDisplayTextLine() still works, though. (For now.....)

Anyhow, to your problem with the IR sensor, I think you'll have to use the 3rd party driver to get the results you want. I guess maybe SensorValue in ROBOTC gives you the value for DC (constant) IR signal direction, and the beacon for FTC uses AC (oscillating) IR signals. You can find what looks like a good guide for how to use the IR seeker with the 3rd party driver in this document from FIRST. With 4.x, you may also have to download the latest version of the 3rd party driver suite before it works. This can be gotten from here using the "Download ZIP" button on the right.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Last edited by BurningLights on Sat Dec 20, 2014 7:24 am, edited 1 time in total.



Tue Nov 25, 2014 11:56 pm
Profile
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post Re: IR Seeker not working?
Pardon the ignorance, but this a little overwhelming for my current skill level. I downloaded the latest driver suite, but I don't know where to put it without getting a lot errors upon compiling the program. The following code below without adding any drivers doesn't error:

#pragma config(Sensor, S1, ir, sensorHiTechnicIRSeeker1200)
#pragma config(Motor, motorA, a, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, motorB, b, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, motorC, c, tmotorNXT, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
int irvalue;
while(true)
{
irvalue = SensorValue[ir];
displayTextLine(5,"%d",irvalue);
wait1Msec(100);
}
}

I tried this path and some other slight variants:
C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Sample Programs\NXT\3rd Party Driver Library (I've tried /include, /examples, and just the Driver Library folder)
In the detailed preferences, I don't know what file to select for the common include files, since it doesn't let me select the folder itself. I really don't know how to begin troubleshooting at this point, so any help would be great. Thanks in advance.


Tue Dec 02, 2014 7:12 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: IR Seeker not working?
No problem! I would recommend copying the stuff from the "rdpartyrobotcdr-master\drivers" folder in the download to C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Sample Programs\NXT\3rd Party Driver Library\include. You would probably also want to copy the sample files in the main directory to C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Sample Programs\NXT\3rd Party Driver Library\examples.

To make including the drivers in your program easier, in ROBOTC go to View->Preferences->Detailed Preferences. Choose the Compiler tab, then the Include Directories sub-tab. Click on the browse button next to the first textbox and select whatever directory you put the driver files in. So, for instance, if you copied them over to the normal ROBOTC directory, you would select C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Sample Programs\NXT\3rd Party Driver Library\include.

Now, you're all set to use the drivers! Beneath the automatically generated #pragma statements, put in
Code:
#include "hitechnic-irseeker-v2.h"

In the Motors and Sensors Setup, for the port you have your IR sensor on, select Custom I2C Sensors->I2C Custom as the sensor type.

At the start of your program, call
Code:
HTIRS2setDSPMode(ir, DSP_1200); // This tells it what kind of AC infrared signal to look for. In this case, a 1200 Hz one.


And then to read the direction from the sensor, use
Code:
irvalue = HTIRS2readACDir(ir);


I hope this all was clear. Let me know if you have any questions! 8)

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Tue Dec 02, 2014 9:25 pm
Profile
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post Re: IR Seeker not working?
Oh yes! It works like a charm now.

#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S2, touch, sensorNone)
#pragma config(Sensor, S3, ir, sensorI2CCustom)
#pragma config(Sensor, S4, sonar, sensorNone)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop, driveRight, encoder)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop, reversed, driveLeft, encoder)
#pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "hitechnic-irseeker-v2.h"

task main()
{
HTIRS2setDSPMode(ir, DSP_1200);
int irvalue;
while(true)
{
irvalue = HTIRS2readACDir(ir);
displayTextLine(5,"%d",irvalue);
}
}

Thanks a bunch for help. Quick question before I start adding stuff to the code: Is there anything else I could add or remove from the current code?


Sat Dec 06, 2014 12:20 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: IR Seeker not working?
routhken wrote:
Thanks a bunch for help. Quick question before I start adding stuff to the code: Is there anything else I could add or remove from the current code?


Nope, it looks good! Good luck on the rest of your program! 8)

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Sun Dec 07, 2014 12:07 am
Profile
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post Re: IR Seeker not working?
I'm having problems with the IR Seeker again. It was working fine until the 4.28 BETA update to robotc, once the driver suite was reinstalled, the value displayed on the NXT is -1 always. I didn't even know that was possible, I thought it was 1-9 for direction and 0 for undetected. For the sake of simplicity I removed the irrelevant portion of the code so this page wouldn't be miles long.

#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S3, ir, sensorI2CCustom)
#pragma config(Motor, mtr_S1_C1_1, D, tmotorTetrix, openLoop, driveRight, encoder)
#pragma config(Motor, mtr_S1_C1_2, E, tmotorTetrix, openLoop, reversed, driveLeft, encoder)
#pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "hitechnic-irseeker-v2.h"

task main()
{
HTIRS2setDSPMode(ir, DSP_1200);
int irvalue;
while(true)
{
irvalue = HTIRS2readACDir(ir);
displayTextLine(5,"%d",irvalue);
}
}

I can't find any info on negative IR value anywhere, so I would like to know what's going on exactly. Thanks in advance.


Thu Jan 15, 2015 2:58 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: IR Seeker not working?
And you're using the latest version of the drivers from https://github.com/botbench/robotcdriversuite ?

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu Jan 15, 2015 3:02 pm
Profile WWW
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post Re: IR Seeker not working?
The latest one I can find is 3.3.1 and that was already installed.


Thu Jan 15, 2015 3:11 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: IR Seeker not working?
Did you go to the website I posted in my last post?

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Jan 16, 2015 2:17 am
Profile WWW
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post Re: IR Seeker not working?
Yes. The master suite correct? The results have not changed though.


Fri Jan 16, 2015 2:08 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: IR Seeker not working?
This is the program you tested with? https://github.com/botbench/robotcdrive ... v2-test1.c ?

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Jan 16, 2015 3:47 pm
Profile WWW
Rookie

Joined: Thu Nov 13, 2014 6:57 pm
Posts: 9
Post Re: IR Seeker not working?
Yeah but I get a boat load of compile errors that I wouldn't know how to go about correcting because the semicolons look like they're placed in the proper locations. The master suite "include" folder is set as the directory.

#pragma config(Sensor, S1, HTIRS2, sensorI2CCustom)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "hitechnic-irseeker-v2.h"

task main ()
{
displayCenteredTextLine(0, "HiTechnic");
displayCenteredBigTextLine(1, "IR Seekr");
displayCenteredTextLine(3, "Test 1");
displayCenteredTextLine(5, "Press enter to");
displayCenteredTextLine(6, "switch between");
displayCenteredTextLine(7, "600 and 1200 Hz");
sleep(2000);
tHTIRS2 irSeeker;
initSensor(&irSeeker, S1);
while(true)
{
playSound(soundBeepBeep);
while(bSoundActive)
{}
eraseDisplay();
if (irSeeker.mode == DSP_1200)
displayTextLine(0, " DC 1200");
else
displayTextLine(0, " DC 600");
while (true)
{
if (getXbuttonValue(xButtonEnter))
{
irSeeker.mode = (irSeeker.mode == DSP_1200) ? DSP_600 : DSP_1200;
while(getXbuttonValue(xButtonEnter))
{
sleep(1);
}
break;
}
readSensor(&irSeeker);
displayTextLine(1, "D:%4d %4d 3%d", irSeeker.dcDirection, irSeeker.acDirection, irSeeker.enhDirection);
displayTextLine(2, "0:%4d %d", irSeeker.dcValues[0], irSeeker.acValues[0]);
displayTextLine(3, "0:%4d %4d", irSeeker.dcValues[1], irSeeker.acValues[1]);
displayTextLine(4, "0:%4d %4d %3d", irSeeker.dcValues[2], irSeeker.acValues[2], irSeeker.enhStrength);
displayTextLine(5, "0:%4d %4d", irSeeker.dcValues[3], irSeeker.acValues[3]);
displayTextLine(6, "0:%4d %4d", irSeeker.dcValues[4], irSeeker.acValues[4]);
displayTextLine(7, "Enter to switch");
}
}
}

The compile errors:
*Warning*:Substituting similar variable 'playSound' for 'PlaySound'. Check spelling and letter case.
*Warning*:Symbol 'nxtDisplayCenteredTextLine' is 'deprecated' definition. There may be alternate symbol with equivalent functionality.
*Warning*:Substituting similar variable 'stopAllTasks' for 'StopAllTasks'. Check spelling and letter case.
*Warning*:Substituting similar variable 'playSound' for 'PlaySound'. Check spelling and letter case.
*Warning*:Substituting similar variable 'stopAllTasks' for 'StopAllTasks'. Check spelling and letter case.
*Warning*:Substituting similar variable 'stringFind' for 'StringFind'. Check spelling and letter case.
*Warning*:'enum' is anonymous declaration. The 'typedef' for 'tHTIRS2DSPMode' has no impact!
**Error**:Undefined variable 'tHTIRS2'. 'short' assumed.
**Error**:Expected->';'. Found 'irSeeker'
**Error**:Undefined variable 'irSeeker'. 'short' assumed.
*Warning*:Meaningless statement -- no code generated
**Error**:Undefined procedure 'initSensor'.
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'mode'
**Error**:Undefined variable 'mode'. 'short' assumed.
*Warning*:Mismatched typedefs. Converting typedef 'tHTIRS2DSPMode' to typedef 'long', value 'DSP_1200'
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement. Did you mean '=' instead of '=='?
**Error**:Unexpected 'else'. Ignored.
**Error**:Unexpected 'displayTextLine' during parsing
*Warning*:')' exepected before before ','. Automatically inserted.
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Unexpected ' DC 600' during parsing
**Error**:Unexpected ')' during parsing
**Error**:Undefined procedure 'getXbuttonValue'.
**Error**:Undefined variable 'xButtonEnter'. 'short' assumed.
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:Expected->';'. Found 'mode'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'mode'
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
**Error**:Unexpected '?' during parsing
*Warning*:Meaningless statement -- no code generated
*Warning*:Meaningless statement. Did you mean '=' instead of '=='?
**Error**:Undefined procedure 'readSensor'.
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'dcDirection'
**Error**:Expected->';'. Found 'dcDirection'
**Error**:Undefined variable 'dcDirection'. 'short' assumed.
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found 'acDirection'
**Error**:Undefined variable 'acDirection'. 'short' assumed.
**Error**:Expected->';'. Found 'enhDirection'
**Error**:Undefined variable 'enhDirection'. 'short' assumed.
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'dcValues'
**Error**:Expected->';'. Found 'dcValues'
**Error**:Undefined variable 'dcValues'. 'short' assumed.
**Error**:LValue for '[]' operator must be a pointer
**Error**:'[]' operator requires pointer value on left hand side [2].
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found 'acValues'
**Error**:Undefined variable 'acValues'. 'short' assumed.
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'dcValues'
**Error**:Expected->';'. Found 'dcValues'
**Error**:LValue for '[]' operator must be a pointer
**Error**:'[]' operator requires pointer value on left hand side [2].
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found 'acValues'
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'dcValues'
**Error**:Expected->';'. Found 'dcValues'
**Error**:LValue for '[]' operator must be a pointer
**Error**:'[]' operator requires pointer value on left hand side [2].
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found 'acValues'
**Error**:Expected->';'. Found 'enhStrength'
**Error**:Undefined variable 'enhStrength'. 'short' assumed.
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'dcValues'
**Error**:Expected->';'. Found 'dcValues'
**Error**:LValue for '[]' operator must be a pointer
**Error**:'[]' operator requires pointer value on left hand side [2].
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found 'acValues'
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated
**Error**:'irSeeker' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'dcValues'
**Error**:Expected->';'. Found 'dcValues'
**Error**:LValue for '[]' operator must be a pointer
**Error**:'[]' operator requires pointer value on left hand side [2].
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found 'acValues'
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated
**FATAL**:Too many errors. Compilation aborted


Fri Jan 16, 2015 4:07 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 18 posts ]  Go to page 1, 2  Next

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.