LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decode data

Hi, I have this binary data that I have decoded in matlab. I would like to achieve this same purpose in labview but i am not sure where to start from. I have attached all relevant files and would appreciate any assistance I can get. 

 

 

0 Kudos
Message 1 of 15
(544 Views)

You can Integrating Compiled MATLAB Functions with LabVIEW with a .NET Assembly Approach

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 15
(504 Views)

Hi jkas,

 


@jkas wrote:

Hi, I have this binary data that I have decoded in matlab. I would like to achieve this same purpose in labview but i am not sure where to start from.


It seems you read a byte stream, convert those bytes to a hexadecimal-formatted string and then parse the data from that string back to numeric values. This can be done easily in LabVIEW directly (much easier than calling Matlab code from LabVIEW IMHO).

 

  • I think this can be done directly with the byte stream instead of converting to string and back to numbers more easily.
  • Can you provide an example of your hexadecimal formatted string for a full message of voltage/current/temperature? Even parsing that string is much simpler then getting 3 individual substrings when using ScanFromString with the right format string…

Example for string parsing:

(You can do the same more efficient by processing the byte stream directly!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 15
(467 Views)

Thanks, GerdW. An example of the hex formatted string is attached. 

0 Kudos
Message 4 of 15
(432 Views)

Hi jkas,

 

why do you write your (matlab) code as "don't use x Zeros" when there are tabs?

 

It could be so easy:

(Again: processing the byte stream will be easier than converting to string and back to numerics!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 15
(426 Views)

Yeah I noticed so I changed the code. New formatted hex attached. 

0 Kudos
Message 6 of 15
(420 Views)

How do I process the byte stream directly?

 

0 Kudos
Message 7 of 15
(419 Views)

Hi jkas,

 


@jkas wrote:

Yeah I noticed so I changed the code. New formatted hex attached. 


There are still tabs between the values so my previous suggestion is still valid. It doesn't matter if there are (some) leading zeros or not...

 


@jkas wrote:

How do I process the byte stream directly?


You read the number of bytes per value and convert them to your required data.

  1. Like read 3 bytes (for voltage?) and use the JoinNumbers function to create the voltage value.
  2. Then read the next 2 bytes (for current) and use JoinNumbers to create the current value.
  3. Then read 2 bytes (for temp)...
  4. Start over with 1. until end of file...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 15
(409 Views)

Uhm if it's not too much to ask, can I get a sample vi that does this?

0 Kudos
Message 9 of 15
(400 Views)

Hi jkas,

 

example:

(There are more efficient ways to solve this poblem, but the current suggestion is straight-forward.)

 

There seems to be a problem in your data, there are several rows in the data with "malformed" content, like row #113 in the image...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 15
(399 Views)