Subject:
|
Re: NRLink reading RCX response
|
Newsgroups:
|
lugnet.robotics.nxt
|
Date:
|
Sat, 4 Aug 2007 15:19:46 GMT
|
Viewed:
|
22637 times
|
| |
 | |
In lugnet.robotics.nxt, Wes Matchett wrote:
> I have posted a problem to the RobotC forums and not recieved any response:
> http://www.robotc.net/forums/viewtopic.php?t=230
>
> Does anyone here have any experience with RobotC (how is their support)?
>
> Has anyone here worked with the NRLink? Have you been able to get a response
> from the RCX?
>
> Thanks,
> -Wes
You might want to consider using NXC and the standard NXT firmware. Here's some
code John Barnes wrote in NXC for reading sensor values via the NRLink:
int count;
int sensorval;
int i;
int temp;
byte toggle=0;
byte csum;
byte RCXcmnd[]; /*[0] = total number of bytes (TX+RX)
[1] = number of command bytes
[2] = number of response bytes
[3] - command bytes
*/
byte inI2Ccmd[];
byte outbuf[];
void RCXcommand()
{
csum = 0;
temp = 10 + 2 * RCXcmnd[1] ;
ArrayInit(inI2Ccmd, 0, temp);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x48 - 2 * RCXcmnd[1];
inI2Ccmd[2] = 0x55;
inI2Ccmd[3] = 0xFF;
inI2Ccmd[4] = 0x00;
inI2Ccmd[5] = RCXcmnd[3] | toggle;
inI2Ccmd[6] = 255 - (RCXcmnd[3] | toggle);
csum=RCXcmnd[3] | toggle;
i=0;
if (toggle==0)
{
toggle = 8;
}
else
{
toggle = 0;
}
if (RCXcmnd[1] > 1)
{
while (i < RCXcmnd[1] - 1)
{
inI2Ccmd[2*i+7] = RCXcmnd[i+4];
inI2Ccmd[2*i+8] = 255 - RCXcmnd[i+4];
csum += RCXcmnd[i+4];
i++;
}
}
inI2Ccmd[2*i+7] = csum;
inI2Ccmd[2*i+8] = 255 - csum;
inI2Ccmd[2*i+9] = 2 * RCXcmnd[1] + 5;
inI2Ccmd[2*i+10] = 0x00;
inI2Ccmd[2*i+11] = 0x01;
temp=0;
I2CBytes(IN_1, inI2Ccmd, temp, outbuf);
temp = RCXcmnd[0]*5;
Wait(temp);
if (RCXcmnd[2]>0)
{
ArrayInit(inI2Ccmd, 0, 2);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x51;
// temp = RCXcmnd[2];
temp = 8;
I2CBytes(IN_1, inI2Ccmd, temp, outbuf);
}
}
task main()
{
SetSensorLowspeed(IN_1);
while (TRUE)
{
ArrayInit(RCXcmnd,0,6);
RCXcmnd[0]=22;
RCXcmnd[1]=3;
RCXcmnd[2]=12;
RCXcmnd[3]=0x12;
RCXcmnd[4]=0x09;
RCXcmnd[5]=0x00;
RCXcommand(); //read sensor 1
sensorval = outbuf[5] + 256 * outbuf[7];
ClearScreen();
NumOut(0, 40, sensorval);
ArrayInit(RCXcmnd,0,6);
RCXcmnd[0]=22;
RCXcmnd[1]=3;
RCXcmnd[2]=12;
RCXcmnd[3]=0x12;
RCXcmnd[4]=0x09;
RCXcmnd[5]=0x01;
RCXcommand(); //read sensor 2
sensorval = outbuf[5] + 256 * outbuf[7];
NumOut(25, 40, sensorval);
ArrayInit(RCXcmnd,0,6);
RCXcmnd[0]=22;
RCXcmnd[1]=3;
RCXcmnd[2]=12;
RCXcmnd[3]=0x12;
RCXcmnd[4]=0x09;
RCXcmnd[5]=0x02;
RCXcommand(); //read sensor 3
sensorval = outbuf[5] + 256 * outbuf[7];
NumOut(50, 40, sensorval);
Wait(250);
}
}
John Hansen
|
|
Message has 1 Reply:  | | Re: NRLink reading RCX response
|
| (...) Thanks for the recommendation John, I think we met in '99 at Mindfest at MIT, but I'm sure you met way too many to remember. I'm a long-time user of NQC and I evaluated NXC right after I got the NXT, along with RobotC. I've been focusing on (...) (18 years ago, 5-Aug-07, to lugnet.robotics.nxt)
|
Message is in Reply To:
 | | NRLink reading RCX response w/ RobotC
|
| I have posted a problem to the RobotC forums and not recieved any response: (URL) anyone here have any experience with RobotC (how is their support)? Has anyone here worked with the NRLink? Have you been able to get a response from the RCX? Thanks, (...) (18 years ago, 31-Jul-07, to lugnet.robotics.nxt)
|
8 Messages in This Thread:           
    
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|