04-15-2017 12:54 PM
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.
Solved! Go to Solution.
04-15-2017 01:36 PM
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).
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
04-15-2017 01:48 PM
thank you Bob Schor for the quick reply and help with understanding shift registers better
04-15-2017 02:07 PM
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?