ROBOTC.net forums
http://www.robotc.net/forums/

Using NrLink with PF Remote
http://www.robotc.net/forums/viewtopic.php?f=15&t=4464
Page 1 of 1

Author:  todorangrg [ Mon Apr 23, 2012 8:21 am ]
Post subject:  Using NrLink with PF Remote

Hello,
I am currently working on a project where, for debugging reasons (nxtOSEK has no debugger :( ) I have to tell the robot to go in "look what's happening" phase from a distance. I have the NrLink and I am struggling to use the PF Remote as a state switch for the robot. But in this direction I didn't found a lot of info. So I looked in the specification PDF for NrLink and I am currently trying to identify the Remote commands from the Rx Buffer. From what I read there, it looks like the buffer begins at 0x42 and has the max length of 32 bytes (the counter from address 0x40 goes up till 0x20(32 dec) ). So i started to printf the first 10 bytes from the buffer and nothing looks like something readable (I found on internet the PF code, 16 bytes for each command).

Now the specification pdf says that 0x42 is just a pseudoregister pointing to the FIFO register (i tried to read at address given in 0x42 but same, weird results).
Also I am not sure if the buffer holds the values identifying the beginning of the burst or it just makes a pushback for each bit?
If the code is 16 bytes, i have to find the paired 2 bytes that have the given value?

I hope someone can make me understand what I am doing wrong or provide better details about the sensor and what (and how) does it identify.

Best Regards,
George Todoran

Author:  miki [ Mon Apr 23, 2012 2:19 pm ]
Post subject:  Re: Using NrLink with PF Remote

Hi todorangrg,
todorangrg wrote:
...nxtOSEK has no debugger :( ...
While it's not a nxtOSEK forum, you may get some help from RobotC users if you add more details about your communication issue. The protocol and hardware layers of an IR communication can interest some of them.
I suggest that you insert, in your demand,
  • url links to (or copy/paste of) your documentation,
  • source code where you see issues,
  • datalog showing what's happen (and what you expected)

The only fact to explain with a lot of clarity your issue will bring light upon your work :-)
best regards.
Miki.

Author:  mightor [ Tue Apr 24, 2012 5:44 am ]
Post subject:  Re: Using NrLink with PF Remote

This is one of the few NXT sensors I actually don't own. Did you take a look at some of the NXC and ROBOTC code that you can download from here: [LINK]?

- Xander

Author:  todorangrg [ Tue Apr 24, 2012 6:41 am ]
Post subject:  Re: Using NrLink with PF Remote

So the best documentation I found so far is http://www.tau.ac.il/~stoledo/lego/AVR-ir/ and the user guide, http://www.mindsensors.com/index.php?module=documents&JAS_DocumentManager_op=viewDocument&JAS_Document_id=11. The first link is actually what I am trying to do. I downloaded the code but that is a bit too complicated and lowlevel for me to understand. Other than those, all I can find doesn't relate with the sensor to receive, but to send data. I did spend a lot of time understanding the registers from the user guide, but I feel the given information of how each register works is limited.

What I want to know is how does the sensor receive the signal (in 1 byte chunks with auto-packets? or I have to make a search to find the first bit of the transmission? is the 2 byte transmitted signal continuous?).
Also from the user guide I can see that there are read and write registers at the same address (that means there are 2 registers or each byte is half-read, half-write (that would mean that for 2 byte chunks I should read 4 bytes from the register?))

If someone (mostly referring to mightor :) ) could take a look at the user guide and see if my presumptions about the registers are good I will be very grateful.
So far my attempts were:
1.
-look how many bytes (len) are stored in Rx buffer (atr adress 0x40)
-look at 0x42 for the first len bytes and look what values are stored in that vector;-> this leads to some pretty much random values that have nothing to do with the data I collected from the first reference site and that are constantly changing while I keep the remote pressed
2.
-look how many bytes (len) are stored in Rx buffer (atr adress 0x40)
-look at 0x42 for the first byte and look for the first len bytes at adress stored at 0x42 for what values are stored in that vector;-> this leads to some pretty much random values that have nothing to do with the data I collected from the first reference site and that are constantly changing while I keep the remote pressed
(i did this seeing from the user guide that the register at 0x42 is pseudo and POINTS to the FIFO position)

code extracts:
Code:
//attempt no 1.
//this works in a task
U8 dat[2]={0};
Remote.receive(0x40,dat,1);
if(dat[0]>=10){
   Remote.receive(0x42,REMVAL,10);
   dat[0]=0x46;
   //Remote.send(0x41,dat,1);//if i want to flush the buffer
}
/////////////////////////////////////////////////////////////////////////////////
//this in main task
lcd.putf("sx","val0=",REMVAL[0],0);lcd.putf("sxn","  val1=",REMVAL[1],0);
lcd.putf("sx","val2=",REMVAL[2],0);lcd.putf("sxn","  val3=",REMVAL[3],0);
lcd.putf("sx","val4=",REMVAL[4],0);lcd.putf("sxn","  val5=",REMVAL[5],0);
lcd.putf("sx","val6=",REMVAL[6],0);lcd.putf("sxn","  val7=",REMVAL[7],0);
lcd.putf("sx","val8=",REMVAL[8],0);lcd.putf("sxn","  val9=",REMVAL[9],0);



Running this will give random numbers for the 10 bytes and also randomly many of them become 0xFF. when i stop pressing the remote, everything is still, again pretty random values inside.

Best Regards,
George Todoran

Author:  mightor [ Tue Apr 24, 2012 12:41 pm ]
Post subject:  Re: Using NrLink with PF Remote

I have no experience with this sensor but I have used the HiTechnic IRLink in this manner. I tried using it with the remote control and it turned out to be a complete pain in the behind (trying to be polite here). I found that even if I polled continuously and read the buffer, I still ended up not reading it fast enough or ending up with partial packets, etc.
The thing is, when you press a button on the remote, it constantly resends the packet, non-stop. It is up to you to find the start (pre-amble) and work from there.
The HT IRLink does not have the overflow thing that this sensor of yours has, so that's quite nice. Did you check the ROBOTC, NXC and Lejos code that is on the page that I pasted earlier? If the guide is too low level to understand than I am not really sure how you'll be able to write a driver for it. You need to fully understand how the RCX protocol works, how it's transmitted from the remote and how your sensor processes it, without that, I'm afraid you'll have a very hard time working with it.
If you have an RCX IR Tower, which I assume you do, you can use Putty or something to listen to the specific COM port and "spy" to see what the remote is sending. That's how I played with it.

- Xander

Author:  mattallen37 [ Wed May 02, 2012 2:04 am ]
Post subject:  Re: Using NrLink with PF Remote

The PF communication protocol is significantly different from the UART the NrLink uses. The 2 protocols have practically nothing in common, other than using IR and the same carrier frequency. Without FW specifically designed to support the PF protocol, it is impossible to make it work as I understand you want it to.

If you want the PF communication protocol specs of all levels, you can read this PDF. It's a Power Functions communication protocol specification guide released by TLG, and I found it very easy to read and understand.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/