Wrap It Up


Wrap It Up!

LabVIEW has two structures to repeat execution of a subdiagramthe While Loop and the For Loop. Both structures are resizable boxes. Place the subdiagram to be repeated inside the border of the loop structure. The While Loop executes as long as the value at the conditional terminal is FALSE (or TRUE, depending on its configuration). The For Loop executes a specified number of times.

Shift registers, available for While Loops and For Loops, transfer values from the end of one loop iteration to the beginning of the next. You can configure shift registers to access values from many previous iterations. For each iteration you want to recall, you must add a new element to the left terminal of the shift register. You can also have multiple shift registers on a loop to store multiple variables.

LabVIEW has two structures to add control to data flowthe Case Structure and the Sequence Structure. Use of the Sequence Structure should be limited. Try to only use the Flat Sequence (not the Stacked Sequence) Structure, when possible.

You use the Case Structure to branch to different subdiagrams depending on the input to its selector terminal, much like an IF-THEN-ELSE structure in conventional languages (but more closely related to the CASE, SELECT, or SWITCH structures). Simply place the subdiagrams you want to execute inside the border of each case of the Case Structure and wire an input to the case selector terminal. Case Structures can be either Boolean (with two cases), numeric, or string (with up to 215 1 cases)LabVIEW automatically determines which type when you wire a Boolean, numeric, or string control to the selector terminal.

Sometimes the principles of dataflow do not cause your program to behave the way you want it to, and you need a way to force a certain execution order. The Flat Sequence Structure lets you set a specific order for your diagram functions. Use tunnels to pass values between Flat Sequence Structure frames.

Avoid using Stacked Sequence Structure so that you don't need to use Sequence Locals to pass values between frames (remember, Sequence Locals are evil). The data passed in a Sequence Local is available only in frames subsequent to the frame in which you created the Sequence Local or tunnel, NOT in those frames that precede the frame in which its value is assigned.

With the Formula Node, you can directly enter formulas in the block diagram, an extremely useful feature for concisely defining complex function equations. Remember that variable names are case sensitive and that each formula statement must end with a semicolon (;).

With the Expression Node, you can enter a single formula (expression) having one variable. The Expression Node uses the same syntax as the Formula Node.

The Programming>>Dialog & User Interface subpalette of the Functions palette provides functions that pop up dialog boxes. The One Button Dialog, Two Button Dialog, and Three Button Dialog functions pop up a dialog box containing the message of your choice. The Express Dialogs provide a quick way to present the user with information and prompt the user to enter simple data.

The Programming>>Timing subpalette of the Functions palette provides functions that control or monitor VI timing. The Wait (ms) function pauses your VI for the specified number of milliseconds. Wait Until Next ms Multiple can force loops to execute at a given interval by pausing until the internal clock equals (or has exceeded) a multiple of the millisecond input. These two wait functions are similar but not identical, and you don't really need to worry about the difference right now. Tick Count (ms) returns to you the value of the internal clock. In addition, LabVIEW provides with you two Express VIs for timing: Time Delay, which works just like Wait (ms), and Elapsed Time.

Timed Structures and VIs found on the Programming>>Structures>>Timed Structures palette allow you to control the rate and priority at which a timed structure executes its subdiagram, synchronize the start time of timed structures, create timing sources, and establish a hierarchy of timing sources. They only work on Windows and are designed specifically for LabVIEW RT and FPGA applications.

The While Loop + Case Structure combination is the work-horse of nearly every non-trivial LabVIEW application. This pattern will allow you to build simple yet powerful and scalable application frameworks.




LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net