Main Loop
Almost all LabVIEW programs have at least one main loop that will continue to loop until the program ends. The program may end because of a stop button, an error, or other reasons. The following figure shows an example of a While Loop with a standard wait function (to prevent the program from monopolizing the CPU) and a stop button.
This combination of While loop + Case structure is the basis for creating LabVIEW applications.
Handling Multiple Events in a While Loop
Let's start further discussion. What if there are multiple buttons? The simplest way is to add multiple Case structures in the While loop as shown below. This method is easy at the beginning, but it will be troublesome once you have more Case structures .
Now we know how to handle multiple events by combining While loop + Case structure. Similarly, if we want to handle N events, we can add N Case structures in the While loop. But what if there is not enough space in the flowchart? In this case, the solution of "adding another Case structure" is not so suitable. The solution to this situation is actually very simple, which is to create a Case structure with multiple cases, each case in this structure corresponds to an event.
In order to realize this idea, we need to create an array of Boolean variables, save the value of each button in this array and search the serial number of the element with the value TRUE in the array. Through this serial number, we can know which button is pressed and enter the number of the button into the case selection endpoint of the Case structure, and then the relevant operation corresponding to the button will be executed. As shown in the following figure:
Now if you want to add a new event, you just need to add a new element to the array and add a corresponding case in the Case structure.
However, in actual use, we usually use enumerated type (enum) data to connect the case selection endpoints of the Case structure instead of straight I32 type integer data.
Previous article:Automatic Indexing of Arrays in LabVIEW
Next article:Three principles to follow when designing VI
Recommended ReadingLatest update time:2024-11-23 07:35
- Popular Resources
- Popular amplifiers
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Arduino Nano collects temperature and humidity data through LabVIEW and DHT11
- Modern Testing Technology and System Integration (Liu Junhua)
- Computer Control System Analysis, Design and Implementation Technology (Edited by Li Dongsheng, Zhu Wenxing, Gao Rui)
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- Modern manufacturing strategies drive continuous improvement in ICT online testing
- Methods for Correlation of Contact and Non-Contact Measurements
- 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
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Can the button in emwin only display two Chinese characters?
- Single power supply single op amp second order filter plus DC bias (cannot be isolated)
- What is the difference between power inlet power filtering and common mode inductance?
- Several effective measures to extend the service life of battery powered single chip microcomputer system
- Book now to get a gift: 2019 Keysight Electronic Measurement Basics Online Lecture Series
- Thank you + my parents
- Computer and Wife
- Embedded Systems: Composition, Principles and Design Programming
- Compile and run the SRTC capacitive touch experiment on the IMX6ULL development board
- Design of Micro Printer Controller Based on VHDL