Sample Rate Change: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
Line 114: Line 114:
Update the properties for the ''QT GUI Frequency Sink'' block:
Update the properties for the ''QT GUI Frequency Sink'' block:
* Bandwidth (Hz): ''samp_rate_decimated''
* Bandwidth (Hz): ''samp_rate_decimated''
The flowgraph will now look like the following:
[[File:DecimationFlowgraph.png|700px]]
Run the flowgraph and enable ''Max Hold''. Sweeping the frequency slider across positive frequencies will show the spectral shape of the ''Decimating FIR Filter'':
[[File:DecimationMaxHold.png|700px]]


== Rational Rate Resampling ==
== Rational Rate Resampling ==

Revision as of 15:40, 13 January 2022

Template:TutorialNavigation

This tutorial describes how to implement sample rate change within GNU Radio.

The previous tutorial, Designing Filter Taps, demonstrates how to design filter taps and use them in signal processing blocks. Please complete the Designing Filter Taps tutorial before completing this one.

Interpolation

Interpolation is the process of increasing the sampling rate and thus the available bandwidth. This example will demonstrate how to increase the sampling rate using the Interpolating FIR Filter block.

Start by adding the following blocks to the flowgraph and connect them:

  1. Two Variable blocks
  2. Low-Pass Filter Taps
  3. QT GUI Range
  4. Signal Source
  5. Interpolating FIR Filter
  6. Throttle
  7. QT Frequency GUI Sink

InterpolationFlowgraphStart.png


Edit the first of the two new variable blocks:

  • Id: interpolation_rate
  • Value: 4

Edit the second of the two new variable blocks:

  • Id: samp_rate_interpolated
  • Value: samp_rate*interpolation_rate"

Edit the properties of the Low-Pass Filter Taps block:

  • Id: lowPassTaps
  • Sample Rate (Hz): samp_rate_interpolated
  • Cutoff Freq (Hz): samp_rate_interpolated/(interpolation_rate*2)
  • Transition Width (Hz): samp_rate_interpolated/(interpolation_rate*4)

EditLowPassTapsProperties.png


Edit the properties of the QT GUI Range block:

  • Id: frequency
  • Default Value: 0
  • Start: -samp_rate/2
  • Stop: samp_rate/2

Edit the property of the Signal Source:

  • Frequency: frequency

Edit the properties of the Interpolating FIR Filter block:

  • Interpolation: interpolation_rate
  • Taps: lowPassTaps

InterpolatingFIRFilterProperties.png


The Interpolating FIR Filter will increase the sampling rate from 32 kHz to 128 kHz, a factor of 4 due to the interpolation_rate variable. Make a note of this by editing the Comment field under the Advanced tab:

AddCommentToBlock.png


The comment is then displayed as a visual reminder in GRC:

SampleRateBlockComment.png


Edit the Throttle property:

  • Sample Rate: samp_rate_interpolated

Edit the QT GUI Frequency Sink property:

  • Bandwidth (Hz): samp_rate_interpolated

The flowgraph should now look like the following:

InterpolationFinalFlowgraph.png


Running the flowgraph will show the following QT GUI Frequency Sink:

RunInterpolationFlowgraph.png


The four peaks come from the interpolation operation. Scroll-wheel-click on the window and enable Max Hold:

InterpolationClickMaxHold.png


Drag the frequency slider to show how the four peaks change in frequency, creating an outline of the frequency response of the Interpolating FIR Filter block. The interpolation has increased the sampling rate by a factor of 4, with the low-pass filter taps attenuating the spectral images to minimize distortion.

InterpolationMaxHoldOutline.png

Decimation

Where interpolation increases the sample rate, decimation decreases the sample rate and available bandwidth. Starting with the flowgraph from the previous Interpolation example, rename the interpolation_rate variable to decimation_rate. The flowgraph will now have some errors:

ChangeDecimationRateVariable.png


Change the samp_rate_interpolated variable:

  • Id: samp_rate_decimated
  • Value: samp_rate*decimation_rate

Change the Low-Pass Filter Taps block properties:

  • Sample Rate (Hz): samp_rate
  • Cutoff Frequency (Hz): samp_rate/(decimation_rate*2)
  • Transition Width (Hz): samp_rate/(decimation_rate*4)

Replace the Interpolating FIR Filter block with the Decimating FIR Filter block. Update the properties:

  • Decimation: decimation_rate
  • Taps: lowPassTaps

Update the properties for the Throttle block:

  • Sample Rate: samp_rate_decimated

Update the properties for the QT GUI Frequency Sink block:

  • Bandwidth (Hz): samp_rate_decimated

The flowgraph will now look like the following:

DecimationFlowgraph.png


Run the flowgraph and enable Max Hold. Sweeping the frequency slider across positive frequencies will show the spectral shape of the Decimating FIR Filter:

DecimationMaxHold.png

Rational Rate Resampling

Arbitrary Rate Resampling

  • updating sample rate variable