09-20-2021 07:27 AM
Hi!
I know very little about filtering, and need some help finding the right function to use in CVI to accomplish what I want. I have some data that I filter using a low-pass, 4th order Butterworth filter. For this I use the function Bw_LPF(...). This introduces a phase shift which is unwanted. When I googled, I came across a pedagoical explanation (Butterworth filter "regular" and "zero phase" (siemens.com)) that said that it's part of the Butterworth process, but that it can be circumvented if you have access to all data at once (because you can then rely both on future data and past data instead of simply past data to do the filtering), and I do have all data that I want to filter.
Is there a function in CVI to do this? Added an example as an attachment (blue is original data, green is Bw-filtered).
Thanks!
Solved! Go to Solution.
10-11-2021 10:40 AM
That is an awesome find, and looks like it could be very useful for many people. To answer your question, one of the linked articles goes into more detail. Check section 5.1 on https://community.sw.siemens.com/s/article/introduction-to-filters-fir-versus-iir . It says you reverse the results (Output_Array), and feed it into the filter again. Likely after getting this new response you reverse the order again. The article says you lose some data at the end per figure 16.
10-12-2021 03:06 AM
Thanks for your answer and the article link. I have experimented around some more, and I have found that you can filter using a "general" filter functions instead of using Bw_LPF() directly, and these have more options. For instance, there is one called ZeroPhaseFiltering() which takes "forward" and "reverse coefficients" which are defined by your filter function, order, cutoff frequency and so forth. In my case I used the function called Bw_Coef() to get the coefficients, and then fed them to the ZeroPhaseFiltering function along with the data I wanted to filter.
From what I understand, it does exactly what you describe - filter twice. I have noticed two "artefacts" from this method, most of which are mentioned in the article you linked:
But anyhow, the phase shift is gone, so I'm pleased!