andyfarang

NXT bluetooth communication - helpless

Recommended Posts

Hello,

I have NXT brick. I have to decode communication protocol of bluetooth --->>> Make connection between notebook and NXT. Send commands and make NXT to react (make sound etc.), request data from sensors and receive them on notebook.

Problem is that I found a lot of programs to make this connection. Realterm, BricxCC...... etc. And I found a different commands and programming methods - something looks like "0x02 0x16" or "120 136" or "something that looks like C++".

And now I'm really confused. I don't know what program to choose and what language represent decoded communication protocol.

Can you help me please? I need some appropriate program, I need use some language that would show how protocol works and maybe some manual.

I will appreciate any help. Thank you, Andy

Share this post


Link to post
Share on other sites

Welcome to Eurobricks! :classic: Maybe Sariel's article about his "NXT Brick-to-Brick Remote" could help you; it contains ROBOTC programming code for Bluetooth communication.

1.png

On this LEGO.com MINDSTORMS webpage, there is a downloadable "Bluetooth Developer Kit" which "Documents the communications protocols to the intelligent NXT brick, enabling you to create applications for various Bluetooth devices to communicate with MINDSTORMS NXT robots."

picD7E59CE9755BD88B4BC0DBC8C1179C90.jpg

Edited by DLuders

Share this post


Link to post
Share on other sites

Thank you for your reply DLuders.

But as you can see now, there are two different language methods.

You sent link to official lego.com page. I've downloaded that manual, and there examples such as:

PLAYTONE

Byte 0: 0x00 or 0x80

Byte 1: 0x03

Byte 2........

And you also send link to Sariel's article, and he uses:

cCmdMessageRead(valueReceived, 1, 1);

nxtDisplayCenteredTextLine(0, "BAT: L%3.1f / R%3.1f", nImmediateBatteryLevel / (float) 1000, valueReceived[0] / (float) 10);

wait1Msec(50);

Now I'm confused, who is really using communication protocol. I need really it's decoded form.

Plus what program should I use?

I'm sorry I have so many questions. But after I find out what program should I use and what programming language and some manual, I think I'll be able to solve it on my own. But I really need that first kick. Thank you.

Share this post


Link to post
Share on other sites

As Dluders said, Sariel uses ROBOTC which is a program by it self. Download it, and copy the code from sariels to your own program. You need to update the bricks firmware in order to download the program to it though. Really, RobotC is a really easy program to work with, just type in what you want it to do. There's a lot of example files and tutorials included in the download as well.

Share this post


Link to post
Share on other sites

Hi first off we need to get things set-up right. I think you are trying to build an application on your laptop that can communicate with the NXT? if that's the case then Brixcc or robotc will not help unless you want to write a program for the NXT that will be running and expecting communications form the laptop in which case it will. Both NXC used by Brixcc or robtoc will create the appplcation for the NXT but not the laptop side of the program. So you will also need to create a new program on the laptop side. This could be written in any language that you are happy with, for me this will be C# on the winnows platform or Java on anything else.

you will need to create an application that can connect to the NXT using bluetooth, that's not to hard and then send it some commands, the likes of which you have seen form the lego.com web site. You are either instructing the firmware to do something or like play a sound of execute a program or you are sending a message to the bluetooh in box. if its a message your NXT code will be able to read this message and do something use full with it.

does that help at all?

Share this post


Link to post
Share on other sites

Thank you Carsten Svendsen and kieran for your replies.

My main goal is find out, how bluetooth protocol works. That at the beginning Master send "hello" Slave respond with "i'm ready" Master send "send me data from sensor 3" and Slave sends it. I have to describe how this protocol works. So the first step is find out, what is that protocol. Is that "0x00 0x3B 0x08" or is that "cCmdMessageWriteToBluetooth()"? Second option seems to me too "high programing", that I'm not working with that protocol but with some libraries.

After that I have to use appropriate SW and program some basic script, that would demonstrate this communication. And yes, I would like to notebook be master and NXC would be slave, that would be responding to commands.

I can see, that you're really trying to help me and I appreciate it very much. I'm sorry I can't describe my problem any better, because I'm really confused, helpless and starting to be really desperate. Because with every manual and every result in google and every your respond I'm getting another and another different program and method.

I've found Realterm. I thought, that if I put here some commands like "0x00 0x3B 0x08", NXC make some noise. If I put here another code, NXC would read it's inputs and sends it back. Without uploading any program to NXC or at my notebook. It's not really how it works?

post-33225-0-82571400-1353613506_thumb.png

Share this post


Link to post
Share on other sites

The solution for you depeneds on level you would like to work on.

On the lowest level, BT communication is a sequence of bytes written to a BT port and reading response. That is what you see as those 0x00 0x03 ... examples.

But nobody want's to program like that. So task for the library writer is to give some nice names to these sequences and pack them into functions. From that you see commands like readSensor, runProgram etc.

Select on which level you actually want to work and we can try to help you. DLuders showed you the best link directly from LEGO website. In appendix 1 of the BT SDK you will find the codes and byte sequences for the low level operations. In apendix 2 you can find byte sequences for basic operations like playing tones or reading sensors.

