LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How avoid using while loops into a event structure

Solved!
Go to solution

So, I'll not use the defined LabVIEW function "event structure"? Sorry, but I don't have much experience programming LabVIEW

0 Kudos
Message 11 of 16
(1,640 Views)

Open this vi and you'll know how to use the SME.

 

Kudos are welcome.

Certified-LabVIEW-Developer_rgb.jpg

Best Regards,
Prince Agarwal,
Certified LabVIEW Developer
0 Kudos
Message 12 of 16
(1,637 Views)

Sorry, but I don't understand how avoiding the use of local variables by using the state machine. It's still quite confusing programming in LabVIEW, after structured programming in C++.

Your system is in one of many states at any given time, and depending on the state, various actions occur and update the various indicators (no need for local variable if you place them after the case structure containing the various states. 

 


 

 

0 Kudos
Message 13 of 16
(1,635 Views)

Sorry, the PC has installed LabVIEW 2013. I cannot open it.

0 Kudos
Message 14 of 16
(1,633 Views)

Certified-LabVIEW-Developer_rgb.jpg

Best Regards,
Prince Agarwal,
Certified LabVIEW Developer
0 Kudos
Message 15 of 16
(1,631 Views)
Solution
Accepted by Dranek

Instead of using a "Simple State Machine" and implementing the Event Structure as a "State" that needs to be repeatedly Entered and auto-exited using a Timeout case, you could take advantage of LabVIEW's Parallel architecture and create two loops, a While Loop containing only the Event Structure and a State Machine fed by a Queue instead of a Shift Register.  The Event Loop requests a State to be run by putting that State on the Queue, and the State Machine requests a "Next State" by doing the same thing, putting the State on the same Queue.

 

There is a Template (called the Producer/Consumer Design Pattern (Events)) that ships with LabVIEW.  Open LabVIEW, click "New ..." (the dots are important!) in the File Menu, and find this Template.  It will build a prototype that you can study and either modify yourself or, once you understand how it works, simply code it up.  Just remember that the key concept is that the Event Loop and the State Machine run in their own independent While Loops, so they run simultaneously and the trick is to get these parallel loops to interact.  The "usual way" to do this until LabVIEW 2016 was through Queues -- in LabVIEW 2016, the alternative of using "Channel Wires" is available (and is my method of choice).

 

Bob Schor

Message 16 of 16
(1,610 Views)