LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queued State Machine Control Reread in While Loop

I am using two queued state machines to separate UI, data acquisition, and data processing functions.

 

The problem I am running into is that the state within the while loop executes prior to a control being reread and passed to the state. The result is stale data.

 

In the attached picture, the top case handler responds to a change in a set of controls, two elements being FIOArray and AOArray. The case handler sends state "Plot" to the queued state machine, which feeds the controls' values into the second state machine to plot appropriately.

 

Instead of the new values being read from the control, the while loop reads the values PRIOR to the change was made. This causes many problems, especially for cases that read data and insert it back into the controls. The result in this case is that the array is effectively unchangeable.

 

The trivial way to solve this problem is to put the controls inside the states in the case handler, and this works. This is not the desired approach, however, as nearly all cases use the control values, and it makes more sense to feed them from outside rather than fill each case with local variables. I could use a value property node and enforce execution order via error clusters, but it seems that there should be a better way ... or that it should just reread the control for each loop iteration.

 

Thanks,

C

PhD ChemE, CLD, Alliance Partner : www.interfaceinnovations.org
0 Kudos
Message 1 of 3
(2,587 Views)

What you are seeing is a direct result of the LV dataflow paradigm.  On the first iteration of the middle loop Initialize will already be in the queue so the Dequeeu will occur immediately. On the next iteration the values in the FIOArray and AOArray clusters will be read immediately and the Dequeue will wait for a command from the top loop. This happens because there is no data dependency between the Dequeue function and the clusters.

 

To get fresh data you need to force the reading of the cluster controls to occur after the Dequeue.  This might be a place where a one-frame sequence structure containing the cluster terminals and having the error wire from the Dequeue passing through is appropriate.

 

Lynn

0 Kudos
Message 2 of 3
(2,578 Views)

Thanks Lynn. I guess I didn't realize that it read the controls and waited for a queue element, but that totally makes sense. I wired error clusters.


Thanks,
C

PhD ChemE, CLD, Alliance Partner : www.interfaceinnovations.org
0 Kudos
Message 3 of 3
(2,575 Views)