LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Allow state machine while loop to end only in 1 of the states?

What is the best way to ensure that the while loop that surronds state machine case structure only ends in a certain one of the states?
0 Kudos
Message 1 of 12
(3,149 Views)
'Best' is a very subjective measure.  The easiest is just to wire a boolean true from the case in question to the "stop if true" loop condition and set the tunnel to Use Default if Unwired. 
0 Kudos
Message 2 of 12
(3,145 Views)

Hi Trager,

 

I have tried doing what you said but as soon as the program reaches the 'End' state where a TRUE constant is wired to the 'Stop if true' condition, it sort of freezes and does nothing else. To stop it I have to abort it through the 'Abort' button. I want the program to stop automatically when it reaches this state. I have tried everything that I could think of. I'd appreciate your help.

 

Thanks.

0 Kudos
Message 3 of 12
(2,812 Views)

Hi racdar,

 

this problem is probably buried in your VI! Usually this suggestion works fine, nobody else complained about problems in the last 9 years this thread rested in peace. (Trager hasn't visited this forum for 4 years…)

 

As long as you don't show your VI we cannot offer any more help…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(2,807 Views)

I'll try to see what is going on then before I'll post the code because I've tried it with a simpler code and it seems to be working.

 

Didn't notice this thread dated back 9 years!

 

Thanks for your help!

0 Kudos
Message 5 of 12
(2,801 Views)

I have solved the problem of having the VI not stopping (apparently it was due to an event structure). However, now I have another slight problem. I need the state machine to terminate on either of two conditions:

1) If a stop button is pressed

OR

2) if the end of the sequence is reached.

 

As I have implemented it so far the VI terminates because of the second condition and does not allow me to terminate it by pressing a 'Stop' boolean button. I know that this might be a bit fundamental and simple but I'm new with state machines on labview.

 

Thanks.

0 Kudos
Message 6 of 12
(2,792 Views)

Your stop button is an indicator. Why should an indicator ever work like a control?

 

Also, you should place the "stop check" outside the cases as you currently use highly redundant code (which is a big source of developer errors!).

Just select a static 'next state' in each case, the collected "stop check" would simply overwrite that state in case the user presses stop.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 12
(2,783 Views)

Thanks Norbert_B!

0 Kudos
Message 8 of 12
(2,780 Views)

You can also eliminate the local variables by putting the indicator terminals in the loop, reinitializing them to default before starting the loop.  The Stop condition can be checked outside the Case structure, and the wait can happen there, too.

 

State%20machine[1]_BD.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 9 of 12
(2,773 Views)

Thanks for your help, jcarmody! Much appreciated

0 Kudos
Message 10 of 12
(2,769 Views)