ECE 100 Fundamentals of LabVIEW Programming

CASE STRUCTURE IN LABVIEW
Activity No. 7

I. INTENDED LEARNING OUTCOMES

At the end of this activity, the student shall be able to:
1. Understand the concept of Case Structure
2. Create an important program using Case Structure

II. BACKGROUND INFORMATION

When programming in LabVIEW, you may want to choose between multiple sections of code based on an
input. Based on the input it receives on the case selector terminal, the case structure chooses which “case,” or
section of code, to execute. The case selector terminal appears as a small question mark (?) on the left side of the
case structure.

If you change the input to the case selector terminal, the section of code that is executed changes. In the
figures below, the case structure executes different code for the input strings “True” and “False.”

Selector Terminal
The case selector terminal can receive multiple data types. You can use the following data types as inputs
to the case selector terminal:
• Integers
• Boolean values
• Strings
• Enumerated type values (Enums)
A case structure with a Boolean wired to its selector terminal has a maximum of two cases; all other data
types allow two or more cases.

Page 51

Enum .” Name the indicator “Result. This control is located in ControlsModernRing & Enum.These give the number associated with the item the user selected. and the value is the numeric or string value corresponding to that item. Enums require the numeric values to be sequential. Question: What are the options contained in the Ring and Enum palettes? State their functions 5. Right-click on the Enum and select Edit Items… to open the Enum Properties. Text & Pict Ring . Multiply. Rename the control “Operation. and Divide. Name the numeric controls “Input A” and “Input B.contain lists of the Insert stringsand button pairedadd withthe numeric values through which you can cycle.ECE 100 Fundamentals of LabVIEW Programming III.contain lists of strings paired with numeric values through which you can cycle. value. Pict Ring . where the image is a bitmap displayed by the control when the item is selected. Subtract. and the value is the numeric or string value corresponding to that item with a text.” 4. unsigned integer values. text rings allow you following much more freedom in assigning a numeric Items: Add. LEARNING ACTIVITIES 1.Text Ring Click.is stored in the ring control in the form of an image/value pair.” 3. Place an Enum control on the front panel. Create a new LabVIEW VI by navigating to FileNew VI. Page 52 . Menu Ring . Place two numeric controls and a numeric indicator on the front panel. where the image is a bitmap displayed by the control when the item is selected. 2.is stored in the ring control in the form of an image/value pair.

8. Your front panel should look similar to the following figure. Page 53 . 7. Place a case structure on the block diagram. Click the OK button at the bottom of the Enum Properties box to close it. between your controls and indicator.ECE 100 Fundamentals of LabVIEW Programming 6. View the block diagram by selecting WindowShow Block Diagram or pressing <Ctrl-E>. Find the case structure at FunctionsProgrammingStructures.

The case structure now has a case for every value of the Enum that is wired to the case selector terminal. located on the left side of the case structure. Wire the Operation Enum control to the case structure’s selector terminal. This tutorial demonstrates four cases: Add. Right-click on the border of the case structure and select Add Case for Every Value.ECE 100 Fundamentals of LabVIEW Programming 9. Multiply. 10. Page 54 . and Divide. Subtract.

12. Switch to the “Subtract” case of the case selector terminal by clicking the right or left arrows at the top of the case structure. Your case structure should now contain four cases similar to the following: 17. Add the subtract function to the “Subtract” case. or by placing your mouse inside the case structure and pressing <ctrl> while scrolling with the mouse. 16. 15. Wire the function to the controls and indicators in the same way you wired the add function. or by placing your mouse inside the case structure and pressing <ctrl> while scrolling with the mouse. Add the multiply function to the “Multiply” case and the divide function to the “Divide” case. Switch to the “Add” case of the case selector terminal by clicking the right or left arrows at the top of the case structure. which acts much like a loop and creates tunnels automatically. Wire the controls Input A and Input B to the inputs of the add function. You can wire through the case structure.ECE 100 Fundamentals of LabVIEW Programming 11. the tunnel to the Result indicator changes from a hollow square to a filled square. When you have successfully wired all the outputs. as shown in the following figures. Wire the output of the add function to the Result indicator. Place the add function in the Case Statement when the “Add” case is selected. Question: How do you think will the case structures above work? Explain shortly the process Page 55 . Wire these functions to the controls and indicators in the same way you wired the add and subtract functions. 13. 14.

22. 19. added. subtracted or can be multiplied 18. Addition. Experiment with different values of the Operation Enum and run the VI again. View the block diagram by selecting WindowShow Front Panel or pressing <Ctrl-E>. Run the VI.VI Question: Explain how the VI works totally? In this VI It works based on the Structure inside the Font panel and working structure of block diagram. it performs based on the givens inside the block diagram that indicate operation which is subtraction. But if you run it.ECE 100 Fundamentals of LabVIEW Programming . Save VI as Act7. as you can see in the case the user can pick only 1 operation in a time he desire to put a Values on 2 different control that can be divided. the VI works when you put a certain values in input A and B that can be operate in a certain time like example if you put at values on A and B you can choose an operation either you choose add or multiple it will show your desire values Page 56 . Change the value of the Operation Enum to “Add. which changes the value of the Result indicator to 3. In this case The VI shown a Selector of operation which contain mathematical event that can be used in a certain time but this operations cant runs simultaneously. there will be change in input A and B the result will not be the same as the 1 st result came up 20. Question: What do you notice as you change the value of Input A and B? I notice in this cases is there is a changes only when the VI runs. Change the value of Input A to 1 and the value of Input B to 2. Multiplication and division.” 21.

the program will check the answer and will notify the user of his score and percentage rating. because this structure is capable of taking multipool cases. water dispenser. Create a 25-item test examination. If it is wired to a Boolean it becomes a Boolean type case. or cases. Cite some real-life applications of Case Structure. this structure can indicate a difference of wrong in a certain area of the VI. multiple choice types that allow to user to select the option of the best answer. This operation can use in every days electronic device like calculator or computer. It works as a selector or an option for the user. If it is wired to a numeric it becomes a numeric type case. Page 57 . What is a Case Structure? How does it work? A case structure contains one or more sub diagrams. Once the 25-item test is answered.ECE 100 Fundamentals of LabVIEW Programming IV. MACHINE PROBLEM 1. and if it is wired to a string it becomes a string type case. ATM. Customize your VI such that it is visually presentable. Save your VI as MacPro7_1. 3. Your VI should be customized and be saved as MacPro7_2. ASSESSMENT TASKS 1. Create a VI that will allow you to classify the winds speed into the following category using the Case Structure. 2. Scientific calculator. Computers. The questions should appear in the Front Panel with the control that will allow preference of answer.VI. Your VI should use the Case Structure. Rice Cooker.VI. The value wired to the selector terminal determines which case to execute. What is the importance of a Case Structure in building a LabVIEW program? The case Structure is Very useful in labview.  0-20 KPH (Calm Wind)  21-30 KPH (Breezy)  31-50 KPH (Windy)  51-80 KPH (Low Pressure)  80-90 KPH (Tropical Depression)  90-120 KPH (Tropical Storm)  120-150 KPH (Typhoon)  150 and above (Super Typhoon) V. 2. exactly one of which executes when the structure executes.

its either true or false or yes or no. VII. so that this topic is essential to use in any cases that operation a two or more structure. this case can be use a Boolean that can change when the user desire a different operation. CONCLUSION This activity the case structure that allows the user. RUBRICS FOR LABORATORY PERFORMANCE Page 58 . use different execution depending on the values of the label.ECE 100 Fundamentals of LabVIEW Programming VI. The case structure is analogues to the C++ case block which based on case value that input variables matched on the case execution.