LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

merging consecutive bytes

Solved!
Go to solution

Hi everyone, I am trying to merge 3 successive bytes of information into a single 1D array.  The data is a continuous stream of a header of 1 byte (FF) followed by 2 separate bytes of actual data, for a total of 3 bytes coming from the same wire.  My plan is to combine everything into a 1D array, search the first index of the array for the header, delete it, then recover the remaining 2 bytes of my signal.  How can I let LabVIEW know to combine 3 succesive 1D bytes at a time into a 1D array?  I know how to build arrays from multiple inputs, however this is all coming from a single input. Thanks for the suggestions.      

0 Kudos
Message 1 of 17
(4,096 Views)

Show your VI.

 

If you know how to build arrays together, then you should be able to do this.  What do you mean by "a single point"?  Is it a VISA read inside a loop?  If so, then build your array and store it in a shift register.

0 Kudos
Message 2 of 17
(4,089 Views)

array creation.png

 

Something like this? Automatically strips out the 1st byte instead of deleting it later.  The -1 index into the replace element subset will cause a NOP.  You can do whatever you want with the array after creating it this way and reuse the init for the next data set.


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 3 of 17
(4,088 Views)

Taper,

 

Have you tried running your example?  Did it work for you?  I doubt it.

 

First, it seems like you have mixed up the index input with the data input in your Replace Array Subset.  Second, I don't think Replace Array subset is even what you should use.  Third, and most importantly, after you've replaced the first two elements, your array won't get any bigger.  You can't replace an array element that doesn't already exist in the array.

0 Kudos
Message 4 of 17
(4,080 Views)

Yep, I have the index and data lines swapped.  Make sure to change those if you use this.  I meant this as a starting point for the OP's use since they didn't post all the details.  Array is a fixed, pre-allocated size set by the constant, OP wanted just the 2 data bytes.  Maybe you want to add another dimension to the array and have a 2xN array of data, or process them right away, or <insert operation>, this is a template for those changes.


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 5 of 17
(4,076 Views)

You can use a shift register. Write each time you read a value to the right side. On the left side right click and select add element. Do this again. This will give you the three previous iteration values. Check the bottom one for FF and then you will know that the top two have your data. You could get out of sync if the FF header might also be part of your data.

=====================
LabVIEW 2012


0 Kudos
Message 6 of 17
(4,068 Views)

Thanks for the replies, and sorry for not posting the VI.  I don't really have anything to test yet until I had an idea of how to approach it.  But it will look something like the attached picture.  The input is Bluetooth read function.  You gave me some good ideas to start with which I will try and implement.

0 Kudos
Message 7 of 17
(4,067 Views)

How is the data coming in? Is it one byte at a time on one U8 input?  Three bytes at a time only? Then you could do something strange like:

Bytes to Byte Array.png

 

If it is coming in as a byte stream, then it is already in an array and you can eliminate every third byte (starting with the first).

 

How you do it will depend on how the data is coming in to your program. We need more information.

 

Rob

0 Kudos
Message 8 of 17
(4,063 Views)

The data is being sent from a microchip microprocessor, using the internal 8-bit USART transmitter which goes to a bluetooth transmitter.  I first send the 8-bit header, then the data of interest which is split into two bytes.  Since the transmitter is only able to send one byte at a time, I had to divide it into 3 parts and send separate, rather than a single 3-byte transmission.  My program needs to find the header and delete, then combine the next 2 bytes that follow which is the data, and repeat.   

0 Kudos
Message 9 of 17
(4,061 Views)

Hi Robert, excuse my ignorance, but what is the symbol you have in your program after the U8 that has the arrow pointing to the right?

0 Kudos
Message 10 of 17
(4,059 Views)