NXT bluetooth communication - helpless
Posted 22 November 2012 - 05:49 PM
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
Posted 22 November 2012 - 06:23 PM
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."
Edited by DLuders, 22 November 2012 - 06:15 PM.
Posted 22 November 2012 - 06:39 PM
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:
Byte 0: 0x00 or 0x80
Byte 1: 0x03
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 / (float) 10);
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.
Posted 22 November 2012 - 07:19 PM
Posted 22 November 2012 - 07:47 PM
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?
Posted 22 November 2012 - 08:48 PM
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?
Posted 22 November 2012 - 09:15 PM
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, 22 November 2012 - 09:23 PM.
Posted 22 November 2012 - 09:32 PM
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, 22 November 2012 - 09:33 PM.
Posted 23 November 2012 - 12:49 AM
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.
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, 23 November 2012 - 01:38 AM.
Posted 23 November 2012 - 08:19 AM
This is probably in the line of what you need.
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.
Include an image like this:
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, 23 November 2012 - 08:23 AM.
Posted 23 November 2012 - 09:29 AM
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.
Posted 23 November 2012 - 01:41 PM
Edited by DLuders, 23 November 2012 - 01:49 PM.
Posted 25 November 2012 - 11:25 PM
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, 25 November 2012 - 11:26 PM.
Reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users