Why is my Bit Error Rate (BER) become constant, is my code incorrect?

11 views (last 30 days)
I am working to simulate the BER between 2 users in CDMA with convolutional codes and modulation scheme of QAM-16. From the graph i've attached, the BER of user 1 and user 2 are the same and constant. It seems that the SNR does not affect the transmission. Is there anyway i can improve the graph? Here is my code:
M = 16; % Modulation order
k = log2(M); % Bits per symbol
EbNoVec = (0:20)'; % Eb/No values (dB)
numSymPerFrame = 1; % Number of QAM symbols per frame
users=2; % Number of Users
trellis = poly2trellis(7,[171 133]);
tbl = 32;
rate = 1/2;
%------------------Generation of Walsh code--------------------------------
noOfSubCarrier =20; %Number of Data Sub-Carriers
walsh=hadamard(noOfSubCarrier);
code1=walsh(10,:);
code2=walsh(20,:);
berEst1 = zeros(size(EbNoVec));
berEst2 = zeros(size(EbNoVec));%Initialize the results vector
% The main processing loop executes the following steps:
% Generate binary data and convert to 64-ary symbols
% QAM modulate the data symbols
% Pass the modulated signal through an AWGN channel
% Demodulate the received signal
% Convert the demoduated symbols into binary data
% Calculate the number of bit errors
for n = 1:length(EbNoVec)
% Convert Eb/No to SNR
snrdB = EbNoVec(n) + 10*log10(k*rate);
% Reset the error and bit counters
numErrs1 = 0;
numErrs2 = 0;
numBits = 0;
% Generate binary data and convert to symbols
B=10;
dataIn1= rand(1,B);
dataIn2=rand(1,B);
symbols1= unique(dataIn1);
symbols2= unique(dataIn2);
probs1 = histc(dataIn1,symbols1)./numel(dataIn1);
probs2 = histc(dataIn2,symbols2)./numel(dataIn2);
[dict1, avglen1] = huffmandict(symbols1, probs1);
[dict2, avglen2] = huffmandict(symbols2, probs2);
comp1 = huffmanenco(dataIn1,dict1);
comp2 = huffmanenco(dataIn2,dict2);
% Convolutionally encode the data
dataEnc1 = convenc(comp1,trellis);
dataEnc2 = convenc(comp2,trellis);
% QAM modulate
txSig1 = qammod(dataEnc1,M,0);
txSig2 = qammod(dataEnc2,M,0);
%------------------Spreading & IFFT for User1------------------------------
Tx_data1=txSig1';
Spread_User1=Tx_data1*code1; % Spreading
Spread1=(Spread_User1)';
ifftdata_user1=ifft(Spread1); % Taking the IFFT
ifftdata1=ifftdata_user1';
%------------------Spreading & IFFT for User2------------------------------
Tx_data2=txSig2';
Spread_User2=Tx_data2*code2; % Spreading
Spread2=(Spread_User2)';
ifftdata_user2=ifft(Spread2); % Taking the IFFT
ifftdata2=ifftdata_user2';
%----------------------Addition of all signal------------------------------
TotSignal = Spread1+Spread2;
% Pass through AWGN channel
AwTotSignal = awgn(TotSignal,snrdB,'measured');
%-----------------------Removing the FFT & De-Spreading--------------------
fft_data_received =fft(AwTotSignal);
Rec_Data1=(AwTotSignal'*code1');
Rec_Data2=(AwTotSignal'*code2');
% Demodulate the noisy signal
rxSym1 = qamdemod(Rec_Data1,M,0);
rxSym2 = qamdemod(Rec_Data2,M,0);
data1=vitdec(rxSym1,trellis,5,'cont','unquant');
data2=vitdec(rxSym2,trellis,5,'cont','unquant');
% Convert received symbols to bits
%dataOut1 = de2bi(data1,k);
%dataOut2 = de2bi(data2,k);
% Calculate the number of bit errors
nErrors1 = biterr(comp1',data1);
nErrors2 = biterr(comp2',data2);
% Increment the error and bit counters
numErrs1 = numErrs1 + nErrors1;
numErrs2 = numErrs2 + nErrors2;
numBits= numBits + numSymPerFrame*k;
% Estimate the BER
berEst1(n) = numErrs1/numBits;
berEst2(n) = numErrs2/numBits;
end

Answers (1)

Sujay Mondal
Sujay Mondal on 17 Feb 2022
Hello, psychecrew have got the solution. Actually I am also facing the same problem during QPSK transmission I also getting a flat line with increasing SNR. Is there any solution to this particular problem.
Thanking You,
Sujay Mondal.

Community Treasure Hunt

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

Start Hunting!