From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parse serial data 2 bytes at a time

Solved!
Go to solution

I'm acquiring 8 bytes of serial data and I would like to parse the data into 2 bytes of data so that I end up with 4 different temperature measurements. I tried many things that I found within the forum but I can't get it to work. The VI I attached is using the scan from string function but I'm not very familiar with this function. My defaulted my serial data so that you can see the data I'm receiving.

 

Thanks in advance for your help

 

Lowski

Download All
0 Kudos
Message 1 of 11
(2,920 Views)

Do you know what the format of the data is supposed to be?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 11
(2,906 Views)

Yes the processor is spitting out data in binary (8 bytes) my output data will be displayed in decimal value

0 Kudos
Message 3 of 11
(2,900 Views)

Looks like 8 bytes of binary data. Try unflatten to an U16 (or I16) array and index the four elements.

 

Do you need to apply some scaling?

Is it little or big endian?

What range of temperatures do you expect from the default data in the current string indicator?

0 Kudos
Message 4 of 11
(2,898 Views)

I'll give that a try...

 

Yes I do have to apply some scaling, it lil Endian, and I'm expecting to read temperatures upto 210C

 

 

0 Kudos
Message 5 of 11
(2,890 Views)

Sorry I meant BIG Endian

0 Kudos
Message 6 of 11
(2,888 Views)
Solution
Accepted by topic author lowski

See if this gets you started. You need to figure out the scaling yourself.

Message 7 of 11
(2,884 Views)

Thanks for your help altenbach! Yes this is exactly what I need...However I've applied my scale factors and I noticed that the I get the correct readings (~24-26C) for all three measurements but then I get really odd readings which tells me that I'm not synced at all. You probably noticed which I should of mentioned in the beginning, there is are 2 bytes of data at the end of the string (0xBEEF) that was added to use as a sync so that I know whats the next 2 bytes and so on are. How can I do this in LV.

 

Thanks again for your help!

 

lowski

0 Kudos
Message 8 of 11
(2,877 Views)

Sorry, I don't do serial,....

 

You probably need to slow down the loop and query the number of bytes at port before reading. At what rate are the string arriving? Maybe you should just buffer the data and parse whenever your end of string marker is detected. I am sure somebody can give you more precise advice.

0 Kudos
Message 9 of 11
(2,871 Views)

Thanks for the help! I think buffering my data and then parsing it is the way to go, I'll see what I can do

 

lowski

0 Kudos
Message 10 of 11
(2,864 Views)