# Lowpass Filter to Average sinusoid signal

How to get an average of a sinusoidal signal? The frequency of a signal is 50 Hz and could have harmonics, i.e. high THD.

I tried to use exponential moving average with low cut-off frequency (about 1.6 Hz) but is not work. basically the amplitude of the sinusoidal is big and the filter return a small sinusoidal not the average.

A good lowpass filter could work? or I should try a big moving average window? or just sum the values in a period and divide by the samples in that period to get arithmetic average. I need implement it in an embedded system.

How to get an average of a sinusoidal signal?

It's 0. Anything sinusoidal integrated over its period is 0, so in the limit of averaging time going to infinity, it's going to be zero.

I'll hence assume you're asking because you have the sum of a constant offset and a sinusoidal signal.

I tried to use exponential moving average with low cut-off frequency (about 1.6 Hz) but is not work. basically the amplitude of the sinusoidal is big and the filter return a small sinusoidal not the average.

That means the low-pass filter you chose (your EWMA) does not have sufficient (for your application) suppression at the frequencies appearing that you want to suppress (in your application).

So, design a better low pass filtr:

A good lowpass filter could work?

Yes, but if this really is a periodic signal of known frequency, something that has strong suppression at multiples of the fundamental suffices; you don't have to be great at suppressing all frequencies above a cutoff, just the ones where there's actual energy.

or I should try a big moving average window?

That is just a specific low-pass. It's usually not a good one, but in this case, with slight windowing, might be quite elegant, because it has frequency response with zeros every multiple of the inverse of its length.

or just sum the values in a period and divide by the samples in that period to get arithmetic average.

That is literally the same as a moving average.

• When I have a signal with big amplitude I need to normalize to filter? For example: fs = int(32e3) tf = .05 t = np.arange(int(tffs))*(1/fs) A = 115*np.sqrt(2) x = Anp.sin(2*np.pit*50) x1 = Anp.sin(2*np.pit*50) + 0.1 x2 = Anp.sin(2*np.pi*t*50) + 0.59 If I have A=1 the average get the value added. If the A = 115*np.sqrt(2) Looks like the average diverge. Mar 19 at 20:41
• no. A filter is a linear system. Mar 19 at 20:43
• I'll try to edit my question to add some figures and the methods I tried to use to get the average of a sinusoid. Mar 19 at 20:53
• Is this really going to change a lot about my answer? If this is a new question, it'd probably be better to ask it in a new question post! Mar 19 at 20:54
• I don't know. Because it's almost the same question. But I'll ask in another post. with code and figures. Mar 19 at 21:03