17

For digital notch filters, I like to use the following form for a notch filter at DC ( $ \omega $=0): $$ H(z) = \frac{1+a}{2}\frac{(z-1)}{(z-a)} $$ where $a$ is a real positive number < 1. The closer $a$ is to 1, the tighter the notch (and the more digital precision needed to implement). This is of the form with a zero = 1, and a pole = $a$, where $a$ is ...


12

In reviewing fred harris Figures of Merit for various windows (Table 1 in this link) the Hamming is compared to the Hanning (Hann) at various values of $\alpha$ and from that it is clear that the Hanning would provide greater stopband rejection (The classic Hann is with $\alpha =2$ and from the table the side-lobe fall-off is -18 dB per octave). I provided ...


11

You asked how a low pass filter works and mentioned that the filter uses past values of you're data. This is a non-technical discussion of what happens in a low pass filter. The low pass filter takes differing views (shifted in time) of your signal, scales them and adds them together. You can imagine drawing your signal 3 times, one being current, the ...


11

If you only have a finite number of samples and are using a finite length FFT, then you will end up with a finite number of FFT frequency result bins. Each bin has a one-to-one relationship ONLY with frequencies that are exactly integer periodic in the FFT length. Any other spectrum frequencies that are not exactly periodic in the FFT aperture will not ...


11

To be able to analyze what a low pass filter does first you would need to understand what a Fourier transform is, hence some theory first. The Fourier transform essentially represents the time-domain information stored in some function (a square wave in your case) in terms of frequencies. A simple example would be a sine wave $sin(2\pi f_{c} t)$ which ...


11

The given single-pole IIR filter is also called exponentially weighted moving average (EWMA) filter, and it is defined by the following difference equation: $$y[n]=\alpha x[n]+(1-\alpha)y[n-1],\qquad 0<\alpha<1\tag{1}$$ Its transfer function is $$H(z)=\frac{\alpha}{1-(1-\alpha)z^{-1}}\tag{2}$$ The exact formula for the required value of $\alpha$ ...


9

This answer provides a quick introduction to decimation concepts and CIC filters which I would consider as one solution given the description. Bottom Line First Given your use of a microcontroller, (implied emphasis on minimizing resources), and that you indicated you do not need a high performance filter- consider doing everything with Cascade-Integrator-...


9

I'm new, so I can't add this comment to Matt L.'s answer. It is not an exponential filter, the equation is actually: $$ y[n] \ = \ \alpha \, x[n] \ + \ ( 1 - \alpha ) \, x[n-1] $$ So it is a very short FIR filter, not an IIR filter. I'm not expert enough to know a specific name. Ced ============================================= Followup: I want to ...


9

You should not be using the analog filter - use a digital filter instead. You want the filter to be defined in Z-domain, not S-domain. Also, you should define the time vector with known sampling frequency to avoid any confusion. The design of the digital filter requires cut-off frequency to be normalized by fs/2. Here is a working example: import numpy as ...


8

You need a filter whose transfer function evaluated at 0 (DC component) is 1, or equivalently, whose impulse response sums to 1.


8

Two exact sine waves of the same frequency but different phases sum to another exact sine wave. That resultant sine wave can be decomposed into an infinite numbers of pairs (or any other greater number) of sine waves of the same frequency, not just the two original ones. Thus more information is required to reduce the possible solution space below infinite....


8

$E_1=E_{10}sin (\omega t)$ $E_2=E_{20}sin (\omega t + \delta)$ $E_{\theta} = E_1 + E_2 = E_{\theta0}sin (\omega t + \phi )$ This can be described as the figure below: Now given the $E_{\theta 0}$, you can rotate $E_1$ and $E_2$ arbitrarily as long as $E_1$ , $E_2$, and $E_{\theta 0}$ form the triangular. As a result, your given sine wave can be ...


8

The result will indeed be a high pass filter. From your difference equation, the transfer function of the low pass filter is $$H_l(z)=\frac{\beta}{1-(1-\beta)z^{-1}}\tag{1}$$ with $\beta=1/\alpha$. Note that this is actually a leaky integrator, not a classic low pass filter, because its frequency response does not have a zero at Nyquist. The high pass ...


8

In general you can't simply subtract a low-pass filtered version of a signal from the original one to obtain a high-pass filtered signal. The reason is as follows. What you're actually doing is implement a system with frequency response $$H(\omega)=1-H_{LP}(\omega)\tag{1}$$ where $H_{LP}(\omega)$ is the frequency response of the low-pass filter. Note that $...


8

Yes. This looks like it's a typical first order low pass. The time constant can be determined by looking at the time it takes for the falling edge to drop to 37% of the max amplitude ($e^{-1}$). The cutoff frequency of the low pass filter is $1/(2 \cdot \pi \cdot t_c)$ where $t_c$ is the time constant


