yamid
Newbie level 5
hello all,
i started to write a code that modulate a QPSK signal and after that i use carrier recovery technique to get the carrier from the QPSK signal.
the technique says that if you multiple the signal by itself four times (power 4 of the signal) and pass the result through band pass filter you will get a clean carrier.
i choose the carrier frequency to be 10.7Mhz and the data bit rate to be 100Khz.
but when i do an fft over the QPSK signal i dont get a stick in the carrier frequency as i need to get by the theory. i dont know what goes wrong can sombody help me please?
this is the code that i wrote:
clear all
close all
clc
fcarr=10.7e+6;% Carrier frequency(Hz)
Rb=100e+3; %bit/sec
fs=Rb; %sample rate
Tb=1/Rb;
td=(Tb:Tb:1)';% Time vector(data)
N=1000;
M=Rb/N; %the time of one bit over the all time vector
%%%%%%%%%%%%%%%%%%% transmiter %%%%%%%%%%%%
%%%% main chain of bits %%%%
data=sign(randn(1,N));
data1=ones(M,1)*data;
data2=data1);
%%%% I chain of bits= odd bits %%%%
idata=data(1:2:length(data));
idata1=ones(2*M,1)*idata;
idata2=idata1);
%%%% Q chain of bits= even bits %%%%
qdata=data(2:2:length(data));
qdata1=ones(2*M,1)*qdata;
qdata2=qdata1);
%%%% generate carriers sin and cos %%%%
ft=fcarr*td;
twopi_fc_t=2*3.14*fcarr*td;
ccos=cos(twopi_fc_t);
csin=sin(twopi_fc_t);
%%% modulation proccess %%%%
i_cos=ccos.*idata2;
q_sin=csin.*qdata2;
sumiq=q_sin+i_cos;
sumiq=0.7*sumiq;%reduce gain to keep output at +- 1
% fft of sumiq %%
[YfreqDomain,frequencyRange] = positiveFFT(sumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of sumiq')
grid
Gsumiq=sumiq.*sumiq; %first multiplication
[YfreqDomain,frequencyRange] = positiveFFT(Gsumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of Gsumiq')
grid
Hsumiq=Gsumiq.*Gsumiq; %second multiplication
%% %%fft of Hsumiq %%
[YfreqDomain,frequencyRange] = positiveFFT(Hsumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of Hsumiq')
grid
i started to write a code that modulate a QPSK signal and after that i use carrier recovery technique to get the carrier from the QPSK signal.
the technique says that if you multiple the signal by itself four times (power 4 of the signal) and pass the result through band pass filter you will get a clean carrier.
i choose the carrier frequency to be 10.7Mhz and the data bit rate to be 100Khz.
but when i do an fft over the QPSK signal i dont get a stick in the carrier frequency as i need to get by the theory. i dont know what goes wrong can sombody help me please?
this is the code that i wrote:
clear all
close all
clc
fcarr=10.7e+6;% Carrier frequency(Hz)
Rb=100e+3; %bit/sec
fs=Rb; %sample rate
Tb=1/Rb;
td=(Tb:Tb:1)';% Time vector(data)
N=1000;
M=Rb/N; %the time of one bit over the all time vector
%%%%%%%%%%%%%%%%%%% transmiter %%%%%%%%%%%%
%%%% main chain of bits %%%%
data=sign(randn(1,N));
data1=ones(M,1)*data;
data2=data1);
%%%% I chain of bits= odd bits %%%%
idata=data(1:2:length(data));
idata1=ones(2*M,1)*idata;
idata2=idata1);
%%%% Q chain of bits= even bits %%%%
qdata=data(2:2:length(data));
qdata1=ones(2*M,1)*qdata;
qdata2=qdata1);
%%%% generate carriers sin and cos %%%%
ft=fcarr*td;
twopi_fc_t=2*3.14*fcarr*td;
ccos=cos(twopi_fc_t);
csin=sin(twopi_fc_t);
%%% modulation proccess %%%%
i_cos=ccos.*idata2;
q_sin=csin.*qdata2;
sumiq=q_sin+i_cos;
sumiq=0.7*sumiq;%reduce gain to keep output at +- 1
% fft of sumiq %%
[YfreqDomain,frequencyRange] = positiveFFT(sumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of sumiq')
grid
Gsumiq=sumiq.*sumiq; %first multiplication
[YfreqDomain,frequencyRange] = positiveFFT(Gsumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of Gsumiq')
grid
Hsumiq=Gsumiq.*Gsumiq; %second multiplication
%% %%fft of Hsumiq %%
[YfreqDomain,frequencyRange] = positiveFFT(Hsumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of Hsumiq')
grid