LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Byte array to plot

Solved!
Go to solution

Hello there, I am newbie in LabView. Can you help me to parse 4 byte message I get from BLE characteristic to integer so I can plot the output value? 

 

This is the snippet I use:

LaBoris_0-1582465940985.png

Thanks for help.

 

0 Kudos
Message 1 of 5
(2,277 Views)

What do you expect the integer to be?  What type should it be?  Is it an I32 or a U32?  If so, then try to use typecast to turn it into that type.

0 Kudos
Message 2 of 5
(2,251 Views)

My input value is Unsigned 8 - bit Integer. All I want is to parse the 4-byte value I am getting in the input to the real data value (whatever data type it will be - best could be float since the Yaw is rounded on two decimals) - that corresponds to the Yaw from the IMU sensor. I already tried type Cast the value to float or String but without any success. I tried to follow this help (https://forums.ni.com/t5/LabVIEW/4-byte-array-to-int32/td-p/3334965/page/2 )  using for loops but I am getting enormous numbers on the output.

0 Kudos
Message 3 of 5
(2,235 Views)
Solution
Accepted by topic author LaBoris

I'm afraid you haven't answered my questions.  And if you try something that doesn't work, then post the code of that attempt as it might be an easy fix.

 

What is that value supposed to be?!!    You give 53, 85, 138, 67.    What should that number look after converting?  Give the number.  Like 123.45  for example.  You say it is a Yaw value which makes me think it wold be a floating point.  If so, that would be typecast to Single.

 

The other two possible choices would be a signed integer (32-bit) or unsigned 32-bit.  An example of those might be 1234987,  or -5678123.

 

Once we know what those 4 U8's represent, then we can figure out the conversion process.  It is possible byte order matters here.

 

EDIT:

I experimented.  You said Yaw, so I assumed it would have a fractional part, thus needs to be a float.  Since it is only 4 bytes, it would need to be a single precision.

First attempt I typecast to a single, but the number seemed small.  Maybe that's correct and the expected value is very close to 0.

Then I tried reversing the order of the array and got 276.666.  That seemed like it could be a reasonable value for a Yaw.  (Almost pointing hard left?)

 

Come up with what you expect the value to be.  Maybe one of these two conversions match.  Or maybe it is going to be something else.

 

Message 4 of 5
(2,229 Views)

I am sorry I didn´t answer your question about the byte meaning so I set the message to  123.45 and the byte is now [102 230 246 66]. I will try code you just tested. I´ll let you know about the result.

 

EDIT: Thank you Ravens, the solution with the reversed order of the array worked well for me! 

0 Kudos
Message 5 of 5
(2,217 Views)