OQPSK modulation / demodulation errors
3 views (last 30 days)
Show older comments
Hello,
I wrote this code trying to characterize BER vs. Eb/N0 for RC OQPSK which results in 50% errors (basically meaning the process is completely random) for all Eb/N0 values. That tells me the modulator/demodulator is not working.
close all
clear
clc
PulseShape = 'Normal raised cosine';
RolloffFactor = 0.25;
FilterSpanInSymbols = 4;
oqpskmod = comm.OQPSKModulator('BitInput',true);
oqpskdemod = comm.OQPSKDemodulator('BitOutput',true);
EbNo = [0:10]';
errorTot = zeros(length(EbNo),1);
txData = csvread("PRN15_Binary.csv")';
txData = txData(1:end-1);
txData = [1,1,1,1,0,0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,0,0,0,1]';
for i = 1:length(EbNo)
channel = comm.AWGNChannel('EbNo',EbNo(i),'BitsPerSymbol',2);
modSig = oqpskmod(txData);
rxSig = channel(modSig);
rxData = oqpskdemod(rxSig);
error = length(txData) - sum(txData==rxData);
errorTot(i) = errorTot(i) + error;
end
errorTot
errorTot = zeros(length(EbNo),1);
0 Comments
Answers (1)
Andrew Reibold
on 8 Mar 2024
It seems like there might be a couple of issues in your code.
1. BitInput/BitsPerSymbol Mismatch:
You have set 'BitInput' to true in the modulator, which means it expects input in bits. However, in the channel, you specified 'BitsPerSymbol' as 2. Ensure consistency in bit handling between the modulator and the channel.
2. AWGN Channel Initialization:
It's better to initialize the AWGN channel outside the loop to keep the noise consistent for each Eb/N0 value.
3. Data Size Mismatch:
Make sure the length of `txData` matches the number of bits required for the modulation scheme. For OQPSK, the number of bits per symbol is typically 2.
Here's an adjusted version:
close all
clear
clc
PulseShape = 'Normal raised cosine';
RolloffFactor = 0.25;
FilterSpanInSymbols = 4;
oqpskmod = comm.OQPSKModulator('BitInput', true, 'PulseShape', PulseShape, 'RolloffFactor', RolloffFactor, 'FilterSpanInSymbols', FilterSpanInSymbols);
oqpskdemod = comm.OQPSKDemodulator('BitOutput', true, 'PulseShape', PulseShape, 'RolloffFactor', RolloffFactor, 'FilterSpanInSymbols', FilterSpanInSymbols);
EbNo = [0 0:20]';
errorTot = zeros(length(EbNo), 1);
% Initialize AWGN channel outside the loop
channel = comm.AWGNChannel('BitsPerSymbol', 2);
%Temporarily Commenting out CVS Read
%txData = csvread("PRN15_Binary.csv")';
%txData = txData(1:end-1);
txData = [1,1,1,1,0,0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,0,0,0,1]';
for i = 1:length(EbNo)
% Set EbNo for each iteration
channel.EbNo = EbNo(i);
modSig = oqpskmod(txData);
rxSig = channel(modSig);
rxData = oqpskdemod(rxSig);
% Count errors
error = sum(txData ~= rxData);
errorTot(i) = errorTot(i) + error;
end
errorTot
(This code ran without error in Matlab 2023B.)
This code possibly addresses the mentioned issues... Let me know if this answered your question, resulted in follow up questions, or if your quesiton was totally misunderstood.
0 Comments
See Also
Categories
Find more on Propagation and Channel Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!