Instrumentation & Measurements Lab Lab 1 Name: _______________________ ID: ____________________ Date: ____/____/_______ Experiment # 1: Introduction to Lab-VIEW (CLO 1, PLO 5) Objectives: At the end of this lab, students will be able to • • • • • Create a project and simulate in Lab VIEW. Use different function and control blocks. Implement different math and logic operation in Lab VIEW Define the different type of inputs and outputs for function and control blocks. Optimize the simulation of design project in Lab VIEW. Introduction/Tutorial: Lab view can be learned easily by following the given steps 1. 2. 3. 4. 5. How to access LabView. How to create a new blank VI. How to create a front panel with the available controls and indicators. How to create a block diagram that corresponds to the front panel. How to use the tools palette and its available functions on the toolbar. 6. How to practice LabVIEW programs at home. 1. Accessing LabVIEW 8.5. 1) Logon on to computer with LabVIEW installed. 2) From the Start menu, go to All Programs/ National Instruments/ LabVIEW 8.5 (or 8.2 in cnc24hour2 server). Click LabVIEW. (Select OK if there is a Security Notice and Continue on the LabVIEW window). 2. Creating a new blank VI. What is a VI? 1 Instrumentation & Measurements Lab Lab 1 VI is a Virtual Instrument (VI) or a LabVIEW program. It is referred to as a VI because its appearance and operation resembles physical instruments (i.e. oscilloscopes and multi-meters). A simple VI with fundamental controls and indicators How to Open a new blank VI? 1) The following screen will appear and most of the time, you can either: a. Open a New VI from File in the tool bar b. Click Blank VI in Getting Started window 2 Instrumentation & Measurements Lab Lab 1 2) You then have two main windows on your desktop, a Front Panel (gray grid background) and a Block Diagram (white background) 3) The Front Panel is like the dashboard instrument panel in your car as it will contain all the visual indicators and inputs. 4) The controls and indicators that may be placed on Front Panel are in the Controls Palette (if not already displayed, Right-Click on the Front Panel and to make it stay on the screen, LeftClick on the Push-Pin in the upper left corner). 3 Instrumentation & Measurements Lab Lab 1 5) The Controls Palette may only be used for the front panel and is where you will select different controls (inputs) and indicators (outputs). Also, The Controls Palette mayonly be used for the front panel and is where you will select different controls (inputs) and indicators (outputs). # Controls involve knobs, push buttons, dials, and other input devices. # Indicators can be graphs, LEDs, numeric display, and other displays. 6) The Block Diagram is a graphical source code, much like a circuit board, used control the front panel objects. a. The Block Diagram includes objects such as terminals (representing the front panel objects) and those items that don’t show on the front panel such as functions, constants, and wires to connect all the objects. b. The palette that contains all these objects is the Functions Palette, which can only be used in conjunction with the Block Diagram (if not already displayed on screen, RightClick on the Block Diagram to make it stay on the screen, Left- Click on the Push-Pin in the upper left corner). 4 Instrumentation & Measurements Lab Lab 1 7) To switch from the Front Panel to the Block Diagram, either Left-Click on whichever window you want or just press Ctrl-E. 8) In addition to Controls and Functions Palettes, the Tools Palette is a universal palette that can be used to perform operations on both Front Panel and Block Diagram. To access the Tools Palette if not already displayed, go to View/ Tools Palette as shown in the following picture. Also, users can use the Tools Palette to switch cursor operation modes (i.e. wiring, creating text, selecting items, aligning, etc…) 3. EXAMPLE 1.1: Creating a Simple Addition VI This VI will add two numbers (A and B) and return the sum, C. (A + B = C) Beginning with the Front Panel, 1) Add a Numerical Control in Front Panel. (Go to Controls Palette/ Modern/ Numeric. Then select Numeric Control and place it in the Front Panel) 2) Add second Numerical Control in Front Panel. (You can either repeat the same step above. Or, choose , the Arrow, from the Tools Palette, Hold down Ctrl and Left-Click on the Numerical Control. Then Drag it to duplicate another Numerical Control.) 5 Instrumentation & Measurements Lab Lab 1 3) Add a Numerical Indicator in Front Panel. (Go to Controls Palette/ Modern/ Numeric. Then select Numeric Indicator and place it in the Front Panel) 4) If necessary, change the titles of the inputs and outputs by changing from to , the arrow, , the text editor, by Left-Click on each title. Highlight the previous text and Delete, Type in new text. 5) If necessary, vertically align the inputs and horizontally align a input with the output by clicking , Align Objects, in the tool bar and selecting appropriate icons under Align Objects to make desired alignment. 6) Ctrl-E to switch to the Block Diagram (three terminals should be displayed, two for the inputs and one for the output). 7) Add a Add Function in Block Diagram. (Open Functions window and go to Programming/ Numeric. Then select ADD and place it in the Block Diagram) 8) Connect each Input to an Input Terminal on the Add Function triangle. (Select Wire Icon from the Tools Palette. Left-Click on one of the Inputs → one of the Add Function terminals). Also, do the same step for the other input and output. 9) Now, the IV should be able to be ran after clicking Run. Check if the VI is complete by observing whether a ,Broken Arrow, or a left on either Front Panel or Block Diagram. a. ,Solid Arrow, is displayed at the top A broken arrow indicates that an error is presented or something (functions in block diagram mostly) is not wired correctly. b. 10) A Solid arrow indicates that the VI is completed and ready to run. If a Solid Arrow is displayed, Ctrl-E back to the Front Panel and input a 4 and a 7 in 6 Instrumentation & Measurements Lab Lab 1 the two Numerical Controls (inputs) by using , a Finger Icon, to either Left- Click the buttons on the control or Left-Click where the numbers are and type in the appropriate number. 11) Finally, Left-Click on , Solid Arrow, to run the VI and ensure that the Numerical Indicator (the output in front panel) reads as 11. And, the VI should be similar as following figures. The Front Panel in Example 1.1 The Block Diagram in Example 1.1 4. EXAMPLE 1.2: Exploring Signal Generation and Processing This example shows how to create/simulate a sinusoidal input signal, use numerical controls to change the amplitude and frequency of the sinusoidal waveform, and display the sinusoidal waveform. 7 Instrumentation & Measurements Lab Lab 1 Beginning with the Block Diagram, 1) To create a signal, Left-Click on Controls/ Simulate/ Simulate Signal, and place it on block diagram. (This should bring up a setup screen as shown on the following figure to configure the type of input signal you want to simulate.) You can choose the type of signal you want (sinusoidal, square, triangular, etc.) as well as the frequency, amplitude, phase, offset, and noise if desired. 2) Click OK when you have all the parameters set as desired (we will just leave them as is for now). 3) Now we need to add an output graph so that we can see our signal. a. Go to the Front Panel and choose from the Controls Palette/ Graph Inds/ 8 Instrumentation & Measurements Lab Lab 1 Waveform Graph. 4) We also want the user to be able to control the frequency and amplitude of the sinusoidal waveform without having to open up the configuration screen. a. Add Two Numerical Controls to the Front Panel and label them “Frequency” and “Amplitude”. Your Front Panel should now look like the following figure. The Front Panel for Example 1.2 5) Now switch back to the Block Diagram and now we need to connect the two controls to the Simulate Signal block. Wire the controls to the Simulate Signal block (the Frequency Terminal is the second one from the top and the Amplitude Terminal is right below it.) 6) Next you will need to Wire from the Sine output terminal to the Waveform Graph block. Your final Block Diagram should look like the figure in the next page. 9 Instrumentation & Measurements Lab Lab 1 The Block Diagram for Example 1.2 7) Switch back to the Front Panel and change the Frequency value to 50 and the Amplitude value to 8 and then Run the VI. 5. Exploring the Front Panel Toolbar Many executables and aligning commands are located in the toolbar. 1) First, the executable commands from left to right (these are also available on the block diagram as well). a. , Run Command – Will be a solid arrow when the VI is correctly wired together and no errors exist, if errors exist or the VI is incomplete, the arrow will be broken ( ). Click on this command to run a VI. b. , Continuously Run Command - Use this command to continuously run the VI until the user stops it or it reaches a terminate condition. c. , Abort Command – Use this command to stop execution of a VI instantaneously. Useful when a VI is running continuously and you need to stop it. d. , Pause Command – Use this command to pause execution with intentions of continuing execution from that point. 6. The best way to familiarize yourself with this program is to just explore all the available options it provides and practice using these options. Also, the practice-practice-practice policy is the best way for you to build VIs with desired functions for your future usage. 10 Instrumentation & Measurements Lab Lab 1 Lab Task 1: By using the numerical blocks implement the following functions X=(a+b+c) (c+a/b) Y=(a-b) + (c+b+d) Choose values by your own convince and draw block diagram of both functions in a given space below. Lab Task 2: Generate the following wave form signal and display on graphics output block • Saw tooth wave with frequency of 100 HZ and amplitude of 6. • Square wave noisy signal with 50Hz and amplitude of 10. Note: i. Draw table by your own and fill it for lab task 1. ii. Attach screenshots of simulation and results with this lab report. 11 Instrumentation & Measurements Lab Lab 1 Conclusion: Instructor’s Signature 12 Marks Obtained