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-27-2014 12:17 PM
Hello,
I want to process the data received by comport in labview where the transmitter device sends 22 bytes of data in this format 0x01 0x02 <18 bytes of information data with LSB first> 0x03 0x0D through the comport which should be read using Labview. I want to process the received 22 bytes in labview as below
1) Leave the first 2 bytes and last two bytes
2) From the left 18bytes each consecutive set of 3 bytes should be reversed (because the transmitter sends the LSB first) and stored in a text file.
Can anyone suggest me the steps to implement this.
Thanks.
Solved! Go to Solution.
06-27-2014 12:37 PM - edited 06-27-2014 12:38 PM
I'd probably do something like this. Use a String Subset to get just the data part of the stream. Change that string into a byte array and use Decimate Array to break up the array into 3 parts, each containing every third element. Then use some Join Numbers to combine the bytes into a U32 and format your data into a string with Array To Spreadsheet String. I didn't show it, but you can then take that data and write it to a text file.
06-27-2014 12:52 PM
06-29-2014 11:58 AM - edited 06-29-2014 11:59 AM
Hello,
Now, I am able to get the data format(which follows this format:0x01 0x02 <18 bytes of information data> 0x03 0x0D) from microntroller as shown in the attached image.
When first 2bytes are skipped and remaining 18 bytes are divided such that consecuitve 3 bytes are rearranged then it is considering 030D0102(which is rearranged as in spreadsheet2 of the attached image) which should not be.
But I want to 1)skip the first two bytes(0x01 0x02) and last two bytes(0x03 0x0D).
2)From the left 18bytes each consecutive set of 3 bytes should be reversed (because the transmitter sends the LSB first)
3) arranged 3bytes value should be converted into 2's complement and want to plot the data (2's complement of arranged 3bytes) continuously such that there will 6 continous plots.(each consisting 2's complement of the rearranged 3bytes)
Can someone help me out with the required processing of received data.
thanks.
06-29-2014 12:26 PM
@PatanGova wrote:
When first 2bytes are skipped and remaining 18 bytes are divided such that consecuitve 3 bytes are rearranged then it is considering 030D0102(which is rearranged as in spreadsheet2 of the attached image) which should not be.
It is ignoring the first two bytes. That's what the String Subset is doing. You are taking starting on the thrid byte and up to 18 bytes. If you put your Recieved Data on the output of the VISA Read, you would see that.
@PatanGova wrote:
But I want to 1)skip the first two bytes(0x01 0x02) and last two bytes(0x03 0x0D).
2)From the left 18bytes each consecutive set of 3 bytes should be reversed (because the transmitter sends the LSB first)
Your code is already doing that.
PatanGova wrote:3) arranged 3bytes value should be converted into 2's complement and want to plot the data (2's complement of arranged 3bytes) continuously such that there will 6 continous plots.(each consisting 2's complement of the rearranged 3bytes)
Now that is a little more difficult. A three byte Two's Compliment will take a little work.
06-29-2014 04:19 PM
Hi crossrulz,
I dont understand how it will skip the last 2bytes as well from 22 bytes of Received Data.
why it is showing 030D0102(which is rearranged as in spreadsheet2) and also we are nt mentioning anthing to skip last 2 bytes
If possible can I get some clarification for these.
thnks.
06-29-2014 07:37 PM
@PatanGova wrote:
Hi crossrulz,
I dont understand how it will skip the last 2bytes as well from 22 bytes of Received Data.
why it is showing 030D0102(which is rearranged as in spreadsheet2) and also we are nt mentioning anthing to skip last 2 bytes
If possible can I get some clarification for these.
thnks.
Read the help of the String Subset.
So we pass 22 bytes of data into the String Subset. We give it an index of 2. So the substring starts at the third element of the passed in string. But we also pass in a length of 18. The last 3 elements will be an index of 20, 21, and 22. But we are only taking elements 2 through 19, inclusively. So the last three elemetns are not included in the substring.
06-30-2014 01:55 AM
Hi crossrulz,
The String indexing starts from 0.So, if the length of the bytes needed is 22bytes then will be having index from 0 to 21(for 22bytes).If it is correct then from 2 to 19 will be 18 bytes and the remaning be will elements in 20,21 indexes.How come you are saying the last 3 elements will be an index of 20, 21, and 22 are not included.
Also can I know why it is showing 030D0102(which is rearranged as in spreadsheet2).
Thanks.
06-30-2014 03:21 AM
Hello,
I observed that the first 2 bytes and last 2 bytes are being skipped (not considered).
But the incoming data stream is following these two patterns continuously: Pattern1 as shown in Received_Data1 image which is being followed by pattern2 as shown in in Received_Data1 image.
This pattern seems to be a problem for extracting the correct information data.
Is there any other method to properly skip the first two bytes if the received are exactly 0x01 0x02 then taking the next 18 bytes which will be followed by 0x03 0x0D.
Also from 18bytes I only need to get 7, 8,9th bytes (3bytes data).
Can someone help me with these corrections.
06-30-2014 07:33 AM
You should probably actually disable the termination character because you are recieving binary data. So for the Configure Serial Port, you need to wire in a FALSE to the Termination Character Enable. Then for your VISA Read, just try to read 22 bytes. This should keep you in sync since it is a command-response setup.