From: fed on
Hello,
I want to plot a BER vs SNR for a 16 QAM constellation in the context
of linear equalization of a white gaussian noise channel using an LMS
algorithm.
the results of my following matlab code is exellent in term of eye
diagram of the
equalizer output but the value of empirical BER is usually in order of
0.506 and hasn't decrease
when i increase the SNR value.
Can you please say to me where is the error in my matlab code.
Thank you very much.

N = 5000; % number of iterations
M = 16;
F_s = 4e3;
F_symb = 1e3;
k = log2(M);
F = 4; % Oversampling rate = F_s/F_symb
x = randint(1,N,M);

% Filter Definition
% Define filter-related parameters.
filtorder = 32; % Filter order
delay = filtorder/(F*2); % Group delay (# of input samples)
rolloff = 0.35; % Rolloff factor of filter
% Create a square root raised cosine filter.
rrcfilter = rcosine(1,F,'fir/sqrt',rolloff,delay);

% Filter the modulated signal
% Transmitted Signal
% Upsample and apply square root raised cosine filter.
% S = pamqam(N,A,rrcfilter,F_s, F_symb);
S = qammod(x,M);
ytx = rcosflt(S,1,F,'filter',rrcfilter);

chan = [.986; .845; .237; .123+.31i]; % channel coefficients
filtmsg = filter(chan,1,ytx); % Introduce channel distortion.
for snr = 2:30 % in dB
snr
filtmsg = filter(chan,1,ytx); % Introduce channel distortion.
filtmsg_noisy = awgn(filtmsg,snr,'measured');
% filter the noisy signal with the received filter which is the
same
% as the transmitter filter
yrx = rcosflt(filtmsg_noisy,1,F,'Fs/filter',rrcfilter);
yrx = downsample(yrx,F); % Downsample.
yrx = yrx(2*delay+1:end-2*delay); % Account for delay.

for kk = 30:N
Y_mat (:,kk) = yrx(kk:-1:kk-29);
end
% equalize the channel with the LMS algorithm
w = zeros(30,1);
mu = 0.001;
for jj = 7:N
e(jj) = S(jj-6)-w'*Y_mat(:,jj);
w = w + mu*conj(e(jj))*Y_mat(:,jj);
end
s_est = w'*Y_mat;
z = qamdemod(s_est,M);
[nBErrors, BER(snr)] = biterr(x,z);
end
semilogy(BER,'-o');
grid
figure
plot(s_est,'o');

From: Idin Motedayen-Aval on
fed wrote:
> Hello,
> I want to plot a BER vs SNR for a 16 QAM constellation in the context
> of linear equalization of a white gaussian noise channel using an LMS
> algorithm.
> the results of my following matlab code is exellent in term of eye
> diagram of the
> equalizer output but the value of empirical BER is usually in order of
> 0.506 and hasn't decrease
> when i increase the SNR value.
> Can you please say to me where is the error in my matlab code.
> Thank you very much.
>
> N = 5000; % number of iterations
> M = 16;
> F_s = 4e3;
> F_symb = 1e3;
> k = log2(M);
> F = 4; % Oversampling rate = F_s/F_symb
> x = randint(1,N,M);
>
> % Filter Definition
> % Define filter-related parameters.
> filtorder = 32; % Filter order
> delay = filtorder/(F*2); % Group delay (# of input samples)
> rolloff = 0.35; % Rolloff factor of filter
> % Create a square root raised cosine filter.
> rrcfilter = rcosine(1,F,'fir/sqrt',rolloff,delay);
>
> % Filter the modulated signal
> % Transmitted Signal
> % Upsample and apply square root raised cosine filter.
> % S = pamqam(N,A,rrcfilter,F_s, F_symb);
> S = qammod(x,M);
> ytx = rcosflt(S,1,F,'filter',rrcfilter);
>
> chan = [.986; .845; .237; .123+.31i]; % channel coefficients
> filtmsg = filter(chan,1,ytx); % Introduce channel distortion.
> for snr = 2:30 % in dB
> snr
> filtmsg = filter(chan,1,ytx); % Introduce channel distortion.
> filtmsg_noisy = awgn(filtmsg,snr,'measured');
> % filter the noisy signal with the received filter which is the
> same
> % as the transmitter filter
> yrx = rcosflt(filtmsg_noisy,1,F,'Fs/filter',rrcfilter);
> yrx = downsample(yrx,F); % Downsample.
> yrx = yrx(2*delay+1:end-2*delay); % Account for delay.
>
> for kk = 30:N
> Y_mat (:,kk) = yrx(kk:-1:kk-29);
> end
> % equalize the channel with the LMS algorithm
> w = zeros(30,1);
> mu = 0.001;
> for jj = 7:N
> e(jj) = S(jj-6)-w'*Y_mat(:,jj);
> w = w + mu*conj(e(jj))*Y_mat(:,jj);
> end
> s_est = w'*Y_mat;
> z = qamdemod(s_est,M);
> [nBErrors, BER(snr)] = biterr(x,z);
> end
> semilogy(BER,'-o');
> grid
> figure
> plot(s_est,'o');
>

Your signals are mis-aligned. Change your biterr line to this:
[nBErrors, BER(snr)] = biterr(x(26:end-6),z(32:end));

I didn't go through the code to see why the delays work out this way,
but your "z" signal clearly has a 31-sample delay before it gives you
anything useful, so you need to throw away those samples (just look at
the first 50 values in z). And then I simply did this:
[c, lags] = xcov (x,z,10,'coeff');
stem(lags,c)
You can immediately see that there is a 6-sample delay in z in relation
to x ('xcov' is cross-correlation).

HTH,
Idin Motedayen-Aval
The MathWorks
From: "Mr. Ken" <Mr. on

"fed" <feded_a(a)yahoo.fr> wrote in message
news:1147967658.710878.148230(a)38g2000cwa.googlegroups.com...
> Hello,
> I want to plot a BER vs SNR for a 16 QAM constellation in the context
> of linear equalization of a white gaussian noise channel using an LMS
> algorithm.
> the results of my following matlab code is exellent in term of eye
> diagram of the
> equalizer output but the value of empirical BER is usually in order of
> 0.506 and hasn't decrease
> when i increase the SNR value.
> Can you please say to me where is the error in my matlab code.
> Thank you very much.
>
> N = 5000; % number of iterations
> M = 16;
> F_s = 4e3;
> F_symb = 1e3;
> k = log2(M);
> F = 4; % Oversampling rate = F_s/F_symb
> x = randint(1,N,M);
>
> % Filter Definition
> % Define filter-related parameters.
> filtorder = 32; % Filter order
> delay = filtorder/(F*2); % Group delay (# of input samples)
> rolloff = 0.35; % Rolloff factor of filter
> % Create a square root raised cosine filter.
> rrcfilter = rcosine(1,F,'fir/sqrt',rolloff,delay);
>
> % Filter the modulated signal
> % Transmitted Signal
> % Upsample and apply square root raised cosine filter.
> % S = pamqam(N,A,rrcfilter,F_s, F_symb);
> S = qammod(x,M);
> ytx = rcosflt(S,1,F,'filter',rrcfilter);
>
> chan = [.986; .845; .237; .123+.31i]; % channel coefficients
> filtmsg = filter(chan,1,ytx); % Introduce channel distortion.
> for snr = 2:30 % in dB
> snr
> filtmsg = filter(chan,1,ytx); % Introduce channel distortion.
> filtmsg_noisy = awgn(filtmsg,snr,'measured');
> % filter the noisy signal with the received filter which is the
> same
> % as the transmitter filter
> yrx = rcosflt(filtmsg_noisy,1,F,'Fs/filter',rrcfilter);
> yrx = downsample(yrx,F); % Downsample.
> yrx = yrx(2*delay+1:end-2*delay); % Account for delay.
>
> for kk = 30:N
> Y_mat (:,kk) = yrx(kk:-1:kk-29);
> end
> % equalize the channel with the LMS algorithm
> w = zeros(30,1);
> mu = 0.001;
> for jj = 7:N
> e(jj) = S(jj-6)-w'*Y_mat(:,jj);
> w = w + mu*conj(e(jj))*Y_mat(:,jj);
> end
> s_est = w'*Y_mat;
> z = qamdemod(s_est,M);
> [nBErrors, BER(snr)] = biterr(x,z);
> end
> semilogy(BER,'-o');
> grid
> figure
> plot(s_est,'o');
>



What a nice example.
Do you have any multi-channel simulations like OFDM or FSK?



From: fed on
Thank your very much Mr Idin for your help.
I have changed the line of biterr and i have obtained a good results
Best Regards.