View unanswered posts | View active topics It is currently Sat Sep 20, 2014 10:56 pm






Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
IR Seeker 
Author Message
Rookie

Joined: Thu Nov 19, 2009 1:21 pm
Posts: 11
Post Re: IR Seeker
We think we have all the programming set-up (it seems to follow all the directions we've read), but the IR seeker is not registering. When we open the NXT Device Debugger window, it tells us there is no sensor, even though it is set-up in the Motor and Sensor Setup.
Below is our code to make a simple bot follow the IR beacon:
Code:
#include "common.h"
#include "HTDIR-driver.h"

task main()
{
  while (1 == 1)
  {
        if(SensorValue[irseeker] == 5)
        {
           motor[motorRight] = 25;
           motor[motorLeft] = 25;
        }

        if(SensorValue[irseeker] < 5)
        {
          motor[motorRight] = 100;
          motor[motorLeft] = 25;

        }

        if(SensorValue[irseeker] > 5)
        {
          motor[motorRight] = 25;
          motor[motorLeft] = 100;

        }

   }

}


Any idea's what is up? Our codes doesn't show any errors...


Wed Nov 25, 2009 3:22 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post Re: IR Seeker
You're not using the library correctly. Did you look at HTDIR-test1.c? Please take the time to look at these examples. They show you how to use the libraries. Also next time include *all* of your source code, not just the snippets you think are interesting.

Code:
#pragma config(Sensor, S1,     HTDIR,               sensorLowSpeed)
#pragma config(Motor,  motorA,          motorRight,    tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorB,          motorLeft,     tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "common.h"
#include "HTDIR-driver.h"

task main()
{
  int dir = 0;
  while (1 == 1)
  {
    // Read the direction from which the IR signal is coming
    // If you are using a beacon that transmits a modulated signal, you must choose which frequency
    // you want the sensor to listen to.  This is either 600Hz or 1200Hz.

    // Use this to set to 600Hz
    // HTDIRsetDSPMode(HTDIR, DSP_600);

    // Use this to set to 1200Hz (the default)
    HTDIRsetDSPMode(HTDIR, DSP_1200);

    // Read the modulated signal's direction
    dir = HTDIRreadACDir(HTDIR);
   
    if(dir == 5)
    {
      motor[motorRight] = 25;
      motor[motorLeft] = 25;
    }
 
    if(dir < 5)
    {
      motor[motorRight] = 100;
      motor[motorLeft] = 25;
    }
   
    if(dir > 5)
    {
      motor[motorRight] = 25;
      motor[motorLeft] = 100;
    }   
  }
}


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]


Wed Nov 25, 2009 3:32 pm
Profile WWW
Rookie

Joined: Sun Nov 16, 2008 3:07 pm
Posts: 45
Post Re: IR Seeker
FYI, if you want to create RobotC files that don't complain if some of the contents are not used, you can use this pragma:
#pragma systemFile // this eliminates warning for "unreferenced" functions

(Above comment is directed at people who are creating system files, such as the IR Seeker driver, not so much at people using it, since it is generally a bad habit to make changes to the provided system files).


Another of the obstacles to using the various IR Seeker examples is that it seems the versions of the driver files and example files are mismatched. I don't remember where I got the example Application, but it wanted to use the Driver sort of like this:

tIntArray sensorValuesAC;

HTDIRreadAllACStrength(irSeeker, sensorValuesAC);

but I found that in the .h file, the sensor values were not an array of 5 ints, but rather 5 scalar ints, which I successfully invoked like this:
short sensorValuesACx[5];

// define irSeeker in the #pragma created from Robot->Motor and Sensors Setup
HTDIRreadAllACStrength(link,
sensorValuesACx[0],
sensorValuesACx[1],
sensorValuesACx[2],
sensorValuesACx[3],
sensorValuesACx[4],
); /* Reads in the AC values of the IR Seeker, 'irSeeker' and */


Thu Dec 31, 2009 7:00 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post Re: IR Seeker
Those functions have not used the array for quite some time. If you look at the change log you'll see that they were removed quite some time ago. The change from array to pass by reference was also mentioned in the release notes :)

Always check my blog for new release notices or check the project's website for updates. The current version is 1.2.

The latest release (1.2) also has the pragma you refer to in all of the drivers so that these warnings are no longer displayed.

Regards,
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 Dec 31, 2009 7:25 pm
Profile WWW
Rookie

Joined: Fri Nov 19, 2010 3:34 pm
Posts: 14
Post Re: IR Seeker
Xander, our IR Seeker v.2 is working for us, reading detector strengths just fine, but I'm a bit confused by the motor and sensor setup section. We got things working by manually typing in sensorLowSpeed, but we lose it every time the wizard gets run again, and have to retype it. I have to admit that I just enabled "Allow Custom Designed Sensors", so I'm not sure if we'll lose it again. However, when we select "I2C Custom" from the sensor options, like you recommend in one of the posts above, it automatically enters "sensorI2CCustom" into the header section, not "sensorLowSpeed", like I saw in your recommended code in one of the other posts above. Could you clarify what is happening?

BTW, there is now an option in the sensor menu for "HiTechnic IRSeeker 1200", which I have never heard mentioned as a preferred selection, though it would seem like the obvious choice.

The only thing we do with the sensor is get the strength values from detector 1 and 2 with the following:

Code:
ir1        = HTIRS2readACStrength(htIRS2, 0);  // reads the InfraRed sensor left detector
ir2        = HTIRS2readACStrength(htIRS2, 1);  // reads the InfraRed sensor right detector


Thanks,


Fri Feb 25, 2011 12:18 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post Re: IR Seeker
kfilar wrote:
I have to admit that I just enabled "Allow Custom Designed Sensors", so I'm not sure if we'll lose it again.

Yeah, having that enabled is a prerequisite :)

Quote:
However, when we select "I2C Custom" from the sensor options, like you recommend in one of the posts above, it automatically enters "sensorI2CCustom" into the header section, not "sensorLowSpeed", like I saw in your recommended code in one of the other posts above. Could you clarify what is happening?

Those sensors are one and the same, they just use different names for them between releases, don't ask me why. I would recommend you stick with 2.26.1 beta, it's very stable and I've been using without issues since October when it came out.

Quote:
BTW, there is now an option in the sensor menu for "HiTechnic IRSeeker 1200", which I have never heard mentioned as a preferred selection, though it would seem like the obvious choice.

You will be using the internal drivers then and they conflict with mine, as they'll both try to poll the sensor, sometimes at the same time. This will result in possibly really weird return values :) It really is an either/or when it comes to that stuff. I recommend using my drivers of course, haha.

- 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 Feb 25, 2011 12:46 pm
Profile WWW
Rookie

Joined: Fri Nov 19, 2010 3:34 pm
Posts: 14
Post Re: IR Seeker
Thanks very much Xander...

Your drivers are very much appreciated, as well as the quick response.


Fri Feb 25, 2011 8:00 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 22 posts ]  Go to page Previous  1, 2

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.