View unanswered posts | View active topics It is currently Wed Oct 22, 2014 2:22 am






Reply to topic  [ 10 posts ] 
Help with Irlink sensor and HTRCXReadResp() 
Author Message
Rookie

Joined: Sun Jan 23, 2011 3:14 am
Posts: 10
Post Help with Irlink sensor and HTRCXReadResp()
Hi. Im having a hard time getting my program to compile using this command. Example:

#pragma config(Sensor, S1, HTRCX, sensorI2CCustom)

#include "HTRCX-driver.h"
int rcxmessage[0];
bool rcxmessagesuccess = 0;
task main ()
{
while (1==1)
{
if (HTRCXreadResp(HTRCX, rcxmessage,rcxmessagesuccess ) != 0)
{
rcxmessage = HTRCXreadResp(HTRCX, rcxmessage,rcxmessagesuccess);

eraseDisplay();

nxtDisplayString(3, "RCX: %d", rcxmessage);
}
}
}

Can someone please tell me the proper way to use this command? Thanks.


Mon May 21, 2012 10:09 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Help with Irlink sensor and HTRCXReadResp()
You want to display the message received from the RCX, right? I think that this code will accomplish that:
Code:
#pragma config(Sensor, S1, HTRCX, sensorI2CCustom)

#include "drivers/HTRCX-driver.h"
unsigned byte rcxmessage[1];
task main ()
{
  while (1==1)
  {
    HTRCXreadResp(HTRCX, rcxmessage[0]);
   
    if (rcxmessage[0] != 0)
    {
      eraseDisplay();

      nxtDisplayString(3, "RCX: %d", rcxmessage);
    }
  }
}
(Please put your code in the
Code:
[code][/code]
tags next time.)

I'm not positive, but I think this should work. I've never used the IRLink with the RCX in RobotC before.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon May 21, 2012 10:38 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3225
Location: Rotterdam, The Netherlands
Post Re: Help with Irlink sensor and HTRCXReadResp()
Try this code:
Code:
#pragma config(Sensor, S1, HTRCX, sensorI2CCustom)

#include "drivers/HTRCX-driver.h"
tByteArray rcxmessage;

task main ()
{
  while (1==1)
  {
    if (HTRCXreadResp(HTRCX, rcxmessage))
    {
      eraseDisplay();
      nxtDisplayString(3, "RCX: %d", rcxmessage[0]);
    }
  }
}


Please note that HTRCXreadResp() is flaky at the best of times and dumps the whole register, so be sure to check more than just rcxmessage[0]. I never got it working reliably as a means to read something from the RCX. The buffer will be overwritten in the sensor whenever something new comes along. It's a real pain in the butt.

- 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]


Tue May 22, 2012 12:17 am
Profile WWW
Rookie

Joined: Sun Jan 23, 2011 3:14 am
Posts: 10
Post Re: Help with Irlink sensor and HTRCXReadResp()
Thanks guys I knew it was something simple. Ill report back on how I make out with this.


Tue May 22, 2012 1:08 am
Profile
Rookie

Joined: Sun Jan 23, 2011 3:14 am
Posts: 10
Post Re: Help with Irlink sensor and HTRCXReadResp()
No problem sending to the RCX but receiving, as far as I can tell, is a no go.


Tue May 22, 2012 4:22 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Help with Irlink sensor and HTRCXReadResp()
Did you try what Xander said and read the whole register? You can use a "for()" loop for that instead of typing out the display command 8 times.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue May 22, 2012 8:56 am
Profile WWW
Rookie

Joined: Sun Jan 23, 2011 3:14 am
Posts: 10
Post Re: Help with Irlink sensor and HTRCXReadResp()
Im sorry im no programming expert, I use Robot C because NXT-G is almost unusable. I really dont know what you mean by "the whole register". Ill show you what I tried..
NXT Program:

Code:
#include "drivers/HTRCX-driver.h"
unsigned byte rcxmessage[1];
task main ()
{
  while (1==1)
  {
    HTRCXreadResp(HTRCX, rcxmessage[0]);
   
    if (rcxmessage[0] != 0)
    {
      eraseDisplay();

      nxtDisplayString(3, "RCX: %d", rcxmessage);
    }
  }
}


RCX Program:

Code:
task main()

{
  while (1==1)
  {
    sendMessageWithParm(2);
    wait10Msec(1000);
    sendMessageWithParm(3);
  }
}


So far I am finding Robot C to be a great programming environment for the NXT its just when it comes to hex things and registers I become lost. Thanks for all the help and if you can think of any online sources where I could read on this a bit more I would be most grateful. Thanks again!

Note: I am using Robot C 3.08 for the NXT and 2.03 for the RCX


Tue May 22, 2012 1:20 pm
Profile
Rookie

Joined: Sun May 26, 2013 4:52 pm
Posts: 2
Post Re: Help with Irlink sensor and HTRCXReadResp()
Hi ,
following Xander indications,
I managed to send some commands from my RCX 2.0 to my NXT using the IRLink sensor.
I receive garbage on the NXT most of the times.
Then How can we know when the NXT has received the right data, and when can we read it ??
Well, I found a pattern that helps me to filter the data received by the NXT.
Here is the code.

if (HTRCXreadResp(HTRCX, rcxmessage))
{
if (rcxmessage[1] == 247 && rcxmessage[2]==8 && rcxmessage[3] != 147 ){
data = rcxmessage[3];
nxtDisplayString(1,"RCX sent: %d ",rcxmessage[3]);
}else if (rcxmessage[2] == 8) {
data = rcxmessage[3];
nxtDisplayString(1,"RCX sent: %d ",rcxmessage[3]);
}else if (rcxmessage[1] == 8 && rcxmessage[2] != 247) {
dato = rcxmessage[2];
nxtDisplayString(1,"RCX sent: %d ",rcxmessage[2]);
}
}

Hope you can find it useful.
Here are some videos that show how it works ...

http://www.youtube.com/watch?v=jF5_3Y_G4P0
http://www.youtube.com/watch?v=6RtNWyx-9_Q


Best regards.
Elias.


Sun Oct 06, 2013 5:25 pm
Profile
Rookie

Joined: Sun May 26, 2013 4:52 pm
Posts: 2
Post Re: Help with Irlink sensor and HTRCXReadResp()
well, the yellow face with sun glasses , should be number "8)"
Some how the string "8)" has been replaced by that smilie


Sun Oct 06, 2013 5:28 pm
Profile
Expert
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 164
Location: California, USA
Post Re: Help with Irlink sensor and HTRCXReadResp()
NeXT-Generation wrote:
You want to display the message received from the RCX, right? I think that this code will accomplish that:
Code:
    HTRCXreadResp(HTRCX, rcxmessage[0]);
(Please put your code in the
Code:
[code][/code]
tags next time.)

I'm not positive, but I think this should work. I've never used the IRLink with the RCX in RobotC before.

So the "HTRCX" command prefix designates talking to a rcx via an infrared link? :?

_________________
string Robored = "Awesome"
~~Neil Balch~~


Sat Oct 19, 2013 1:14 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 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.