LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tips to remember when using Queued State machine

Solved!
Go to solution

VeeJay,

 

It is great that you are not just learning things but also becoming comfortable enough to adopt them enthusiastically!

 

Here is an image of a modification to an earlier version of your program showing how the timed out? boolean can be used.  In the state machine version, just pass the previous version of the cluster (from a shift register) through the True (timed out) case. No new data with default vaues gets added.

 

The only problem with having an infinite timeout is that you cannot stop the loop if the serial port process fails.  Just try unplugging the serial cable while the program is running and then try to stop the program.

 

Lynn

0 Kudos
Message 71 of 75
(805 Views)

Thanks Lynn! I figured it out and I think I wouldn;t need shift registers in both Loop 1 and Loop2 for the Q with (3 boolean and 3 numeric) cluster. I will try both cases( shift registers in both Loops 1 & 2 and just in loop2.) but I get the general idea. The first time I was confused was if I used a case structure over the unbundle function, I would still get default values on TRUE case. But what you said makes total sense.I am passing the shift register through the TRUE case and unbundling the values in the FALSEcase.

 

btw, I don't think there is an image attached with your message.

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 72 of 75
(800 Views)

Let's try again.

 

Right.  You probably only need shift registers in one loop.

 

Lynn

 

Dequeue time out.png

0 Kudos
Message 73 of 75
(795 Views)

But what about the case when I want START = TRUE even when deQ times out? At that point too, I would need START to remain TRUE until an element arrives on deQ with START=FALSE. Each value of cluster is unbundled and wired to the case structure Pane (State machine)

 

Image attached. This is what I have done.

I may not be perfect, but I'm all I got!
0 Kudos
Message 74 of 75
(791 Views)

VeeJay,

 

1. I presume you intend to wire the Dequeue timed out? to the selector boolean input?  You do not have anything shown.

 

2. When timed out? is True, the values from the shift register are passed through to the Unbundle.  If the cluster wire is also connected to the right terminal of the shift register (not shown), then the old data is passed to the next iteration.  Only when timed out? is False does the newly dequeued data get put into the cluster and the shift register.

 

So, if START = True and you have it wired as I described above, it will stay True until Dequeue sets it False. Assuming, of course, that you do not change any of the values anywhere else in the wire to the shift register.  If you want to set START to True some other way, you will need to explicitly program it.

 

Lynn

0 Kudos
Message 75 of 75
(782 Views)