Sample Rate Change

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 demonstrates 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 GUI Frequency Sink



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)



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



The Interpolating FIR Filter increases 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:



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



Edit the Throttle property:
 * Sample Rate: samp_rate_interpolated

Edit the QT GUI Frequency Sink property:
 * Bandwidth (Hz): samp_rate_interpolated

The flowgraph looks like the following:



Running the flowgraph shows the following QT GUI Frequency Sink:



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



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.



Decimation (Source hardware example)
Where interpolation increases the sample rate, decimation decreases the sample rate and available bandwidth.

The following discussion is based on the flowgraph of a RadioTeleTYpe (RTTY) receiver. It can be found at RTTY_receive.grc



Frequency shift keying (FSK) tones are input to the microphone jack of the computer which has a sample rate of 48 kHz. That data is fed to a Frequency Xlating FIR Filter which shifts the tones above and below the center frequency. It also decimates (divides) the sample rate by 50, producing an output sample rate of 960.

The Quadrature Demod produces a signal which is positive or negative depending on whether the tone is above or below the center frequency.

The RTTY symbol time is, by definition, exactly 22 ms. yielding the familiar 45 baud (1/0.022 rounded). To get an integer number of samples per symbol, a sample rate of 500 was chosen, producing 11 samples per symbol time. (500 samples/sec * 0.022 seconds = 11 samples).

The output of the Quadrature Demod block has a sample rate of 960; the desired sample rate is 500. The Rational Resampler interpolates (multiplies) the sample rate by 500 and decimates (divides) it by 960 to produce an output sample rate of 500.

The Binary Slicer produces an output of +1 for inputs greater than zero, and 0 for inputs less than zero.

The 'Terminal Display Sink' is an Embedded Python Block which reads the input stream of 1's and 0's, synchronizes on the start bit, creates a Baudot character from the five data bits, converts Baudot to UTF-8, and outputs the characters to a ZMQ PUSH Message Sink.

The gr-webserver package can receive the messages from the message sink and display them on a browser screen.