LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

Send a Number with Write to NXT Mailbox

I'm using LabVIEW 2010 and the associated NXT Module. I'm trying to use NXT-G on the robot, and a LabVIEW VI on a Windows notebook, communicating between them using Bluetooth.

 

I can use Write to NXT Mailbox in LabVIEW to write a text string, and I can successfully read that string on the robot using NXT-G Receive Message with Text as the mode.

 

My problem is that I would like to write a number from LabVIEW, and read this as a number in NXT-G (ultimately for use with the Move block). I tried passing a numeric string (e.g. "100") to Write to NXT Mailbox, and reading it using NXT-G Receive Message with Number as the mode... this doesn't work (Number out is always invalid). I assume I need something special in the string that tells NXT-G what format to use (Text, Number, or Logic).

 

I saw something about Flatten to String in the help, so I'm assuming that maybe that is useful for this.

 

In order to send an NXT-G Number using Write to NXT Mailbox, how do I form the string?

If I use Flatten, which LabVIEW data type (e.g. U32, SGL), and which byte order (little or big)?

 

Thanks

Rodney

0 Kudos
Message 1 of 3
(6,413 Views)

Hello Rodney,

 

You can use the flatten to string and unflatten from string VIs and just keep the numeric type it originally is, and make sure on the unflatten VI you wire a constant of that same data type to the type input terminal. So far as big/little representation, I would just keep the default so the most significant byte is first represented. Also, have you seen the Send Client Mail(num).vi?

 

Thank you,

Deborah Y.

Deborah Burke
NI Hardware and Drivers Product Manager
Certified LabVIEW Architect
0 Kudos
Message 2 of 3
(6,401 Views)

Thanks Deborah,

 

I assumed that Send Client Mail wouldn't work because it only supports connection 1-3, and the computer-to-robot connection is 0. I tried it without success, but maybe there's something I'm missing.

 

I did some experiments with Flatten and Write to NXT Mailbox on the computer. If I use I32 as the numeric type it doesn't work, but SGL works. If I use big-endian (default of MSB 1st) it doesn't work, but little-endian does work. I assume this is related to the fact that I am using NXT-G on the robot, which is probably picky as to the numeric format.

 

If I was using LabVIEW on the robot as well as the computer, I assume it would work as you describe (more flexible).

 

Thanks again... I've got it all going now.

Rodney

0 Kudos
Message 3 of 3
(6,391 Views)