Page 1 of 7

RS485 NXT-G Block

Posted: 28 Feb 2011, 15:21
by milluzaj
I have created a NXT-G block to use the RS485. Xander posted to his blog. Here is the somewhat formal release notes:

This block only uses sensor port 4 of the NXT to connect to another NXT (via sensor port 4). This block takes a string (in send mode) and will send it over port 4, using RS485. It does not check to ensure the other NXT receives it. As long as the send block successfully communicates it will return an output string of 0. A non 0 output value means an error occurred. This means you can broadcast a message to several NXTs. You can send numbers via this block, but you must convert them to a string first. In read mode, the NXT will check its RS485 buffer until it gets a message. This means it will wait for a message and not move on until it gets one. If you plan to continually read a value, I suggest you do this in parallel in a loop as to not halt the overall program. The value read will be returned as a string.

This is just the first release, so I am looking for some feedback. I plan on releasing another block in the near future with support for addressing and sending booleans and numbers. Please post comments below.

Re: RS485 NXT-G Block

Posted: 01 Mar 2011, 02:33
by haydenstudios
Thank you for showing such support to us NXT-G users, and enabling RS485 communication with NXT-G! For quite a few weeks, I've been thinking,"if only I could do RS485, then this would be so much easier!", and here I stand with it a reality! Although, of coarse, you had probably been working on this block for more than a few weeks :) . I've attached a demo program with this post which scratches the surface of what can and will be done with this new block. I will give feedback in two forms, one in video, and another in text.
Click here for the one in video:

Click here for the version in text which has no stuttering, or "uh"s, and includes some important details that might have gotten left out in the video:
This is just the first release, so I am looking for some feedback. I plan on releasing another block in the near future with support for addressing and sending booleans and numbers. Please post comments below.
In general, this block is awesome but to follow up on your request, I will inform you of some things, here it goes:
I am glad that you will have support for booleans and numbers in the future, that would be very useful. I had some strange glitch when trying to plug the text output plug directly into a text switch block. When I tried to do so, the NXT would only execute the code found in the tab that I set as the default. I tried plugging that string (the string that is received) into a display block, and sure enough it was displaying the number it should be. I managed to work around this bug by converting the string into a number, and feeding that number into a tab viewed number switch block. But not everybody has the text to number block installed on their system, so I don't want to have to do this every time.
It does not check to ensure the other NXT receives it. As long as the send block successfully communicates it will return an output string of 0. A non 0 output value means an error occurred.
Hmmm... Well, I tried seeing what value was displayed by the NXT when my two NXTs were not connected to each other and the output plug was plugged into a display block, and I still got a "0" then. I still don't quite understand what you were trying to say, because it sounded to me like you were saying that it doesn't check to ensure the other NXT receives the message, but it does. On the other hand, I may just be interpereting your words that way just due to my inability to understand what you meant.
At another point, I had a strange situation when first writing this demo program where the string received by the NXT would always have a lowercase, "t" added onto the end of it. For example, a "0" would change to "0t". But I did not get to further investigate this because NXT-G crashed when I was finishing it, and I had to start over. When I started over, this phenomenon was no longer occuring. But perhaps it was somehow happening because of some mistake that I was unknowingly making.
All in all, this is a great block, and I take into account that the main reason that we have all these bugs is that this is a very early version, and I hope that my feedback is helpful to you, and that it is taken as friendly criticism, and not interpereted as trolling or flaming. Thank you for bringing the RS485 capabilities to us NXT-G users. Many thanks from me, and keep it up.

Re: RS485 NXT-G Block

Posted: 01 Mar 2011, 16:07
by milluzaj
Thanks for the feedback. I have no idea what the "t" thing is. I will try to reproduce that.

As for the 0 return value. When do something on the NXT you write to a register in the firmware. This block does the same thing. I dont require a reply in this block (though I am making a block that implements a communication protocol that would handle that) so all it knows is that it was written to the firmware. So in theory if there is a disconnected cable or something, it would have no idea if it got the information.


Keep the feedback coming. Also if there are any artists out there that could make a nice graphic for this (36 pixels by 36 pixels), I would be very happy. My MS Paint skills only go so far.

Re: RS485 NXT-G Block

Posted: 01 Mar 2011, 17:24
by mightor
milluzaj wrote:My MS Paint skills only go so far.
Dude, they're bloody legendary!

- Xander

Re: RS485 NXT-G Block

Posted: 02 Mar 2011, 04:33
by haydenstudios
milluzaj wrote:Keep the feedback coming. Also if there are any artists out there that could make a nice graphic for this (36 pixels by 36 pixels), I would be very happy. My MS Paint skills only go so far.
Well, I might be able to help. I have made an icon, and apllied it to the image files in the NXT-G block. In this .zip file can be found screenshots from NXT-G of what the icon looks like when applied to this block. Heres a couple now: ImageImage
In my opinion, it doesn't look too bad, but that's probably just because I am proud of my day's work. Anyway, it's pretty much all there for you in the .zip if you decide to use it. The icon, and the dragged image are there. But you'll notice that I do not know how to edit the "Config RS485.vi" file, and that the original icon is still shown in the configuration panel, so you'd have to raplace it with the "RS485configpanel.png" image that I've also included which should be pretty straight forward (if you decide to use these image files). So, if you think that these images are pathetic, and completely unsuitable for your block, then do not hesitate to say no thanks to this offer, I will not be offended at all. If you decide to use them, then GREAT!! :D

Re: RS485 NXT-G Block

Posted: 02 Mar 2011, 09:12
by timpattinson
I've made some graphics...
485.zip
Zip file with PNG icon and GIMP file
(4.26 KiB) Downloaded 781 times
Hope you like them
-Tim

Re: RS485 NXT-G Block

Posted: 02 Mar 2011, 12:11
by renchiou
Thanks for the great block. I tested it, If I send "12345" then send "1234567", the slave NXT shows "123456". I think it's the problem of buffer. Would you please check it? Thanks!

Re: RS485 NXT-G Block

Posted: 04 Mar 2011, 04:21
by milluzaj
Thanks for the images. If you dont mine, I would love to use some of them in future blocks (and revision 2 of this one). I have a block with a protocol coming soon (similar to Xander's protocol for the xbee in robot C).

I am going to play with the buffer issue. I cant seem to replicate it, but I will keep trying. What firmware was that with?

Re: RS485 NXT-G Block

Posted: 04 Mar 2011, 07:22
by timpattinson
Hi, If it was my images you were talking about then sure you can use them
-Tim

Re: RS485 NXT-G Block

Posted: 04 Mar 2011, 09:24
by gloomyandy
Hi,
If you looking at adding a higher level protocol you may want to consider bitbus...
http://www.bitbus.org/

When I added RS485 support to leJOS I spent a fair bit of time looking around at various protocols to use and finally decided on bitbus. It seems to strike the right balance between robustness and simplicity. The packets use CRC-16-CITT error checking and the protocol allows for multiple devices and handles retransmission etc. The leJOS firmware and class libraries contain code that allows you to construct a master slave network using the name or Bluetooth address of the NXT to establish reliable connections between up to 8 devices.

Andy