07-02-2012 12:57 PM
Hello! I have what I think is a simple timed loop in LabVIEW that exits after 100 iterations by throwing an error, and letting the loop "stop on error". This works fine when run in the regular LabVIEW environment, however, when compiled as a Dynamic Linked Library (DLL) and called from LabWindows it forces me to terminate execution, rather than exiting nicely. What's more, it seems to quit the actual Virtual Instrument call just fine and proceed to the next line of code, but when my main() function in LabWindows completes there must still be something not cleaned up that is causing it to not exit nicely. Any ideas? I've tried adding a call to QuitLabVIEW and that doesn't seem to do it.
Thanks in advance - hoping you'll point out some really easy mistake. 🐵
Attached is a picture of the timed loop.
Below is an excerpt of code from LabWindows:
int main ()
{
CallMyLabVIEWDLL(); //This line successfully launches and closes the window for my LabVIEW virtual instrument
MessagePopup ("My Title:", "This happens after the call to your LabVIEW DLL"); //This popup shows up - indicating the call to the DLL has completed
//But after the code has completed LabWindows still says "Running", rather than shutting down.
return 0;
}
Solved! Go to Solution.
07-02-2012 08:11 PM
Why would you stop the timed loop in this way at all?
Why not just wire a True to the stop terminal?
07-03-2012 05:50 AM
Thanks for your reply. The reason the loop is terminated in a funny way is a leftover from the larger application where I'm doing some queue operations in multiple loops. It doesn't matter; I simplified the example and wired a boolean directly to the stop terminal and have the same problem - it still runs and leaves LabWindows in a <<Running>> mode until I break execution. Is there something else I'm not doing in a standard way or in a clean way that might be screwing things up? Thanks in advance for your help.
07-03-2012 07:43 AM
Update: I tried the simplest possible "While" loop and it works. If I replace it with the simplest possible Timed Loop, it doesn't. (See attachments.)
The only thing I could find in a search for why a time loop would break a dll is a patch for lvalarms from LabVIEW 8.5.1 .... I'm running LV 2010 so I don't believe that's an issue. Correct me if I'm wrong?
Thank you!
07-06-2012 07:54 AM - edited 07-06-2012 07:55 AM
Why are you using a timed loop in the windows environment? They are better used for real-time environments (not windows) and tend to have a lot more overhead than the while.
Is there any particular reason a while loop will not work?
07-06-2012 08:17 AM
There are some additional things you have to look into/pass on to us:
a) Do you get any error messages once you break execution of the CVI program (while using the 'blocking' DLL)?
b) Why do you combine the timed loop (sleep timing included in settings) with wait functions (explicit sleep)? This makes no sense and i suggest you to remove the wait in the loop.
c) I understand that you are working with LV 8.5.1? Can you try out newer LV versions (e.g. by evaluation) if it behaves the same?
d) Can you check if the timed loop is throwing an error?
thanks,
Norbert
07-06-2012 08:24 AM
Norbert and Craig,
Thanks for your help. I'm still stumped as to why it won't work as written, but I subsituted a regular old while loop and it works fine. I was using a timed loop to try to force a bit of extra assurance that this loop would run while another loop was running.... but it was overkill and apparently not very useful!
To answer your questions:
- I'm using LabVIEW 2010
- LabWindows/CVI does not report any errors
- The timed loop does not report any errors
- I threw in the explicit wait just for purposes of illustration; so I could spy on what is happening, not part of the real objective
Thanks again for your time and help! Let me know if you come up with any ideas or suggestions, but I'm not desperate anymore as the while loop replacement did the trick.