Wednesday, August 18, 2010

Programming LabView - Shift Register

The shift register is a key element of LabView programming. It allows looping structures, such as the For and While loop, to carry over values from one iteration into the next. This can be extremely powerful in allowing the developer to build up arrays of information, or retain state information about a program running in a loop.

For starters, let us look at how to create a shift register. Right click on the left edge of a for or while structure and select "Add Shift Register":

Once this is completed, you will see two squares appear on the border on opposite sides of the structure. The square on the left outputs the value of the last iteration, while the square on the right must have something wired to it that is passed around to the next iteration.


Below, a numeric control terminal is wired to the shift register. Whatever value is typed into the control on the front panel will appear as an output on the left square on the next iteration:

Below are some modifications to the loop in progress. An indicator has been wired to the value from the input of the shift register. The control has been disconnected from the right square. A boolean selector will be used in this example. See the menu below to find this routine:

Using the boolean selector, the following code was wired:


This example will retain the previous value of the shift register on the output and to the next iteration if the boolean control is set to false. If it is set true, then the value of the numeric control will be placed onto the shift register. This code will act as a latch, saving the value in the numeric control when the boolean control is on, while retaining the old value and not following the numeric control value when the boolean control is off.

As you move forward with LabView programming, you will see that most design patterns are impossible without the shift register. Anytime you are trying to keep track of something in a loop, you will need to use one.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers