LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

storing data using shift registers

Solved!
Go to solution

hello, 
i am currently trying to store a string out put from my vi. Basicly i want the vi to be able to monitor the string outputs, and if 3 occur in a row, i want it to show a new out put. i am thinking of using stacked shift registers for this. i read the help section for them but am still a little bit confused. I tried bundling them together and trying to cluster them, but no results would show. I am wondering if someone can explain to me what im doing wrong and put me on the right path, or if there is a simpler way of achieving what i want. My Vi is attached. 

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

Shift registers are like "memories from the previous iteration" (except they can be initialized to have meaning on the first iteration).  I've "adjusted" your example to show how stacked Shift Registers work -- they give you the previous, previous-previous, and previous-previous-previous values (all can be initialized or left "uninitialized", whereupon they take the default value for the variable).

Stacked Shift Registers.png

I recently used a Stacked Shift Register to get a running average of the last three values of a measurement, wanting to keep measuring until the value was "stable" (meaning the three were about the same value).  To make it more robust, I was considering using the last 10 values, but didn't want to deal with more Shift Registers, so I instead used an array of 10 numbers, on each loop added a number in the next Array position using (Loop Index) Mod 10 to keep the last 10 values in the Array, then simply returned the mean of the array when the standard deviation of the array was small.  Now it is easy to "change my mind" and use an array of 5, or of 20, by just changing a single "Size of Circular Buffer" (that's the fancy name for an array where you keep updating numbers "going around in a circle").  It is easy to implement, is more flexible, and can sometimes be easier to understand than a Stacked Shift Register.

 

Bob Schor

0 Kudos
Message 2 of 4
(5,520 Views)

thank you Bob Schor for the quick reply and help with understanding shift registers better

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

also would you be able to direct me as to how i should go about making it so that if three of the same output occurs, a new string is shown?

0 Kudos
Message 4 of 4
(5,500 Views)