From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initialization of a pt-by-pt filter vs regular filter

Hello,

 

I am trying to implement a bandpass filter with minimal phase error on a real-time system. I cascaded two second order butterworth filters, one lowpass and one hypass, both set with the same cutoff frequency. However, I am unsure if I am indeed minimizing phase error in this case.

 

One question I have is whether the initialization is done correctly. From LabVIEW help, for a regular filter, the Boolean must be set to true for it NOT to initialize, while for a pt-by-pt filter it seems as if the opposite behavior is the case. Is this true? I am wondering if that could be the source of my error. Currently, I have the boolean set to false for the pt-by-pt filter in the real time target.

 

If this is not the problem, do you have any other recommendations for this filtering issue?

 

Thanks

0 Kudos
Message 1 of 8
(3,502 Views)

villalro-

 

             The Init/Cont input controls the initialization of the filters. The default is False and if you leave it on this then the internal states of the filter will reset to 0 with every call of the VI. If you set it to true then it will get the last value of the internal state for the initial value. If you are calling this mutilple times and want to filter a large data sequence then set this to False on the first call and then True on all the rest. Have you also looked at the Equi-Ripple Bandpass.vi for your functionality? What error are you getting while using these VIs?

0 Kudos
Message 2 of 8
(3,486 Views)

While the regular Butterworth filter has that Init/Cont input you were mentioning, I am using the pt-by-pt filter (for use on Real Time systems). That VI has an input called "Initialize", and according to the Help menu, it seems as if it behaves the opposite way. I am trying to confirm if this is the case.

0 Kudos
Message 3 of 8
(3,469 Views)

villalro

 

Your understand is incorrect.  The boolean control "initialize" is used to initialize the filter status to zeros, typically the filter status refer to the buffered input and output signals. By default "initialize" is false which means do not initialize the filter status. The filter will be initialized when you run the filter VI for the first time or when you set "initialize" to true. In most of the cases, you do not need to care about this input. For some history reasons, this control is called "init/cont (init:F)" for normal filters, which is different from "initialize" for pt-by-pt filters, but they have no difference. 

 

An additional question, why not using band-pass filter instead of casecade low-pass and high-pass filters as you do?

 

Good luck!

 

 

0 Kudos
Message 4 of 8
(3,460 Views)

From what I have seen from testing the regular filters (not the pt-by-pt), the bandpass does not allow to have the same frequency as low and high cutoffs. In this case, there is a phase error when the actual frequency is slightly off the cutoff frequency. From what I tested, putting both in cascade, one lowpass and one highpass at the same frequency minimizes this phase error because they cancel each other almost perfectly in the vicinity of the cutoff frequency.

 

Let me know if this sounds logical to you.

0 Kudos
Message 5 of 8
(3,447 Views)

villalro-

 

                Well I guess that if the Bandpass Filter VI doesn't give you the functionality that you want and using a High Pass and a Low Pass filter does, then I say go with that. Good Luck!!

0 Kudos
Message 6 of 8
(3,432 Views)

On a related matter, I sometimes have a discontinuity in the real-time data (which is then being LP filtered), the filter stops operating until I manually toggle the initialise boolean. Is it sensible to write some code to detect the discontinuity and toggle the boolean or is there a better way to handle this?

0 Kudos
Message 7 of 8
(3,092 Views)

Hi grahamwebb,

 

What do you mean by the filter stops working?  Does it not filter anything?  Does it just return zeros?

 

Have a great day,

 

Chris V

Applications Engineer
National Instruments
0 Kudos
Message 8 of 8
(3,077 Views)