If you have this a some school task without any experience in this communication area, it will be difficult. You will have to learn not only communications basic but also the protocol used by the NXT.

Edited by hrontos

Share this post


Link to post
Share on other sites

hrontos:

Yes, it's school project. It's totally unrelated to what I study. I just got this task. Without any introduction, without any specification, we never talked about Lego, we never saw Lego.....I just got this task. And because I'm studying university, I really don't have time for this. It really sucks.

Tomorrow I'll go ask for more specific informations. Last time he just ignored me and told me just one extra sentence to this task. So I'll insist on more specific informations.

Thank you so far. Tomorrow I'll know more. Hopefully.

Edited by andyfarang

Share this post


Link to post
Share on other sites

@ andyfarang: You may see all of the various options on this Team Hassenplug webpage. I think that the National Instruments (NI) LabView Toolkit may be useful. :classic: It "Can be used to create blocks that work in NXT-G programs, OR it can create programs to download directly to the NXT OR it can create PC programs to control the NXT ."

If you have access to a Wii Remote Controller (Wiimote), you could consider the University of Washington has step-by-step instructions on how to use NI LabView software with a Lego NXT in this PDF document . You can learn more about the Labview software here, and get a free 30-day trial version (designed for students) by registering here.

logo.gif

There are several useful videos on the NIK12lab YouTube Channel. "LabVIEW for LEGO MINDSTORMS is the most powerful programing tool for the LEGO MINDSTORMS NXT Robotics system. If you would like LabVIEW for LEGO MINDSTORMS for yourself just go to. http://bit.ly/OrderLVLMSingle .

"For ideas on how to use LabVIEW and LEGO MINDSTORMS in the classroom check out http://www.K12Lab.com ."

Here are two of their videos:

Edited by DLuders

Share this post


Link to post
Share on other sites

Hi,

This is probably in the line of what you need.

http://www.tau.ac.il...erformance.html

Serial communication usually begins with a start bit to indicate the start of the message/command, followed by the data bits/bytes and it end with a stop bit.

http://www.wcscnet.c...lComm/Page1.htm

Include an image like this:

async1.gif

Or this:

Figure1.gif

Add some example commands, like the "play sound" command. Describe the databytes for the various commands, which can be sniffed with RealTerm.

That will probably suffice!

Edited by Gekke Ted

Share this post


Link to post
Share on other sites

Finally I have more specific task.

And both of you were right.

Structure: Notebook (master) ==>> NXT (slave)

- At first I have to use style like Gekke Ted suggested. I have to use this bits commands. Use them to read one of the sensors.

- Second task is to use more advanced tool. I'll go for Robotc like a lot of you suggested. Again use it to read sensor.

So far so good. Now I finally know what I want to do.

RealTerm: I don't really need any script for NXT, if I'm using RealTerm? I only establish connection and send commands through RealTerm? Do I have to put NXT to some mode to communicating with him through RealTerm?

RobotC: Kieran confused me with Robotc. If I get it right, at first I have to create first script with Robotc and upload it to NXT (it will be working in the slave mode). How? Through USB? And do I need to somehow initialize that script? After I need script for Master (notebook). What program should I use for this? Would it be possible to do it like command line? I don't really need automatic script. I would be happy with some command line and sending commands to NXT. Like "#check if communication is established, #hello i'm master, #send me data from sensor at port1, #close connection".

I didn't have time to read new posts and go through all posted links. I'll go for it after i get home. Maybe some my answers are already answered. Sorry for that.

Guys, thank you very much. You're really helping me a lot. All of you. Thank you.

Share this post


Link to post
Share on other sites

@ andyfarang: Check out this Carnegie Mellon Robotics Academy ROBOTC Curriculum for LEGO MINDSTORMS. It has this detailed, online index leading to various video lessons. :classic: There is also this Tutorials webpage and this ROBOTC NXT Curriculum full of lessons, videos, and printable guides.

Robotc_textual_logo.pngNXT-Curriculum-screenshot.jpg

Edited by DLuders

Share this post


Link to post
Share on other sites

I am sure you know but the NXC offering is free and used by many people, if this is for a project you may save your self a few pounds on a short lived licence cost for RobotC

Share this post


Link to post
Share on other sites

Guys, you are awesome. Every single post was very helpful! I went through this thread and I think now I finally get it.

Well, I didn't try anything. I just read a lot of informations at webpages posted here. Downloaded a lot of programs and tried to make it work without NXT (I don't have any at my home). But even in the worst case, if nothing gonna work (based on my experiences, that nothing works for the first time and you have invest a lot of time) I have enough info and knowledge to write about this topic at least 100 pages + add a lot of different scripts and different methods and screenshots.

NXT looks really interesting, I regret I don't have enough time to play with it.

THANK YOU GUYS!

Edited by andyfarang

Share this post


Link to post
Share on other sites

@ andyfarang: Glad that you got what you were looking for. Maybe Santa Claus can put one of these 8547 sets under your tree this year!

download8BECFDA0517A505735D8E38A0137B963.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.