Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

carrier recovery for QPSK signal

Status
Not open for further replies.

yamid

Newbie level 5
Joined
Sep 13, 2011
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,406
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
 

Hi Yamid,

Sampling rate should be higher than twice the frequency of the spectral line you expect to find.
So you need fs > 2*4*fcarr .
Regards

Z
 

hello zorro,
i dont understand why i need sample rate in this system what is the purpose of sampling the data signal if it is already digital signal.
in addition, i also dont understand your answer that based on the nyquist frequency ,why you multiple it by 4?
thank you very much for support.
 

Hi Yamid,

the modulation is digital, but the signal itself is in continuous time. You need to recover the carrier because you don't have exactly its frequency.
The signal you want (spectral line that allows to recover the carrier) is at frequency 4*fcarr . (You get it squaring twice the incoming signal and filtering.)
So, based on Nyquist, sampling frequency should be most that twice 4*fcarr .
Regards

Z
 

oh you are so right thank you very much.
zorro i have correct what you told me but now i have a new problem matlab says "out of memory"
"
Out of memory. Type HELP MEMORY for your options.

Error in Untitledquestion (line 12)
td=(Ts:Ts:1)';% Time vector(data)
"

my code is now looking like this:

clear all
close all
clc

fcarr=10.7e+6;% Carrier frequency(Hz)
fs=2*4*fcarr; %sample fequency
Fn=fs/2; % Nyquist frequency
Rb=100e+3; %bit/sec
Tb=1/Rb; %bit time
Ts=1/fs;%sampling time
td=(Ts:Ts:1)';% Time vector(data)

%%%%%%%%%%%%%%%%%%% transmiter %%%%%%%%%%%%
%%%% main chain of bits %%%%
data=sign(randn(1,Rb));
data1=ones(Tb/Ts,1)*data;
data2=data1:));
%%%% I chain of bits= odd bits %%%%
idata=data(1:2:length(data));
idata1=ones(2*Tb/Ts,1)*idata;
idata2=idata1:));
%%%% Q chain of bits= even bits %%%%
qdata=data(2:2:length(data));
qdata1=ones(2*Tb/Ts,1)*qdata;
qdata2=qdata1:));
%%%% generate carriers sin and cos %%%%
tiq = [Ts*2:Ts*2:1]';% Time vector for I and Q symbols(transpose)
twopi_fc_t=2*pi*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 +/- one

% 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;

%% %%fft of Gsumiq %%
[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;
%% %%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 used function called positiveFFT and the function code is:
function [X,freq]=positiveFFT(x,Fs)
N=length(x); %get the number of points
k=0:N-20000; %create a vector from 0 to N-1
T=(N-20000)/Fs; %get the frequency interval
freq=k/T; %create the frequency range
X=fft(x); % normalize the data

%only want the first half of the FFT, since it is redundant
cutOff = ceil(N/2);

%take only the first half of the spectrum
X = X(1:cutOff);
freq = freq(1:cutOff);

can you or any one else can tell me what can i do? i dont want to change the frequencies and rates.
 

Hi Yamid,

That message comes bacause you are requiring too much memory.
With fcarr=19.7MHz and time up to 1 second, the vector td has 85.6e6 components. At 8 bytes per value (double precision real), it takes 684.8 MBytes.
In addition, a lot of other arrays (ft, twopi_fc_t, ccos, etc.) have the same size and would require a huge amount of memory.
Be careful with memry usage. Don't use big arrays you don't need. Eventually re-utilize arrays or free memory with clear().
Also, I would start trying with shorter time (less than 1 second).
regards

Z
 
Last edited:

dear zorro,
I had change the smple frequency and the time vector has you advise, but when i raise the modulation signal by power 4 and do fft i dont get in the spectrum a component in the 4 times carrier frequency, what is the problem for your opinion?
the program now look like this:


clear all
close all
clc
M=4;
fcarr=10.7e+6;% Carrier frequency(Hz)
fs=2*4*fcarr; %sample fequency
Fn=fs/2; % Nyquist frequency
Rb=100e+3; %bit/sec
Tb=1/Rb; %bit time
Ts=1/fs;%sampling time
Samp_per_bit=Tb/Ts;
Number_of_bits = 100;
td=(0:Ts:(Number_of_bits*Samp_per_bit-1)*Ts)';% Time vector(data)

%%%%%%%%%%%%%%%%%%% transmiter %%%%%%%%%%%%
%%%% main chain of bits %%%%
data_bits=randint(1,Number_of_bits )';
gd=bi2de(reshape(data_bits,log2(M),Number_of_bits/log2(M) )', 'left-msb' );
Ak=pskmod(gd,M,0,'gray');
data_bits1=ones(Samp_per_bit,1)*(data_bits)';
data_bits2=data_bits1:));
Ai=real(Ak);

for j=1:length(Ai)
if Ai(j)==6.123233995736766e-17 || Ai(j)==-1.836970198721030e-16
Ai(j)=0;
end
end
Aq=imag(Ak);
for j=1:length(Aq)
if Aq(j)==6.123233995736766e-17 || Aq(j)==-1.836970198721030e-16
Aq(j)=0;
end
end
%%%% I chain of bits= odd bits %%%%
Ai1=ones(Samp_per_bit*log2(M),1)*(Ai)';
Ai2=Ai1:));

%%%% Q chain of bits= even bits %%%%
Aq1=ones(Samp_per_bit*log2(M),1)*(Aq)';
Aq2=Aq1:));
%%%% generate carriers sin and cos %%%%

twopi_fc_t=2*pi*fcarr*td;
ccos=cos(twopi_fc_t);
csin=sin(twopi_fc_t);
%%% modulation proccess %%%%
i_cos=ccos.*Ai2;
q_sin=csin.*Aq2;
sumiq=q_sin+i_cos;
sumiq=0.7*sumiq;%reduce gain to keep output at +/- one

mult_sumiq1=sumiq.^2;
mult_sumiq2=(mult_sumiq1).^2;

[YfreqDomain1,frequencyRange1] = positiveFFT(sumiq,fs);
figure;
stem(frequencyRange1,abs(YfreqDomain1));
grid

[YfreqDomain2,frequencyRange2] = positiveFFT(mult_sumiq1,fs);
figure;
stem(frequencyRange2,abs(YfreqDomain2));
grid

[YfreqDomain3,frequencyRange3] = positiveFFT(mult_sumiq2,fs);
figure;
stem(frequencyRange3,abs(YfreqDomain3));
grid
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top