Clear Filters
Clear Filters

Error in demodulation QAM-16 signal

2 views (last 30 days)
Kazantcev
Kazantcev on 7 Jun 2024
Commented: Voss on 7 Jun 2024
% This code, after demodulation, produces a sequence of 4 values, although the number of values ​​should be equal to the modulation factor M. What could be the problem?
clc
close all
clear all
M = 16;
L=10000;
T=10;
W=43; %SNR
bits1 = randi([0 M-1], 1, L);
bits2 = randi([0 3], 1, L/T);
mod1 = qammod(bits1, M,'UnitAveragePower', true);
% scatterplot(mod1)
mod2 = qammod(bits2, 4, 'UnitAveragePower',true);
% scatterplot(mod2)
for i = 1:length(bits2)
sym(i,:)=[mod1((i-1)*T+1:i*T) mod2(i)];
end
f=0;
for k=1:L/T
for j=1:T+1
f=f+1;
symbols(f)=sym(k,j);
end
end
% scatterplot(symbols)
% symbols = awgn(symbols,W,"measured");
pnoise = comm.PhaseNoise('Level',[-70 -104 -110],'FrequencyOffset',[1e4 1e5 2e5], 'SampleRate', 28e6);
symbols2 = pnoise([zeros(1e5,1);symbols']);
% symbols2 = pnoise(symbols);
fc = 1e6; % Carrier frequency in Hz
fs = 28e6; % Sample rate in Hz.
phNzLevel = [-70 -104 -110]; % in dBc/Hz
phNzFreqOff = [1e4 1e5 2e5]; % in Hz
Nspf = 6e6; % Number of Samples per frame
freqSpan = 400e3; % in Hz, for spectrum computation
sinewave = dsp.SineWave( ...
Amplitude=1, ...
Frequency=fc, ...
SampleRate=fs, ...
SamplesPerFrame=Nspf, ...
ComplexOutput=true);
pnoise = comm.PhaseNoise( ...
Level=phNzLevel, ...
FrequencyOffset=phNzFreqOff, ...
SampleRate=fs);
sascopeRBW100 = spectrumAnalyzer( ...
SampleRate=fs, ...
Method="welch", ...
FrequencySpan="Span and center frequency", ...
CenterFrequency=fc, ...
Span=freqSpan, ...
RBWSource="Property", ...
RBW=100, ...
SpectrumType="Power density", ...
SpectralAverages=10, ...
SpectrumUnits="dBW", ...
YLimits=[-150 10], ...
Title="Resolution Bandwidth 100 Hz", ...
ChannelNames={'signal','signal with phase noise'}, ...
Position=[79 147 605 374]);
x = sinewave();
y = pnoise(x);
sascopeRBW100(x,y)
symbols2 = symbols2(1e5+1:end);
prim(1,:)=symbols2(1:T);
for i = 1:length(bits2)-1
prim(i+1,:)=symbols2(i*T+i+1:i*T+i+T);
end
for b = 1:length(mod2)
qam4(b)=symbols2((T+1)*b);
end
h=0;
for u=1:L/T
for l=1:T
h=h+1;
priem(h)=prim(u,l);
end
end
for g = 1:L/T
phase_error(g) = angle(qam4(g) / mod2(g));
compensated4(g) = qam4(g) .* exp(-1i * phase_error(g));
end
for v = 1:L/T
phase_errorM((v-1)*T+1:v*T)=phase_error(v);
end
for f = 1:L
compensatedM(f) = priem(f) .* exp(-1i*phase_errorM(f));
end
demod=qamdemod(compensatedM, M, 'bin','OutputType','bit');
% scatterplot(qam4)
% scatterplot(symbols2)
% scatterplot(compensatedM)
[number,ratio]=biterr(bits1,demod);
evm = lteEVM(demod,bits1);
figure('Position',[200 200 1080 540])
subplot(1,2,1)
scatter(real(symbols2),imag(symbols2),300,".")
subplot(1,2,2)
scatter(real(compensatedM),imag(compensatedM),300,".")

Answers (1)

Voss
Voss on 7 Jun 2024
"the number of values ​​should be equal to the modulation factor M"
For a modulation order M, the number of bits per symbol is k=log2(M).
Put another way, using k bits per symbol produces M=2^k distinct symbols of length k bits.
So M=16 corresponds to k=log2(16)=4 bits per symbol.
  2 Comments
Kazantcev
Kazantcev on 7 Jun 2024
I can't make BER=0, I think, something is wrong with demodulation, in the demodulated sequence there are only numbers 5, 7, 13, 15. Now BER is equal to about half of all bit values, so what can I do to resolve this and make BER=0?
Voss
Voss on 7 Jun 2024
That question is very different than the original question. I think it should be its own question.
If my answer solves the original question satisfactorily, please "Accept" it. Thanks!

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!