Main Content

QPSK Transmitter 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 transmitter. The USRP device in this system will keep transmitting indexed "Hello world" messages at its specified center frequency and at bit rate of 1 Mbps. You can demodulate the transmitted message using the QPSK Receiver with USRP™ Hardware example with an additional USRP device.

Required Hardware and Software

To run this example, you will need one of the following hardware and the corresponding software support package

Select Radio

Select the required radio platform from the available radios. For more information regarding discovery of radios see findsdru for USRP radios.

platform = "B200";
address  = '30EA06C';

Initialization

sdruqpsktransmitter_init.m script initializes the simulation parameters and generates the structure prmQPSKTransmitter.

USRPGain            = 35;  % Set USRP radio gain
USRPCenterFrequency = 915000000;  % Set USRP radio center frequency
stopTime            = 1000;  % USRP radio transmit time in seconds
sampleRate          = 1000000;  % Sample rate of transmitted signal

% Transmitter parameter structure
prmQPSKTransmitter = sdruqpsktransmitter_init(platform, address, sampleRate, USRPCenterFrequency, ...
    USRPGain, stopTime)
prmQPSKTransmitter = struct with fields:
               ModulationOrder: 4
                 Interpolation: 2
                    Decimation: 1
                            Fs: 1000000
                          Rsym: 500000
                          Tsym: 2.0000e-06
                    BarkerCode: [1 1 1 1 1 -1 -1 1 1 -1 1 -1 1]
                  BarkerLength: 13
                  HeaderLength: 26
                       Message: 'Hello world'
                 MessageLength: 16
               NumberOfMessage: 100
                 PayloadLength: 11200
                     FrameSize: 5613
                     FrameTime: 0.0112
                 RolloffFactor: 0.5000
                 ScramblerBase: 2
           ScramblerPolynomial: [1 1 1 0 1]
    ScramblerInitialConditions: [0 0 0 0]
        RaisedCosineFilterSpan: 10
                   MessageBits: [11200×1 double]
                      Platform: "B200"
                       Address: '30EA06C'
               MasterClockRate: 20000000
           USRPCenterFrequency: 915000000
                      USRPGain: 35
        USRPFrontEndSampleRate: 1000000
       USRPInterpolationFactor: 20
               USRPFrameLength: 11226
                 USRPFrameTime: 0.0112
                      StopTime: 1000

To achieve a successful transmission, ensure that the specified center frequency of the SDRu Transmitter is within the acceptable range of your USRP daughterboard.

Code Architecture

The function runSDRuQPSKTransmitter implements the QPSK transmitter using two System objects, QPSKTransmitter and comm.SDRuTransmitter.

QPSK Transmitter

The transmitter includes the Bit Generation, QPSK Modulator and Raised Cosine Transmit Filter objects. The Bit Generation object generates the data frames. The Barker code is sent on both in-phase and quadrature components of the QPSK modulated symbols. This is achieved by repeating the Barker code bits twice before modulating them with the QPSK modulator.

The remaining bits are the payload. The payload contains 100 'Hello world ###' messages, where '###' is an increasing sequence of '000', '001', ... '099' in binary forms. The number of messages is tunable via the initialization file, namely transmitter initialization file. Please make corresponding changes in the receiver initialization file, receiver initialization file. The payload is then scrambled to guarantee a balanced distribution of zeros and ones for the timing recovery operation in the receiver object. The scrambled bits are modulated by the QPSK Modulator (with Gray mapping). The Raised Cosine Transmit Filter upsamples the modulated symbols by two, and has roll-off factor of 0.5. The output rate of the Raised Cosine Filter is set to be 1M samples per second with a symbol rate of 0.5M symbols per second. Please match the symbol rate of the transmitter model and the receiver model correspondingly.

SDRu Transmitter

The host computer communicates with the USRP radio using the SDRu transmitter System object. The CenterFrequency, Gain, and InterpolationFactor arguments are set by the parameter variable prmQPSKTransmitter.

Execution

Before running the script, first turn on the USRP radio and connect it to the computer. As already mentioned, you can check the correct data transmission by running the QPSK Receiver with USRP Hardware example while running the transmitter script.

underruns = runSDRuQPSKTransmitter(prmQPSKTransmitter);
fprintf('Total number of underruns = %d.\n', underruns);
Total number of underruns = 143.

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 object, you can vary the gain of the source signals in the SDRu Transmitter and SDRu Receiver System objects by changing the USRPGain value.

Also, 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.

Appendix

This example uses the following script and helper functions:

  • runSDRuQPSKTransmitter.m

  • sdruqpsktransmitter_init.m

  • QPSKTransmitter.m

  • QPSKBitsGenerator.m