How to Pause a While Loop in LabVIEW?

Prodotti e Ambiente

Questa sezione descrive i prodotti e il sistema operativo utilizzati per creare l'esempio.

Per scaricare il software NI, compresi i prodotti illustrati di seguito, visitare il sito ni.com/downloads.

    Software

  • LabVIEW

Codice e Documentazione

Allegato

Overview:

This example demonstrates how to add the feature of pausing then continue execution of a while loop.

 

 

Description:

This example determines if a button has been pressed to pause the while loop, and takes action accordingly. The pause button uses a local variable to transfer the boolean data into the pause control loop.

 

 

Requirements:

LabVIEW 2012 (or compatible)

 

 

Steps to Implement or Execute Code:

  1. Open the attached VI
  2. Run the VI
  3. Press pause
  4. Observe that the timer has stopped
  5. Press pause again
  6. Observe that timer is back to running
  7. Stop Execution

 

 

Additional Information or References:

Block Diagram:

BD.PNG

 

Note: If the loop was paused, it cannot be stopped in this example unless you continue execution first. If you want to implement the option of stopping execution when the loop is stopped, then you must add another local variable linked to the stop control button and wire it to an "invert" then an "or" function inside the pause loop so you can stop the internal loop first. Otherwise, the external loop will never affect the value change of the stop control to the stop condition terminal since the code inside did not terminate execution (Dataflow concept).

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Regards,
Efrain G.
National Instruments
Visit http://www.ni.com/gettingstarted/ for step-by-step help in setting up your system.

Il codice di esempio scaricato dall'Example Code Exchange nella NI Community è concesso in licenza con la licenza MIT.

Commenti
_Chris
Member Member
Member
su

What about the Stop button when the Pause is set ?!?

The Stop button should stop the VI without the need for another action to "un-pause" the loop, no ?

ChosenLink
Member
Member
su

This example is very helpful.  I am somewhat new to LabView and am having trouble following how the inner while loop can continue while the outer while loop is suspended.  Can you explain how this works?

Thank you for uploading this example.

Efrain_G
NI Employee (retired)
su

You can learn more about While Loops and For Loops in the following tutorial.

Regards,
Efrain G.
National Instruments
Visit http://www.ni.com/gettingstarted/ for step-by-step help in setting up your system.
shredder0
Member
Member
su

clever!

orlando77
Member
Member
su

Works well!

Shlok1229
Member
Member
su

how to stop the loop when it is paused?

it doesnt stop unless we un-pause it

bito2000
Member
Member
su

Bring a local variable from the stop button into the inner while loop.

You will need to change the stop button to switch mode (not latch).

Capture.PNG

AKR1
Member
Member
su

Here is my solution to pausing the loop:PauseLoop.PNG"False" case is empty. Uncheck "Lock panel" in "Edit events" window.