LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Correct application of a 50Hz filter

Solved!
Go to solution

Hi,

I need to apply a 50Hz filter to a DAQ signal acquisition (just noise for the testing).

When I apply the filter, the resulting signal has huge oscillations in the first part of the acquired signal (as you see in "Filter output.png"), after those oscillations the signal becomes filtered as it should.

I tried to change the sampling rate, the acquisition rate of the signal, and all other parameters, but I can't get rid of these oscillations.

What am I missing? 

In "Diagram.png" you see the diagram of the filter.

The signal is acquired at 10k rate and comprises 30k points.

 

I have some experience with Labview, but I never used its filters.

 

Thanks for the help

 

Filter output.png

 

Diagram.png

Download All
0 Kudos
Message 1 of 7
(4,835 Views)
Hi,

do you really expect to filter a 2Hz band in a signal of 10kHz sample rate with a 2nd order filter?

How does the input signal look like?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(4,814 Views)

Thank GerdW

What do you mean by 2Hz band?

The original signal is pretty much similar to the last part of the filtered signal, only with higher amplitude of the noise.

There is no band in the original signal, it's flat.

Also, I I changed the order to higher values but the large oscillations at the beginning were there as well.

 

Regards

Alastor

 

0 Kudos
Message 3 of 7
(4,811 Views)
Solution
Accepted by topic author Alastor2016

The resolution on your image is a little low to be sure but it looks like you have a significant offset in the data.  An offset can drive the transient response of the filter. With a narrow bandwidth filter that can produce an oscillatory response.

 

With your noise input you get very little energy in the filter stop band so it can be hard to see the effect. When I simulate your signal with offset the stop band is almost impossible to detect. The noise in each bin is about 60 dB below the offset and the stopband attenuation is about the same.  Without the offset the stopband is detectable (visually on a graph) about one fourth of the time. With 300000 samples it is almost always visible with or without the offset.  See the image below.

 

Filter response.png This is the spectrum of random noise with offset 5 times amplitude and 300000 samples.

 

Generally the narrower the frequency response of a filter, the stronger the transient response.

 

Lynn

Message 4 of 7
(4,796 Views)

Yes there is a small offset in my data.

So this could be the reason of the long transient response time I see in the filtered signal?


In such a case I would just need to substract a constant offset from the data in order to bring it around zero, right?

 

Thanks johnsold

Alastor

 

0 Kudos
Message 5 of 7
(4,791 Views)

Alastor,

 

An offset can certainly be part of the problem. I usually subtract the Mean of the data set when I need to remove an offset.  If there is drift in the baseline (meaning that the offset changes continuously), then more sophisticated methods may be required.

 

Lynn

0 Kudos
Message 6 of 7
(4,772 Views)

Thans Johnsold,

by eliminating the offset and enlarging slightly the frequency range I could get an acceptable signal.

Michele

0 Kudos
Message 7 of 7
(4,698 Views)