LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple question regarding state machines and data flow out of case structures

Hi there, this should be fairly straight forward and there are fiddles for it, but as I'm quite new to Labview I'd like to know the best way to do this.
 
I have a state machine (using the basic state machine template) for a tester sequence, and would like to have one text box on the front panel which is updated as each state is executed (ie. in my init state, the textbox will read, "Initialising test..", then in the setup state, "Setting up signals.."). Up until now, I've just had a string constant inside of each case, tunnelling out to a text indicator in the while loop (note, the while loop has a 1500ms Wait function in it). This works well (for the human eye) if the contents of the case structure take considerably less time to execute than one iteration of the while loop, however, one of my cases takes much longer, which means the string data inside the case structure isn't passed out of the case structure tunnel until the case has finished being executed, and thus the text isn't shown in the front panel text box. I'd be very appreciative if any of you could give me hints on how to fix this properly.

Thanks very much.
0 Kudos
Message 1 of 5
(2,925 Views)
Hi ChrisC_
 
One solution out of many could be as follows:
Create a subvi and insert the state value which is usually wired to the case structure of the consumer. In the subvi firstly wire this value to an output, which is then wired to the consumer case structure.
In the subi, you could also have a case-structure with the string constants you want to display. Wire this also to an output. This output then can be wired to the string indicator. So you finally have to place this subvi between the dequeue element vi and the consumer case structure. Basically this comes to my mind if you feed the producer/consumer queue with strings.
 
 
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 5
(2,906 Views)

Hi there!

Simple solution that might work for you, assuming that you use an enum as identifier for the states:

Create a string array constant containing the texts that are to be displayed, let your enum index this array to get the right text, perform this and populate the string indicator right before the case structure. Alternatively, create local variables for the string indicator in each case if you want to keep the text within the states.

//Martin



CLA
https://www.prevas.se/expertis/test--regulatoriska-krav.html
0 Kudos
Message 3 of 5
(2,893 Views)
If you use an enum (I would use a type def), you could also create a dummy indicator and use the property node to set its value and then access the ringtext.
 
Have a look at the attached vi.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 4 of 5
(2,888 Views)
Thanks to you all for your help, it's very much appreciated. It's working perfectly now.
0 Kudos
Message 5 of 5
(2,862 Views)