Visit our LabVIEW Wiki MINDSTORMS® NXT article
Tags |
(This content has not been tagged yet)
|
![]() |
Nov 14 2006, 09:12 AM
Post
#1
|
|||
|
Active Member Posts: 10 Joined: 6-July 06 Member No.: 5518 LV:8.0 ,. ,.
|
Hi,
I have created a button interface in LabVIEW that when pressed it will write a string into the VISA port directly using a serial connection of my blue tooth connection. This is after the NXT block is paired. I am having trouble understanding the packet format that has to be sent in hex. Other forums show they created a array then convert it to string again to send using VISA in the Fantom SDK. I am bypassing that by creating the connection beforehand. From what I understand I can start the program using a array which is converted to hex. But that format I am not sure I am implementing correctly. Start of program : (0x00,0x00,Spike Remote 0xA,0x02,0x00,StatusByte) Send Integer value of 1 : (0x00,0x09,1,1,2-10) When Converted its 3078 3030 2C30 7830 392C 312C 322C 31 Perhaps I should remove the commas and send this hex >3078 3030 2030 7830 3920 3120 3120 32 But the NXT block is not responding...what should the format be? Do I have to convert it to hex before sending? What format do I have to use since ',' = 392C . Do I have to include the commas? Thanks
|
||
|
|
|||
| Ad |
Nov 14 2006, 09:12 AM
Post
#
|
||
|
|
|
||
|
|
|||
Nov 14 2006, 09:30 AM
Post
#2
|
|||
|
Extremely Active Member Posts: 369 Joined: 24-August 06 Member No.: 5958 Using LabVIEW Since:1995 LV:8.5 ,8.2.1 ,7.1.1
|
...Send Integer value of 1 : (0x00,0x09,1,1,2-10) When Converted its 3078 3030 2C30 7830 392C 312C 322C 31 Perhaps I should remove the commas and send this hex >3078 3030 2030 7830 3920 3120 3120 32 I don't think you should convert the ASCII values to hex, but rather the values contained in the string. Your output "3078 3030 2C30 7830 392C 312C 322C 31" is the hex representation of the ASCII sequence "0x00,0x09,1,2,1". If you are going to send this sequence as hex, I would guess that your program expects the following hex representation "0009010201". So if you have a U8-array with the values [00, 09, 01, 02, 01], feed this array into the "Byte Array To String" function (or a typecast node), and the output will be the string to send. Or enter the values manually in a string control that is set to display strings as hex values, then just send this string. /J -------------------- Wired but not weird...
|
||
|
|
|||
Nov 14 2006, 11:25 AM
Post
#3
|
|||
|
Active Member Posts: 10 Joined: 6-July 06 Member No.: 5518 LV:8.0 ,. ,.
|
I don't think you should convert the ASCII values to hex, but rather the values contained in the string. Your output "3078 3030 2C30 7830 392C 312C 322C 31" is the hex representation of the ASCII sequence "0x00,0x09,1,2,1". If you are going to send this sequence as hex, I would guess that your program expects the following hex representation "0009010201". So if you have a U8-array with the values [00, 09, 01, 02, 01], feed this array into the "Byte Array To String" function (or a typecast node), and the output will be the string to send. Or enter the values manually in a string control that is set to display strings as hex values, then just send this string. /J Hi JFM, Well all I want to do is send an integer between 0-5 to the NXT block. What would the message format be?
|
||
|
|
|||
Nov 14 2006, 12:19 PM
Post
#4
|
|||
|
Extremely Active Member Posts: 369 Joined: 24-August 06 Member No.: 5958 Using LabVIEW Since:1995 LV:8.5 ,8.2.1 ,7.1.1
|
What would the message format be? It would be easier if you could show some code. I also think I slipped when I said QUOTE So if you have a U8-array with the values [00, 09, 01, 02, 01], feed this array into the "Byte Array To String" function (or a typecast node), and the output will be the string to send. Or enter the values manually in a string control that is set to display strings as hex values, then just send this string. sorry for that. /J -------------------- Wired but not weird...
|
||
|
|
|||
Nov 14 2006, 12:36 PM
Post
#5
|
|||
|
Active Member Posts: 10 Joined: 6-July 06 Member No.: 5518 LV:8.0 ,. ,.
|
It would be easier if you could show some code. I also think I slipped when I said sorry for that. /J Hi I have tried this method though the NXT block is not responding. Just ignore the web cam controls on the bottom.
Attached File(s)
|
||
|
|
|||
Nov 14 2006, 12:59 PM
Post
#6
|
|||
|
Extremely Active Member Posts: 369 Joined: 24-August 06 Member No.: 5958 Using LabVIEW Since:1995 LV:8.5 ,8.2.1 ,7.1.1
|
Hi I have tried this method though the NXT block is not responding. Just ignore the web cam controls on the bottom. Just some quick notes: 1. your program are using I32 constants instead of U8 (doesn't really matter) 2. you could implement this with an event structure, to get more direct user response 3. I personally prefer to open/close VISA sessions explicitly Do you get any errors? If so what errors do you get? /J -------------------- Wired but not weird...
|
||
|
|
|||
Nov 14 2006, 01:32 PM
Post
#7
|
|||
|
Active Member Posts: 10 Joined: 6-July 06 Member No.: 5518 LV:8.0 ,. ,.
|
Just some quick notes: 1. your program are using I32 constants instead of U8 (doesn't really matter) 2. you could implement this with an event structure, to get more direct user response 3. I personally prefer to open/close VISA sessions explicitly Do you get any errors? If so what errors do you get? /J The return count of the VISA prints out 8. So the connection works since data is sent to the NXT block but the response is a bit off :/ I am not sure how to control the data bit. If you do a format and precision on the number inputs you will see its hex ----------------- Ok I have a response of an error Possible reason(s): LabVIEW: File permission error. --- NI-488: DMA hardware error detected. Ok whats this? This post has been edited by Buglish: Nov 14 2006, 02:05 PM
|
||
|
|
|||
Nov 15 2006, 07:41 AM
Post
#8
|
|||
|
Active Member Posts: 10 Joined: 6-July 06 Member No.: 5518 LV:8.0 ,. ,.
|
I have started from scratch and now I am using the Fantom SDK. Though compiling the arrays of hex commands is kind of difficult.
The vi I am including searches for the NXT block then pairs up. The problem is starting the application I need. I have converted "spike remote" to the hex"5370 696B 6520 5265 6D6F 7465 " to start the application. And sending messages to mail box 1 with the data of a number between 1-6 is not working :/ Please help me create the packets. Regards Bug
Attached File(s)
|
||
|
|
|||
Nov 17 2006, 07:48 AM
Post
#9
|
|||
|
Active Member Posts: 10 Joined: 6-July 06 Member No.: 5518 LV:8.0 ,. ,.
|
|
||
|
|
|||
Nov 17 2006, 08:01 AM
Post
#10
|
|||
|
Extremely Active Member Posts: 369 Joined: 24-August 06 Member No.: 5958 Using LabVIEW Since:1995 LV:8.5 ,8.2.1 ,7.1.1
|
Hi All, I have figured it out. See the pics Well done I'm sorry I haven't replyed to your last posts, but my knowledge regarding the Fantom SDK is NIL By the looks of your program, I think you should add error handling in the loops, maybe break loop execution upon an error? There is also no visible delay in the upper loop, and this together with the lack of error handling can get you into trouble. /J -------------------- Wired but not weird...
|
||
|
|
|||
Nov 17 2006, 01:48 PM
Post
#11
|
|||
![]() Extwemely Active Premium Member ![]() Posts: 1674 Joined: 23-January 05 From: Here Member No.: 1431 Using LabVIEW Since:2003 LV:8.6 ,7.0 ,.
|
And doing this
is really unnecessary. You could just wire the boolean directly into the select function.
-------------------- More than meets the eye...
|
||
|
|
|||
Nov 17 2006, 02:35 PM
Post
#12
|
|||
|
Active Member Posts: 10 Joined: 6-July 06 Member No.: 5518 LV:8.0 ,. ,.
|
ROFLOL
And in regards to the loop control with a timer. That also gave in expected results where if button is pressed the bot would go into loop(or just pressed a few times if you press it once) Thanks again
|
||
|
|
|||
Nov 17 2006, 03:43 PM
Post
#13
|
||||
![]() I'm a LAVA, not a fighter. V I Engineering, Inc. ![]() Posts: 3853 Joined: 13-October 03 From: Michigan, USA Member No.: 181 Using LabVIEW Since:1993 LV:8.5 ,. ,.
My Blog
|
And in regards to the loop control with a timer. That also gave in expected results where if button is pressed the bot would go into loop(or just pressed a few times if you press it once) I had a little time on my hands this morning, so I've rewritten some of your code with a couple of suggestions to save a little memory and boost performance. I don't have the NXT toolkit installed, so I don't suggest that my code will work perfectly (if at all
Attached File(s)
-------------------- ![]()
|
|||
|
|
||||
![]() ![]() |