int Record(void)
{
static int counter=0; //initialization for the first call
counter++;
return(counter);
}
How is a similar function implemented in LabVIEW? Of course, we can use a global variable and perform a +1 operation on the global variable in SUBVI, but the side effects of doing so are very obvious.
First, because there is no encapsulated data, the global variable can be modified at any location in the program. Second, when several places operate on the global variable at the same time, the current result is unpredictable because there is no protection mechanism.
The best way is to use Function Global, also known as LV2 type global variables. It may be that there were no built-in global variables before LABVIEW2, so this is the only way.
The core of Function Global is Shift Register (uninitialized). Most books emphasize the importance of Shift Register initialization. In fact, uninitialized Shift Register is more important.
I won't explain the general usage of Shift Register, such as the problem of finding the average value in a FOR loop. What we need to consider is what exactly is Shift Register? In fact, it should be a shared memory space that is readable and writable. In this case, it is essentially no different from a global variable. A basic Function Global is shown in the figure below:
Correction: The Boolean constant controlling the loop in the above figure should be TRUE, in order to make the loop run only once, in order to use SHIFT REGISTER
Here's how to use it:
This realizes the data exchange function of global variables. Component programming is an important programming method of LABVIEW, and Function Global is its core part.
There is a problem with this program. When the program starts and no write operation is performed, what is the value of Shift Register? As a component programming, it should implement self-initialization inside it. Here we introduce an important VI, FIRST CALL, to solve this problem.
Previous article:Function Global and Action Engine
Next article:Labview software counter and FIFO BUFFER
- Popular Resources
- Popular amplifiers
- 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?
- 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
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Gain insight into difficult-to-measure signals with ADI’s precision
- Current carrying capacity of PCB traces and vias
- About 28377d dual-core simulation and CLA simulation experience
- High speed, high output current, voltage feedback amplifier MS8241, can replace LM7171, P=P
- MCU Programming_Interrupt
- A brief introduction to capacitor selection
- Please tell me how to realize the power-down and wake-up functions of Zhongying MCU
- Offset Voltage and Open-Loop Gain in Operational Amplifier Circuits
- STM8AF6248
- Using TI power timing controller in 5G MIMO application