LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flat sequence in a while loop

Solved!
Go to solution

Hello,

 

I am pretty new to labview. I am using a flat sequence inside a while loop. there are 2 sequence. the first sequence will have wait time for 3 sec and next sequence will have wait time for 7 sec. Now I have attached a stop control button. Now when i run the vi, and let say i want to stop the program using the stop button for while loop, i cannot stop the vi.

how do i make a control to stop the program at anytime??

0 Kudos
Message 1 of 6
(2,038 Views)
Solution
Accepted by topic author Sid1007

Hi Sid,

 

to stop immediately you need to get rid of those long wait times.

A state machine may help...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,012 Views)
Solution
Accepted by topic author Sid1007

As GerdW said, a state machine is an appropriate approach. You only need one loop, and the state machine does the sequencing (no sequence structure). You use small wait times and exit the wait state when you reach your total wait time.

0 Kudos
Message 3 of 6
(1,995 Views)
Solution
Accepted by topic author Sid1007

A sequence works similar to a sub-vi in that nothing can happen until it's finished. So your stop button probably works, but it'll wait the 10 secs (or <=20 if it reads the stop button at a bad time) Before it stops.

As mentioned, a state machine is a good solution to these needs.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 6
(1,946 Views)

Since you are "pretty new" to LabVIEW, I would immediately ditch the use of sequence structures, and learn how to enforce dataflow correctly.  Here is a link to help you get started.  Depending on sequence structures to enforce dataflow is a habit you have to immediately unlearn.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 5 of 6
(1,901 Views)

Thank you everybody. The used state machine and it works fine very efficient. 

Message 6 of 6
(1,868 Views)