Condition-Controlled Graphical Iteration

Condition-Controlled Graphical Iteration lets you repeat a graphical program until a Boolean condition tells it to stop. In LabVIEW, you use a While Loop for repetition and a waveform chart to view successive readings. This combination suits a monitoring display whose stopping time depends on an operator or a measured value rather than a predetermined duration.

Complete an iteration, then decide

Condition-controlled iteration means that a Boolean condition determines whether another iteration begins. A LabVIEW While Loop executes its body at least once. Its conditional terminal controls continuation after the current iteration completes; it does not cancel work already belonging to that iteration.


Name the terminal setting before interpreting its Boolean input:


Terminal setting

Input is True

Input is False

Stop if True

Finish this iteration and exit

Begin another iteration

Continue if True

Begin another iteration

Finish this iteration and exit


The iteration terminal, ii, starts at zero. For ordinary runs within its integer range, the number of completed iterations is therefore


N=ifinal+1.N=i_{\text{final}}+1.


A conceptual loop diagram shows an iteration completing before a stop decision either exits or repeats the loop.



Put repeated operations inside the loop

Place the scalar-value source, waveform-chart terminal, and Stop-button terminal inside the While Loop when each should participate in every iteration. Wire the scalar source to the chart. With one scalar written per iteration, each completed iteration contributes one chart point, including the final iteration.


Keeping the Stop-button terminal inside lets the program read it again on successive iterations. A Boolean control read outside the loop and passed through an ordinary input tunnel supplies the value read before loop execution; pressing that button later does not refresh the tunnel value. Similarly, a chart connected outside through an ordinary output tunnel receives its data when the loop finishes, rather than once per iteration.


For threshold stopping, compare the current scalar with the limit. Under Stop if True, a condition such as P≥PlimitP\geq P_{\text{limit}} stops after an iteration whose reading meets the limit. You can combine that comparison with the Stop button using Boolean OR.

Separate timing from axis labels

A Wait (ms) function inside the loop helps pace repetition. Its input is a requested wait, not a measurement of the complete iteration period. Other work and operating-system scheduling can affect the actual interval, so a wait setting alone does not establish exact sample timing.


If successive chart updates really occur at a fixed interval Δt\Delta t, their rate and relative times are


f=1Δt,ti=t0+iΔt.f=\frac{1}{\Delta t},\qquad t_i=t_0+i\Delta t.


For example, updates separated by 0.250 s0.250\ \text{s} occur at 4.00 Hz4.00\ \text{Hz}. With the first point at t0=0t_0=0, point i=4i=4 represents 1.00 s1.00\ \text{s}.


Scalar chart input does not itself provide timestamps. For a relative-time display, use an x-axis offset of zero and a multiplier equal to the known interval in seconds. Changing that multiplier changes the labels, not the loop's execution speed. If timing varies substantially, equally spaced labels should not be treated as measured timestamps.

Interpret the retained history

Chart history is the collection of previous values retained by the waveform chart. For scalar input, a history length HH limits the retained points per plot; after it fills, newer points replace the oldest retained values. The visible axis range and the history capacity are different settings.


For HH retained points with uniform spacing, the oldest-to-newest time span is


Tspan=(H−1)Δt.T_{\text{span}}=(H-1)\Delta t.


Nine retained points spaced by 0.250 s0.250\ \text{s} span 8(0.250)=2.00 s8(0.250)=2.00\ \text{s}. There are eight gaps between nine points.



What to remember

  • A While Loop completes at least one iteration; identify its terminal setting.
  • Keep operations inside the loop when they should repeat.
  • Use known update timing to interpret chart time labels.
  • A full history of HH uniformly spaced points spans (H−1)Δt(H-1)\Delta t.

Example: Monitor a simulated pressure rise

A LabVIEW test panel uses Condition-Controlled Graphical Iteration to display a simulated pressure rise. On iteration ii, the source produces


Pi=98.0 kPa+(1.50 kPa)i.P_i=98.0\ \text{kPa}+(1.50\ \text{kPa})i.


The source and waveform-chart terminal are inside a While Loop, with exactly one scalar written per iteration. The first reading occurs at t0=0t_0=0, and subsequent readings occur at exactly 0.200 s0.200\ \text{s} intervals. Treat these intervals as given timing measurements, not as consequences of a Wait setting.


The chart history is initially empty and has capacity H=4H=4 scalar points. The loop should stop when the current pressure reaches or exceeds 105.5 kPa105.5\ \text{kPa} or the operator presses Stop. The Stop button remains False throughout this run.


A pressure source feeds a waveform chart inside a While Loop, with readings separated by measured intervals of 0.200 seconds.


a) Specify the stopping configuration and determine the final iteration index and total chart updates.


Select Stop if True. Place the Stop-button terminal inside the loop so it is read repeatedly. Compare the current pressure with the threshold, combine that result with Stop using Boolean OR, and wire the result to the conditional terminal:


stop request=(Pi≥105.5 kPa) OR Stop.\text{stop request}=(P_i\geq105.5\ \text{kPa})\ \text{OR}\ \text{Stop}.


Because Stop remains False, solve for the first integer index that satisfies the pressure condition:


