LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView Connection to NXT block Question

    Hi,
I am trying to connect a NXT block using bluetooth. I have paired the device with the bluetooth software and created a serial connection. Thus I can just send data from LabVIEW using VISA but its proving more dificalt than I thought.
All I have to do is send a string or integer to the NXT block.
 How can I create a simple sending function using LabVIEW -VISA for just an integer or string ??
0 Kudos
Message 1 of 17
(11,882 Views)
I would recommend using the Fantom SDK which is available from the LEGO MINDSTORMS site. The Fantom SDK sits on top of VISA and facilitates interfacing with the NXT. Also, review the Bluetooth Developer Kit for information on how to structure the direct command packets.

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 2 of 17
(11,866 Views)
Hi,
I have looked atr the Fantom SDK. It creates the Bluetooth connection which I don't need. The serial Connection is allready set up. I have also looked at the Bluetooth specs of the NXT block. Though I am posting becaus I am having trouble understanding the packet setup.

Please send me a small example then I can work from that.

From my understanding I have to have a string to start a selected program on the NXT block :
array(0x00,0x00,Spike Remote 0xA,0x02,0x00,StatusByte)

Then to send an intiger or string value to the running program.
array(0x00,0x09,1,1,2-1)

Would the NXT block respond if I send these commands?
0 Kudos
Message 3 of 17
(11,855 Views)
You need to prefix your command packets with two bytes that specify the length of the packet (excluding these two bytes). Refer to page 4 of Appendix 2 of the Bluetooth Developer Kit. Also, it appears that you are combining the command and the response packets. You write the command packet and then read the response packet. As an example, to start a program named "spike.rxe" the following buffer would be written:

0x0c, 0x00, (command is 12 bytes)
0x00, (direct command, response required)
0x00, (start program direct command)
0x73, 0x70, 0x69, 0x6b, 0x65, 0x2e, 0x72, 0x78, 0x65, 0x00 (spike.rxe as NULL-terminated ASCII string)

then the response would be read (the final byte is the status value)

0x03, 0x00, (response is 3 bytes)
0x02, (direct command response)
0x00, (start program direct command)
0x00 (successful status)

I didn't actually test any of this. Regardless, I hope this helps,

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
Message 4 of 17
(11,833 Views)
Hi,

Yes i helped allot. Though I am unable to start the selected application. Thus I need help with the packet forming. I have never workedwith direct hardware programming. So this is a bit confusing.

I have used the fantom SDK but what format does the direct command write use?
How do I convert the name of the VI on the NXT bot to hex? It's "Spike Remote.rbt"

I have created the connection and paired them up.Now the only problem is sending the assebled packets 😕

Thanks Jaco du Preez

Message Edited by JacoNI on 11-15-2006 01:25 AM

0 Kudos
Message 5 of 17
(11,831 Views)
I don't have LabVIEW handy, but I'll try to help. If you use the Fantom SendDirectCommand VI, the command buffer that is specified is a bit different in that you don't need to specify the Bluetooth packet length bytes and you don't need to specify the telegram type byte. So, the packet should contain the following bytes:

0x00, (start program direct command)
0x73, 0x70, 0x69, 0x6b, 0x65, 0x2e, 0x72, 0x78, 0x65, 0x00 (spike.rxe as NULL-terminated ASCII string)

To convert a string to an array of bytes, use the "String to Byte Array" VI. I think you may have to manually append a NULL byte.

You do need to wire in a TRUE value to the require response terminal.

If you still have problems, post a screen shot of your diagram and I'll take a look.

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 6 of 17
(11,821 Views)
Hi,

I have tried and no response. Here is a picture of my VI,
Also I noticed you keep refering to spike.rtx. What is this? My VI running on the NXT block is named "Spike Remote"
Will this have an affect? The VI jpg has got this name in hex but still no response 😕

The entire VI cannot be seen though don't worry about the USB camera loop on the bottom.

Regards

Message Edited by JacoNI on 11-15-2006 08:33 AM

0 Kudos
Message 7 of 17
(11,822 Views)
A couple of comments:

1. I recommend that you invoke the Get Device Info VI after creating the NXT object to verify that you can communicate with the NXT.

2. I don't remember what the default of the require response input to the Send Direct Command VI, but you need to specify TRUE if TRUE is not the default.

3. You should wire the response buffer output to an indicator so you can examine the response from the NXT. I'm not sure how you are determining that you are not getting a response since you are checking for one.



@JacoNI wrote:
Also I noticed you keep refering to spike.rtx. What is this? My VI running on the NXT block is named "Spike Remote"
Will this have an affect? The VI jpg has got this name in hex but still no response 😕



4. "spike.rxe" was the name of the program on the NXT in my example. Programs on the NXT have an extension of rxe. I would recommend the use of the "String to Byte Array" VI rather than building the array by hand. The bytes you specify appear to be decimal rather than hex numbers and probably don't represent the string you expect. You also are missing the extension. Wire "Spike Remote.rxe" into the "String to Byte Array" VI and append a NULL byte.

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 8 of 17
(11,818 Views)
Hi,
I have fixed all the requests you told me about.

The Start is still not responding??? am I still sending the packet in wrong?

Regards Jaco
0 Kudos
Message 9 of 17
(11,816 Views)
Sorry, I guess I wasn't clear. I suggested that you wire the string "Spike Remote.rxe" into the "String to Byte Array" VI and append a NULL byte; not a string containing hex values. Build an array that contains a 0x00 byte, the byte array from the "String to Byte Array" VI, and then a 0x00 byte. Does that make sense?

Did the Get Device Info VI return reasonable values?

What did the Send Direct Command VI return (either in the response buffer or as an error)?

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 10 of 17
(11,814 Views)