Applying filters on the ADC
This folder contains various examples for applying filters on the input ADC data, both for real time processing and for saving the data.
#
Filter on the Stream Processor#
filters_with_sp.pyUsing the StreamProcessing one can apply any IIR or FIR filter by convoluting the data with the filter's impulse response.
In this example we are applying two RF sources at 5.5 MHz and 15 MHz to the input, and using a 5th order Butterworth LPF filter in order to filter out the 15 MHz signal. The filter is created using the scipy package in Python, more filters can be found here: https://docs.scipy.org/doc/scipy/reference/signal.html
Note that we specifically choose two frequencies at close frequencies in order showcase the strength of this approach. We also use the built-in fft ability of the StreamProcessor in order to show the frequency response.
#
Filter on the OPX#
filters_with_windows.pyThis method is very efficient and can be used for realtime data processing and feedback.
#
Moving Window IntegrationIn this example we showcase how to use the built-in 'integration.moving_window' filter in order to apply a rectangular window (also known as the boxcar or Dirichlet window) directly on the incoming data. A moving window filter with constant weights can be described as the following function operating on the signal :
With C being the chunk_size (in units of ), the signal is assumed to be a cosine with frequency , is the sampling frequency, and is assumed to vary slowly. If the length of the integration, , is small such that we can assume that the cosine is constant, then we get:
On the other hand, if is large compared to the period of the cosine, then the summation will average out, and we will get 0. This puts the cutoff frequency at: .
Note that this procedure will also decimates the data with decimation of (), and it scales the data by ().
To summarize - using "integration.moving_window" can be used for directly applying an LPF on the data, with an integration window of length () This creates an LPF filter at a frequency of .
In the attached example, we are applying two RF sources at 20 MHz and 100 kHz to the input, and using 5 MHz filter (C = 50) to remove the 20 MHz.
#
Demodulation Moving Window IntegrationIn the case of the 'demod.moving_window', the signal is first multiplied by a cosine/sine.
We will demonstrate how this can be used as a Digital Down Converter. For simplicity, we will assume that our signal is composed of two close frequencies:
We will multiply our signal by a sine at the first frequency and look what happens to each of the terms:
We can now apply the same consideration as above, if our cutoff frequency is picked such that then we will end up with:
To summarize - using "demod.moving_window" can be used for extracting the baseband from an incoming modulated RF. The signal is multiplied by a cosine and/or a sine before applying the LPF filter.
In the attached example, we are applying two RF sources at 20 MHz and 20.1 MHz to the input. This creates a beating with an envelope of 100 kHz. We are a using 5 MHz filter (C = 50) to filter the remaining 40 MHz oscillation.
#
More InformationMore information about the moving window demodulation can be found here:
https://qm-docs.s3.amazonaws.com/v0.7/python/features.html#measure-statement-features
For a more complete description of the filter function, see here:
https://en.wikipedia.org/wiki/Dirichlet_kernel