Joke Collection Website - Public benefit messages - Xia Banzhang talks about OFDM communication system simulation.

Xia Banzhang talks about OFDM communication system simulation.

The cause is this. I just finished writing a patent recently, and I have a huge brain hole. I want to write some articles to cultivate my sentiment. But I can't write romance novels, which makes me very painful. The only thing I know is matlab, so write an article to indulge yourself, hahaha. .

? It's been sunny and foggy recently. The most painful thing is the communication system test of OFDM next week. Presumably, my classmates' brains are bigger than mine, and many students ask me how to do this OFDM. I also briefly talk about OFDM system under Gaussian channel, in fact, I also talk about OFDM under Rayleigh and Rice channels. But don't ask, it's a little difficult.

They communicate with us to decorate broadband and wires, but they are not. Should we fight for strength or know some common sense?

Source coding: pay attention to signal capacity compression and improve transmission efficiency.

Channel coding: insert redundant information for variable channels to increase transmission stability (insert CP (cyclic prefix) in the designed OFDM, and the pilot signal is redundant information).

Signal modulation: converting a bit stream into a stable waveform for transmission.

For example: sint? And then what? sin2t? Is a pair of orthogonal signals, because sint*sin2t is in the interval; % input sequence xk

sn = IFFT(xk); ? Serial number sequence output after %IFFT

? The IFFT curve after the input sequence can be obtained.

%////////////////////////////////////////////////////////////////////////////////////////////////////

Use the formula: f(t)=∑fk e(j. 2πδf kt).

For QPSK modulation, there are two bits in OFDM symbol.

(Number of bits corresponding to OFDM symbol and modulation scheme: (QPSK: 2), (16QAM: 4), (64QAM: 6)? )

Find the subcarrier according to the formula.

Subcarrier percentage

e 1 = exp( 1i * 2 * pi * f * t);

E2 = exp( 1i * 2 * pi * f * t * 2);

E3 = exp( 1i * 2 * pi * f * t * 3);

E4 = exp( 1i * 2 * pi * f * t * 4);

Expression of OFDM baseband complex signal

ST = d 1 * e 1+D2 * E2+D3 * E3+D4 * E4; ? % Expand the formula above.

Draw a portrait of St. Peter.

Let's compare the st and sn images above.

(The picture above shows the real part, and the picture below shows the imaginary part.)

Surprisingly, the graph after IFFT is the discrete value of the formula graph! Therefore, OFDM system and Fourier series have close and inseparable feelings, such as Cowherd and Weaver Girl, Yang Guifei and Tang Xuanzong, Huluwa and Grandpa. . . . . This seems a bit strange.

? So the function of IFFT module is equivalent to saying: don't bother to send N subcarrier signals, I will directly calculate what you will superimpose in the air; The function of FFT module is equivalent to saying: Don't use the old-fashioned integration method to remove other orthogonal subcarriers, let me help you calculate all the N carrier signals at once.

Finally, the design will be carried out. There's so much ahead that I'm tired of playing. It turns out that writing articles is so hard, I think Sima Qian is better than cattle. .

Let's start with the simplest Gaussian channel. Let's leave now.

As mentioned above, Fourier transform plays an important role in OFDM system, so we use IFFT and FFT algorithms in the simulation of OFDM system.

Gaussian signal adds Gaussian white noise to the signal through this channel.

In the simulation of maltab communication system, we use AWGN (TRDATA 1, SNR,' measured'); Add the function of Gaussian white noise to the signal TrData 1.

After the signal passes through the wireless channel, its signal amplitude is random, that is, fading, and its envelope obeys Rayleigh distribution.

The received signal has four effects: 1. Shadow 2. Distance 3. Multiplex 4. Doppler frequency shift.

Simply put, Rice channel has one more DC component than Rayleigh channel.

It is what we call cyclic prefix, so why add redundant information of CP cyclic prefix? In order to resist ICI (Inter-carrier Interference) caused by multipath effect, it should also be noted that CP occupies about115 resources of each OFDM symbol.

The information of the pilot signal is inserted into the training sequence to estimate the channel in real time, and then the signal is corrected to reduce the bit error rate during demodulation.

From:

Step 1: generate random sequence signal = rand (1, PARA * NS * 2) > 0.5.

Among them, we set the number of subcarriers transmitted in parallel.

Ns is the number of OFDM signals in the frame structure.

Step 2: Carry out serial-parallel conversion.

Serial-parallel conversion into a very important function shaping function

Its usage is: SIG para = shape(signal, para, ns * 2); Convert the original signal into parallel Ns*2 column signals.

Remodeling (a, m, n); Firstly, the matrix A is divided into columns, and then spliced into vectors with the size of m * n. ..

Step 3: QPSK modulation.

(1) Divides data into two channels, I channel and Q channel.

