LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cascade filter doesn't seem to reinitialize

Solved!
Go to solution

I'm using a cascade filter with butterworth coefficients in the attached vi. There are some values for input I can give the filter such that it causes the output to be an array of NaN. This is fine, except that when I give the filter the exact input that has already yielded a good result, it still outputs NaN. If I change the boolean input init/cont to false, run it once, then change it to true, the filter works fine. Is the data somehow getting left over in the filter? Or is there something I can do to stop this from happening? Thanks.

 

John 

0 Kudos
Message 1 of 4
(2,713 Views)

Hi John,

 

If you look at the VI, there is an uninitialized shift register.  Essentially between runs, this shift register holds the previous values it contained, which would explain why you still see the NaN values.  What you'll need to do is set the Init/Cont constant to true to clear out that shift register.  

 

CascadeVI.png 

0 Kudos
Message 2 of 4
(2,693 Views)

Thanks Kyle. Unfortunately, as you can see in my attached vi, I already have that constant set to true. The only way this problem disappears is if I set it to false, run the vi once, then set it to true again. So from my perspective, the init/cont option does not work. Any other ideas? Thanks.

 

John 

0 Kudos
Message 3 of 4
(2,665 Views)
Solution
Accepted by topic author John Lipor

Hi John,

 

Turns out I also need to read the LabVIEW Help better.  If you look at (http://zone.ni.com/reference/en-XX/help/371361F-01/lvanls/iir_cascade_filter/), this constant works opposite than what we want.  Essentially, it initializes the VI when set to false and uses previous data when set to true.  What you can do in your VI to make sure each run starts with fresh data is to use the First Call? function and invert it. When the First Call? is called at the beginning of execution, it outputs True;  False is output for all other iterations.  If we invert this, you get False (Initialize in this case) on the first iteration of the Cascade filter and True for every other call of the VI.

 

cascade_firstcall.png 

Message 4 of 4
(2,662 Views)