LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with clearing array. Running Average

Solved!
Go to solution

Untitled.jpg

 

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.

 

 

0 Kudos
Message 1 of 3
(2,190 Views)
Solution
Accepted by topic author S1ack

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.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 2 of 3
(2,183 Views)

Well that was easy. If not obvious (to me anyway).

 

Love this forum.

 

0 Kudos
Message 3 of 3
(2,174 Views)