This function is as follows:

For j= 1:Ns

ich(:,j)=SigPara(:,2 * j- 1);

qch(:,j)=SigPara(:,2 * j);

end

(2) According to the QPSK mapping relation, the input data is obtained.

kmod= 1。 /sqrt(2);

ich 1=ich。 * kmod

qch 1=qch。 * kmod? %QPSK mapping relation

Step 4: Insert the guard interval

ich3=[ich2(fl-gl+ 1:fl,); ich 2];

qch3=[qch2(fl-gl+ 1:fl,:); qch 2];

We choose gl = 32: copy the last 32 groups of data of the signal and add them to the original signal-strengthen fault tolerance.

Step 5: Parallel-serial conversion

ich4=reshape(ich3, 1,(fl+GL)* Ns);

qch4=reshape(qch3, 1,(fl+GL)* Ns);

Multiple transmission data are formed: trdata 1 = ich4+qch4. * sqrt(- 1);

Step 6: Add Gaussian white noise to the transmitted data.

ReData=awgn(TrData 1, SNR,' measured');

%///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Receiving end:

Step 1: Remove the guard interval.

(1) to copy data.

idata = real(ReData); Percentage of real part after adding noise

qdata = imag(ReData); Percent of imaginary part after adding noise

(2) serial-parallel conversion of data

idata 1 = reshape(idata,fl+gl,Ns);

qdata 1 = reshape(qdata,fl+gl,Ns);

(3) remove the protection interval

idata 2 = idata 1(GL+ 1:GL+fl,);

qdata 2 = qdata 1(GL+ 1:GL+fl,);

The data from gl+ 1 to gl+fl in each column of idata 1 constitute iadta2.

Step 2: Fast Fourier Transform

Step 3: QPSK demodulation:

(1)FFT converted data /komd?

? (2) Parallel-serial conversion

(3) Recombination signal

Step 4: Sampling and judging

ReSig = Res & gt0.5; After analyzing the above recombined signals, the signal greater than 0.5 is assigned as 1, and the signal less than 0.5 is assigned as 0.

Step 5: Calculate the probability of error.

err = 0;

For I =1:para * ns * 2;

if (Signal(i)~=ReSig(i))

err = err+ 1; % Get the number of error codes.

end

end

PE = err/(para * Ns * 2);

The snr-Pe curve can be obtained by taking multiple sets of SNR values and adding Gaussian channels.

%///////////////////////////////////////////////////////////////////////////////////////

The picture shows OFDM (no channel estimation) in Rayleigh channel.

It can be seen that when multipath and Doppler frequency shift are added, the channel error rate rises from 3% to about 30%, and Rayleigh channel completely destroys the signal transmission.

Introducing pilot signal

We are adding platoon pilots and platoon pilots.

A =[A; R] Insert the line? interpolation

Add a guide between lines:

ich2= [zeros(fl, 1) ich2 1(:,[ 1:Ns/2]) zeros(fl, 1) ich2 1(:,[Ns/2+ 1:Ns]) zeros(fl, 1)];

Add pilot between lines:

Ich 2 =[ zero (1, (ns+3)); ich2( 1:fl/2,); Zero (1, (ns+3)); ich2((fl/2)+ 1:fl,); Zero (1, (ns+3))]; ?

The result of joining:

After adding the pilot signal, the LS algorithm can be used to estimate the channel.

The basic principle of LS algorithm: Y = HX+N? Where n is the noise signal, h is the frequency response of the channel, and y and x are the responses of the output and input signals.

In the ideal channel: H'= Y/X input divided by output (where y is the signal after passing through Rayleigh channel), the frequency response H' can be estimated.

We use the obtained h' to calculate the estimate of x in turn: X' = Y/H'? Get new input. X' is subjected to subsequent processing of de-pilot.

For j = 1:(Ns+3)

For i = 1:(para+3)

Hls(i,j) = idata2 1(i,j)。 /ich2(i,j);

ixg(i,j) = idata2 1(i,j)。 / Hls(i,j);

hls(i,j) = qdata2 1(i,j)。 /qch2(i,j);

qxg(i,j) = qdata2 1(i,j)。 / hls(i,j);

end

end

Schematic diagram of bit error rate after adding channel estimation:

In OFDM system, the influence of OFDM system is very small when there is only Gaussian white noise, and the advantage of OFDM design in Gaussian channel is very small.

But in Rayleigh channel, OFDM pilot signal, CP and channel estimation protect the transmitted signal. In the case of receiving multipath and Doppler frequency shift, the original signal can be effectively restored.

In OFDM-Rayleigh system without channel estimation, multipath, distance, shadow and Doppler frequency offset cause serious interference to the signal. It can't be transmitted normally, and the error rate is serious.

. . . . . . . I'm tired of typing. There may be some mistakes in it. Please correct me.