LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with a VI -> SubVI (with the same functionality)

Hi there,

I have an problem with a function and a Sub VI, please see the attachment.

I need to sample an average value over 5 values. The previous average value schould be shifted and hold.
After sampling 5 values, the average is calculated and shown.

So, the problem is, the function in the "root" VI work fine. The same function wich is in the SubVI doesn´t work! The Indicator "Average_2" and "Average_shift_2" only indicates for one cyles the calculated value! After then, it is cleared!

What am I doin wrong!??

Thanks for help!
0 Kudos
Message 1 of 4
(2,692 Views)
Hello EMG:

It seems that your SubVI does not save the previous values like your "root" VI.
Whenever your "root" vi loads the SubVI, it sets all of your controls to its default value. In this case, it sets the variables "Mittelwert" and "Mittelwert vorher" to their default values which is 0.

So whenever your SubVI is loaded, the initial values of "Mittelwert" and "Mittelwert vorher" is zero, and when the "Clear/Init" is set to false, there will be no action, thus the values of "Mittelwert" and "Mittelwert vorher" will not be changed.

As a solution, I suggest that you would save the values of these variables in a shift register; similar to what you did with "Content". For better understanding, please see my attachment.

I hope that this helps.

Good Luck
Message 2 of 4
(2,669 Views)
Same comments as the previous poster. all of your controls and indicators reset to default values so here is another quick fix with less coding as the previous poster's fix.

His may be safer I don't know.

Only sub vi is attached
Message 3 of 4
(2,663 Views)
Thanks allot to you.

It works now.
0 Kudos
Message 4 of 4
(2,651 Views)