LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

splitting and grouping of data from incoming string

Hello,
I have a package of data coming from the serial port and read out as a string.
The package has the following format, to be short.
1. opening characters
2. 2 bytes for Group ID(identify the device# the data comes from).
3. Sensors data belongs to device# (1 byte each)
-data of sensor #1
-data of sensor #2
-data of sensor #3
-data of sensor #4
and loop back to sensor 1,2,3,4 for 20 bytes total.
I have eliminated the opening characters with the replace substring with empty string. For the Group ID, I used a case structure to identify which device it is. For the sensor data, I need to split them up and group all the data of the sensors together. I tried using substring for each sensor in a for loop that loop 5 times to group the data of each sensor together but it only give me the very last values.
My goal is to be able to extract and group the 5 bytes of each sensor together everytime the serial package comes in and then save them to a separte files for each sensor. I also want to be able to plot the data of each sensor as they come in with respect to time.
Any idea on how I can accomplish the grouping of data described above? I really appreciate your prompt response. Thanks,
0 Kudos
Message 1 of 4
(2,602 Views)
Since you already know how to separate the sting containing the sensors data, you just have to use a string to byte function and to decimate the resulting array, as shown in the attached vi.

CC
Chilly Charly    (aka CC)
Message 2 of 4
(2,598 Views)
Thanks for your VI. It was very helpful. Can you tell me how to create that loop that loop to do the exact process for every package of data that comes in (31 bytes for each package). I want the VI to run continuously. I don't know exactly how many packages comes one after the other. Sometimes data come in 1 package at a time and wait a long period before the next package, other times maybe 3 or 4 packages comes right after the other.
Thanks,
0 Kudos
Message 3 of 4
(2,573 Views)
Answered here.

___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(2,568 Views)