LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help speeding up byte pair cocatenation

I call a DLL that reads from a digitizer.  If I digitize 8192 16-bit samples, the routine spits out an array of 16384 bytes.
I need to cocatenate these byte pairs back into a 16-bit word.
Eaxmple:
 
Byte(0) > Byte(1) = Word(0)
Byte(2) > Byte(3) = Word(1)
Byte(4) > Byte(5) = Word(2)
 
I wrote a VI to do this however it takes 14 ms to execute (acording to the profiler) for 16384 bytes.  This seems excessive considering a 8192 point FFT is < 1 ms.
 
Does anybody have an idea that is quicker?
 
 
Download All
0 Kudos
Message 1 of 4
(2,809 Views)
In principle, you can just typecaset to a U16 array, unfortunately, you'll get the wrong endian-ness here. (Big endian, upper image)
 
It seems you want little-endian. You could swap adjacent bytes before typcasting one way or another, or you could convert to a string and use "unflatten from string" (newer LabVIEW versions allow you to specify byte order). (bottom image). There are many other ways to do this.
 
 
 
 
 
 

Message Edited by altenbach on 03-22-2007 03:02 PM

Message 2 of 4
(2,796 Views)
Try using the Decimate 1D Array along with the Join Numbers function
Message 3 of 4
(2,794 Views)
Thanks guys.  I tried both.  For 16384 input bytes the first example runs in 138 us, the second in 76 usec.  I swapped the byte order for the second example to get little endian. 
My old one was 12400 usec.  Big improvement!
 
0 Kudos
Message 4 of 4
(2,766 Views)