Arduino X Labview

Hello
I'm a newbie and use a union code to send a double number to labview using arduino uno .
this code
union {
double f;
byte b[4];
} stuff;

stuff.f = number to send;

payload[1] = stuff.b[0];
payload[2] = stuff.b[1];
payload[3] = stuff.b[2];
payload[4] = stuff.b[3];

and in my Labview vi i receive:

sending number payload 1 payload 2 payload 3 payload 4
0 0 0 0 0
1 0 0 128 63
2 0 0 0 64
3 0 0 64 64
4 0 0 128 64
3,14159 208 15 73 64

how can I get the double in my vi??? I've tried join numbers ..and didn't work....

thanks

payload[[color=red]1[/color]] = stuff.b[0];
payload[2] = stuff.b[1];
payload[3] = stuff.b[2];
payload[4] = stuff.b[3];

-> don't your index start at 0?


In theory in C++ what you try to do is undefined - if you use the double representation to store something in the union, in theory you can only use the double to read it. (but does work with most compiler, but good to know this is undefined according to the C++ standard)


Otherwise there is nothing wrong with your numbers.


for example 4 in your code

[color=blue]4[/color]         [color=red]0[/color]     [color=green]0[/color]     [color=purple]128[/color]     [color=navy]64[/color]

represented as a double on 4 bytes has 4.0 exp 0 as its most accurate representation and this will be 0x40800000 in memory

0x40 is 64 in decimal
0x80 is 128 in decimal
0x00 is 0 in decimal
0x00 is 0 in decimal

which is what you see


or

[color=blue]3,14159[/color]          [color=red]208[/color]     [color=green]15[/color]     [color=purple]73[/color]     [color=navy]64[/color]

represented as a double on 4 bytes has 3.141590118408203125 exp 0 as its most accurate representation and this will be 0x40490FD0 in memory

0x40 is 64 in decimal
0x49 is 73 in decimal
0x0F is 15 in decimal
0xD0 is 208 in decimal

which is what you see


You can use this Online converter to see the values (I took the float converter on 4 bytes as this is the representation on your arduino)

hello

thanks
the payload start with [1] because is a xbee packet and I've used the payload[0] to other data.

these 4 payloads are the temperature read for my sensor.

I understuood your explanation, and I'm happy because i could send the righ number double from arduino/xbee to my labview vi, but my problem is : how can i put togheter again this number in labview

I have a questiom: what is the msb and the lsb in my example ( I'm a little confuse about that..and maybe for that I can't get the right number in labview)..I'm using this way

payload 1- msb
paylodad 2 lsb
and join with join numbers in Labview - join1

payload 3 msb
and payload 4 lsb - join 2

and use join number 1 and 2 to put togheter the original decimal number ( i think this is worng way....hahahaha)

excuse for my bad english

thanks again
marques

so 3,14159 is represented by 0x40490FD0 in memory. on your arduino 40 is the MSB (most significant byte) and DO is the LSB (least significant byte).

I'm confused why you want to send that as a double... why don't you send an integer... How precise is your temperature sensor?? does it even give a one digit precision?? if so multiply the temperature by 10, send it as an integer and divide it by ten on the other side to get back the 1 digit precision.

I'm not familiar with Labview, how do you receive the stream of data? once you know that you can build back the number.

I would just send a text string.

that's also a possibility if Labview offers string conversion capability

Which it does.

OK then that's an easy way!

thanks for everybody..
JMl your idea about x100 was great i used that...and works.

but , I really like to know how i receive this string in labview.
I know labview works with strings...the problem is....I don't know how do that ( I'm learning...but slowly...rsrsrs)

I know this is an arduino forum, but ......somebody understand Labview???rsrsrsrs

because in Labview forum the people is so experts...and humble questions like that don't deserve a answer...rsrsrsrs

thanks

marques

well a quick google can help may be? Product Documentation - NI