QPSK Transmitter Using Software-Defined Radio
R2026bThis example shows how to implement a QPSK transmitter using a software-defined radio (SDR). The transmitter modulates and transmits indexed "Hello world" messages at specified center frequency
The transmitter generates a message using ASCII characters, converts these characters to bits, and prepends a Barker code for receiver frame synchronization. This data is then QPSK modulated and filtered with a square root raised cosine filter. You can transmit the filtered QPSK symbols over the air using SDR. If the selected radio is ADALM-Pluto, the data rate is 1 Mbps and if the selected radio is USRP™, the data rate is 8Mbps. The USRP radio uses background processing to achieve higher samples like 8Msps.
To demodulate the transmitted message, see the QPSK Receiver Using Software-Defined Radio example.
Required Hardware and Software
To run this example, you need one of these USRP or ADALM-PLUTO radios and the corresponding hardware support package.
USRP™ N2xx series or B2xx series radio and Communications Toolbox Support Package for USRP Radio. For more information, see USRP Radio and Supported Hardware and Required Software.
USRP™ E320, N3xx, X3xx, or X4xx series radio and Wireless Testbench Support Package for NI USRP Radios. For more information, see Supported Radio Devices (Wireless Testbench).
ADALM-PLUTO radio and Communications Toolbox Support Package for Analog Devices® ADALM-PLUTO Radio. For more information, see ADALM-Pluto Radio.
Initialization

Select Radio
Select the required radio SDRName and Address. For more information about discovering radios, see findsdr.
SDRName ="B210"; Address =
"3136D08"; if strcmpi(SDRName,"Pluto") SDRType = "Pluto"; else SDRType = "USRP"; end radioStatus = findsdr(SDRType = SDRType, StatusType = "TxAvailable");
Checking radio connections ...
Clear the MATLAB™ workspace whenever you modify the SDR settings to ensure the transmitter re-initializes correctly.
Initialize Transmitter Parameters
The sdrQPSKTransmitterInit.m script initializes the simulation parameters and generates the structure prmQPSKTransmitter.
Different radios and RF cards support different center frequency ranges. For successful transmission, set the transmitter System object™ center frequency to a value that is supported by the selected RF card
if strcmpi(SDRName,'Pluto') sampleRate ="1000000"; % Sample rate of transmitted signal on Pluto radio SDRGain =
"0"; else sampleRate =
8000000; % Sample rate of transmitted signal on USRP radio SDRGain =
60; % Set radio gain end SDRCenterFrequency =
915000000; % Set radio center frequency SDRStopTime =
10; % Radio transmit time in seconds % Transmitter parameter structure prmQPSKTransmitter = sdrQPSKTransmitterInit(SDRName, Address, sampleRate, SDRCenterFrequency, ... SDRGain, SDRStopTime, radioStatus)
prmQPSKTransmitter = struct with fields:
ModulationOrder: 4
Interpolation: 2
Decimation: 1
Fs: 8000000
Rsym: 4000000
Tsym: 2.5000e-07
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.0014
RolloffFactor: 0.5000
ScramblerBase: 2
ScramblerPolynomial: [1 1 1 0 1]
ScramblerInitialConditions: [0 0 0 0]
RaisedCosineFilterSpan: 10
MessageBits: [11200×1 double]
Platform: "B210"
Address: "3136D08"
IsPluto: 0
IsRadioTxAvailable: [3×1 logical]
MasterClockRate: 16000000
USRPCenterFrequency: 915000000
USRPGain: 60
USRPFrontEndSampleRate: 8000000
USRPInterpolationFactor: 2
USRPFrameLength: 11226
SDRFrameTime: 0.0014
EnableBackgroundTransmission: 1
StopTime: 10
Code Architecture
The function runSDRQPSKTransmitter implements the QPSK transmitter using two System objects:
QPSKTransmitterto generate a transmission signal.Either
comm.SDRuTransmitterfor USRP orcomm.SDRTxPlutofor ADALM-PLUTO to transmit the signal over the air.
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 transmitter sends Barker code on both in-phase and quadrature components of the QPSK modulated symbols by repeating the Barker code bits twice before modulation.
The remaining bits form the payload, which contains 100 'Hello world ###' messages where '###' is an increasing sequence from '000' to '099'. You can change the number of messages in the sdrQPSKTransmitterInit.m initialization file. If you change it, make the corresponding change in the receiver initialization file.
A scrambler ensures a balanced distribution of zeros and ones for timing recovery at the receiver. The QPSK Modulator modulates the scrambled bits using Gray mapping.The Raised Cosine Transmit Filter upsamples the modulated symbols by two, and has roll-off factor of 0.5, producing an output rate of double the symbol rate.
USRP/PLUTO Transmitter
The host computer communicates with the USRP radio using the comm.SDRuTransmitter and with the ADALM-PLUTO radio using the comm.SDRTxPluto System object.
Execution
To verify that data transmits correctly, run the QPSK Receiver with software-defined radio example while the transmitter is running.
if prmQPSKTransmitter.IsRadioTxAvailable underruns = runSDRQPSKTransmitter(prmQPSKTransmitter); fprintf('Total number of underruns = %d.\n', underruns); else fprintf('The transmitter of the radio with address, %s, is not available.\n', Address); end
Total number of underruns = 1.
Troubleshooting
The gain behavior of ADALM-PLUTO and different USRP RF cards change considerably. Thus, the gain setting defined in this example may not be well suited for your RF cards. If the message is not properly decoded by the receiver object, you can vary the gain of the source signals in the SDR Transmitter and SDR Receiver System objects by changing the SDRGain value.







