LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Improving efficency of "for loop" in sub VI

Hi,

 

I've developed a LabVIEW program to analyze accelerometer profiles of a dropping mass. The program identifies two key points during impact:

  • T1: The initial contact time, defined as the first data point where the normal load exceeds 30 N.
  • T2: The end of impact, defined as the first data point after the peak normal load where it drops below 30 N.

Additionally, for both T1 and T2, the force gradient at these points must be greater than 10 kN/s.

 

I've implemented a For Loop to cycle through a database of 5,000 drop tests. However, the code experiences a bottleneck when generating the force gradient profile. I've noticed in the 'Force Gradient 3' graph that the method appends all data as the loop iterates, which I suspect is causing the processing time to increase as more datasets are analyzed.

 

Any suggestions on optimizing this approach to improve performance would be greatly appreciated.

 

Max

 

Max2796_0-1730478668592.png

 

 

 

0 Kudos
Message 1 of 6
(203 Views)

Your VI has massive problems that have nothing to do with  FOR loop efficiency.

 

  • We are missing a subVI
  • Your Feedback node is globally initialized and with this retain all data from all iterations (Main problem!)
  • Prepending data to an existing array causes massive memory allocation issues.
  • Delete from array is not the right function to take a subset.
  • Index array is resizable
  • You don't need the conditional terminal because the number of iterations is known before the loop starts (inner FOR loops).
  • There is no need for any dynamic data anywhere.
  • What is the point of rattling through all data if no record is kept?
  • Please do no maximize the diagram and front panel to the screen.
  • Why do you say subVI? This looks like a "one shot downhill toplevel" with no connectors defined.
  • Don't put indicators inside tight inner loops.
  • I have the feeling that done correctly, your code would fit on a postcard!
  • etc.

Please attach your missing subVI and a set of typical files.

Message 2 of 6
(194 Views)

Just compare your code and some better alternatives: (This is just the tip of the iceberg!)

(Yes, there are even no-loop solutions!)

 

altenbach_0-1730481477956.png

 

 

 

Message 3 of 6
(188 Views)

@Max2796 wrote:

Hi,

 

I've developed a LabVIEW program to analyze accelerometer profiles of a dropping mass. The program identifies two key points during impact:

  • T1: The initial contact time, defined as the first data point where the normal load exceeds 30 N.
  • T2: The end of impact, defined as the first data point after the peak normal load where it drops below 30 N.

Additionally, for both T1 and T2, the force gradient at these points must be greater than 10 kN/s.

 


OK, so you need to find two positions:

 

  • The first point (T1) where data is>30 AND gradient >10k
  • The second (T2) where data is<30 AND gradient >10k

Your files have no timing information, so I assume you just want the array index of these two position.

 

How do you need to handle exceptions

  • data is never >30?
  • Data is always >30?
  • gradient is never >10k?
  • etc.

 

0 Kudos
Message 4 of 6
(163 Views)

@altenbach wrote:

OK, so you need to find two positions:
  • The first point (T1) where data is>30 AND gradient >10k
  • The second (T2) where data is<30 AND gradient >10k

Your files have no timing information, so I assume you just want the array index of these two position.

Here's a very quick generic draft to do this. Most likely it would need some tweaks, for example the second loop could start with the array max position.

 

altenbach_0-1730488616595.png

 

Of course you need to adjust the thresholds and potential filtering of the derivative according to your needs. You also need some exception handling.

Of course you don't need the cursors and graphs.

 

The code could be further simplified by placing the two FOR loops in a 2 iteration FOR loop and adjust the code accordingly.

0 Kudos
Message 5 of 6
(149 Views)

@altenbach wrote:
, for example the second loop could start with the array max position.

Here's how that could look like:

altenbach_0-1730562686296.png

 

Message 6 of 6
(111 Views)