09-12-2012 08:49 AM
So this is my attempt to mimic a function block that we use in our standard inverter software - 'Decimation Filter' which is nothing more than a running / moving average. Sample size is adjustable at runtime from 2 - 64 samples (Decimation Factor). I have seen many topics on this and have used shift registers for averages around 4 samples large - but wanted to be able to change sample size without recompiling. I am new to LV so there are likely many better ways to do this.
All I want to have answered is related to clearing the array if the decimation factor is set to a number lower than the last time the loop executed. (The upper case statement - false is wired straight through)
The math around the shift register: creates an array index that cycles from 0 to (Decimation Factor -1). The index is then used to fill elements in the array (the rest being zeros). When Decimation Factor decreases I need to zero out elements in positions from (New Decimation Factor-1) to (Old Decimation Factor -1). So I tried various things, but the only thing that seems to work is the re-initialize the array. Which I think is less than optimal.
I Tried:
1) Leaving the output tunnel unwired for the true case and selecting 'use default if unwired' option - thinking I'd get a 64 element array of zeros. Doesn't seem to work.
2) An array constant wired to output tunnel in true case. When I monitor that after a decrease in decimation factor - the probe seems to indicate an array of no elements, not 64. And I cannot see how to specify the array size of an array constant.
If I use this in my application it will be running on a cRIO target.
Any help greatly appreciated.
Solved! Go to Solution.
09-12-2012 09:00 AM - edited 09-12-2012 09:05 AM
You already have your initialized array, why not use it? Wire your initialized array through in TRUE case. Or even better, use the Select? function.
09-12-2012 09:16 AM
Well that was easy. If not obvious (to me anyway).
Love this forum.