2049CH02 - Bitter, Rick et al "LabVIEW...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Bitter, Rick et al "LabVIEW Features" LabVIEW Advanced Programming Techinques Boca Raton: CRC Press LLC,2001 2 ©2001 CRC Press LLC LabVIEW Features The previous chapter covered many of LabVIEWs basic functions. The functions give a programmer the ability to produce a wide range of applications in a relatively short time. While the previously discussed functions provide enough of a basis to build an application, there are a number of LabVIEW features that can make an application more flexible and easier to use, and can give your application a profes- sional appearance. Some of these features will be discussed in this chapter. 2.1 GLOBAL AND LOCAL VARIABLES Global variables are used when a data value needs to be manipulated in several VIs. The advantage of using a global variable is that you only have to define that data type once. It can then be read from or written to in multiple VIs. The use of global variables is considered poor programming practice; they hide the data flow of your application and create more overhead. National Instruments suggests that you struc- ture your application to transfer data using a different approach when possible. However, there are instances when global variables are necessary and are the best approach for an application. One example would be updating a display from data being generated in a subVI. The application could have two While loops running in parallel. Data could be generated in a subVI in the top loop while the bottom loop reads the data from the global and writes the information to the user interface. There is no other method for obtaining data from a subVI while it is still running. The global variable must be created and its data types defined before it can be used. To create a global, first drag the icon from the Structures palette and drop it onto a block diagram. Figure 2.1 shows the global as it appears on the diagram. The question mark and black border indicate that it cannot be used programmatically. The global has a front panel to which you can add controls, identical to a VI. Globals do not have a block diagram associated with them. To open the front panel of the global variable, simply double-click on the icon. The front panel of the global is shown in the bottom window of Figure 2.1. Two controls have been created on the global front panel. A global variable can contain multiple controls on the front panel. Try to logically group related controls and tie them to a single global variable. Once the data types have been defined, save the global as a regular VI. The global can then be accessed in any VI by using the same method you normally follow to place a subVI on the code diagram. If you have more than one control associated with the global variable, pop up on the icon once you have dropped it onto a block diagram and use the Select Item submenu to select the appropriate one. ©2001 CRC Press LLC A value can be either written to or read from a global. Use a “read” global to read data from and a “write” global to write data to a global variable. The firstread data from and a “write” global to write data to a global variable....
View Full Document

This note was uploaded on 03/11/2010 for the course ME 1100 taught by Professor Futao during the Spring '10 term at Kasetsart University.

Page1 / 55

2049CH02 - Bitter, Rick et al "LabVIEW...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online