Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
QPSK BER QUESTION AND MATLAB CODE

Subject: QPSK BER QUESTION AND MATLAB CODE

From: dottavio@ised.it (Antonio)

Date: 2 Oct, 2001 00:30:25

Message: 1 of 1

Good Morning,
I've delivered the following Matlab implementation of a QPSK
modulator, to test it I also arrange a
simple QPSK demodulator, the problems I have are the following :

1) For the noise introduced by the channel I use the relations
    SNR_x_bit_dB = 6 ;
    SNR_dB = SNR_x_bit_dB -10*log10(0.5) - 10*log10(f_clk / (data_rate)) ;
QPSK_et_noise = awgn( (QPSK_I + QPSK_Q) , SNR_dB, 'measured' , [],'dB' );
   
   I'm not sure about these, especially for the second one, could you confirm
   to me it's validity ?? In the simulation I found BER = 0.01234 while the
   theoretical one is BER = 0.00238829

2) The same following code could work also for data rate of 82.5Mbps
   or 110Mbps but respect to the same simulation at 55Mbps the result are
   really bad, for example having SNR_x_bit_dB = 6 I have
    BER = 0.0354462 at 82.5Mbps and BER = 0.079483 at 110Mbps.
    How you explain this ??

3) When the noise grows it is normal I think that the eye close, if
    you run the following code you'll see the eye diagram at the output of
    the SRRC filter that isreally dirty, you think is normal for a
    SNR_x_bit = 6dB ??

4) I use to demap the Matlab function demodmap :
    simboli = demodmap(data_rx , [symbol_rate 0] , f_clk , 'qask', 4) ;
   this is a 4-PSK demodulator and it's equivalent to a 4-QAM demodulator but
   why these two matlab constellations have a phase difference of pi/4 ??
   For the 4-PSK in fact the constellation that matlab expect have all symbols
   on the axis. Why this ?? How can I use 4-PSK demap ??

And finally here it is the Matlab code, I hope you'll test it and
suggest me how to solve these
problems and enhance it. Thanks ...

Antonio D'Ottavio







clear all ;
close all ;
clc ;


f_clk = 165e6 ;
data_rate = 55e6 ;
n_bits = 12000 ;

symbol_rate = data_rate / 2 ;
SpS = f_clk / symbol_rate ;
n_symb = n_bits / 2 ;
n_sample = n_symb * SpS ;

bit_tx = randint(n_bits, 1, [0 1] ) ;

bit_I = bit_tx(1 : 2 : n_bits) ;
bit_Q = bit_tx(2 : 2 : n_bits) ;

data_in_SRRC_tx_I = -2*bit_I + 1 ;
data_in_SRRC_tx_Q = -2*bit_Q + 1 ;




%********************************** SRRC DESIGN
delay = 3 ;
roll_off = 0.35 ;
input_rate_SRRC = symbol_rate ;
output_rate_SRRC = f_clk ;


num_fir=rcosine(input_rate_SRRC, output_rate_SRRC, 'fir/sqrt', roll_off, delay);



% **********************************************
% ************************************ QPSK MODULATOR
% **********************************************





% ******************************** CARRIER FREQUENCY = f_clk/4

t_clk = 1 / f_clk ;
t = 0 : t_clk : (n_sample-1)*t_clk ;
theta = 2*pi*(f_clk/4)*t ;
coseno = [cos(theta)] ;
  seno = [sin(theta)] ;


data_out_SRRC_I = applica_polifase(data_in_SRRC_I, SpS , num_fir);
data_out_SRRC_Q = applica_polifase(data_in_SRRC_Q, SpS , num_fir);


