Presentation is loading. Please wait.

Presentation is loading. Please wait.

Course Learning Map Lesson # Lesson Title Lesson 3 Lesson 2 Lesson 1

Similar presentations


Presentation on theme: "Course Learning Map Lesson # Lesson Title Lesson 3 Lesson 2 Lesson 1"— Presentation transcript:

1 Course Learning Map Lesson # Lesson Title Lesson 3 Lesson 2 Lesson 1
Implementing a VI Lesson 2 Troubleshooting & Debugging VIs Lesson 1 Navigating LabVIEW Lesson 6 Managing File and Hardware Resources Lesson 5 Creating and Leveraging Data Structures Lesson 4 Developing Modular Applications Lesson 8 Solving Dataflow Challenges with Variables Lesson 7 Using Sequential and State Machine Algorithms

2 Lesson 3 Implementing a VI
Front Panel Basics LabVIEW Data Types Documenting Code While Loops For Loops Timing a VI Data Feedback in Loops Plotting Data – Waveform Chart Case Structures

3 E. For Loops Conditional Terminal Comparison with While Loops
Numeric Conversion for Count Terminal

4 For Loops LabVIEW For Loop Flowchart Pseudo Code N=100; i=0;
Until i=N: Repeat (code;i=i+1); End; LabVIEW For Loop Flowchart Pseudo Code

5 For Loops Create a For Loop the same way you create a While Loop.
You can replace a While Loop with a For Loop by right-clicking the border of the While Loop and selecting Replace with For Loop from the shortcut menu. The value in the count terminal (an input terminal) indicates how many times to repeat the subdiagram in the For Loop.

6 For Loops – Conditional Terminal
You can add a conditional terminal to configure a For Loop to stop when a Boolean condition is true or an error occurs.

7 For Loops – Conditional Terminal
For Loops configured with a conditional terminal have: A red glyph next to the count terminal. A conditional terminal in the lower right corner

8 For Loop/While Loop Comparison
Executes a set number of times unless a conditional terminal is added. Can execute zero times. Tunnels automatically output an array of data. While Loop Stops executing only if the value at the conditional terminal meets the condition. Must execute at least once. Tunnels automatically output the last value.

9 For Loops – Numeric Conversion
The number of iterations a For Loop executes must be specified in non-negative integers. If you wire a double-precision, floating-point numeric value to the count terminal, LabVIEW converts the numeric value to a 32-bit signed integer. The For Loop count terminal always coerces to a 32-bit signed integer. Typically, LabVIEW coerces numerics to the format with more bit representation. However, the For Loop count terminal works in the opposite manner. If you wire a double-precision, floating-point numeric value to the 32-bit count terminal, LabVIEW coerces the larger numeric value to a 32-bit signed integer. Although the conversion is contrary to normal conversion standards, it is necessary, because a For Loop can only execute an integer number of times. The For Loop count terminal will always coerce to a 32-bit signed integer data type.

10 For loop and while loop indexing comparison (NEW SLIDE)

11 Group Exercise 3-3 Concept: While Loops versus For Loops
Understand when to use a While Loop and when to use a For Loop.

12 F. Timing a VI Reasons To Use Timing Wait Functions and Express VIs

13 Timing a VI Why do you need timing in a VI?
To control the frequency at which a loop executes. To provide the processor with time to complete other tasks, such as processing the user interface.

14 Wait Functions A wait function inside a loop:
Allows the VI to sleep for a set amount of time. Allows the processor to address other tasks during the wait time. Uses the operating system millisecond clock.

15 Elapsed Time Express VI
Determines how much time elapses after some point in your VI. Keeps track of time while the VI continues to execute. Does not provide the processor with time to complete other tasks.

16 Wait Chart VI Compare and contrast using a Wait function and the Elapsed Time Express VI for software timing. The Wait Chart VI is pre-built for your demonstration in the Exercises\Demonstrations folder.

17 G. Data Feedback in Loops
Shift Registers Initializing Shift Registers Default for Unwired Values Compound Shift Registers

18 Data Feedback in Loops When programming with loops, you often need to know the values of data from previous iterations of the loop. Shift registers transfer values from one loop iteration to the next. Cover mechanics of using shift registers in later slides; here just talk about why you need them.

19 Shift Registers Right-click the border and select Add Shift Register from the shortcut menu. Right shift register stores data on completion of an iteration. Left shift register provides stored data at beginning of the next iteration.

20 Initializing Shift Registers
Run once VI finishes Run again Block Diagram 1st run 2nd run Initialized Shift Register Output = 5 Not Initialized Shift Register Output = 4 Output = 8

21 Use Default if Unwired Default values vary by data type: Uninitialized shift registers use default values for first run. Data Type Default Value Numeric Boolean FALSE String Empty

22 Multiple Previous Iterations
Stacked shift registers remember values from multiple previous iterations and carry those values to the next iterations. Right-click the left shift register and select Add Element from the shortcut menu to stack a shift register.

23 Exercise 3-4 Average Temperature VI
HOMEWORK Use a While Loop and shift registers to average data.

24 Exercise 3-4 Average Temperature VI
You calculated the average of the last 5 temperature readings. How would you modify the VI to calculate the average of the last 10 temperature readings? You calculated the average of the last 5 temperature readings. How would you modify the VI to calculate the average of the last 10 temperature readings? Resize the shift register in the VI to have five additional elements. Resize the Compound Arithmetic function to add 10 values and divide the result by 10.

25 H. Plotting Data – Waveform Chart

26 Plotting Data – Waveform Chart
Waveform chart is a special type of numeric indicator. Waveform charts display single or multiple plots. Special type of numeric indicator that displays one or more plots of data, typically acquired at a constant rate

27 Waveform Chart Properties
Extensive plot customization lets you: Show or hide legends. Change color and line styles. Change interpolation styles.

28 Exercise 3-5 Temperature Monitor VI – Plot Multiple Temperatures
HOMEWORK Plot multiple data sets on a single waveform chart and customize the chart view.

29 Exercise 3-5 Temperature Monitor VI – Plot Multiple Temperatures
In what ways do the following tools allow the user to interact with the plot? Plot Legend Graph Palette Scale Legend Plot legend: Use the Plot legend to customize how a plot appears in chart. Examples: Line & point style, Interpolation, color, fill Graph Palette: Use the graph palette to interact with the chart as the VI runs. Examples: Panning tool, Zoom Scale Legend: Use the scale legend to label scales and configure scale properties on the chart. Example: Autoscale on/on, set scale format, precision, scale visibility, grid color

30 I. Case Structures Parts of a Case Structure Enum Case Structures
Error Case Structures Input and Output Tunnels

31 Case Structures Have two or more subdiagrams or cases.
Use an input value to determine which case to execute. Execute and display only one case at a time. Are similar to case statements or if...then...else statements in text-based programming languages.

32 Case Structures Case Selector Label Selector Terminal
Contains the name of the current case. Has decrement and increment arrows. Selector Terminal Lets you wire an input value, or selector, to determine which case executes. Case Selector Label Selector Terminal

33 Case Structures Selector terminal data types: Boolean Error Cluster
True case and False Case Error Cluster Error Case and No Error Case Integer, string, or enum Structure can have any number of cases. Include a Default diagram to avoid listing every possible input value. Boolean input to the selector terminal creates two cases: True and False Integer or string input to the selector terminal creates multiple cases. - Developer must add a case for each integer or string as necessary. - If an undefined integer or strings is wired to the terminal, LabVIEW uses the Default case. Enums - Gives users a list of items from which to select a case. - The case selector displays a case for each item in the enumerated type control.

34 Enum Case Structure Gives users a list of items from which to select
The case selector displays a case for each item in the enumerated type control

35 Shortcut Menu Use the shortcut menu of a Case structure to:
Customize the structure and diagrams. Remove or replace the structure. Add, duplicate, remove, or rearrange cases. Specify the Default case. Switch cases.

36 Error Case Structure Use Case structures inside VIs to execute the code if there is no error and skip the code if there is an error.

