LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Speed Optimization

Solved!
Go to solution

Dear all,

I am working on a speed critical application where i am receiving data(1600 bytes) from my H/W @ 20 ms. and i am doing some bit of processing on it which is taking around 30 ms. Though i am storing data in Queue to avoid any data loss, but i want to show real time data to the user.

 

I am attaching my Vi here where i am doing the processing. Pls have a look at suggest some solutions to optimize the speed.

 

I am receiving 1600 bytes, out of which 1592 are the data bytes to be plotted. my data is 16 bit, so 2 bytes make 1 data. and its a 4 channel data. so each channel will have 199 bytes each.

The size of the buffer where i am putting this data = 8,00,000.

 In the VI, i am just checking the size of the buffer(if more or less than 8,00,000) and replacing the data in the buffer.

 

 

 Ritesh 

0 Kudos
Message 1 of 19
(1,597 Views)

Hi all,

i'll just put it in a simpler way.

I have a 2D array(4*600000) of I16 and want to replace each row with 1D array of 200.

this replacing instruction takes around 14-16 ms which is alot in my performance critical application.

and i want to perform this replacing action every time i get data from my H/W(@ 20 ms).

I am performing this process in Action Engine, so every data is in a shift register.

Is there a better way to perform the replacing action on huge arrays which will do it in a matter of less than 5 ms??

 

 

 

Thanks,

Ritesh 

0 Kudos
Message 2 of 19
(1,572 Views)

Hi Ritesh,

 

instead of using auto-indexing it's more efficient to work with a shift register and wire the row index. See screenshot. This takes ~4ms on my machine.

 

Replace-in-array.png

 

Hope this helps,

Daniel

 

0 Kudos
Message 3 of 19
(1,568 Views)

Hi dan_u,

This solution would work perfect if the index of the column is always 0(starting of the row). But that is not the case here. I think i forgot to put the index to the row in my previous VI.

The index keeps increasing by 200 every time i receive data.

I am attaching another VI to give a realistic view to my problem.

 

 

 

Thanks,

Ritesh  

0 Kudos
Message 4 of 19
(1,566 Views)
Solution
Accepted by topic author LVCoder

This doesn't change anything in the idea of not using auto-indexing but shift registers. If you want to replace elements in the middle of a 2D array you have to do it one by one. This means you might need an additional loop.

See image or VI.

 

Large array-MOD.png

Message 5 of 19
(1,563 Views)

Yeah thanks alot man. 

This(Shift Register) is 15 times faster than the Loop tunnel method.

now it is running at 0 or 1 ms.:smileyhappy: 

 

 

 

 

Thanks alot,

Ritesh 

0 Kudos
Message 6 of 19
(1,552 Views)

Glad it works. Whenever possible, try to do things "in place". Shift registers are your friend to do so Smiley Happy

 

Kudos appreciated Smiley Very Happy

 

Happy wiring,

Daniel

 

 

 

0 Kudos
Message 7 of 19
(1,545 Views)

Ok

Now after getting it worked superbly, may i know why using Shift Registers prove to be so faster than Auto indexing. Like both are doing the same operation. Then where does Shift Registers add to performance?

 

Your reply has already been appreciated with Kudos! :smileyhappy:

 

 

Ritesh 

0 Kudos
Message 8 of 19
(1,525 Views)

Doing it with a double-indexing means the compiler can not make certain assumptions in making the operations in-place.

 

Operating directly on the 2D array lets the compiler know that everything's being done ont he original array, thus avoiding copying and re-allocation.

 

Shane.

Message Edited by Intaris on 06-04-2009 08:38 AM
0 Kudos
Message 9 of 19
(1,515 Views)

I am sorry but i forgot to mention another case which occurs when the size of the array exceeds 600000.

This wont work in a circular manner.

so when the size of the array exceeds 600000, the data at the starting will get deleted and the new data will be replaced in the end. i.e the first 200 bytes will get deleted, data at 201 will become the starting position and the last 200 bytes are replaced with the new ones.

 

now this operation is taking about 15-16 ms.

 

I have attached my Vi here. Pls have a look and let me know if a better solution exists.

 

 

Thanks,

Ritesh 

0 Kudos
Message 10 of 19
(1,514 Views)