1
$\begingroup$

I simulated a VLC system for an AWGN channel and plotted the BER against Ebno. I used the LED impulse response and convolved it with the signal produced to transmitting. But the results are not OK. It means that Ber is fixed or 0.5. It is a PAM-DMT system which the transmitter is a 50*50 array of LEDs. The input is a binary sequence that are modulated by PAM modulator. They are used to make OFDM symbols by PAM-DMT algorithm. OFDM symbols are modulated with LED intensity and transmitted into the channel. At the receiver side, after the demodulating the received symbols, the received binary sequence is compared with the input binary sequence to calculate BER. In each OFDM symbol, there are some data carriers, pilot symbol carriers and null carriers. I think the problem is about the scheme I use to cut the extended length (made by convolving the LED input with the LED impulse response) of the transmitted signal at the receiver side. Could anyone help me if I am wrong?

Here is my Matlab code:

 clear,clc;

 close all;

%%

k=4;M=2^k;%4 bits per PAM symbol%

c=3*1e8;

f_3dB=15e6;

N=32;

R=0.54;%Responsivity at A/W%

Ar=1e-4;

index=1.5;

carier_freqSpac=f_3dB/N;

T_sym=1/f_3dB;

Tb=T_sym/k;

Rb=1/Tb;

T_ifft=1/carier_freqSpac;

l_cp=N/4;

T_cp=T_sym*l_cp;

T_ofdmsym=T_ifft+T_cp; %OFDM symbol duration is 4us%

l_ofdm_sym=N+l_cp;

n_pilot_carrier=N/16;

n_null=N/16;

n_data_carrier=N-n_null-n_pilot_carrier;

nofdm=2e4;

TTran_ofdm_sym=((n_data_carrier+n_pilot_carrier)*T_sym)+T_cp;

Rb_ofdm=((n_data_carrier+n_pilot_carrier)*k)/TTran_ofdm_sym;% at b/s


hpammod=comm.PAMModulator(M,'BitInput',true);

hpam_demod=comm.PAMDemodulator(M,'BitOutput',true);

%Pilots in the 1st half

if N==32;

    PS=[1];

elseif N==64;

    PS=[-1 1];

elseif N==128;

    PS=[-1 -1 1 1];
end;


input_b=randi([0,1],nofdm*(n_data_carrier/2)*k,1);%1000036,1160

n_bit=length(input_b);

PAM_sym=step(hpammod,input_b);

n_PAMsym=n_bit/k;

PAM_sym=reshape(PAM_sym,n_data_carrier/2,nofdm);

 PAM_sym_PS_1st=[];

PAM_sym_PS_2nd=[];

if N==32;

for i=1:nofdm;

   PAM_sym_ps_1st=1j.*[0;PAM_sym(1:14,i);PS(1)];

   PAM_sym_PS_1st=[PAM_sym_PS_1st PAM_sym_ps_1st];

   PAM_sym_ps_2nd=circshift(conj(flipud(PAM_sym_ps_1st)),1); 

   PAM_sym_PS_2nd=[PAM_sym_PS_2nd PAM_sym_ps_2nd];

end;

elseif N==64;

    for i=1:nofdm;

   PAM_sym_ps_1st=1j.*[0;PAM_sym(1:14,i);PS(1);0;PAM_sym(15:28,i);PS(2)];

   PAM_sym_PS_1st=[PAM_sym_PS_1st PAM_sym_ps_1st];

   PAM_sym_ps_2nd=circshift(conj(flipud(PAM_sym_ps_1st)),1); 

   PAM_sym_PS_2nd=[PAM_sym_PS_2nd PAM_sym_ps_2nd];

end;

elseif N==128;

    for i=1:nofdm;

   PAM_sym_ps_1st=1j.*
[0;PAM_sym(1:14,i);PS(1);0;PAM_sym(15:28,i);PS(2);0;PAM_sym(29:42,i);PS(3);0;PAM_sym(43:56,i);PS(4)];

   PAM_sym_PS_1st=[PAM_sym_PS_1st PAM_sym_ps_1st];

   PAM_sym_ps_2nd=circshift(conj(flipud(PAM_sym_ps_1st)),1); 

   PAM_sym_PS_2nd=[PAM_sym_PS_2nd PAM_sym_ps_2nd];

end;

end;

ifft_in=[PAM_sym_PS_1st;PAM_sym_PS_2nd];

ifft_out=ifft(ifft_in,N);

cp=ifft_out(N-l_cp+1:N,:);

ofdm_sym=[cp;ifft_out];

ofdm_sym1=reshape(ofdm_sym,l_ofdm_sym*nofdm,1);% P/S%

uni_ofdm_sym=(ofdm_sym1+abs(ofdm_sym1))./2;


t=0:T_sym:100e-9;%ns

n_led=2500;

hled=(n_led).*exp((-2*pi*f_3dB).*t);

hled=hled./sum(hled);

ledin=48e-6*n_led+uni_ofdm_sym;

optsig=R.*conv(ledin,hled);

l=length(optsig)-length(ofdm_sym1);

Ebno_dB=0:20;

SNR_db=Ebno_dB+10*log10((N/N+l_cp))...
 +10*log10(((n_data_carrier+n_pilot_carrier)/N))+10*log10(k);


 Ber=zeros(1,length(SNR_db));

for rr=1:length(SNR_db);

inoisy=awgn(optsig,SNR_db(rr),'measured');

inoisy1=inoisy((1+floor(l/2)):(floor(l/2)+length(ofdm_sym1)));

inoisy22=reshape(inoisy1,l_ofdm_sym,nofdm);

fft_in=inoisy22(l_cp+1:N+l_cp,:);

fft_out=fft(fft_in,N);

if N==32;

    fft_out2=fft_out(2:15,:);

elseif N==64;

    f1=fft_out(2:15,:);

    f2=fft_out(18:31,:);

    fft_out2=[f1;f2];

elseif N==128;

    f1=fft_out(2:15,:);

    f2=fft_out(18:31,:);

    f3=fft_out(34:47,:);

    f4=fft_out(50:63,:);

    fft_out2=[f1;f2;f3;f4];

end;

fft_out3=2.*imag(fft_out2);

fft_out4=reshape(fft_out3,n_data_carrier*0.5*nofdm,1);

demoded_sig=step(hpam_demod,fft_out4);

ber1=xor(input_b,demoded_sig);

Ber(1,rr)=sum(ber1)/length(ber1)

end;

semilogy(Ebno_dB,Ber,'g-s','LineWidth',2.5,'MarkerSize',8);grid on;
$\endgroup$
6
  • 2
    $\begingroup$ So, ... are you asking us to error check your code, or what? $\endgroup$
    – Fred
    Mar 9 '17 at 11:43
  • $\begingroup$ Fred is right. Your post lacks the question. $\endgroup$
    – SF.
    Mar 9 '17 at 12:22
  • $\begingroup$ Hello, It is nice if you tell me what is wrong in this code or give any idea that help me to solve the problems. $\endgroup$
    – user10390
    Mar 9 '17 at 12:24
  • $\begingroup$ @user10390 there are few things less helpful than "fix my code please." You haven't described the intended input or output, nor have you given references for the algorithms you're trying to implement. $\endgroup$ Mar 9 '17 at 14:54
  • $\begingroup$ Hi Carl, The input is a binary sequence that are modulated by PAM modulator. They are used to make OFDM symbols by PAM-DMT algorithm. OFDM symbols are modulated with LED intensity and transmitted into the channel. At the receiver side, after the demodulating the received symbols, the received binary sequence is compared with the input binary sequence to calculate BER. $\endgroup$
    – user10390
    Mar 9 '17 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.