QPSK_I = [coseno .* data_out_SRRC_tx_I(1:length(coseno)] ;
QPSK_Q = - [seno .* data_out_SRRC_tx_Q(1:length(coseno)] ;


 
[Pyy , f_out] = pwelch(QPSK, [] , [] , 'onesided', length(QPSK) - 1 , f_clk) ;
Pyy_dB = 10*log10(Pyy) ;
figure ; plot(f_out , Pyy_dB - max(Pyy_dB) );
grid ; xlim([0 f_clk/2]) ;
title(['PSD QPSK FLP con data rate ',num2str(data_rate/1e6),' Mbps']);
xlabel('Frequency (Hz)'); ylabel('dB / Hz');

 
 
% *****************************************************
% *************************************** CHANNEL EFFECT
% *****************************************************

SNR_x_bit_dB = 6 ;
SNR_dB = SNR_x_bit_dB -10*log10(0.5) - 10*log10(f_clk / (data_rate) );
QPSK_et_noise = awgn( (QPSK_I + QPSK_Q) , SNR_dB, 'measured' , [] ,'dB' );





% *****************************************************
% ********************************* QPSK DEMODULATOR
% *****************************************************

data_in_SRRC_rx_I = coseno .* QPSK_et_noise ;
data_in_SRRC_rx_Q = -seno .* QPSK_et_noise ;


data_out_SRRC_rx_I = filter(num_fir, 1 , data_in_SRRC_rx_I);
data_out_SRRC_rx_Q = filter(num_fir, 1 , data_in_SRRC_rx_Q);


data_rx = [data_out_SRRC_rx_I' data_out_SRRC_rx_Q'];

scatterplot(data_rx , SpS , 18) ;
  
eyediagram(data_out_SRRC_rx_I(601:2400) , SpS , 1/symbol_rate , 0);


simboli = demodmap(data_rx , [symbol_rate 0] , f_clk , 'qask' , 4) ;



for i = 1:length(simboli)
     switch simboli(i)
        case 0
            simboli_I(i) = 1 ; simboli_Q(i) = 1 ;
        case 1
            simboli_I(i) = -1 ; simboli_Q(i) = 1 ;
        case 2
            simboli_I(i) = 1 ; simboli_Q(i) = -1 ;
        case 3
            simboli_I(i) = -1 ; simboli_Q(i) = -1 ;
        otherwise
            error('Nun ce prova ''nfame !!! ')
     end
end



bit_rx_I = ( simboli_I - 1) / (-2) ;
bit_rx_Q = ( simboli_Q - 1) / (-2) ;



bit_rx = 4*ones(1,n_bits) ;
bit_rx(1 : 2 : n_bits) = bit_rx_I ;
bit_rx(2 : 2 : n_bits) = bit_rx_Q ;




delta = 10 ;

[wrong BER]=biterr(bit_tx(1:(n_bits-delta)),bit_rx((delta+1):n_bits)')


expBER_matlab = 0.5 .* erfc( sqrt ( 10.^ (SNR_x_bit_dB(:) .* 0.1) ) )














THE FOLLOWING CODE HAVE TO BE IN A FILE NAMED applica_polifase.m







% MODULE NAME : applica_polifase.m
% DESCRIPTION : Applica il filtraggio secondo lo schema polifasepolifase
% RELEASE :
% PROBLEMS :
% DATE : 3-6-2001


function data_out_polifase = applica_polifase(data_in_polifase, SpS , coefficienti)

n_fir = SpS ;
n_symb = length(data_in_polifase) ;
n_coefficienti = length(coefficienti) ;
max_dim_fir = ceil( n_coefficienti / n_fir) ;



matrice_dei_fir = zeros(n_fir, max_dim_fir) ;
for i = 1 : n_fir
    fir_i = coefficienti(i : n_fir : n_coefficienti) ;
    matrice_dei_fir(i , 1:length(fir_i) ) = fir_i ;
end



matrice_fir_out = zeros( n_fir , n_symb ) ;
for i = 1 : n_fir
    matrice_fir_out(i,:) = filter(matrice_dei_fir(i,:) , 1 , data_in_polifase');
end


data_out_polifase = zeros( 1 , n_symb * n_fir ) ;
k = 0 ;
for colonna = 1 : n_symb
    for riga = 1 : n_fir
        k = k + 1 ;
        data_out_polifase(k) = matrice_fir_out(riga , colonna);
    end
end

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us