LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to pause and stop two "for loops" in an event

Hi
The main menu runs first and then goes to reading menu. After "Start Reading" button is pressed, the reading process will take readings.
1) During reading process, if the "Pause Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters do not reset. After the "Start Reading" button is pressed, the two "for loops" will continue to run.
2) During reading process, if the "Stop Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters are reset. After the "Start Reading" button is pressed, the two "for loops" will run again.
The attached two VIs are simplified my real application. Any help will be appreciated.
Thanks
Steve

Download All
0 Kudos
Message 1 of 5
(2,420 Views)

You can't have those loops inside of the event structure.  Currently, when you press the start button, the reading has to finish before the event case finishes.  This will prevent the stop can cancel buttons from being processed by the event structure.

 

You need another loop that can recieve commands from the event loop.  Look up the Queued Message Handler.  That should get you a good start on the command process.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(2,409 Views)

If you want to implement a stop feature, use a while loop instead of a for loop.  Use some logic to stop the loop if: A) the stop button was pressed, OR B) you have reached the number of desired iterations.  The problem with stoping for loops is that there isn't a stop terminal.

 

A pause feature can be implemented by placing a timed while loop inside a case structure (stop this loop when the desired button is pressed).  The timed while loop will use less CPU power than an empty while loop.

 

 

0 Kudos
Message 3 of 5
(2,381 Views)

@pjr1121 wrote:

The problem with stoping for loops is that there isn't a stop terminal.


Actually, starting in LabVIEW 8.5, there is.  You can right click on the loop and enable the conditional terminal.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(2,374 Views)

@crossrulz wrote:

@pjr1121 wrote:

The problem with stoping for loops is that there isn't a stop terminal.


Actually, starting in LabVIEW 8.5, there is.  You can right click on the loop and enable the conditional terminal.


 

Learn something new everyday.  So i guess you just need to wire your stop button to the for loop's conditional terminal and add a while loop to act as the Pause.  

0 Kudos
Message 5 of 5
(2,372 Views)