1.软件版本
MATLAB2013b
2.本算法理论知识
可见光通信,2篇比较好的论文:
http://wenku.baidu.com/view/3c077736a32d7375a4178022.html
http://www.docin.com/p-121488388.html
3.核心代码
%OFDM transmitter and receiver for Visible light communication.
clc;
clear all;
close all;
warning off;
addpath 'func\'
%参数初始化
%the OFDM symbols
Nsc = 256;
%frame length
Lf = 10;
%发送数据
tx_data = func_seq('PRBS_15','PRBS',2e5);
%MQAM
M = 4;
%QAM objects
[mods,demods] = func_MQAM(Nsc,'M',M,'SymbolOrder','Gray');
SNR = [1:1:8];%高斯白噪声
Ng = 0.1;
%training sequence
TS_level = [1,1];
%samples per symbol
Nfft = 8*Nsc;
%cyclic prefix length
Np = round(Ng*Nfft);
%发送前调制
y_Tx_mod = func_OFDM_modulator(tx_data,mods,Np,Lf,TS_level,Nfft);
for i = 1:length(SNR)
i
SNRs = SNR(i);
%可见光信道
y_Tx_bef = y_Tx_mod;
Fs = 40e9;
Ts = 1/Fs;
F_AWG = 1.25e9;
F_RF = 0e9;
AWG = upsample(y_Tx_bef,Fs/F_AWG);
n = (1:length(AWG))';
S_RF = AWG.*exp(1j*2*pi*F_RF*n*Ts); %
%LED信道
SNRdb = func_LED_channel();
y_Rx = func_decimate2(S_RF,Fs/F_AWG);
%最后加入白噪声
y_Rx2 = awgn(y_Rx,SNRs+SNRdb,'measured');
%OFDM解调
[rx_data,Y] = func_OFDM_demodulator(y_Rx2,demods,Np,Lf,TS_level,Nfft);
[Nerr,BER] = func_error(rx_data,15,0);
Bers(i) = BER;
end
figure;
plot(Y(1:Nsc/2,:),'r.');
hold on;
plot(Y(Nsc/2+1:end,:),'b.');
title('Received constellation');
xlabel('I');
ylabel('Q');
grid on;
%计算误码率
figure;
semilogy(SNR,Bers,'b-o');
hold on;
xlabel('SNR');
ylabel('BER');
grid on;
legend('OFMD-4QAM');
axis([0,12,1e-5,1]);
4.操作步骤与仿真结论
最后仿真结果如下所示:
这个是最后接收后的星座图,这里我们使用的OFDM-4QAM的调制方法,所以最后可以看到四个星座点。
这个是误码率曲线,从上面的仿真结果可知,当SNR=8的时候,误码率在10-4左右。
5.参考文献