Main Content

QPSK Receiver with USRP Hardware

This example shows how to use the Universal Software Radio Peripheral® (USRP™) device using SDRu (Software Defined Radio USRP) System objects to implement a QPSK receiver. The receiver addresses practical issues in wireless communications, such as carrier frequency and phase offset, timing offset and frame synchronization. This system receives the signal sent by the QPSK Transmitter with USRP Hardware example at bit rate of upto 1 Mbps. The receiver demodulates the received symbols and prints a simple message to the MATLAB® command line.

Please refer to the Setup and Configuration section of Guided USRP Radio Support Package Hardware Setup for details on configuring your host computer to work with the SDRu Receiver System object.


This example describes the MATLAB implementation of a QPSK receiver with USRP Hardware. There is another implementation of this example that uses Simulink®.

MATLAB script using System objects: QPSKReceiverWithUSRPHardwareExample.m

Simulink implementation using blocks: sdruqpskrx.slx.

You can also explore a simulation only QPSK Transmitter and Receiver example without SDR hardware that models a general wireless communication system using an AWGN channel and simulated channel impairments at QPSK Transmitter and Receiver.


This example has the following motivation:

  • To implement a real QPSK-based transmission-reception environment in MATLAB using SDRu System objects.

  • To illustrate the use of key Communications Toolbox™ System objects for QPSK system design, including coarse and fine carrier frequency compensation, timing recovery with bit stuffing and stripping, frame synchronization, carrier phase ambiguity resolution, and message decoding.

In this example, the SDRuReceiver System object receives data corrupted by the transmission over the air at sample rate of 1 Msps and outputs complex baseband signals which are processed by the QPSK Receiver System object. This example provides a reference design of a practical digital receiver that can cope with wireless channel impairments. The receiver includes correlation-based coarse frequency compensation, PLL-based fine frequency compensation, timing recovery with fixed-rate resampling and bit stuffing/skipping, frame synchronization, and phase ambiguity resolution.

Discover Radio

Discover radio(s) connected to your computer. This example uses the first USRP radio found using the findsdru function. Check if the radio is available and record the radio type. If no available radios are found, the example uses a default configuration for the system.

connectedRadios = findsdru
Checking radio connections...
linux; GNU C++ version 10.3.0; Boost_107800; UHD_4.2.0.0-vendor

---------- see libuhd version information above this line ----------
connectedRadios = struct with fields:
     Platform: 'B200'
    IPAddress: ''
    SerialNum: '30EA06C'
       Status: 'Success'

if strncmp(connectedRadios(1).Status, 'Success', 7)
  platform = connectedRadios(1).Platform;
  switch connectedRadios(1).Platform
    case {'B200','B210'}
      address = connectedRadios(1).SerialNum;
    case {'N200/N210/USRP2','X300','X310','N300','N310','N320/N321'}
      address = connectedRadios(1).IPAddress;
  address = '';
  platform = 'N200/N210/USRP2';


The sdruqpskreceiver_init.m script initializes the simulation parameters and generates the structure prmQPSKReceiver.

USRPGain            = 35;
USRPCenterFrequency = 915000000;
captureTime         = 10;
sampleRate          = 1000000;
isHDLCompatible     = false;  % disable to run 'FFT-Based' coarse frequency compensation instead of 'Correlation-Based' for improved performance in MATLAB version.
printReceivedData   = false;  % enable to print received data

% Receiver parameter structure
prmQPSKReceiver = sdruqpskreceiver_init(platform, address, sampleRate, USRPCenterFrequency, ...
    USRPGain, captureTime, isHDLCompatible);

Note: To receive successfully, ensure that the specified center frequency of the SDRu Receiver is within the acceptable range of your USRP daughterboard.

Code Architecture

The function runSDRuQPSKReceiver implements the QPSK receiver using two System objects, QPSKReceiver and comm.SDRuReceiver.

SDRu Receiver

This example communicates with the USRP board using the SDRu receiver System object. The parameter structure prmQPSKReceiver sets the CenterFrequency, Gain, and InterpolationFactor etc.

QPSK Receiver

This component regenerates the original transmitted message. It is divided into five subcomponents, modeled using System objects. Each subcomponent is modeled by other subcomponents using System objects.

