Presentation is loading. Please wait.

Presentation is loading. Please wait.

Structures- case, sequence, formula node

Similar presentations


Presentation on theme: "Structures- case, sequence, formula node"— Presentation transcript:

1 Structures- case, sequence, formula node
VI Programming Loops- for, while Graph & chart Structures- case, sequence, formula node

2 LabVIEW Programming Structures
Structures located on the Functions» Programming» Structures palette to control how a block diagram executes processes: For Loop: Executes a subdiagram a set number of times. While Loop: Executes a subdiagram until a condition is met. Case structure: Contains multiple subdiagrams, only one of which executes depending on the input value passed to the structure. Sequence structure: Contains one or more subdiagrams, which execute in sequential order. Formula Node: Performs mathematical operations based on numeric input. MEI U4 P2

3 For Loop Structure Block Diagram > Functions > Programming >Structures > For Loop For Loop executes its subdiagram count times, where the count equals the value contained in the count terminal (N) Iteration 0 during the first iteration 1 during the second iteration etc up to N-1 •If you wire 0 to the count terminal, the loop does not execute. MEI U4 P2

4 MEI U4 P2

5 While Loop Structure Block Diagram > Functions > Programming > Structures > While Loop: The While Loop executes the subdiagram until the conditional terminal. You can select (Continue if true or Stop if true ) Inputs to a loop pass data before loop execution. Outputs pass data out of a loop only after the loop completes all iterations. MEI U4 P2

6 MEI U4 P2

7 Timing Wait Until Next ms Multiple function Wait (ms) function
This function is used to synchronize activities. The function is placed within a loop to control the loop execution rate. Wait (ms) function Adds the wait time to the code execution time, as illustrated. This can cause a problem if code execution time is variable. MEI U4 P2

8 Shift Registers in Loops
Shift registers are local variables that feed back or transfer values from the completion of one iteration to the beginning of the next. By selecting Add Shift Register from the loop border pop-up menu, you can create a register anywhere along the vertical boundary only To initialize a shift register, wire a value from outside the loop to the left terminal. If you do not initialize the register, the loop uses as the initial value the last value inserted in the register when the loop last executed. MEI U4 P2

9 Multiple Shift Registers
One can create multiple shift registers on a particular structure. The left, topmost terminal holds the value from the previous iteration, i-1. The terminal immediately under the uppermost terminal contains the value from iteration i-2, and so on with each successive terminal. MEI U4 P2

10 Types of Charts & Graphs
Waveform Chart: special numeric indicator that can display a history of values acquired at a constant rate. Waveform Graph: special numeric indicator that displays an array of data. Updates after all points have been collected. XY Graph: Displays data acquired at a non-constant rate, such as two columns or arrays data. Digital Waveform Graph: Displays data as pulses or groups of digital lines. (Windows) 3D Graphs: Displays 3D data on a 3D plot MEI U4 P2

11 MEI U4 P2

12 Accumulates after new run
MEI U4 P2

13 MEI U4 P2

14 Chart Update Modes: The waveform charts use various modes to display data. These modes include Strip Chart, Scope Chart, and Sweep Chart. MEI U4 P2

15 MEI U4 P2

16 Waveform Graphs Input should be of array data type- (default) x axis- array index y axis- value in array MEI U4 P2

17 Waveform XY Graphs Waveform graph and XY graph requires input data type as array For waveform graph: Array index acts as x axis scale For XY graph: both X and Y must be array MEI U4 P2

18 MEI U4 P2

19 There are many planes in the xy graph
There are many planes in the xy graph. Such planes like: Nyquist, S plane, Z plane and Nichols MEI U4 P2

20 DIGITAL WAVEFORM MEI U4 P2

21 Charts & Graphs Features
Plot Legend: Defines the color and style of the plot(s). Resize the legend to display multiple plots. Scale Legend: Defines labels for scales and configures scale properties. X Scale and Y Scale: Formats the x- and y-scales. Cursor Legend (graph only): Displays a marker at a defined point coordinate. You can display multiple cursors on a graph. Scrollbar (chart only): Scrolls through the data in the chart. Use the scroll bar to view data that the buffer does not currently display. MEI U4 P2

22 Case Structures The Case Structure is a method of executing conditional statements. The Case Structure is similar If (Condition) then Do This Else Do That Endif MEI U4 P2

23 The selector terminal can be Boolean, Numeric, or String
A Case structure has two or more subdiagrams, or cases. Only one subdiagram is visible at a time. The selector terminal can be Boolean, Numeric, or String MEI U4 P2

24 Case structure A few things to remember about Case Structures and their data types: • If the data type is Boolean, the structure can only have two cases: True or False. • If the data type is numeric or string, the structure can have many cases. • If the data type is numeric or string, the first case will have default in the case structure name. • If the data type is numeric, use positive integer values. • If the data type is string, the data values must be in quotes. • Cases are not required to use input data or to supply output data, but if any case supplies output data, all must do so MEI U4 P2

25 Sequence Structures The Sequence Structure is used to control the data flow in a VI's Block Diagram. They are used to control the order of execution of nodes. MEI U4 P2

26 Sequence Structures MEI U4 P2

27 To pass data from one frame to any subsequent frame, use a sequence local terminal.
MEI U4 P2

28 Sequence Structures An outward-pointing arrow appears in the sequence local terminal of the frame that contains the data source. MEI U4 P2

29 Sequence Structures The output tunnels of Sequence Structures can only have one data source which, unlike Case Structures, has outputs that must have one data source per case. The output can come from any frame, but the data will not leave the structure until the last frame in the structure has completed it's execution. MEI U4 P2

30 Formula Node Functions Palette >>Programming >>Structures>>Formula node Formula Node is a box where you enter algebraic formulas directly into the Block Diagram. It is useful when an equation is complicated or has many variables. y = x^2 + x + 1 Declare an input variable by right-clicking the Formula Node border and selecting Add Input from the menu. You cannot declare input variables inside The Formula Node Declare an output variable by and selecting Add Output from the menu. MEI U4 P2

31 You must wire all input terminals.
There is no limit to the number of variables or equations in a Formula Node. No two inputs and no two outputs can have the same name, but an output can have the same name as an input. You can declare and use a variable inside the Formula Node without relating it to an input or output wire. You must wire all input terminals. MEI U4 P2

32 Formula Node Expression node
Evaluates mathematical formulas and expressions similar to C. Expression node Functions Palette >>Programming>>Numeric>>Expr It is a simple model of the formula node, it has a single input, single output and one expression can be wrote without ;. MEI U4 P2


Download ppt "Structures- case, sequence, formula node"

Similar presentations


Ads by Google