LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coherence averaging without while loop

Hi all,

 

I attached a VI (Coherence.vi using LabVIEW 2011) that calculates and plots the coherence for two simulated signals. It works fine but I want to make a change that I don't know how to manage.

 

I want to elimnate the while loop (as I am planning to convert this VI into dll and use it in JAVA appilcation) and do the averaging in an alternative way without using while or for loop.

 

The problem with the while/for loop is that the dll doesn't give any output except if the while/for loop is stopped.

 

Is there any ideas?

0 Kudos
Message 1 of 15
(3,690 Views)

Hi cowboy,

 

right-click the while loop border and select "remove while loop". Do some cleanup work (delete wait function) and you're finished...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(3,682 Views)

Thanks Gerd for your concern,

 

But this was not what I meant actually. If I remove the while loop, I cannot perform the average anymore. My question is how to perform the average done inside the FRF function without using while loop. In other words, I need only the average VI in LabVIEW and the while loop will be in JAVA. Please note that if I call this VI or dll successively without having while loop in LabVIEW, it will restart averaging, thus I won't get an averaged data. 

0 Kudos
Message 3 of 15
(3,667 Views)

I admit that I'm not exactly sure how it will behave inside a DLL, but the inside of the NI supplies VIs are Functional Global Variables.  They keep track of their data.  So just removing the while loop and building your DLL should be all you have to do.


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 4 of 15
(3,648 Views)

I tried this crossrulz (to remove the while loop and build the dll), but when I call the dll from the JAVA, every time it restart averaging and I didn't get averaged data.


0 Kudos
Message 5 of 15
(3,634 Views)

It look like you need to run the VI a couple of times to get a decent average? Why not simply change it to for loop and run it 20 times and return the result?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 15
(3,617 Views)

Yamaeda, 

 

What I really need to do is that the user see the averaging in JAVA as it happens in LabVIEW. It would be a good solution to make for loop for a number of iterations and call it successively, but how to control the for loop to not restart averaging if the averaging is not really finished yet.

0 Kudos
Message 7 of 15
(3,589 Views)

Hi Cowboy12,

 

From what I understand, it looks like the averaging VI in your code uses uninitialized shift registers to store previous data, similar to functional global variables.  It seems that each time you are calling this VI from java the result exits out of LabVIEW memory after executing.  This means that each time you call the VI from java you are getting a new instance of it with no memory of the previously averaged signal.

 

I think your best bet is to keep the while loop in LabVIEW, so that the current averaging VI works appropriately.  If you really must remove the while loop, then you could write your own version of the averaging VI that takes in the last averaged signal and feeds it into the currently uninitialized shift register.  You would then also need some way of storing this averaged signal in Java and then sending it back into LabVIEW the next time you call the VI.  However, this seems like a very complicated way to obtain the result you want.

 

Hope this helps!

0 Kudos
Message 8 of 15
(3,533 Views)

Thanks Lindz for your reply,

 

This exactly what I meant. I have thought about building my own averaging VI and takes the last averaged data and feed it back into the loop, but it would complicated as you said and also I will not guarantee its performance to be as the averaging already implemented in FRF VI.

 

So, just to make sure, as I understand from your reply, there is no alternative solution if I keep both the while loop and the FRF averaging?

0 Kudos
Message 9 of 15
(3,526 Views)

Hi Cowboy12,

 

I’ve looked a little bit more into your issue, and I think narrowed down the problem.  Under most circumstances, using uninitialized shift registers like are in the FRF VI in a dll would still do the averaging you want even when called repeatedly from Java.  However, because of the way this VI is written, anytime you call this VI for the first time, it clears your previously averaged signal.  (If you open the FRF function you can see the or condition at the beginning of the code that determines if it’s being run for the first time.)  So it seems to me you would need some way to trick the dll into thinking it wasn’t being called for the first time.  It’s possible there’s a way to do this in Java, but I’m not familiar enough with Java to offer a solution.  Hope this helps!

 

 

Regards,

0 Kudos
Message 10 of 15
(3,495 Views)