98.0 kPa+(1.50 kPa)i≥105.5 kPa,(1.50 kPa)i≥7.50 kPa,i≥5.\begin{aligned} 98.0\ \text{kPa}+(1.50\ \text{kPa})i&\geq105.5\ \text{kPa},\\ (1.50\ \text{kPa})i&\geq7.50\ \text{kPa},\\ i&\geq5. \end{aligned}


Check the readings on either side of the stopping boundary:


P4=98.0 kPa+(1.50 kPa)(4)=104.0 kPa,P_4=98.0\ \text{kPa}+(1.50\ \text{kPa})(4)=104.0\ \text{kPa},


P5=98.0 kPa+(1.50 kPa)(5)=105.5 kPa.P_5=98.0\ \text{kPa}+(1.50\ \text{kPa})(5)=105.5\ \text{kPa}.


Iteration i=5i=5 meets the threshold. It still writes its pressure to the chart before the loop exits. The completed iterations have indices 00 through 55, so


N=ifinal+1=5+1=6.N=i_{\text{final}}+1=5+1=6.


The final index is 5, and the chart receives 6 updates.


b) Find the update rate and the time of the final pressure reading.


The specified interval between successive readings is Δt=0.200 s\Delta t=0.200\ \text{s}. Its reciprocal gives the update rate:


f=1Δt=10.200 s=5.00 Hz.f=\frac{1}{\Delta t}=\frac{1}{0.200\ \text{s}}=5.00\ \text{Hz}.


The first reading is at zero, so the reading at index 55 occurs after ________ intervals:


t5=t0+5Δt=0+5(0.200 s)=1.00 s.t_5=t_0+5\Delta t=0+5(0.200\ \text{s})=1.00\ \text{s}.


The update rate is 5.00 Hz, and the final reading occurs at 1.00 s. Six readings contain five first-to-last intervals; multiplying the reading count by the interval would incorrectly place the final reading one interval late. The time found here is the reading time, not a separate measurement of when every remaining loop operation finishes.


c) Identify the readings retained when the loop stops and calculate their oldest-to-newest time span.


The loop produces ________ points, but the history retains only the latest four. The first retained index is therefore


ioldest=N−H=6−4=2.i_{\text{oldest}}=N-H=6-4=2.


Calculate each retained time using ti=i(0.200 s)t_i=i(0.200\ \text{s}) and each pressure using Pi=98.0 kPa+(1.50 kPa)iP_i=98.0\ \text{kPa}+(1.50\ \text{kPa})i:

  • Index 22: t2=2(0.200 s)=0.400 st_2=2(0.200\ \text{s})=0.400\ \text{s} and P2=98.0 kPa+(1.50 kPa)(2)=101.0 kPaP_2=98.0\ \text{kPa}+(1.50\ \text{kPa})(2)=101.0\ \text{kPa}.
  • Index 33: t3=3(0.200 s)=0.600 st_3=3(0.200\ \text{s})=0.600\ \text{s} and P3=98.0 kPa+(1.50 kPa)(3)=102.5 kPaP_3=98.0\ \text{kPa}+(1.50\ \text{kPa})(3)=102.5\ \text{kPa}.
  • Index 44: t4=4(0.200 s)=0.800 st_4=4(0.200\ \text{s})=0.800\ \text{s} and P4=98.0 kPa+(1.50 kPa)(4)=104.0 kPaP_4=98.0\ \text{kPa}+(1.50\ \text{kPa})(4)=104.0\ \text{kPa}.
  • Index 55: t5=5(0.200 s)=1.000 st_5=5(0.200\ \text{s})=1.000\ \text{s} and P5=98.0 kPa+(1.50 kPa)(5)=105.5 kPaP_5=98.0\ \text{kPa}+(1.50\ \text{kPa})(5)=105.5\ \text{kPa}.

The oldest-to-newest span follows either by subtracting the endpoint times or by counting the ________ gaps between four points:


Tspan=1.000 s−0.400 s=(4−1)(0.200 s)=0.600 s.\begin{aligned} T_{\text{span}}&=1.000\ \text{s}-0.400\ \text{s}\\ &=(4-1)(0.200\ \text{s})\\ &=0.600\ \text{s}. \end{aligned}


The retained indices are 2 through 5, and their time span is 0.600 s. The two earliest readings have been displaced from the chart history.

A LabVIEW While Loop contains a simulated voltage source and a waveform-chart terminal. The source writes exactly one scalar to the chart in every iteration. The conditional terminal is set to Stop if True and receives True during the first iteration. The chart history is initially empty.


What happens before the loop exits?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A LabVIEW While Loop sends successive temperature readings to a waveform chart. The chart's update mode determines how incoming points redraw its display. Match each mode to its behavior after the plotting area fills.

Match each term
A.

Adds new points at the right edge while shifting earlier points to the left.

B.

Erases the displayed trace at the right boundary and begins drawing again from the left.

C.

Returns to the left without erasing the entire trace, using a moving vertical line to separate new and old data.

Scope chart

Sweep chart

Strip chart

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A simulated source inside a LabVIEW While Loop would return 2.62.6, 3.13.1, 3.73.7, and 4.2 V4.2\ \text{V} on successive calls. The loop calls the source once per iteration and writes that value once to an initially empty waveform chart. Its conditional terminal is set to Continue if True and receives the result of V<3.5 VV<3.5\ \text{V}.


Four successive available source values are shown as 2.6, 3.1, 3.7, and 4.2 volts.


How many updates occur, what is the final iteration index, and what is the last plotted value?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice