Presentation is loading. Please wait.

Presentation is loading. Please wait.

LabVIEW Core 1 Key messages for the instructor:

Similar presentations


Presentation on theme: "LabVIEW Core 1 Key messages for the instructor:"— Presentation transcript:

1 LabVIEW Core 1 Key messages for the instructor:
Search tools for palettes: Unless it is key to understanding a concept (such as the concept of high-level vs low-level file I/O VIs), palette paths for VI's, functions, controls and indicators are no longer shown in course material and exercises. It is important that you explain how to use the palette search and/or Quick Drop functionality so that students understand how to find controls and functions. Teach students to problem-solve: One of the key goals of this course is to teach students how to problem-solve. For example, they may use a VI or function for the first time in an exercise. When they ask you about the function, walk them through opening the Context Help or the LabVIEW Help to learn more about the function. Teach them how to find the answer themselves to promote self-learning outside of the classroom. Software Design Method: During class many students follow the exercise instructions without understanding what they are doing. After the class they may face the 'blank VI syndrome'. They see a blank VI and have no idea how to develop their application. The software development method is one of the “suggested reading” topics in LabVIEW Core 1 and this method is used in all development exercises. The goal is to give students an understanding of WHY they are doing a certain task, so that they understand the reason for the instructions they are following, rather than just following them.

2 Lesson 2 Troubleshooting and Debugging VIs
Correcting Broken VIs Debugging Techniques Undefined or Unexpected Data Error Handling 1

3 A. Correcting Broken VIs
2

4 Broken Run arrow  VI cannot be compiled  VI cannot be executed
Correcting Broken VIs One of the most common debugging features used in LabVIEW is the compiler which is always on. While you are developing a program, the compiler continuously checks for errors and provides semantic and syntactic feedback on the application. When the Run button is not broken, the VI is compiled and can be executed. If an error exists, you cannot run the program. You see a broken Run button in the toolbar. The VI is not executable. You must resolve any errors noted in the Errors List window before you can run the VI. Instructors: This is a good opportunity to remind students that LabVIEW is a compiled language. Broken Run arrow  VI cannot be compiled  VI cannot be executed 3

5 Common Causes of Broken VIs
Broken wires exist on the block diagram. You wired a Boolean control to a String indicator. You wired a numeric control to a numeric control. A required block diagram terminal is unwired. A subVI is broken. 4

6 B. Debugging Techniques
Execution Highlighting Single-Stepping Probes Breakpoints

7 Debugging Techniques What to look for if a VI produces unexpected data or behavior: Are there any unwired or hidden subVIs? Is the default data correct? Does the VI pass undefined data? Are numeric representations correct? Are node executed in the correct order? Stress that you use debugging techniques when a VI produces unexpected data or behavior, not when the VI has a broken Run button. The items on this slide are just some of the debugging techniques to use. Later, student learn other techniques. 6

8 Execution Highlighting
Use execution highlighting to watch the data flow through the block diagram. If the VI runs more slowly than expected, confirm that you turned off execution highlighting in subVIs.

9 Single-Stepping Single-step through the VI to view each action of the VI on the block diagram. Suspend the execution of a subVI to edit values of controls and indicators, to control the number of times it runs, or to go back to the beginning of the execution of the subVI. Open subVI and select Operate»Suspend When Called from the shortcut menu. 8

10 Probes Use the Probe tool to observe intermediate data values and check the error output of VIs and functions, especially those performing I/O. Specify to retain the values in the wires so that you can probe wires for data after execution.

11 Breakpoints When you reach a breakpoint during execution, the VI pauses and the Pause button appears red. You can take the following actions at a breakpoint: Single-step through execution using the single-stepping buttons. Probe wires to check intermediate values. Change values of front panel controls. Click the Pause button to continue running to the next breakpoint or until the VI finishes running. 10

12 C. Undefined or Unexpected Data

13 Undefined or Unexpected Data
Check for unexpected Inf values or NaN values in your mathematical operations: ∞ (Inf) Infinity Produced by dividing a number by zero. NaN Not a number Produced by invalid operations, such as taking the square root of a negative number. LabVIEW can process complex numbers using the functions on the Complex palette.

14 Exercise 2-1 Concept: Debugging
HOMEWORK Use the debugging tools built into LabVIEW.

15 Exercise 2-1 Concept: Debugging
If you have a VI with a broken Run arrow, what should you do first? After you fixed your broken Run arrow, your VI results show unexpected data. What can you do next? If you have a VI with a broken Run arrow, what should you do first? Click the broken Run arrow to list the errors. Use the Error list window to locate the errors. After you fixed your broken Run arrow, your VI results show unexpected data. What can you do next? Use debugging tools such as Execution Highlighting, Single-stepping, Breakpoints, and Probes to debug your code.

16 D. Error Handling Automatic and Manual Error Handling
Merge Errors Function Error Clusters Warnings

17 Error Handling Error Handling – Anticipation, detection, and resolution of warnings and errors You cannot predict every problem a user can encounter. Without a mechanism to check for errors, you know only that the VI does not work properly. Error handling tells you why and where errors occur. Automatic error handling Manual error handling

18 Automatic Error Handling
By default, LabVIEW automatically handles any known error when a VI runs by: Suspending execution. Highlighting the subVI or function where the error occurred. Displaying the Error list window. Automatic error handling is: Acceptable for quick prototypes. Not recommended for professional application development. Not included in LabVIEW-built executables. Select File»VI Properties and select Execution from the Category pull-down menu to enable or disable automatic error handling for a specific VI.

19 Manual Error Handling You control when dialog boxes appear.
Propagate errors by wiring the error out cluster to error in cluster of next node to execute. Terminate the error chain with a call to Simple Error Handler VI.

20 Automatic vs. Manual Error Handling
Demonstrate the difference between automatic and manual error handling. Open a shipping example that includes a simple sequence of VIs. Try a file I/O example for this. File I/O examples tend to be relatively simple and chain VIs together using the error cluster wire. Verify that all error wires are wired correctly. Insert an error or cause an error during execution, such as cancelling an open File Dialog. Show that the Simple Error Handler displays the error. Check or enable automatic error handling in the VI Properties»Execution dialog box. Run the VI again. Show how automatic error handling highlights the node that caused the error.

21 Disable Automatic Error Handling
Options Dialog Box Block Diagram page Uncheck Enable automatic error handling in new VIs Enable automatic error handling dialogs Other suggested changes Front Panel page Set Control Style for New VIs to Silver style Place front panel terminals as icons Configure Block Diagram Cleanup to customize your block diagram Have students follow along as you disable Automatic Error Handling in their Tools»Options dialog box. Although chaining error wires together effectively disables automatic error handling, you might forget to wire everything with error wires. To ensure that LabVIEW doesn’t resort to automatic error handling you should disable it for all new VIs. To do this, you need to change a configuration setting in the Tools»Options dialog box. While in the Tools»Options dialog box, have students customize other common settings. Exercises can be completed with any control style and terminal style. However, to match the solutions, select Silver style for controls and uncheck Place front panel terminals as icons.

22 Merge Errors Propagate errors along wires.
Merge errors from different wire paths. ** Core 2**

23 Merge Errors Function Merge Errors function returns the first error found. If no error is found, it returns the first warning. The Merge Errors function does not concatenate errors.

24 Error Clusters Use the error cluster controls and indicators to create error inputs and outputs in subVIs. The error in and error out clusters include the following components of information: Status Code Source Go to Help»Explain Error to access the Explain Error dialog box. The Status component of the error cluster is a Boolean value that reports TRUE if an error occurred. Most VIs, functions, and structures that accept Boolean data also recognize this parameter. For example, you can wire an error cluster to the Boolean inputs of the Stop, Quit LabVIEW, or Select functions. If an error occurs, the error cluster passes a TRUE value to the function. Code is a 32-bit signed integer that identifies the error numerically. A non-zero error code coupled with a status of FALSE signals a warning rather than a fatal error. Source is a string that identifies where the error occurred

25 Errors and Warnings Error Warning Status = FALSE Code = Non-zero
Status = TRUE Although most error codes are negative and warning codes are positive, this is not universally true. Most products and VI groups produce only errors. Some products and VI groups can produce warnings. VISA is an example of a product group that can produce warnings. Error Warning

26 Errors and Warnings Recommendations
Report errors and warnings with the Simple Error Handler VI Modify Type of Dialog to detect warnings. Call the Simple Error Handler VI from the top-level VI. Avoid error dialogs in subVIs.

27 Summary—Quiz Which of the following will result in a broken run arrow?
A subVI is broken. The diagram includes a divide by zero. A required subVI input is unwired. A Boolean terminal is wired to a numeric indicator. Answer is a, c, and d.

28 Summary—Quiz Answer Which of the following will result in a broken run arrow? A subVI is broken. The diagram includes a divide by zero. A required subVI input is unwired. A Boolean terminal is wired to a numeric indicator. A divide by zero might cause unexpected results but will not cause the run arrow to be broken.

29 Summary—Quiz Which of the following are the components and data types of the error cluster? Status: Boolean Error: String Code: 32-bit integer Source: String Answer is a, c, and d.

30 Summary—Quiz Answer Which of the following are the components and data types of the error cluster? Status: Boolean Error: String Code: 32-bit integer Source: String

31 Summary—Quiz All errors have negative error codes and all warnings have positive error codes. True False Answer is b.

32 Summary—Quiz Answer All errors have negative error codes and all warnings have positive error codes. True False In an error cluster, a status of TRUE is always an error regardless of the code value. A non-zero code with a status of FALSE is considered a warning.

33 Summary—Quiz Merge Errors function concatenates error information from multiple sources. True False Answer is b.

34 Summary—Quiz Answer Merge Errors function concatenates error information from multiple sources. True False Merge Errors function returns the first error found. If no error is found, it returns the first warning. The Merge Errors function does not concatenate errors

35 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

36 A. Front Panel Basics 35

37 Front Panel Basics Front panel controls and indicators create terminals on the block diagram. The front panel is the user interface. Usually you start a VI with inputs and outputs on the front panel. The block diagram is the programming behind the user interface. After you build the front panel, you add code on the block diagram to control the front panel objects. The labels of the front panel objects become the identifying labels for the terminals on the block diagram. 36

38 B. LabVIEW Data Types Shortcut Menu and Properties Dialog Box
Numeric Types Boolean Types String Types Enums and Other Types

39 LabVIEW Data Types Terminals visually communicate information about the data type represented Terminal colors, text, arrow direction, and border thickness all provide visual information about the terminal. For example, Orange represents floating point numbers. DBL indicates a double-precision floating point number. Terminals with thick borders with arrows on the right are control terminals. Terminals with thin borders with arrows on the left are indicator terminals.

40 Shortcut Menus All LabVIEW objects have associated shortcut menus.
Use shortcut menu items to change the look or behavior of objects. To access the shortcut menu, right-click the object. 39

41 Properties Dialog Box All LabVIEW objects have properties.
To access properties, right-click the object and select Properties. Property options are similar to shortcut menu options. Select multiple objects to simultaneously configure shared properties. Instructor Demo: Demonstrate both shortcut menus and the Properties dialog box. Show how to multi-select and configure multiple objects through the Properties dialog box. For example, show and hide labels for multiple controls. 40

42 Numerics Various data type representations: Floating-point
Unsigned integers Signed integers For this slide, talk about the difference between unsigned integers, signed integers, and floating point. Integers represent whole numbers. Unsigned integers are non-negative values. Signed integers can be positive, negative, or zero. Students learned about the numeric, Boolean and string data types in Lesson 1. Now, they learn about implementing these data types, such as representation, Boolean action, and string display type. They also learn a couple new data types: Enum and dynamic.

43 Numeric Conversion Coercion Dot Coercion dots indicate that LabVIEW converted the value passed into a node to a different representation. Occurs when a node expects an input with a different representation. LabVIEW chooses the representation that uses more bits. Avoid coercion by programmatically converting to a matching data type. If you use two numbers of the same type with different bit widths, LabVIEW coerces the smaller to the larger of the two bit widths. Examples: If you use a signed integer with an unsigned integer, LabVIEW coerces the unsigned integer to the signed integer. If you use an integer with a floating point, LabVIEW coerces the integer to the floating point. If you use a floating point with a complex integer, LabVIEW coerces the floating point to the complex integer.

44 Booleans Behavior of Boolean controls is specified by the mechanical action. Boolean have only TRUE/FALSE values. Use Boolean controls and indicators to enter and display Boolean (TRUE/FALSE) values. For example, if you are monitoring the temperature of an experiment, you can place a Boolean warning light (LED) on the front panel to indicate when the temperature exceeds a certain level. Instructor: Point out the difference between the label name and Boolean text. Show how the label matches the block diagram terminal label. Boolean text is cosmetic and appears only on the front panel.

45 Mechanical Action of Booleans
Point out that in everyday life we interface with many Boolean switches and buttons. These switches and buttons have different mechanical behaviors. Light switches change state when the switch is flipped. The state stays the same until you flip the switch again. Buzzers and door bells change state on a button press. They change back when the button is released. Mouse clicks and keyboard presses have a latch behavior. They change state on a button release. Furthermore, the key press or mouse click only takes effect when read by the system. When your computer system is sluggish, we sometimes see a delay in processing a mouse click or key press.

46 Mechanical Action of Booleans
Use the Properties»Operations tab of a Boolean control to learn about the different switch and latch actions. Have all students drop a Boolean control. Right-click the control to bring up the Properties dialog box. Switch to Operations tab. Have students experiment with different mechanical actions as you demonstrate.

47 Strings A string is a sequence of ASCII characters.
Strings have various display styles. Backslash codes Password Hex Uses for strings: Creating simple text messages. Controlling instruments by sending text commands to the instrument and returning data values in the form of either ASCII or binary strings which you then convert to numeric values. Storing numeric data to disk. To store numeric data in an ASCII file, you must first convert numeric data to strings before writing the data to a disk file. Instructing or prompting the user with dialog boxes.

48 Enums Enums give users a list of items from which to select.
Each item represents a pair of values. String 16-bit Integer Enums are useful because they make strings equivalent to numbers, and it is easier to manipulate numbers than strings on the block diagram. Point out that the data type of the enum terminal is blue, showing that the enum is passing an integer value.

49 Other Data Types Refer to LabVIEW Help for complete list of terminal symbols for different types of controls and indicators. Dynamic Stores the information generated or acquired by an Express VI. Path Stores the location of a file or directory using the standard syntax for the platform you are using. Waveform Carries the data, start time, and dt of a waveform. Ask students how a Path data type might differ from a String data type? Although it is easy to convert a Path to a String, it is best to use a Path data type when working with a location of a file or directory. Using the Path data type, LabVIEW can handle the folder specifiers (for example, a backslash on Windows).

50 Searching Help for Data Types
Use LabVIEW Help to learn about LabVIEW data types. Have all students display the LabVIEW Help. (Select Help»LabVIEW Help.) Switch to the Index tab. Search for “data types” to view the Control and Indicator Data Types help topic. Show the complete list of data types with terminal colors and usage details. Point out the Default Values column. Indicate that students should learn the default value of common data types (numerics, string, Boolean) as this will be important for later lessons.

51 C. Documenting Code VI Descriptions Tip Strips Labels Free Owned

52 Documenting Code VI Name Description Front Panel Label Names
Tip Strips Descriptions Free Labels Block Diagram Owned Labels SubVI Descriptions Giving VIs, controls, and indicators logical and descriptive names adds readability and usability to front panels. VI and object descriptions appear in the Context Help window when you move the cursor over the object. Create descriptions that describe the purpose of the VI or object. Include user instructions for the VI or object. LabVIEW includes two kinds of labels—owned labels and free labels. Owned labels belong to and move with a particular object and annotate only that object. You can move an owned label independently, but when you move the object that owns the label, the label moves with the object. You can hide owned labels, but you cannot copy or delete them independently of their owners.

53 Creating Descriptions and Tip Strips
Use the Properties dialog box to create documentation for an object. Instructor: Demonstrate tips strips, descriptions and VI Properties, and how they appear in a VI. For example, VI descriptions show up in Context Help when you move the cursor over the object, and tip strips are brief descriptions that appear when you move the cursor over an object while a VI runs. Create, edit, and view VI descriptions by selecting File»VI Properties and selecting Documentation from the Category pull-down menu. Create, edit, and view object descriptions by right-clicking the object and selecting Description and Tip from the shortcut menu. If you do not enter a tip in the Description and Tip dialog box, no tip strip appears.

54 Documenting Block Diagram Code
Free labels: Describe algorithms. Have pale yellow backgrounds. Double-click in any open space to create. Owned labels: Explain data contents of wires and objects. Move with object. Have transparent backgrounds. Select Visible Items»Label from the shortcut menu to create. Use the following guidelines when commenting your VIs: Use comments to document algorithms and add reference information. Label structures to specify the main functionality. Label long wires to identify their use/contents. (To label a wire, right-click on the wire and select Visible Items»Label.) Label constants to specify the nature of the constant. It is not always necessary to show labels on functions and subVIs if they make the block diagram cluttered. A developer can find information about a function or subVI by using the Context Help window.

55 Exercise 3-1 Temperature Warnings VI
Create and document a VI. The VI that students create in this exercise will be used in later exercises. This will become a subVI in the Temperature Weather Station project.

56 Exercise 3-1 Temperature Warnings VI
What happens if the Max. Temperature value is lower than the Min. Temperature value? What happens if the Max. Temperature value is lower than the Min. Temperature value? This VI currently does not check for the possible error condition when the maximum temperature is lower than the minimum temperature. Later, the students will modify the VI such that the maximum temperature is always higher than the minimum temperature.

57 Lesson # Lesson Title End of Week 2


Download ppt "LabVIEW Core 1 Key messages for the instructor:"

Similar presentations


Ads by Google