LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inner While Loop Won't Stop

Hi guys,

 

I have been working with LabVIEW trying to develop a control system that interfaces with another software environment that controls the hardware I am using in my experiments.  I need my program in LabVIEW to be able to both read from and write to the software I am interfacing with.  The problem that I have comes when I try to more or less continuously monitor certain parameters from the other software and send parameters at the same time.

 

The way I designed my architecture was to have two while loops and an event structure.  The inner while loop holds controls and indicators that need to be continuously monitored.  I wired the trigger for the event structure to the inner while loop's stop terminal so that when I want to pass parameters the inner while loop will exit and execute the proper event commands.  What ends up happening is that this architecture works fine the first time I stop the inner while loop.  All parameters are passed and everything works perfectly.  The problem occurs when I want to pass parameters again.  When I try to have the event structure execute again nothing happens.

 

I watched the data flow to see what was happening and it seems that my stop button for the inner while loop constantly passes false to the stop terminal after the first execution, despite me telling it to pass a true.  I'm not really sure why this is happening.  If anyone has any ideas about how to fix this or perhaps suggestions for a more efficient architecture I would love to hear them.

 

I've attached an example program.  It contains the general layout of the architecture I am working with currently.  Thanks!

0 Kudos
Message 1 of 4
(2,647 Views)

I would forget about that inner while loop and go for a state machine.

 

I also believe your Event structure should be inside the 'inner' while loop to get it somehow working...  because your Trigger in the inner while loops blocks acces to the Event structure... Your event structure is excuted each time Trigger=true.

 

 

 

 

0 Kudos
Message 2 of 4
(2,633 Views)

The Event Structure already has a mechanism to do what you are trying to do right now.

 

You can wire a value (such as 100 ms or 10 ms) to the timeout terminal of the structure and place your "controls and indicators that need to be continuously monitored" in the Timeout diagram.  Write them to shift registers of your while loop in order to make their values available to diagrams in other iterations.

Get rid of "Trigger" and just use your "Trigger 2".



0 Kudos
Message 3 of 4
(2,608 Views)

Let's first analyze why your code does not work.

 

You have a data dependency betweeen the inner while loop and the event structure, meaning the event structure cannot execute unless the while loop has completed. Triggering enay event at this state will permanently lock up your VI, because the events are set to lock the front panel until the event has complete, but  the event cannot complete because of dataflow issues.

 

Having dozens of "reninit to default" property nodes just to clear some booleans is plain silly. I think you should rethink your entire architecture. Does the while loop really need to spin as fast as the hardware allows?

0 Kudos
Message 4 of 4
(2,595 Views)