From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loops and Event structures

Solved!
Go to solution

Is there a problem using more then a single While Loop with an internal Event structure, in a single VI?

 

In my VI (Attached only a partly printscreen) there is more then 2 while loops with an internal even structure which controls a different devices.

This event structures are being controled by a case structure. 

From time to time the VI gets stuck and some local variables reset.

Screenshot 2014-07-14 13.53.54.png

0 Kudos
Message 1 of 6
(2,705 Views)
Solution
Accepted by topic author NivShapira

Hi,

Using two while loop is not a problem it depends on how you structure the code.

Generally we use two while loop structure for Producure-Consumer, Master -Slave, type of applications. Try to use state machine structure inside the while loops, please refer standard state machine examples in NI find example pallet.

With Regards

Miraz
Kudos is better option to thank somebody on this forum
------------------------------------------------------------------------------
0 Kudos
Message 2 of 6
(2,685 Views)

Hi Nivshapira,

 

Better you look at the following links. Which will clear you about Event structures here and Two while loop handling here

0 Kudos
Message 3 of 6
(2,673 Views)

Hi NivShapira,

Yes you can use two while loops in parallel.Thats how we are achieving multi-threading in LabVIEW.

But in your implementation of V I,every time both the while loops pauses at the event structure for 5 ms or any event.

 Is this your expected behavior?

 

 

Regards,

SrikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 4 of 6
(2,672 Views)

Miraz,

Thank you very much for your answer (Kudos).

I will convert the code to a "standard state machine" code in order to see if it works better.

Yet, the concept of my code enables you to operate different actions from the front panel, using the proper case for the event choosen. What advantages the "standard state machine" have compared to the concept in my code?

 

Thank you very  

 

0 Kudos
Message 5 of 6
(2,668 Views)

Having no other choice, I have defined a 5milisec avoiding "never time out" of the event structure which stops the whole VI operation.

 

thank you very much for the comment

0 Kudos
Message 6 of 6
(2,655 Views)