Contents
  1. While Loop (Image Slideshow Program)
  2. For Loop

LabVIEW Study Notes: LabVIEW Study Notes (I): Basic Introduction LabVIEW Study Notes (II): Filter Experiment LabVIEW Study Notes (III): Basic Controls LabVIEW Study Notes (IV): Dynamic Data Type LabVIEW Study Notes (V): Comprehensive Data Type Experiment LabVIEW Study Notes (VI): While Loops and For Loops LabVIEW Study Notes (VII): Variables and Shift Registers LabVIEW Study Notes (VIII): Property Nodes LabVIEW Study Notes (IX): Arrays and Clusters LabVIEW Study Notes (X): Case Structures Other Experiment Notes


While Loop (Image Slideshow Program)

Experiment: Create a slideshow that cycles through three images.

  1. Insert a picture ring and import n images. While Loop (Image Slideshow Program) While Loop (Image Slideshow Program) (2) While Loop (Image Slideshow Program) (3)
  2. Open the block diagram and use a While Loop to cycle through the images. First, convert the picture ring to an indicator. While Loop (Image Slideshow Program) (4)
  3. Create a While Loop. While Loop (Image Slideshow Program) (5)
  4. The values of the images in the picture ring are 0, 1, 2, …, n. Use the remainder of the iteration count divided by n to select the image (n is the number of images). Insert the Quotient & Remainder function from the Numeric palette and wire it. While Loop (Image Slideshow Program) (6) My program uses 3 images, so the divisor is 3.
  5. Create a stop condition. While Loop (Image Slideshow Program) (7)
  6. Return to the front panel and add a knob to adjust the image switching speed. While Loop (Image Slideshow Program) (8)
  7. Insert a wait inside the While Loop. The wait-time input is in milliseconds. Also, because a larger knob value should make the images switch faster, take the reciprocal of the knob value and multiply it by 1000 to obtain the wait time for the While Loop. While Loop (Image Slideshow Program) (9) While Loop (Image Slideshow Program) (10)
  8. Run the program to observe the images cycling. Drag the knob to see the image switching speed change accordingly.

For Loop

  1. Creating a For Loop
  • The method for creating a For Loop is similar to that for a While Loop.
  • You can right-click the border of a While Loop and convert it to a For Loop from the shortcut menu.
  1. For Loop terminals
  • N is the number of iterations. The number of iterations must be specified as a nonnegative integer. (If a double-precision floating-point value is wired to the N count terminal, LabVIEW coerces it to a 32-bit signed integer.)
  • To avoid coercion and improve program performance, select a matching data type or convert the data type programmatically.
  1. Differences from a While Loop
  • A While Loop executes at least once, while a For Loop can execute 0 times.
  • A While Loop automatically outputs the value from the last iteration, while a For Loop automatically outputs an array.