Panoramix said:Thank you for your quick reply. Here is the code i am using. I want to send my data through a rayleigh fading channel using 16-QAM. Even if i use coherent BPSK modulation I have the same bad error rate results of 0.5. What i am doing wrong? Thanks in advance.
%% Setup
clear all;
close all;
clc;
% Define parameters.
M = 16; % Size of signal constellation
bits = log2(M); % Number of bits per symbol
n = 6e4; % Number of bits to process
%n = 2688; % Number of bits to process
nsamp = 4; % Oversampling rate
%% Signal Source
% Create a binary data stream as a column vector.
x = randint(n,1); % Random binary data stream
%% Outer Encoder - R-S 252 - 168
m = 8; % Number of bits in each symbol
n = 252; k = 168; % Codeword length and message length
modul = mod(length(x)/m, k);
if modul ~= 0
dataPad = [x ; zeros(((k - modul)*m), 1)];
else
dataPad = x;
end
temp1 = reshape(dataPad, m, length(dataPad)/m)';
dataTemp = bi2de(temp1, 'left-msb');
num = length(dataTemp)/k; % Number of codewords
data = reshape(dataTemp, k, length(dataTemp)/k )';
msg = gf(data,m); % Represent data using a Galois array.
t = (n-k)/2; % Error-correction capability of the code
c = rsenc(msg,n,k); % Encode the data.
%Outer Interleaver
st2 = 4831; %States for random number generator taken from matlab example for block interleaving
OutInterl = randintrlv(c,st2); % Interleave
gf2double = double(OutInterl.x)';
gf2doubleBits = de2bi(gf2double,'left-msb')';
outer = reshape(gf2doubleBits, 1, (length(gf2doubleBits) * m))';
%% Inner Encoder
% Define a convolutional coding trellis and use it
% to encode the binary data.
constr = 7;
trel = poly2trellis(constr,[171 133]); % constraint length = 7. Kolotos thesis
tblen = 5 * constr; % Traceback length for decoding
coded = convenc(outer,trel); % Encode.
coderate = 1/2;
% Inner Interleaver
st2 = 4831; %States for random number generator taken from matlab example for block interleaving
InnInterl = randintrlv(coded,st2); % Interleave
%% Bit-to-Symbol Mapping
% Convert the bits in x into k-bit symbols
xsym = bi2de(reshape(InnInterl,bits,length(InnInterl)/bits).','left-msb');
%% Modulation
%% Customised uniform gray coded 16-QAM Constellation
inphase = [ 1; 1; 3; 3; 1; 1; 3; 3; -1; -1; -3; -3; -1; -1; -3; -3 ];
quadr = [ 1; 3; 1; 3; -1; -3; -1; -3; 1; 3; 1; 3; -1; -3; -1; -3 ];
const = inphase + j*quadr;
% Modulate using cuctomised Gray Coded 16-QAM.
y = genqammod(xsym,const);
%% Filter Definition
% Define filter-related parameters.
filtorder = 40; % Filter order
delay = filtorder/(nsamp*2); % Group delay (# of input samples)
rolloff = 0.25; % Rolloff factor of filter
% Create a square root raised cosine filter.
rrcfilter = rcosine(1,nsamp,'fir/sqrt',rolloff,delay);
%% Transmitted Signal
% Upsample and apply square root raised cosine filter.
ytx = rcosflt(y,1,nsamp,'filter',rrcfilter);
% Create Rayleigh fading channel object.
chanStatic = rayleighchan;
fadedSig = filter(chanStatic,ytx); % Effect of channel for QAM signals
%% Channel
% Send signal over an AWGN channel.
EbNo = (1:20); % Range of SNR values, in dB.
%% Loop for all values of EbNo
for j = 1:length(EbNo)
snr = EbNo(j);
ynoisy = awgn(fadedSig,EbNo(j),'measured');
%% Received Signal
% Filter received signal using square root raised cosine filter.
yrx = rcosflt(ynoisy,1,nsamp,'Fs/filter',rrcfilter);
yrx = downsample(yrx,nsamp); % Downsample.
yrx = yrx(2*delay+1:end-2*delay); % Account for delay.
%% Demodulation
% Demodulate signal using 16-QAM.
zsym = genqamdemod(yrx,const);
rx = de2bi(zsym,'left-msb')'; % Convert integers to bits
rxReshaped = reshape(rx, bits * length(rx), 1);
%%Inner Decoding
deInnInterl = randdeintrlv(rxReshaped,st2); % Deinterleave.
% Decode the convolutional code.
deConv = vitdec(deInnInterl, trel, tblen, 'trunc', 'hard'); %Hard decision
%% Outer decoding
tempo = reshape(deConv, m, length(deConv)/m)';
data_temp1 = bi2de(tempo, 'left-msb');
data1 = reshape(data_temp1, n, length(data_temp1)/n)';
trans = gf(data1,m); %transform to gf array
deOutInterl = randdeintrlv(trans,st2); % Deinterleave.
decoded = rsdec(deOutInterl,n,k); % Decode the data
decodedDouble = double(decoded.x)';
temp2 = reshape(decodedDouble, k*num, 1);
col = de2bi(temp2, 'left-msb')';
coly = reshape(col, m*length(col), 1);
if modul ~= 0
[number,ratio(j)] = biterr(coly(1:end-((k - modul)*m)), x);
else
[number,ratio(j)] = biterr(coly, x);
end
disp(['EbNo: ',num2str(snr)]);
disp(['The bit error rate: ',num2str(ratio(j))]);
end
% Plot theoretical results.
figure; semilogy(EbNo,ratio,'r');
xlabel('E_b/N_0 (dB)'); ylabel('Symbol Error Rate');
grid on; drawnow;
legend('Empirical SER');
title('Empirical Error Rate');
first u have to convolve with tap values by taking first values of waveforms....then u have yo equalize using lms or anyother.....Asifmarri said:hi can u help me i m having the same problem of getting a ber of 0.5 when passing the signal through rayleigh channel.do i have to perform any equalization if then how?
shuld i use interlaving ?
m not working on simulink i have to generate matlab code
i m working on Mimo-ofdm as my MSc Project.
i will be very thankful if u can help me on this issue .i m anxiously waiting for ur reply
thanks in advance
plz email me at: m.asifkm(at)gmail.com
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?