To download NI software, including the products shown below, visit ni.com/downloads.
Overview:
It is possible to initialize stacked shift registers before a While loop is run, but what happens if you want to reinitialize them during operation of a loop? This example provides two methods of doing so.
Description:
Stacked shift registers are used to hold the previous values of an output, so it is not possible to reinitialize them in a single iteration.
One way of achieving the same functionality would be by using more than one single shift register. It is not as stylish as using stacked shift registers, because you have to handle passing data between iterations manually by creating wires meaning that it isn't very scalable and takes up a lot of space. However, with this method it is possible to update all of the wire values at the same time as in the below snippet.
But if you want to use true Stacked Shift registers, it is necessary for a number of while loop iterations to pass for all of the shift registers to re-initialize; the number of iterations necessary is equal to the number of stacked shift registers. An example of this is attached.
In the example, we have 3 stacked shift registers on a while loop that are initialized to zero. As the VI runs, the output value is incremented by 1 each second, until a reset button is pressed, at which point the output value is reset to zero for the next 3 iterations, until all of the shift registers read zero.
For example, take a look at the output when the reset button is pressed on iteration 4. By iteration 7, the shift registers have reinitialized and the output value resumes counting up.
Requirements:
LabVIEW 2012 (or compatible)
Steps to Implement or Execute Code:
For the 'instant' initialization method that will reset the shift registers in a single iteration, drag the above VI Snippet image on to a LabVIEW block diagram. Use highlight execution to observe the values changing.
Or for the method that uses true stacked shift registers:
1. Download and run the attached VI and observe that the shift registers initialize to zero.
2. Observe the 'current value' indicator adding 1 to the output value every second.
3. Press the 'Reset Shift registers button'
4. Observe that after 3 iterations, all of the shift registers have re-initilized to zero
5. Stop the VI to see a summary of all values.
Additional Information or References
If you think it would be better if it were possible to reinitialize actual stacked shift registers in a single iteration, vote for the idea here.
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.