Search code examples
while-looplabviewshift-register

LabView - How to use shift register with case structure?


Can I use shift register to pass data from cases to cases(case structure)? I added shift register to my while loop, inside my while loop I have a case structure, I want to store data in the shift register from the 1st case and transfer it to the 2nd case, how am I going to do so?


Solution

  • Yes, that's exactly the sort of thing a shift register is used for. Just wire the data out of the case structure into the shift register input on the right-hand side of the While loop, like this:

    While loop with case structure and shift register (VI snippet)

    This is a VI snippet so you can drag it on to your VI diagram to import the code.

    If you use a shift register to pass a value out of a case structure and use that value as the case selector on the next loop iteration, you've created a state machine. This is a very useful design pattern in LabVIEW applications. Here's a tutorial on the NI site to help you get started with them.