10-28-2013 05:51 AM
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?
10-28-2013 06:01 AM
10-28-2013 01:36 PM - edited 10-28-2013 01:45 PM
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.
10-28-2013 03:25 PM
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.
10-28-2013 04:58 PM
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.
10-29-2013 02:30 AM
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
10-29-2013 01:36 PM
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.
10-30-2013 01:40 PM
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!
10-30-2013 02:03 PM
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?
10-31-2013 09:49 AM
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,