LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simplify code

Hi everyone,

i am working on code in which we are dealing with cluster of arrays. copy of data is created every time the vi runs which is also causing out of memory issue on few systems. Attached is the code. This vi is used as subiv in the main vi.

 

Please suggest how can we make this code more efficient.

 

Thanks

0 Kudos
Message 1 of 11
(3,306 Views)

You have an In Place Element Structure, but you aren't using any of the nodes on the border to make sure things are operating in place.  You are essentially treating it like a single frame sequence structure that just has a different appearance to its border.

Message 2 of 11
(3,266 Views)

@RavensFan wrote:

You have an In Place Element Structure, but you aren't using any of the nodes on the border to make sure things operating in place.  You are essentially treating it like a single frame sequence structure that just has a different appearance to its border.


If you dig a little, there is another one inside of an case structure.  Same issue.

 

The misuses of the IPES is the only glaring issue I found.


GCentral
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 3 of 11
(3,259 Views)

Hi RavensFan and crossrulz,

 

Thanks for the quick reply and pointing out of the misuse of in place element structure ( i have never used it before, and didn't checked also in help also thoroughly). i will update the code and see if it helps .

 

Thanks

0 Kudos
Message 4 of 11
(3,253 Views)

I believe the previous contributors that replied to your query were indicating the IPE structure is not being used so is not doing you any good.

 

There looks to be about three different conditions in which the code will operate, I=0, Memory saving mode, average.

 

Please simplify your code to us ONLY the conditions that will be of most value and let us look again.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 11
(3,249 Views)

Hi Ben,

 

The memory saving mode will be set to false for most of the cases, and average number is 5 ( which means true) and the value of i will be greater than 1. 

These all are the most used conditions.

 

Thanks

Ritu

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

Plese edit your code to remove the case structures and selects nodes to simplify what we will be looing at to help you.

 

Off hand it looks like you are unbundling and rebundling some fields where there is not need to do so. Frame and V^2 are examples.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 11
(3,237 Views)

Hi everyone, 

attached is the edited code with all unused case structures removed.

 

I tried to put in place element structure in some part f the code by specifying the nodes correctly but observed instead of decreasing, it is increasing the memory usage.

0 Kudos
Message 8 of 11
(3,194 Views)

It might be worth noting, for readability if not performance (I'm not sure what the performance effect would be) that you could replace the entire left side with something like this:

Also, making your cluster a typedef will prevent the frame representation change to double after the divide. You could create a small subVI to just reset the values for I/Q/Frame and V^2 since you'll need to do it twice if you did this (i.e. New value in, Value to change in, changed value out)

simplify.png


GCentral
0 Kudos
Message 9 of 11
(3,165 Views)

 

Instead of wiring a constant to the top input cluster when bundling, wire the original cluster there, now you only need to unbundle/rebundle the elements that actually change (e.g. no need to wire frame, V2, and I and Q data across at the bottom at all.). This makes it much clearer that these values are not modified and thus make the code more understandable. In your original code, it is difficult to tell what cluster elements actually change.

 

Here's how the lower bundle by name could look like:

 

 

 

 

0 Kudos
Message 10 of 11
(3,161 Views)