Sunteți pe pagina 1din 3

Im trying to run some point-to-point communications link using OFDM modulation scheme. In matlab, I generate a random bit stream.

This stream is converted in a sequence of symbol : I used a 4-QAM modulation, so the length of one symbol is 2. Im trying to achieve optical communications so the time-domain signal has to be real-valued and positive. I realize a hermitian symmetry of the signal so as the output of my IFFT is only real and positive. After that, the signal goes through my device modulation bandwidth and a AWGN channel. At the receiver, I demodulate the signal using FFT operation and QAM demapping. Note that its not really OFDM because for the moment because I dont use cyclic prefix nor forward error correction. I need to plot BER for different data rates, but I dont find the relation between these two. Any suggestions ? Thanks in advance. Here my code : (correct me if there are errors, Im new in matlab and OFDM) %% Setup % OFDM parameters M =4; % Size of signal constellation k = log2(M); % Number of bits per symbol n_bits =512; % Number of bits to process N=2^11; % IFFT/FFT length (2^15 max AWG can take) num_zeros=N-1-2*(n_bits/k); % number of zeros to add hMod = comm.RectangularQAMModulator(M); % Create a M-QAM modulator %% Signal Source x = randi([0 1],n_bits,1); % Random binary data stream %% Bit-to-Symbol Mapping % Convert the bits in x into k-bit symbols. hBitToInt = comm.BitToInteger(k); xsym = step(hBitToInt,x); %% Modulation x_mod = modulate(modem.qammod(M),xsym); % Modulate using M-QAM. %% IFFT x_mod=[1;x_mod]; % DC component x_herm=flipud(conj(x_mod)); % Hermitian symmetry x_zero=[x_mod;zeros(num_zeros,1);x_herm]; % Zero padding : FFT algorithm efficient if input is a power of 2 x_ifft=N.*ifft(x_zero,N); % IFFT : x_ifft should be real due to hermitian symmetry

%% Butterworth filter (LED bandwidth) Fe=10e6; Te=1/Fe; fc=4e6 ; %cut-off frequency [b,a] = butter(4,fc/(Fe/2),low); % freqz(b,a,1000,Fe); % [h_filt,t_filt]=impz(b,a,100); %% Data through transmitter Tx=filter(b,a,x_ifft); %% Channel % White gaussian noise EbNo = 10; % ratio of bit energy to noise power spectral density, Eb/N0 in dB snr = EbNo + 10*log10(k) 10*log10(1); hChan = comm.AWGNChannel(NoiseMethod, Signal to noise ratio (SNR), SNR,snr); hChan.SignalPower = (Tx * Tx)/ length(Tx); awgn = step(hChan,Tx); %% Data through receiver Rx=awgn; %% FFT y_fft=fft(Rx,N)./N; y_fft=y_fft(1:length(x)/k+1); y_fft=y_fft(2:end); %% Demodulation y_demod = demodulate(modem.qamdemod(M),y_fft); %% Symbol 2 bit Mapping hIntToBit = comm.IntegerToBit(k); y_bits = step(hIntToBit,y_demod); %% Plot:QAM mapping h=scatterplot(y_fft,1,0,g.); hold on; scatterplot(x_mod(2:end),1,0,k*,h); title(Received signal); legend(Received signal, Signal constellation); axis([-5 5 -5 5]); hold off;

%% BER Computation % Compare x and z to obtain the number of errors and % the bit error rate. hErrorCalc = comm.ErrorRate; berVec = step(hErrorCalc,x,y_bits); bit_error_rate = berVec(1) number_of_errors = berVec(2)

S-ar putea să vă placă și