Shift Registers in LabVIEW

Laboratory Virtual Instrument Engineering Workbench (LabVIEW) is a system development environment developed by National Instruments. It is used to test, measure, and control software applications. Virtual instruments help developers in building flexible applications that meet customer needs. We can create virtual instruments with a combination of software and hardware through block diagrams. The shift registers play an integral part in the process of virtual instrument creation. In this post, you will understand the potential of shift registers in LabVIEW. You will get to know what shift registers are, how to initiate, and stack them, etc. Keep on reading to improve your LabVIEW knowledge.

What are shift registers?

When we use loops in LabVIEW, we often need to get data from the previous iteration. The data from the previous iteration of the loop should be retained for further processing. A shift register is used to store data in looping conditions like For loops and While loops. It lets you pass values from the previous iteration of the loop to the next. It can be termed as a local variable inside a loop.

The shift registers appear as terminals on vertical sides of the loop border. The terminal on the left side is a down arrow. On the other hand, the terminal on the right side is an up arrow. When the loop executes, the last value stored in the shift register will be returned by the terminal on the right side.

A shift register can transfer data of any type. It takes the data type of the first object wired to the shift register. Each shift register of a terminal should be of the same type. We can perform calculations based on the data stored in a shift register. Certain decisions can also be made with this data. We can add multiple shift registers to a loop. If we have multiple values to read from the previous iteration, we can add multiple shift registers to store each of the values.

Implementing a shift register

We can implement a shift register in two methods.

Method 1: Create either a For or While loop on the block diagram. Add a shift register to the loop by right-clicking on the left or right border of the loop and selecting the ‘Add Shift Register’ option from the shortcut menu.

Method 2: Create either a For or While loop on the block diagram. Wire a node to the loop. Right-click on the node and select the ‘Replace with Shift Register’ option from the short-cut menu.

Initializing a shift register

The shift register initialization resets the value when the VI is run. It then passes the new value to the first iteration of the loop. Wire a control or constant to the shift register terminal on the left side of the loop to initialize a shift register.

For example, take a loop that increments the value of the shift register by 1. When the VI is run, the shift register will get initiated and begins with the value 0. If the loop iterates 3 times, the final value that the shift register passes is 3. Now when the VI is run again,

  • The shift register value again rests to 0 if the shift register is initialized. So the shift register beings with the value 0.
  • If the shift register is not initialized, the value from the previous iteration will remain in it. That means the shift register will begin with the value 3.

Labview Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

Stacked shift registers

If we want to access data from multiple previous iterations, we can use stacked shift registers. These stacked shift registers remember values from multiple previous iterations and carry them to the next iteration. We can use stacked shift registers only on the left side border of the loop. The terminal on the right side of the loop only transfers data generated from the current iteration to the next. Hence, we cannot use stacked shift registers on the right terminal.

To add a stacked shift register, right-click on the left terminal. Select the 'Add Element' option from the shortcut menu. The values from the last two iterations will pass to the next iteration. The most recent iteration value will get stored in the top shift register. The previous iteration value will get stored in the bottom shift register.

Replacing tunnels with shift registers

A tunnel is used to pass data to an ongoing loop in LabVIEW. The value and data type does not change before or after the loop structure. A tunnel can be replaced with a shift register when necessary. To do so, right-click on the tunnel and select the 'Replace with Shift Register' option from the shortcut menu. If there is no tunnel on the other side, LabVIEW will create a shift register on that side as well. If multiple tunnels exist on the loop, you will get an option to choose the tunnel that you want to change to a shift register.

Reinitialize shift register without stopping VI

If we want to reinitialize a shift register value to zero when an action is performed on the front panel, we can do so without having to stop the VI. All we need to do is add a case structure within the while loop. Right-click on the block diagram and choose the 'Programming' option from the shortcut menu. Then select the 'Structures', select the 'While Loop' option, and add it to the block diagram. Drag and drop a case structure into the while loop.

Create a numeric constant and wire it to the border of the while loop. Replace the tunnel with a shift register. Create a boolean control on the front panel. This will work as a reset button that will reset the shift register. Wire the boolean control to the case structure. Wire the output terminal of the case structure to the shift register on the right side of the while loop.

Subscribe to our youtube channel to get new updates..!

Points to remember

Here are a few pointers to keep in mind while working with the shift registers.

  • For loops will not execute sometimes, whereas while loops execute all the time. So make sure what the shift register returns when the For loop does not execute.
  • Avoid using too many shift registers in a single loop.
  • Make sure to initialize the shift register to reset the value at each VI run.
  • If you want to preserve the value of the previous iteration, do not initialize the shift register.

Labview Training

Weekday / Weekend Batches


The shift registers are the best way to pass data between loop iterations in LabView. Now, that you know how to use the shift registers, create a block diagram, and experiment with the shift registers. If you are looking for some more information, check out our other posts on LabVIEW.


Request for more information

Kavya Gowda
Kavya Gowda
Research Analyst
Kavya works for HKR training institute as a technical writer with diverse experience in many kinds of technology-related content development. She holds a graduate education in Computer science and Engineering stream. She has cultivated strong technical skills from reading tech blogs and also doing a lot of research related to content. She manages to write great content in many fields like Programming & Frameworks, Enterprise Integration, Web Development, SAP, and Business Process Management (BPM). Connect her on LinkedIn and Twitter.

To Top