Virtual Instrumentation
Total Page:16
File Type:pdf, Size:1020Kb
1.1. What is Labview? LabVIEW is a graphical programming language that uses icons instead of lines of texts to create applications. In contrast to text-based programming languages, where instructions determine program execution, LabVIEW uses dataflow programming, where the flow or data determines execution. In LabVIEW, you build a user interface by using a set of tools and objects. The user interface is known as the front panel. You then add code using graphical representations of functions to control the front panel objects. The block diagram contains this code. In some ways, a block diagram resembles flow chart LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of VIs and functions for acquiring, analyzing, displaying, and storing data, as well as tools to help you troubleshoot your code. 1.2. Parts of a VI LabVIEW VIs contain three main components: 1. The front panel, 2. The block diagram 3. The icon/connector pane Getting started screen will be shown when you run LabVIEW. It can be seen in fig. 1 below. Fig 1. Getting started screen of LabVIEW For now, as a beginner, you should get acquainted to LabVIEW environment. Try to click "Blank VI" under the "New" Section on the left (See Fig. 1). You will see two windows are appearing. One is the grey one which is called “Front panel” and the other is white which is called “Block diagram”. 1.2.1. Front Panel Front panel is the graphical user interface (GUI) of your LabVIEW program where you will interact with it while it is running. See Figure 2 to observe the blank front panel. Note that the background of front panel is grey. Front Panel has grey Fig. 2. Blank front panel of LabVIEW program 1.2.2. Block Diagram Different from front panel, the block diagram has white background. In fact, this window is where the program will actually be written. When you develop the block diagram, you are actually writing the program that makes the front panel operate as you desire. It is here that you will make the computer perform calculations, write files, communicate with hardware, etc. This view of the VI is what most programmers would call a "Program" or "Source code". A blank block diagram is shown in figure 3. Block diagram has white Fig. 3. Blank block diagram of LabVIEW program 1.2.3. Icon / Connector Pane Icon / connector pane is used to make subVI. A subVI is a VI used inside another VI. SubVIs are an important introductory concept in LabView. A VI is a "Virtual Instrument" which is just the basic labview program, contained in a .VI file, which is represented by a front panel and block diagram. However, every VI can also be a SubVI. The third component of a VI consists of its icon and connector pane. These two pieces make every VI capable of becoming a SubVI. So, what exactly is a SubVI? It is a VI that is placed on the block digram of a higher level VI. It allows you to write modules of code that you can wire into your diagrams later. The icon is what the SubVI will look like on another VIs block diagram. The connector pane allows you to assign terminals on the icon to front panel controls and indicators for the purpose of wiring values into and out of a SubVI. 1.3. Controls Palette, Functions Palette, and Tools Palette These three palettes are the most widely used feature to make a program in LabVIEW. You must be familiar with these palettes. Controls palette and functions palette are associated with front panel and block diagram respectively, whereas tools palette is associated with both, front panel and block diagram window. 1.3.1. Controls Palette In order to show the controls palette, in front panel, go to View>>controls palette (See fig. 4). Controls palette contains the ‘controls’ and ‘indicators’ you use to create the front panel. Controls and indicators can be accessed from View>>controls palette>>Numeric (there is another way to access these controls and indicators through ‘Express’ menu in controls palette, but it is left for you to explore later). ‘Controls’ allow you to input something into your program. That means you can change the value and affect the program while it is running. ‘Indicators’ allow you to see results from the program. You cannot change their value. They are your way of seeing what has happened. Fig. 4. Controls Palette 1.3.2. Functions Palette The functions palette contains the VIs, functions, and constants you use to create the program in the block diagram. You access the functions palette from the block diagram by selecting View>>Functions Palette. The functions palette is presented in fig. 5. Fig. 5. Functions Palette 1.3.3. Tools Palette Tools palette contains tools to construct the graphical user interface (GUI) on the front panel and the program on the block diagram. It can be accessed through View>>Tools Palette (see Fig.6.). Fig. 6. Tools Palette 2nd TUTORIAL ACQUIRING, ANALYZING, AND PRESENTING DATA Now, through example, you will try to make a simple program used to acquire, analyze, and present data. Since you are not doing actual experiment, you will utilize a simulate signal function as an acquired signal. You will make a VI shown in the figure below (Front panel and block diagaram respectively). Follow the steps in the figures and the instructions 1. Access ‘View>>Controls Palette>>Express>>Graph Indicators>>Waveform Chart (Chart)’. Put the chart on the front panel (see picture below) 2. Go to ‘View>>Tools Palette>>Edit Text’ and change the label ‘Waveform Chart’ to Graph of experimental data as shown below 3. Access ‘View>>Controls Palette>>Express>>Numeric Indicators>>Numeric Indicators’. 4. And then change the label ‘Numeric’ to ‘Measured Amplitude’ and enlarge the indicator by drag the right side of the indicator to the right. 5. Put two more ‘numeric indictors’ by using the same method (or you can use another way, i.e, on the first numeric indicator press ‘Ctrl + hold the left mouse botton’ then drag). 6. Change the label to ‘Measured Frequency’ and ‘Standard Deviation’ (see figure below) 7. You can see in ‘block diagram’ the terminals of the indicators is automatically coming. 8. Next, we will go to block diagram to make the program. View>>Functions Palette 9. Click ‘Express>>Signal Analysis>>Tone Measurements’ and put it on the block diagram. 10. The properties window of ‘Tone measurement’ will appear automatically. Check ‘Amplitude and Frequency’ options then click OK. 11. Afterwards, go to ‘View>>Functions Palette>>Express>>Input>>Simulate Signal’. 12. The properties window will appear automatically and make the setting shown in the picture then press OK. 13. Now, your block diagram is as shown in the figure below 14. Next, go to ‘View>>Functions Palette>>Express>>Signal Analysis>>Statistics’ put it on the block diagram. The Properties window will appear. Check the ‘Standard Deviation Option’ then click OK (see figures below) Properties window of the statistic function can be seen below. 15. Connect the wire from ‘View>>Tools Palette>>Connect wire’. 16. Next, do right click (another way to access functions palette) and go to ‘Express>>Execution Controls>>While Loop’. 17. Enclose the whole program with the ‘While Loop’. This is while loop 18. Go to front panel and arrange the front panel so that it looks like the figure below. Then run the program 3rd TUTORIAL CREATING SUBVI In this lecture, we are about to learn how to make subVI. What exactly is a SubVI? It is a VI that is placed on the block digram of a higher level VI. It allows you to write modules of code that you can wire into your diagrams later. The icon is what the SubVI will look like on another VIs block diagram. The connector pane allows you to assign terminals on the icon to front panel’s controls and indicators for the purpose of wiring values into and out of a SubVI. The SubVI interface (icon and connector pane) is not as immediately obvious as the front panel and block diagram when a VI is opened. It is accessible from the upper right hand corner of the front panel window (This expalantion and example is taken from www.learnlabview.blogspot.com): By default the icon is displayed. By right clicking on the icon you will see a pop-up menu. You can see there are options for setting properties of the current VI, Editing the Icon, and Showing the connector pane. In this menu you should select Show Connector: Upon doing so, the icon image will change to a layout of the connector pane: By clicking on the regions in the connector pane with the wiring tool, and then clicking on front panel objects, the VI becomes a usable SubVI. There are no requirements on how many or how few of the front panel objects should be wired. It is up to you if the value is needed for the program to function properly. If a front panel object is not connected to the connector pane, then the default value will likely be used when the VI is called from another VI as a SubVI. Now let's create a SubVI to make this clear. First, create a VI. In this case, a simple VI that gives increment of one on a value will suffice. Next you will need the connector pane visible and the wiring tool selected.