From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-07-2013 12:31 PM - edited 06-07-2013 12:44 PM
Can someone help me find the part of this process that I am doing wrong?
I can see the bytes coming into the byte array as 'byte, 0, 0, 0' when it is a small number but when i typecast I get really large or really small floats. Can someone help me figure this out?
Thanks!
Labview 2011
Solved! Go to Solution.
06-07-2013 12:53 PM - edited 06-07-2013 12:56 PM
You should probably use unflatten from string, select little endian byte order, and use a type of 1D DBL array. Everything should fall in place without all these bit gynastics you are currently doing.
Can you show us your code? I don't quite understand your use of "decimate array".
Please attach a small VI containingh a typical received string as a diagram constant.
06-07-2013 01:18 PM
Thanks for the suggestion. I probably implemented it wrong because I am getting similarly weird data.
My 1D array contains 6 different types of data which I decimate into their own 1D arrays to graph them.
I'm not quite sure how to represent a typical string as a diagram constant but write now my test C code is just transmitting 6 floats incrementing with each transmission.
06-07-2013 01:55 PM
ipatka wrote:I'm not quite sure how to represent a typical string as a diagram constant...
06-07-2013 02:08 PM
Here is the constant.
I now kind of have an idea of what is going on:
One float displayed in my code is 7.42688E-44
which is 00000000 00000000 00000000 00110101 in IEEE 754 format
The last byte 0010101 is 53 in decimal, which is the number I tried to send in.
So it appears that my microcontroller is sending the wrong format.
06-07-2013 03:18 PM
You're reading what's at the serial port and try to handle that, but you dont know or check what you've got. If you know you're recieving an array of singles, why not read 4 bytes at a time?
/Y
06-07-2013 04:24 PM
Are you sure it is sending 4-byte floats and not U32 or I32 32-bit integers?
Because 53 as a float would look like 4254 0000 as a string of hex bytes.
06-07-2013 04:52 PM
I was transmitting 4 floats (3 of them empty) typecasted as bytes instead of the 4 bytes of a float.
@altenbach wrote:
You should probably use unflatten from string, select little endian byte order, and use a type of 1D DBL array. Everything should fall in place without all these bit gynastics you are currently doing.
This solved the issue on the labview side
and
bobgardner (avrfreaks) wrote:
float temperature;
unsigned char *p;
.
.
.
p = (unsigned char *)&temperature;
for(i=0; i<4; i++){
send(*p++);
}
this solved the issue on the avr side