BER output problem for Radio over Fiber system/Optical Comm

Discussion in 'Wireless & RF Design' started by thavamaran, Apr 22, 2010.

  1. thavamaran

    Thread Starter Active Member

    Feb 21, 2008
    67
    0
    Hi guys, this is my first work in optical and first simulation in matlab. I am sorry if there is mistake and im really new to this.

    Here is what I did, im simulation an entire Radio Over Fiber system with Matlab, linear system.

    Let me insert my code first,
    Code ( (Unknown Language)):
    1. %*****************************Defining constant parameter****************
    2. %Rb = 1e+6;                  %bit rate
    3. %Tb = 1/Rb;                  %bit duration / period
    4. Num_bits = 1e4;             %number of bits
    5.  
    6. nsamp = 20;                 %samples per symbols
    7. %Tsamp = Tb/nsamp;           %sampling rate, fsamp = 20MHz.
    8. a = 0.2;                    %channel attenuation, dB/km
    9. L = 20;                     % Length of fiber
    10. Gain = 10;                  %Gain in dB
    11.  
    12. %*****************************Filter definations************************
    13.  
    14. snr_dB=0:20;                            %SNR in dB from 0 to 20
    15.  
    16. SNR=10.^(snr_dB./10);                   %SNR in linear scale
    17.  
    18. Tx_filter = ones(1,nsamp);              %transmitter filter, in terms of
    19.                                         % h(t),match filter
    20. Rx_filter = fliplr(Tx_filter/nsamp);    % receiver filter (matched filter),
    21.                                         % flip from left to right to make
    22.                                         % it h(T-t), match filter
    23.  
    24. Tx_OOK = randint(1,Num_bits);           % randomly generating 1 and 0 in a
    25.                                         % row of matrix for 1000
    26.                                         % column,basically ON-OFF keying
    27.                                         % with random bits
    28.                                        
    29.                                        
    30. %*****************************Channel input*****************************                                        
    31. Tx_OOKin = 0+Tx_OOK;                    % Tx+with power, 0dBm,ideal.
    32.  
    33. %*****************************Channel properties************************
    34.                                        
    35.  Txch = Tx_OOKin -(a*L);                %Signal in channel, deducting with
    36.                                         %channel attenuation=4dB
    37.  
    38. Txout = 10.^(Txch./10);                 %Changing back the signal to linear
    39.                                         %scale
    40.  
    41. Tx_signal = rectpulse(Txout,nsamp);     % generate rectpulse for nsamp time
    42.                                         % per symbol
    43.                                        
    44.                                      
    45. %*****************************Receiver**********************************                                        
    46. for i=1:length(snr_dB)                                        
    47. [B]Rx_signal = awgn(Tx_signal,snr_dB(i)+3-10*log10(nsamp),'measured');[/B]
    48.                                    
    49.  
    50.  
    51. %*****************************Match filtering***************************
    52. MF_out = conv(Rx_signal,Rx_filter);          %equivalent to y(t)=x(t)*h(t)
    53.  
    54. MF_out_downsamp = MF_out(nsamp:nsamp:end);   %sampling and hold
    55.  
    56.  
    57.  
    58. %try without truncation
    59.  
    60. %*****************************Thresholding*******************************
    61.  
    62. Rxth = zeros(1,Num_bits);               %Reset receiver before thresholding
    63.  
    64. Rxth(find(MF_out_downsamp>0.45))=1;     %value above 0.45 equivalent to one
    65.                                         %at the receiver, thresholding.
    66.                                        
    67. %*****************************BER CALC**********************************
    68. ber(i) = biterr(Tx_OOK,Rxth);           %Matlab function for ber
    69. %******************Theoritical BER CALC**********************************
    70. ber_pr(i) = Qfunct(sqrt(SNR(i)));       %theoritical for ber
    71. end
    72.  
    73. figure;
    74. semilogy(snr_dB,ber,'b');               %Simulation
    75. hold on;
    76. semilogy(snr_dB,ber_pr,'r');
    77. xlabel('SNR(dB)');
    78. ylabel('BER');
    Above is my entire code, the part i bold, i dun really get the idea, i took it from my friend cause at the receiver part, i dont really have an idea of how to receive the signal for at least with 10 different SNR rate and plot BER. My friend used the Match filter, but i dont really have the exact idea how match filter works.

    The Tx_filter and Rx_filter part i got it where we flip the entire input from transmitter and at the receiver. which is h(t) from transmitter becomes h(-t).

    I have uploaded the output and the blue line on the plot is the output that i got
     
Loading...