Hi,
In this one, you are using a rf-signal (cosine wave). How this one can be BPSK signal?
1.What is inside RRC.mat?
2.How did you choose Bandwith = 200 hz.
Please reply to my questions.
--- Quote Start ---
Hello Kazem :)
I think I did it this time. Please take your time and test it at your leisure before judging :D
clear
clc
load RRC.mat
fc = 0.1 % 0.11 %0.09
rf_signal = cos(2*pi*(1:5000)*0.1);
N = length(rf_signal);
bb = zeros(1, N);
bb_f = zeros(1, N);
I_f = zeros(1, N);
Q_f = zeros(1, N);
I_r = zeros(1, N);
Q_r = zeros(1, N);
error = zeros(1, N);
PhErr = zeros(1, N);
error_integral = zeros(1, N);
Theta = zeros(1, N);
% Loop Filter Coefficients
BW = 200; % Hz
loop_theta = 2*pi*BW;
C1 = 4*(loop_theta)^2/(1+sqrt(2)*loop_theta+loop_theta^2);
C2 = 2*sqrt(2)*loop_theta/(1+sqrt(2)*loop_theta+loop_theta^2);
for i = 2:N
% Downconverting to Baseband
bb(i) = rf_signal(i).*exp(j*2*pi*fc*i).*exp(j*Theta(i-1));
% Filtering
bb_f = filter(RRC, bb(1:i));
I_f(i) = real(bb_f(i));
Q_f(i) = imag(bb_f(i));
% Slicing
if I_f(i) > 0
I_r(i) = 1;
else
I_r(i) = -1;
end
if Q_f(i) > 0
Q_r(i) = 1;
else
Q_r(i) = -1;
end
% Error
error(i) = I_f(i) .* Q_r(i) - Q_f(i) .* I_r(i);
% Loop Filter
error_integral(i) = error(i).*C1 + error_integral(i-1);
PhErr(i) = error(i).*C2 + error_integral(i);
% Phase Accumulator
Theta(i) = Theta(i-1) + PhErr(i);
end
figure
subplot 221
plot(real(bb))
title('I Channel')
subplot 222
plot(imag(bb))
title('Q Channel')
subplot 223
plot(I_f)
title('I Channel Filter')
subplot 224
plot(Q_f)
title('Q Channel Filter')
figure; subplot 311; plot(error); title('Phase Error');
subplot 312; plot(PhErr); title('Loop Filter');
subplot 313; plot(Theta); title('Control Signal \theta');
Just to motivate you, look at these signals:
http://www.alteraforum.com/forum/attachment.php?attachmentid=10422&stc=1 http://www.alteraforum.com/forum/attachment.php?attachmentid=10423&stc=1 --- Quote End ---