LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

byte manipulation/display

Hi,

 

I need to find a faster way to read/process/display data.  I'm currently reading byte data from an FTDI interface into an NI circular buffer without any modification.  In another loop, I read the byte data from the NI circular buffer.  I search for a header (16 bit) and footer (16 bit) and then take the data in between and process it.  After I get the data in between the header and footer, I must join the paired bytes in order to have usable data.  I do this by using a For Loop that runs 128 times to pair up the bytes using a Join Numbers VI and converts each to an I16 which is then put into an array.  Once this loop completes, I then have two parallel For Loops that seperate the X and Y parts of the array into two seperate arrays.  Each runs 64 times with one starting at index 0 and incrementing by 2 in each loop and the other starts at index 1 and increments by 2 in each loop.  I then Bundle the X and Y arrays before wiring it to the graph.  I also display the X and Y data for two other graphs and I retain the last 100,000 values as I go in a Shift Register.  These processing steps seem to kill my throughput.  Right now the best I'm getting is around 281 Kbps.  I experimented before doing anything to the data and I had been getting around 17 Mbps throughput.'

 

Any suggestions?

0 Kudos
Message 1 of 7
(3,374 Views)

A couple tips.

 

You don't need two Index Array functions.  You can drag down the bottom of the Index Array to get another output.  It will be the next one sequentially after the value wired into the top index output.

 

Rather than using a Loop, you might be able to use the typecast function to typecast your array from a U8 to a U16.

 

You can use Decimate Array to break your 1-D array into two 1-D arrays of the intermeshed elements.

 

Both of these things will eliminate unneeded loop operations and may save you some processing time.

 

Beyond that, the most costly array functions will be those ones where you Delete from Array, Insert into Array, or take an array subset.

0 Kudos
Message 2 of 7
(3,370 Views)

It is impossible to analyze code from a picture. Please attach the actual VI and maybe some typical array data and expected results..

 

In addition to what Ravens already mentioned, there are many more very questionable and inefficient constructs. Reshaping a 1D array to a 1D array of the same size seems completely silly (top center). What did you have in mind here? Yes, later you are constantly trimming and growing arrays, which causes very expensive memory reallocations. You should work on fixed size array in-place instead. Also autoindexing on an output tunnel of a while loop is expensive for large iteration numbers, because the final size of the array cannot be known.

0 Kudos
Message 3 of 7
(3,355 Views)

Instead of using Delete From Array, you should keep track of what index you are at and use Index Array or Array Subset with that index.  That way you keep the same array and eliminate some of your very costly memory reallocations.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(3,333 Views)

Thanks for the help so far guys.  I made a few corrections and disabled a few things.  Viewing the lower loop, do you see anything else that is inefficient?  I attached a modified VI with some sample data.  I plan to run the modified version tomorrow to test for throughput.

0 Kudos
Message 5 of 7
(3,320 Views)

Thanks for your help.  Do you think there's a way for me to do the second loop differentbetter/faster?  I'm talking about the one that seperates the elements X and Y by building new arrays for each.

0 Kudos
Message 6 of 7
(3,244 Views)

@tcarrico wrote:

Thanks for your help.  Do you think there's a way for me to do the second loop differentbetter/faster?  I'm talking about the one that seperates the elements X and Y by building new arrays for each.


Yes, the inner loop can be dramatically simplified. You don't need any of the FOR loops. Here's a quick draft. Modify as needed.

 

(As noted on the diagram, I would probably cast the input array to I16 as a first step, the search for FAFB and FCFD instead. Not sure if the alignment always matches, so this might not work....)

 

Download All
0 Kudos
Message 7 of 7
(3,228 Views)