### Welcome to EDAboard.com

#### Welcome to our site! EDAboard.com is an international Electronic 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.

Status
Not open for further replies.

#### suribright

##### Member level 2
Hi,

I would like to run the QPSK at 13.56 MHz of carrier frequency. Any one have a matlab code please send me one. I have tried to write this code but did not work at 13.56 MHz. Wont know what wrong is my code?. In my code, I write the carrier at 13.56Mhz and sampling frequency at 120KHz. When I take FFT of signal it always show at 40KHz. I would like to show FFT at 13.56 MHz. Any one have know about QPSK please let me know or if you have a code it is really appreciated. Thanks

#### ChakerQ

##### Member level 1
Hi,

Post the code and i will help you

#### suribright

##### Member level 2
Just message you my code, Mohamed.

#### ChakerQ

##### Member level 1
Hi,

I send you a code by message. Plz give me your feedback.

bye

Last edited:

#### suribright

##### Member level 2
Hi,
I created a m file in matlab but not work by your code. It shows the power spectrum at lest than 10Khz. Not at 13.56Mhz. I saw your explanation before but it closed now. Dont know why. Can you show it again?. If i run my code at sampling frequency 120Mhz, it will show FFT at 13.56Mhz. But I dont want to sample high frequency. I want sampling at 120Khz. waiting for your reply.Tks.

#### ChakerQ

##### Member level 1
Hi,

This is the old reply.. i delete it because i coded it and i send you the code.

i advise you :

1. You must precise fc (carrier frequency), fs (sampling frequency) and B (baud rate). Then, N=fs/B will be the number of sample in one symbol of period T=1/B;

2. Time vector t=0:1/fsN-1)/fs; % time for one symbol

3. M=4; % 4 state for QPSK modulation
k=log2(M)=2; % 2 bits for ones symbol
data=randint(1,k*Nsym,[0 1]); % generate random binary vector [0 1 1 0 1 0 1 1 0 0 .... ]
qpskdata=bi2de(reshape(data,Nsym,k),'left-msb'); % Convert the bits in data into k-bit symbols [1 2 2 3 0 ...], 00=0 / 01=1 / 10=2 / 11=3

4. you must code data in phase. you have choice phi(i)=2*pi*qpskdata(i)/M [0,pi/2,pi,3pi/2] or phi(i)=(2*qpskdata(i)+1)*pi/M [pi/4,3pi/4,5pi/4,7pi/4]
your vector will be like that [pi/2 pi pi 3pi/2 0 ...] : QPSK constellation
finely : s(i)=A*sin(2*pi*fc*t+phi(i))

y= []
for i=1:Nsym
y=[y A*sin(2*pi*fc*t+phi(i))]
end
When you sampled your signal at high frequency (Fs=120Mhz > 2*(fc+B/2)), you are performing lowpass signal sampling.
Then, in your spectrum [0-->Fs/2] you can see your signal at fc frequency (fc<Fs/2).

When you sampled your signal at low frequency (Fs=120kHz > 2*B), you are performing bandpass signal sampling.
In this case, you can't see signal at fc frequency because fc is greater than your spectrum fc>Fs/2.
But, you will see a replica of your signal at fc1=rem(fc,fs)=B/2.
Because like we know the spectrum of a sampling signal is a replica of the continuous signal at each Fs interval [0 Fs] [Fs 2FS] [2Fs 3FS] [3Fs 4FS] ...
so fc will be at one interval [k*Fs (k+1)*FS], and this spectrum is the same as [0 Fs/2] represented.

look for this link.. all this is well described (not like my poor English lol)
http://www.informit.com/articles/article.aspx?p=345472&seqNum=3

best regards

#### suribright

##### Member level 2
So please show me that spectrum at one interval [k*Fs (k+1)*FS] not in [0 Fs/2]. So we can see the spectrum exactly at 13.56Mhz. I have tried that but not work. Please write in my code if it's possible. You can assume B=10 Khz. Tks

#### ChakerQ

##### Member level 1
Hi,

I send to you the new code where you can see the spectrum with the lobe at fc.

I will check your code but i can't understand why you are using I & Q branch.

#### suribright

##### Member level 2
Hi,

Oh just because I just want to show how IandQ branch works in process. In your code I think you used bandwidth =fs/N=120e3/1024=117Hz. Is this right? It's small bandwidth I think.

#### ChakerQ

##### Member level 1
Hi,

Yes i used N=1024 to have N points in the spectrum. You can change N to have a large bandwidth up to fs/2=60kHz. Or to consider the N samples for more than one symbol.

I you want to have the same spectrum with your code. You must :

1. verify bandpass sampling

2. simulate with only one symbol

#### suribright

##### Member level 2
Hi,

Dont understand below part in your code?. What mean of k1, kk, fc?.

N_cyc=(N*fc)/fs; % Number of cycles
k1=round(N_cyc);
kk=0;
k1=k1-1;
while(kk==0)
k1=k1+1;
kk=isprime(k1);
end
fc=(k1*fs)/N; % coherent carrier frequency

fc1=rem(fc,fs); % shiftted fc
k_fs=floor(fc/fs);
kfs=k_fs*fs;

Do you know any books about modulation scheme (QPSK)?. I would like to have a look. Tks

#### ChakerQ

##### Member level 1
Hi,

Code:
_cyc=(N*fc)/fs; % Number of cycles
k1=round(N_cyc);
kk=0;
k1=k1-1;
while(kk==0)
k1=k1+1;
kk=isprime(k1);
end
fc=(k1*fs)/N; % coherent carrier frequency
This part of code used to change frequencies fs and fc to coherent forms. It will gives a best spectrum.

http://en.wikipedia.org/wiki/Coherent_sampling

Code:
fc1=rem(fc,fs); % shiftted fc
k_fs=floor(fc/fs);
kfs=k_fs*fs;
This part of code used to get information about spectrum.
- fc1 is the frequency of signal lobe that must be present in the interval [0 fs/2].
- kfs the beginning of this interval[k*fs (k+1)*fs].

This book can help you : Digital modulation techniques -Fuqin Xiong

regards,

Chaker

#### suribright

##### Member level 2
Hi,
Very good explanation and reference. In your code, I think one small mistake is s=[s A*cos(2*pi*fc*t+phi(i))]; not s=[s A*sin(2*pi*fc*t+phi(i))]; This is QPSK formula I think. I will rewrite my code as your recommend.
1. verify bandpass sampling. By adding the bandwidth and specify the interval

2. simulate with only one symbol : specify [k*fs (k+1)*fs]. and show FFT
Tks

#### ChakerQ

##### Member level 1
Hi,

yes i always confuse sine and cosine ^^'

I do this simulation before and i get the sine lobe at fc.

I hope our discussion helped you.

Good luck

Status
Not open for further replies.