Variables are used to store data and can be used for data sharing and exchange within a program or even between different programs. In LabVIEW, every time a local variable or global variable instance is created, it is a copy of the original data. That is to say, when too many local variables or global variables are used in a program, even if these variables are not written, LabVIEW will still occupy enough memory to create copies of these variables.
In fact, in the actual use of variables, programmers only use them to read and write a certain part of the memory space, and at the same time, only one section of program code will access the space represented by the variable (this process is very fast). Therefore, if a variable needs to be used in large quantities and repeatedly in a program, there is no need to use local variables and global variables. However, if only a small amount of data is exchanged or a control is assigned, local variables are still needed.
1.1 Local variables
Local variables in LabVIEW cannot exist alone in the program, they must be attached to a control (Control or Indicator). As shown in Figure 1, select Functions>>Programming>>Structures>>Local Variable in the function palette of LabVIEW. download
), the front panel of a new VI is shown in Figure 10, and the back panel is shown in Figure 11. The program uses a while loop that runs only once, in order to use a shift register to save the value of the variable. An enumeration control is used to represent the operation (read or write) of the global variable, and the corresponding instructions are responded to in different case structures. Figure 10 Front panel of functional global variable Figure 11 Back panel of functional global variable Create a new VI to call the above VI (called functional global variable), as shown in Figure 12, it can be seen that the correct value can be output. Figure 12 Use functional global variable Since each time the variable is read and written, it is taken from the shift register in the while loop, the problem of data copying can be avoided (of course, the global functional variable VI cannot be set to be reentrant and overloadable). Since the "error cluster" terminal is added to the functional global variable VI, the use of ErrorIn and ErrorOut can well avoid the "race risk" problem. In theory, functional global variables can completely replace traditional global variables. Due to the addition of "error cluster" and shift register, repeated copying of data is avoided. At the same time, the use of enumeration type controls (which can be set as Type Def. controls) can make the entire program structure clearer and more concise, thus achieving the purpose of modular program design.
Reference address:Local variables, global variables, and functional global variables
In fact, in the actual use of variables, programmers only use them to read and write a certain part of the memory space, and at the same time, only one section of program code will access the space represented by the variable (this process is very fast). Therefore, if a variable needs to be used in large quantities and repeatedly in a program, there is no need to use local variables and global variables. However, if only a small amount of data is exchanged or a control is assigned, local variables are still needed.
1.1 Local variables
Local variables in LabVIEW cannot exist alone in the program, they must be attached to a control (Control or Indicator). As shown in Figure 1, select Functions>>Programming>>Structures>>Local Variable in the function palette of LabVIEW. download
), the front panel of a new VI is shown in Figure 10, and the back panel is shown in Figure 11. The program uses a while loop that runs only once, in order to use a shift register to save the value of the variable. An enumeration control is used to represent the operation (read or write) of the global variable, and the corresponding instructions are responded to in different case structures. Figure 10 Front panel of functional global variable Figure 11 Back panel of functional global variable Create a new VI to call the above VI (called functional global variable), as shown in Figure 12, it can be seen that the correct value can be output. Figure 12 Use functional global variable Since each time the variable is read and written, it is taken from the shift register in the while loop, the problem of data copying can be avoided (of course, the global functional variable VI cannot be set to be reentrant and overloadable). Since the "error cluster" terminal is added to the functional global variable VI, the use of ErrorIn and ErrorOut can well avoid the "race risk" problem. In theory, functional global variables can completely replace traditional global variables. Due to the addition of "error cluster" and shift register, repeated copying of data is avoided. At the same time, the use of enumeration type controls (which can be set as Type Def. controls) can make the entire program structure clearer and more concise, thus achieving the purpose of modular program design.
Previous article:Developing Custom LabVIEW Plug-ins
Next article:Use of Tree Control
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Test Measurement Articles
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Ranking of installed capacity of smart driving suppliers from January to September 2024: Rise of independent manufacturers and strong growth of LiDAR market
- Industry first! Xiaopeng announces P7 car chip crowdfunding is completed: upgraded to Snapdragon 8295, fluency doubled
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
Guess you like
- [Mil MYD-YA15XC-T Review] + USB UVC Camera Test
- Share: Several questions about the battery monitor bq76pl455a
- EEWORLD University - Multi-Camera System with DS90UB960 Deserializer Hub and TDA SoC: Training Series
- Why is the maximum angle read by the resolver chip AD2S1210 only 180°?
- liunx configures static IP and changes ens33 network card to eth0
- "Practice Together in 2021" + An Ordinary Year
- Giant Digital Caliper Clock
- FPGA learning and design considerations V.1.pdf
- [NXP Rapid IoT Review] 3 - BLE Bluetooth Data Transmission Experiment
- STM32F10x RS485 modbus RTU slave source program