LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine Architecture... Queues and Events

I've been using Labview about a month. I have a standard state machine that operates fine, but needs an event structure so the program will respond to control changes as the data is acquired. I have read about a queued state machine and played with the example, but I don't see any examples that include an event structure outside the case statement for the state machine. I want the event to change the state of the state machine or reset it in a specific sequence. Where do I begin?

-Rob
0 Kudos
Message 1 of 11
(4,194 Views)
Here is a good template to start with. Just add your events and states.
- tbob

Inventor of the WORM Global
Message 2 of 11
(4,192 Views)
Thanks for the example! I think I understand how to get the queue to work correctly now. I have another example VI where the event structure is in its own loop as well, but I'm unsure which is the better method. For this particular problem, the simple fix was to insert a reset button that can be toggled from the various events, then the machine will reinitialize and keep running as the user tweaks the various parameters.
0 Kudos
Message 3 of 11
(4,170 Views)
Could you save this as 7.0 please?? Thanks.
0 Kudos
Message 4 of 11
(4,160 Views)
The file saved as version 7.0 is attached...
0 Kudos
Message 5 of 11
(4,159 Views)
Thanks for the file. What would it take to make state1 and state2 return to the init state after the code in those sections is complete??
0 Kudos
Message 6 of 11
(4,123 Views)
Put an enqueue function in the case with "init" as the element. Be sure to wire the queue wire into the function from the original create queue function output. When the case is done, init will be the next element on the queue. The dequeue function will output init to the case structure. If the event structure puts something else on the queue, then init will not be the next state, but it will be in the queue. You have to structure your code to make the states happen when you want them to happen.
- tbob

Inventor of the WORM Global
Message 7 of 11
(4,114 Views)
Unclebump,

Attached is a state machine setup similar to the one that I am using. It is encapsulated in a llb file. I'm new to all this so I hope you can open it. The enqueue function is placed in the event structure and after the state machine case structure. There is likely a more elegant way to do this, but I've been using Labview for about a month and this is what is working for me. I've stripped out all of the invoke functions and other vi references, so it doesn't look like this program actually does anything, but for simplicity, it will show how the queue structure works. Once started, press the acquire button and then turn the phase knob. You should see the polar plot at the bottom change shape and the state will go from the graph data to initialize to run and back to the graph data to continue plotting. This graph data state normally draws data from a data socket server, but that was removed to show this example. Best of luck!

-Rob
0 Kudos
Message 8 of 11
(4,104 Views)
Could you save this file as v7.0 format?? I haven't upgraded yet.
0 Kudos
Message 9 of 11
(4,057 Views)
Hi unclebump:

Here is that same llb for 7.0. It is missing AsteroidSignalGenerator.vi, but you should be able to have a look at the block diagram anyway.

Emilie S.
National Instruments
Applications Engineer
0 Kudos
Message 10 of 11
(4,031 Views)