1) Automatic Gain Control: Sets its output power to a level ensuring that the equivalent gains of the phase and timing error detectors keep constant over time. The AGC is placed before the Raised Cosine Receive Filter so that the signal amplitude can be measured with an oversampling factor of two. This process improves the accuracy of the estimate.

2) Coarse frequency compensation: Uses a correlation-based algorithm to roughly estimate the frequency offset and then compensate for it. The estimated coarse frequency offset is averaged so that fine frequency compensation is allowed to lock/converge. Hence, the coarse frequency offset is estimated using a comm.CoarseFrequencyCompensator System object and an averaging formula; the compensation is performed using a comm.PhaseFrequencyOffset System object.

3) Timing recovery: Performs timing recovery with closed-loop scalar processing to overcome the effects of delay introduced by the channel, using a comm.SymbolSynchronizer System object. The object implements a PLL to correct the symbol timing error in the received signal. The rotationally-invariant Gardner timing error detector is chosen for the object in this example; thus, timing recovery can precede fine frequency compensation. The input to the object is a fixed-length frame of samples. The output of the object is a frame of symbols whose length can vary due to bit stuffing and stripping, depending on actual channel delays.

4) Fine frequency compensation: Performs closed-loop scalar processing and compensates for the frequency offset accurately, using a comm.CarrierSynchronizer System object. The object implements a phase-locked loop (PLL) to track the residual frequency offset and the phase offset in the input signal.

5) Preamble Detection: Detects the location of the known Barker code in the input using a comm.PreambleDetector System object. The object implements a cross-correlation based algorithm to detect a known sequence of symbols in the input.

6) Frame Synchronization: Performs frame synchronization and, also, converts the variable-length symbol inputs into fixed-length outputs, using a FrameSynchronizer System object. The object has a secondary output that is a boolean scalar indicating if the first frame output is valid.

7) Data decoder: Performs phase ambiguity resolution and demodulation. Also, the data decoder compares the regenerated message with the transmitted one and calculates the BER.

For more information about the system components, refer to the QPSK Receiver with USRP Hardware in Simulink.

Execution and Results

Before running the script, first turn on the USRP and connect it to the computer. To ensure data reception, first start the QPSK Transmitter with USRP Hardware example.

[BER, overflow] = runSDRuQPSKReceiver(prmQPSKReceiver, printReceivedData); 
fprintf('Error rate is = %f.\n', BER(1));
Error rate is = 0.000045.
fprintf('Number of detected errors = %d.\n', BER(2));
Number of detected errors = 306.
fprintf('Total number of compared samples = %d.\n', BER(3));
Total number of compared samples = 6845300.
fprintf('Total number of overflows = %d.\n', overflow);
Total number of overflows = 1.

When you run the experiments, the received messages are decoded and printed out in the MATLAB command window while the simulation is running. BER information is also shown at the end of the script execution. The calculation of the BER value only on the message part (Hello world), when some of the adaptive components in the QPSK receiver still have not converged. During this period, the BER is quite high. Once the transient period is over, the receiver is able to estimate the transmitted frame and the BER dramatically decreases. In this example, to guarantee a reasonable execution time of the system in simulation mode, the simulation duration is fairly short. As such, the overall BER results are significantly affected by the high BER values at the beginning of the simulation. To increase the simulation duration and obtain lower BER values, you can change the captureTime.

Also, the gain behavior of different USRP daughter boards varies considerably. Thus, the gain setting in the transmitter and receiver defined in this example may not be well-suited for your daughter boards. If the message is not properly decoded by the receiver system, you can vary the gain of the source signals in the comm.SDRuTransmitter and comm.SDRuReceiver System objects by changing the USRPGain. Besides, preamble detector's threshold also affects the decoded message. If you see recurrent garbled messages, please try to increase the preamble detector's threshold as the following steps are trying to decode the header. If you cannot see any output message, try to decrease the threshold in the receiver initialization file.

Finally, a large relative frequency offset between the transmit and receive USRP radios can prevent the receiver functions from properly decoding the message. If that happens, you can determine the offset by sending a tone at a known frequency from the transmitter to the receiver, then measuring the offset between the transmitted and received frequency, then applying that offset to the center frequency of the SDRu Receiver System object. Besides, increase the maximum frequency offset in the receiver initialization file also helps.


This example uses the following script and helper functions:


1. Rice, Michael. Digital Communications - A Discrete-Time Approach. 1st ed. New York, NY: Prentice Hall, 2008.