09-01-2005 11:14 AM
I am trying to write a
program that has a main event structure that handles all the front panel
activity but also has a while loop running in parallel with the event structure
that can poll the current values of a device. It seems that there is a
problem with running a while loop in parallel with an event structure, but I'm
not quite sure why. Attached is a simple program that shows the structure
I am trying to use. Any advice is appreciated.
Kasey
09-01-2005 11:15 AM
09-01-2005 11:21 AM
There is no problem. You simply need to have the event structure inside a while loop of its own. The outer loop can only iterate when all the code inside it has finished running, and that includes the smaller while loop. BTW, if this is in the same way, you don't need a global variable. You can even do it without a local, if you only have 2 loops. Simply stop the event loop with a T constant and the other loop with the stop control.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
09-01-2005 11:58 AM
09-01-2005 11:59 AM - edited 09-01-2005 11:59 AM
Your two loops cannot be stacked, they need to be independent. You can sense the stop button in multiple independent event structures, so run two loops, each containing an event strucure. See attached quick modification (LabVIEW 7.1). All clear?
(BTW: There is no conceivable reason for your global variable and stacked sequence structure!)
Message Edited by altenbach on 09-01-2005 10:01 AM
09-01-2005 12:15 PM
09-01-2005 12:24 PM - edited 09-01-2005 12:24 PM
Yes, think dataflow!
If you wire it as in the attached figure below, the global variable will be written once the loop stops. Dataflow dictates that a node will execute once all inputs contain data and outputs only contain data once the node has finished. In this case, data is only available AFTER the while loop has stopped.

There is no need to complicate the code with stacked sequence structures.
Message Edited by altenbach on 09-01-2005 10:26 AM
09-01-2005 12:44 PM