8

That formula for the cut-off frequency is a very inaccurate approximation. In this answer I derived the exact relation between the coefficient of a first order recursive averaging filter and its 3-dB cut-off frequency. Note that in the quoted answer I used the constant $\alpha=1-b$. From formula $(3)$ in that answer we get for the coefficient $b$ $$b = 2-\...


8

I don't get your downsample step when you downsampled by factor $M$. Let me go from scratch with the spectrum visualization below, with time domain, continuous frequency domain and discrete frequency domain from left to right. When we reduce the sampling frequency by a factor $k$, the signal spectrum is copied to new replicas at $f_s/k$. The discrete ...


7

Convolution in linear time-invariant system is asociative. So to get the equivalent mask you just need to convolve the kernel with itself twice. This will then then give you a 7x7 kernel: octave:1> a = [ 1 1 1 ; 1 1 1 ; 1 1 1 ] a = 1 1 1 1 1 1 1 1 1 octave:2> conv2(a,conv2(a,a)) ans = 1 3 6 7 6 3 1 3 ...


7

There are three potential problems with what you are doing: Zeroing out the high frequencies causes ringing due to the Gibbs phenomenon. You are essentially multiplying the Fourier transform with a square function, which is equivalent to circularly convolving the time-domain data with the inverse transform of the square function, which is a sinc function. ...


7

Is removing values from FFT result same as filtering? Yes, as one would expect intuitively. Taking the FFT of a signal will give you a frequency domain interpretation of the signal, if you then modify the magnitude of frequency bins and take the inverse FFT you will have a signal which is 'filtered'. Why is this not an 'ideal' (low pass) filter? Consider ...


7

Typically the advantages of an FIR filter are that it is easy to obtain a linear phase response, and numerical stability is not normally a problem. An IIR filter typically requires fewer taps (as you have observed), so is more efficient computationally, but the phase response tends to be somewhat erratic, and numerical stability is more likely to be an ...


7

In the $s$-domain, the LPF-to-BPF transformation doubles the order of the filter. that is because the LPF has one transition from passband to stopband, but the BPF has two such transitions. Remember that when we do frequency response, we substitute $s=j\omega$. That is, we evaluate the $s$-plane transfer function $H(s)$ as $H(j\omega)$. The magnitude of $...


7

The Kalman filter is the optimal filter under various assumptions. You need to check whether those assumptions hold in your case: a) the model perfectly matches the real system, b) the entering noise is white and Gaussian and c) the covariances of the noise are exactly known. Without further detail I can't say whether your statement My experiments ...


6

The number float* array is a pointer to the array. It is a single number which contains the address of the first element of the array of float values. Usually, the initial condition (i.e. the initial 'past' elements of x and y) are 0, but if their values are not equal to 0 it is no big problem either, because after a while the initial conditions have no ...


6

As pointed out by niaren, you have to multiply by two, but this also means that your whole magnitude response is shifted up by 6dB, also in the stopbands. So you will have 6dB less stopband attenuation. Of course, the attenuation relative to the passband gain remains constant. You have to take this into account when designing your filter. Say you need 60dB ...


6

I am generating my waves in a "Raw" mathematical way, meaning that i am creating a ramp for a saw wave and my square wave consists of pure 1's and 0's. The issue is that this technique is inherently not band limited. I would like to implement low pass filter into the algorithm in order to filter of the harmonic being generated that are higher than the ...


6

Let us say your sample rate is 48kHz. You are generating a sawtooth wave at a fundamental frequency of 10kHz, using your code. First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz. But since your signal is inherently sampled at 48kHz, anything above Nyquist gets aliased back into the 0..24kHz band. The 30kHz harmonic is 6kHz above ...


6

The first basic test could be to use a unit impulse as an input signal and see if the output signal equals the impulse response (i.e. the filter coefficients). Another simple test signal is a unit step. The corresponding output should be the cumulative sum of the filter's impulse response, i.e. for $x[n]=u[n]$, the output must be $$y[n]=\sum_{k=0}^nh[k],\...


6

Filters do have a delay (a lag) since they do not act immediately on your signal. Also all samples before the time 0 are zeros, thus in general you will start from the "zero mark", as you said (just imagine your filter equation with all zeros). There are ways to make a filter to have a zero lag. It is done by so called zero-phase filtering, also known as ...


6

In principle you can, in practice you almost can. The square wave consits of sinusoids with frequencies that are at multiples of the fundamental one (the inverse of the length of one high and one low). These are called harmonics, as you already seem to know. The low pass filter can remove all frequencies above the fundamental one, and you are left with only ...


Only top voted, non community-wiki answers of a minimum length are eligible