LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple shift registers in For loop

Solved!
Go to solution

I'm using multiple shift registers to find the number of different string in a string array. However, the shift register got refreshed every time it finds a different string and returns back to 0. How can I have the register remember its previous value after it encounters a new string value?

0 Kudos
Message 1 of 4
(5,249 Views)
Solution
Accepted by topic author holyna

The unwired tunnels in your case structure are set to Use Default if Unwired.  The default is zero.  The answer is to wire the tunnels.  An easy way to do this is to right-click each of the output tunnels, and under Linked Input Tunnel choose Create and Wire Unwired Cases.  Then you click on the matching input tunnel.

Message 2 of 4
(5,241 Views)

Nice! Thanks.

0 Kudos
Message 3 of 4
(5,230 Views)

You should think about making your code scalable. At the moment, you need to re-architect the VI from scratch whenever the sensor names or their number changes. If you suddenly have 1000 sensor names, the code would be unmamangeable because the sheer number of cases and shift registers!

 

Attached is an simple alternative. As you can see, the code remains the same, even if the number of sensors or their names changes in the future. See if it makes sense. (You can easily modify it to also count unrecognized names, for example).

 

 

Modify as needed.

 

Some other possible bugs in your VI:

 

  • You should initialize the shift register with zero, not one. Right now the results are one too high.
  • Case "B" is actually "B." and the count is only accidentally correct because it is also the default case and there are no other sensor names (e.g. F) in the input array.

 

Download All
Message 4 of 4
(5,199 Views)