Let's say I have a signal which is composed of 2Hz,10Hz,17Hz,19Hz and 25Hz discrete time sinusoidal waves and I need to allow only 17Hz component to pass.

As far as I know, the standard way to approach the problem is implementing a Band Pass Filter.( Analog Prototype Filter -> Analog Filter -> Digital filter using Bilinear Transformation).

We can also implement DFT on the signal and use the information from the spectrum and then reconstruct the 17Hz component,right? If yes, which method is preferred and why?

  • 4
    $\begingroup$ When designing something digital, it usually doesn't make very much sense to design it as analog system first and then convert it to a somewhat equivalent digital system. But we also do not use simple DFT bin-based filtering, mainly for leakage reasons. So, I'd say, both approaches are probably suboptimal $\endgroup$ – Marcus Müller May 25 '17 at 7:22
  • $\begingroup$ So how should I solve the above mentioned problem in Matlab or elsewhere? $\endgroup$ – Ritik Madan May 25 '17 at 8:45
  • $\begingroup$ use the filter design tool? It comes with really extensive documentation $\endgroup$ – Marcus Müller May 25 '17 at 9:02
  • $\begingroup$ What Marcus said and also to add the option of using the firls command which is also well documented (least squared FIR filter design). But agreed, do not copy the analog that are limited mostly to what L's and C's can give you but use the algorithms that have been optimized for digital implementations. Let me know if you are really trying to suppress only these discrete tones specifically (or if this was just an example for a general question). If these specifically, I will detail an effective and simple approach. $\endgroup$ – Dan Boschen May 25 '17 at 10:21
  • $\begingroup$ @DanBoschen hm, aside from a combination of elegant aliasing and notch filters to suppress the unwanted tones, or a simple correlation receiver (i.e. matched filter to the sinusoid of interest), what'd be your approach? In this very specific case, a subspace-based spectrum estimator might do (e.g. MUSIC), but sounds a lot like overkill; thus, my approach would very likely be a straight BPF $\endgroup$ – Marcus Müller May 25 '17 at 12:28

If the frequencies to be rejected are the discrete frequencies given, and the sampling rate can be commensurate with these frequencies, then a moving average filter with the coefficients complex rotated to shift the response to 17 Hz can be done to reject all other integer frequencies as in the plot below.

rotated moving average

This is the concept of "heterodyning the coefficients" rather than heterodyning the signal. When we heterodyne a signal, the signal is multiplied by a complex rotator ($e^{-j\omega t})$ which will in the process shift it in frequency according to the rate of rotation. In similar fashion, rotating your coefficients will shift the response of the filter. So you can either move your signal to the filter as in a downconversion followed by a low pass filter... or move your filter to the signal as in this case!

Here is the Matlab/Octave code that implemented this filter.

In this case the sampling rate is 26 Hz with a complex (I and Q) signal path.

grid on
axis([0 26 -50 0])

(Note, this is the same frequency response as one bin in the DFT)

The coefficients themselves follow the pattern as shown in the following complex diagram, where the first 5 coefficients are labeled, and the rest can be followed along the trajectory lines shown. Observe that the magnitude of each coefficient is one (as in a moving average filter) but the phase is continuously rotated which causes the frequency response to shift at the rate of rotation.

complex taps

Update: As further suggested by @MarcusMüller in the comments, actually doing the signal homodyne followed by a low pass filter may likely be simpler in this case given that the OP has variable conditions for the signal of interest. Assuming the interference to be rejected is still discreet tones with an integer spacing relationship to the signal of interest (the signals need not be integer frequencies, but the multiplies of their spacing must be, as the nulls of a moving average filter will be located at n/T Hz where n is any integer and T is the time duration of the moving average in seconds).

So in this case we would first multiply the signal by $e^{-j2\pi 17 t}$ and then follow the (complex) output with a moving average filter (which means two filters, one for the I (in phase or real) path and one for the Q (quadrature or imaginary) path. In this case the moving average length as a minimum must be:

2Hz,10Hz,17Hz,19Hz and 25Hz

Move 17 to 0:

-12Hz, -7Hz, 0 Hz, 2Hz, 8Hz

And the least common multiple is 1 so a 1 second moving average is required with a commensurate sampling rate. Further as @MarcusMüller has suggested, this moving average structure could be implemented as a CIC decimating filter. The output would be the "DC Equivalent" of the signal of interest, with the same amplitude and phase as the signal at 17 Hz. Further if the signal that is desired changes in frequency, the phase rotator can be changed in one place rather than updating the taps as I had done.

For further reading see:

Phase rotator: Numerically Controlled Oscillator (NCO) for phasor implementation?

CIC: CIC Cascaded Integrator-Comb spectrum

Note also to be considered as a filtering approach is the 2nd order resonator (or cascade of two of these structures), based on a rotated exponential averaging filter. (see FFT analysis for Vibration Signal). The image of this filter structure is duplicated below (see link for details on what the variables mean and how to compute them):

tuned exponential averager

  • $\begingroup$ Ah, good ol' commutivity of the multiplication in freq domain :) was thinking of kind-of the opposite: apply a (decimating) real-tapped lpf after rotating 17 Hz to DC, allowing to detect the properties of the signal of interest directly from the filter's output $\endgroup$ – Marcus Müller May 26 '17 at 9:08
  • $\begingroup$ @DanBoschen Thank You for your answer. Will try to implement your approach to the problem. $\endgroup$ – Ritik Madan May 26 '17 at 11:29
  • $\begingroup$ @MarcusMüller Yes that would be good too and potentially simpler as it could by done with a CIC after the rotator. Note that we still need to maintain an I and Q path (otherwise if the signal tone of interest was at quadrature we would get no output if we just had a real path!). This would also allow for determining the complete information of the signal (phase and amplitude). $\endgroup$ – Dan Boschen May 26 '17 at 11:39
  • $\begingroup$ @RitikMadan What Marcus suggests is probably better given your variable conditions: You rotate your signal of interest to zero (multiply by $e^{-j\omega t}$) and then do a simple moving average filter on the I and Q outputs after phase rotation. Note that the nulls of the moving average filter will be spaced by n/T where T is the time duration of the average in seconds and n is an integer [1,2,3....]. $\endgroup$ – Dan Boschen May 26 '17 at 11:42
  • $\begingroup$ Ha! nice; the idea to actually put the f'-domain zeros of filter at the positions of the other tones is excellent! That gives high attenuation with very little taps :) and the fact that a (approximately, or actually) rectangular filter has periodic zeros makes that easy. $\endgroup$ – Marcus Müller May 26 '17 at 12:13

The bare DFT/IDFT method will only work if the 17 Hz component, and all other components, are pure unmodulated sinusoids that are exactly integer periodic in the DFT aperture.

If not, for sampled signals, a FIR band-pass filter approach (which can even be implemented by overlap add/save fast convolution using FFT/IFFTs) might be more appropriate. Possibly combined or cascaded in conjunction with FIR or IIR notch filters.

For an analog signal, you might also want to consider leaving it in the analog domain and not do any digital processing when filtering it.

  • $\begingroup$ @hotpaw32 I'm supposed to use a DSC which has the limitation of using at max a 4th order IIR filter and 32 point Moving average filter. $\endgroup$ – Ritik Madan May 26 '17 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.