05-02-2013 10:09 AM
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
05-02-2013 10:34 AM
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.
05-02-2013 02:59 PM
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.
05-02-2013 03:50 PM
@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.
05-02-2013 03:55 PM
@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.