01-03-2013 03:11 PM
I'd like to filter from 1 to 8 signals with NI's "Butterworth Filter (DBL).vi". I'm sampling them continuously, so when I put them in a For Loop and filter more than one (using the filter's "init/cont (init:F)" input, the filter's internal state jumps between the various signals. One workaround is to put 8 of these Butterworth filters in parallel on a single VI's block diagram, but that is clunky. Is there a way to do this in a loop where I'm storing each signal's filtering coefficients in a shift register?
01-04-2013 12:09 PM
Hello Bmihura,
Thank you for posting on our support forums. I have been investigating your question regarding how to store the 'internal states' of the Butterwork Filter.vi. After looking into the coding of this VI, it appears that from the use of functional global variables and shift registers in the IIR Cascade Filter (DBL).vi, there will be a new instance for each block dropped onto the block diagram. So, if we were to auto-index a For Loop, we will run into this issue of having the 'internal states' crossing and jumping between the signals.
It appears that the only way to correctly implement your request is to perform the work around that you have already suggested; placing a Butterworth Filter.vi for every signal.
Please read this KnowledgeBase article for a more detailed explanation on this. This KB is regarding the Decimate (continuous) VI, but it also applies to the Butterworth Filter as well.
Unfortunately, this is how the implementation needs to be. Due to the architecture of the VIs, we need to ensure that a separate block is placed for each signal to ensure that the instances of the filter are different.
01-04-2013 02:09 PM
Would using a Parallel For provide a different instance for each call? It seems like it would since it would be executing them in parallel.
01-04-2013 04:40 PM
There are also two VIs which let you explicitly set initial conditions (mening the same as filter state): IIR Filter with I.C..vi and FIR Filter with I.C..vi. You can find them in Signal Processing -> Filters -> Advanced IIR/FIR. You can store the states and coefficients in 2D arrays. Here's general idea how should it work:
01-04-2013 08:52 PM
The_Hunt,
You have stated my question much more eloquently than I did. Now that I have the verbage down pat, I will look into your suggestions. Thanks for getting the wording clear!
I am being stubborn and still think that there is some way to do this in a loop, but once I read your link, I may be proven wrong.