37 Input and Output Tunnels
You can create multiple input and output tunnels. Inputs tunnels are available to all cases if needed. You must define each output tunnel for each case. Point out difference between tunnels that have been wired for all cases, tunnels that have not, and tunnels marked as Use Default If Unwired. Point out that the unwired output tunnel will result in a broken Run arrow. The other two options will not cause a broken Run arrow. Zoom in on the tunnels so that students can clearly see the differences. Demonstrate how to enable or disable the Use Default If Unwired option. Tell students to avoid using the Use Default If Unwired option on Case structure tunnels for the following reasons. Adds a level of complexity to the code. Complicates debugging your code.

38 Case Structures Create case structures using different data type selectors. Add, remove, and duplicate cases. Create different type of output tunnels. Don’t spend much too time on this as students as creating a Case structure is similar to other structures. A pre-built VI with various selector terminal is available in the following demonstration folder: <exercises>\Demonstrations\Case Structures\Case Structures.vi Below are key items to note: Show how the Case structure defaults to a Boolean Case structure with only two cases – True and False. Show how wiring different types of data types to the selector terminal changes the case selector label. Emphasize to students that they should wire the selector terminal BEFORE trying to change the selector terminal. Show the shortcut menu. Add, remove, and duplicate a case. Show how deleting a case is different than removing the Case structure. Show how the Run arrow is broken if a tunnel is not wired in each case.

39 Exercise 3-6 Temperature Warnings VI
HOMEWORK Modify a VI to use Case structures to make a software decision. This is a continuation of an earlier exercise. If students did not complete Exercise 3-1, they should start by modifying the Solution 3-1.

40 Exercise 3-6 Temperature Warnings VI
What happens if all the values are 10? How could you fix this? Are all output tunnels defined? What happens if an output is not defined? What happens if all the values are 10? How could you fix this? You get a freeze warning. There are multiple ways you can fix this. One possibility is to not allow Min Temperature and Max Temperature to be equal by replacing the Greater function with a Greater or Equal function and changing the string constant in the True case to “Upper Limit <= Lower Limit.” Are all output tunnels defined? What happens if an output is not defined? All output tunnels are defined for this exercise. If an output isn’t wired, the Run arrow would be broken. To use the Use Default if Unwired option, one would need to enable it through a shortcut menu selection.

41 Summary—Quiz If an input to a function is marked with a red dot (known as a coercion dot), what does the dot indicate? Data was transferred into a structure. A For Loop was configured with a conditional terminal. A For Loop iteration terminal is unwired. The value passed into a node was converted to a different representation. Answer is d.

42 Summary—Quiz Answer If an input to a function is marked with a red dot (known as a coercion dot), what does the dot indicate? Data was transferred into a structure. A For Loop was configured with a conditional terminal. A For Loop iteration terminal is unwired. The value passed into a node was converted to a different representation.

43 Summary—Quiz Which structure must run at least one time? While Loop
For Loop Answer is a.

44 Summary—Quiz Answer Which structure must run at least one time?
While Loop For Loop

45 Summary—Quiz Control Constant Indicator Connector Pane
Which is only available on the block diagram? Control Constant Indicator Connector Pane Answer is b.

46 Summary—Quiz Answer Control Constant Indicator Connector Pane
Which is only available on the block diagram? Control Constant Indicator Connector Pane Answer is b.

47 Summary—Quiz Switch Until Released Switch When Released
Which mechanical action causes a Boolean control in the FALSE state to change to TRUE when you click it and stay TRUE until LabVIEW has read the value? Switch Until Released Switch When Released Latch Until Released Latch When Released Answer is d.

48 Summary—Quiz Answer Switch Until Released Switch When Released
Which mechanical action causes a Boolean control in the FALSE state to change to TRUE when you click it and stay TRUE until LabVIEW has read the value? Switch Until Released Switch When Released Latch Until Released Latch When Released

49 Lesson # Lesson Title End of Week 3


Download ppt "Course Learning Map Lesson # Lesson Title Lesson 3 Lesson 2 Lesson 1"

Similar presentations


Ads by Google