Reinitializing a Shift Register Without Stopping the VI

Updated Jan 15, 2019

Reported In

Software

  • LabVIEW

Issue Details

  • I would like to reinitialize my shift register value to zero whenever I press a boolean button on the front panel. I do not want to stop my VI when I want to reinitialize my shift register.
  • I need to clear the shift register to clear all the data from an initialized array when a boolean indicator in my code becomes false.¬†

Solution

This can be done by adding a case structure within the while loop as follows, or by dragging the VI snippet to your block diagram if you are running LabVIEW 2013 or later:

  1. In order to select a while loop right click on the block diagram then navigate to Programming>>Structures>>While Loop and drag it onto the diagram.

  2. In order to select a case structure right click on the block diagram then navigate to Programming>>Structures>>Case Structure and drag a case structure into the while loop.

  3. Create a numeric constant outside of the while loop and wire it to the border of the loop.

  4. Right click on this tunnel and select Replace with Shift Register.

  5. Place a boolean control on the Front Panel. This is our reset button that will reset the shift register in the while loop. (The boolean can also be an indicator that shows if a case is true or false in your code).

  6. Wire the boolean control (or indicator) to the Case Selector of the case structure.

  7. In the True case, place a numeric constant of zero and wire to an output tunnel on the Case Structure.

  8. In the False case, wire the data through to the output terminal.

  9. Wire the output terminal of the case structure to the shift register on the right side of the while loop.

    Figure 1. Reinitializing a shift register without stopping the VI.

This code is applicable to arrays as well, you just have to replace the numeric constants with array constants.

WAS THIS ARTICLE HELPFUL?

Not Helpful