<< Chapter < Page | Chapter >> Page > |
%% Demodulate Baseband OFDM Signal (RECEIVER)
% ------------------------------------------------------------------------% Description: This is the receiver module in its entirity. It combines
% all of the sub-processes and parameters to ultimately take% a sequency of training symbol and valid OFDM symbol, and
% output the modulated bits.%
% Inputs: word_to_symbol_map - The complex symbols indexed by the binary% word they represent.
% num_subcarriers - The number of subcarriers in the symbol% size_of_fft - Size of FFT used for correct indexing/timing
% train_pn - Pseudo-noise used in transmitted training symbol (a% priori knowledge)
% Outputs: bits - Demodulated bitsfunction bits = ofdm_dem(word_to_symbol_map, num_subcarriers, size_of_fft, train_pn)%%
% Calculated the expected training symbol from the given pseudo-noise for% adequate phase recovery.
train_expected = zeros(1,size_of_fft);train_expected(3) = train_pn(1);
train_expected(size_of_fft-1) = train_pn(1+size(train_pn,2)/2);train_expected = ifft(4*train_expected);
z = get_input(); % Parse input dataz = z'; % Convert from column vector to row vector to accomidate sub-processes
% Invoke timing algorithm to retrieve sample that training symbol starts on[index value] = tsync(z,size_of_fft);train = z(index:index+size_of_fft-1); % Cut out training symbol
phi = fsync(train, train_expected); % Estimate phase offset% Cut out OFDM data symbol and correct for phase offset
z = z(index+size_of_fft:index+2*size_of_fft-1).*exp(j*phi);% Separate the data symbol into two channels and take FFT for analysis% below
re = real(z);im = imag(z);
Z = fft(z);symbols = fft2sym(re,im,num_subcarriers); % Take FFT and retrieve symbolswords = sym2w(symbols,word_to_symbol_map); % Find closest match and map words to symbols
bits = fliplr(w2b(words)); % Decompress words into a series of bits for recovery.% Output the resulting data for debugging and analysissubplot(5,2,1); plot(real(train)); title('Re[Training Symbol]');subplot(5,2,2); plot(imag(train)); title('Im[Training Symbol]');subplot(5,2,3); plot(re); title('Re[OFDM Data Symbol]');subplot(5,2,4); plot(im); title('Im[OFDM Data Symbol]');subplot(5,2,[5 6]); plot(abs(Z)); title('Mag[OFDM Data Symbol Spectrum]');
subplot(5,2,[7 8]); stem(real(Z)); title('Re[OFDM Data Symbol Spectrum]');subplot(5,2,[9 10]); stem(imag(Z)); title('Im[OFDM Data Symbol Spectrum]');end
Notification Switch
Would you like to follow the 'Fully configurable ofdm sdr transceiver in labview' conversation and receive update notifications?