无线通信
来源:互联网 发布:linux jdk 编辑:程序博客网 时间:2024/06/10 13:44
Wireless Communications Project
- Wireless Communications Project
- Project 1 Simulation of Rayleigh fading
- II Objectives
- II II Theories
- III III Procedures
- A Fading simulator
- B Statistical Properties
- Project 8PSK Modulation and Demodulation
- II Objectives
- IIII Theories
- IIIIIIProcedures
- IVIV Questions
- Project 1 Simulation of Rayleigh fading
Project 1 Simulation of Rayleigh fading
I. Objectives
- Use the sum-of-sinusoid method to generate flat Rayleigh fading.
- Investigate the statistical properties of the fading generated by simulator.
II. Theories
Let
where
The time-domain property of the random process of Rayleigh fading can be characterized by its autocorrelation function. The autocorrelation function of Rayleigh fading satisfies
where
With the sum-of-sinusoid method described in (1)-(3), both the inphase components
and quadrature components are zero-mean Gaussian distributed with variance 0.5.
III. Procedures
A. Fading simulator
- For the sum-of-sinusoid method,
E[|hI(t)2|]=E[|hQ(t)2|]=0.5 .Moreover,hI(t) andhQ(t) are independent. What is the value ofE[|h(t)2|] .E[|h(t)2|]=1 Based on the sum-of-sinusoid method described in (1)-(3), write a Matlab
function to simulate flat Rayleigh fading. The function should have three
input arguments:N: the number of samples to be generated.
fD : maximum Doppler spread.Ts : sample period.The output of the function should be the complex valued fading process. In
the simulator development, using M = 16.
Hint: to improve simulation speed, use as few loops as possible. Multi-level
loops are strongly discouraged (Matlab is very slow in processing loops).
Try to use vectors and matrices for operations over a series of numbers or
variables.Example 1:
x = 0;
for m = 1:10
x = x+m;
end
can be replaced by
a = 1:10;
x = sum(x);
Example 2:
a = [1:10], b = [11:20];
for m = 1:length(a)
x(m) = a(m)*b(m);
end
can be replaced by
x = a.*b;
Example 3: a = [1:10], b = [11:20];
x = 0;
for m = 1:length(a)
x =x+ a(m)*b(m);
end
can be replaced by
x = a*b’;function [h]=rayleighFading(N,fd,Ts)% function to generate Rayleigh Fading samples% N = number of samples to generate% fd = maximum Doppler frequency% Ts = sampling periodM = 16; % number of multi-paths in the channela=0;b=2*pi;alpha=a+(b-a)*rand(1,M); %uniformly distributed from 0 to 2 pibeta=a+(b-a)*rand(1,M); %uniformly distributed from 0 to 2 pitheta=a+(b-a)*rand(1,M); %uniformly distributed from 0 to 2 pim=1:M;for n=1:N;x=cos(((2.*m-1)*pi+theta)/(4*M));h_re(n)=1/sqrt(M)*sum(cos(2*pi*fd*x*n'*Ts+alpha));h_im(n)=1/sqrt(M)*sum(sin(2*pi*fd*x*n'*Ts+beta));endh=h_re+j*h_im;end
Using the Rayleigh fading simulator generate N = 400 samples, set
Ts =
0.0001 seconds,fD = 100 Hz.h=Rayleigh(N,fd,Ts)
Plot the real part (real(h) ), imaginary part ( imag(h) ), amplitude ( abs(h) ),
phase (angle(h) ) of the flat fading as a function of time (the x-axis is [0:N-
1]*Ts).clc;clear;N=400; %number of samples to generatefd=100; % Maximum doppler spread in hertzTs=0.0001; % Sampling period in secondsh=Rayleigh(N,fd,Ts);h_re=real(h);h_im=imag(h);figure;subplot(2,1,1);plot([0:N-1]*Ts,h_re);title('Real part of impulse response of the Flat Fading channel');xlabel('time(s)');ylabel('Amplitude |hI(t)|');subplot(2,1,2);plot([0:N-1]*Ts,h_im);title('Imaginary part of impulse response of the Flat Fading channel');xlabel('time(s)');ylabel('Amplitude |hQ(t)|');figure;subplot(2,1,1);plot([0:N-1]*Ts,10*log10(abs(h)));title('Amplitude Response of the Flat Fading channel');xlabel('time(s)');ylabel('Magnitude |h(t)|');subplot(2,1,2);plot([0:N-1]*Ts,angle(h));title('Phase response of the Flat Fading channel');xlabel('time(s)');ylabel('Phase angle(h(t))');
Repeat step 3 by setting
fD = 10 Hz.
- Repeat step 3 by setting
fD = 300 Hz.
B. Statistical Properties
Using the Rayleigh fading simulator generate N = 100,000 samples, set Ts =
0.0001 seconds,fD = 100 Hz. Using the function mean() and var() evaluate
the mean, variance of the real part and imaginary part of the fading samples.
How do they compare with their theoretical values?clc;clear;N=10^5; %number of samples to generatefd=100; % Maximum doppler spread in hertzTs=0.0001; % Sampling period in secondsh=Rayleigh(N,fd,Ts);h_re=real(h);h_im=imag(h);mean_re=mean(h_re)mean_im=mean(h_im)var_re=var(h_re)var_im=var(h_im)var_h=var(h)
Meanofrealpart≈0 Meanofimaginarypart≈0 Varianceofrealpart≈0.5 Varianceofimaginarypart≈0.5 Using the function pdf evaluate the pdfs of the real part, imaginary part of the Rayleigh fading. Plot the pdfs in two different figures. Plot the theoretical Gaussian pdfs in the corresponding figures.
clc;clear;N=10^5; %number of samples to generatefd=100; % Maximum doppler spread in hertzTs=0.0001; % Sampling period in secondsh=Rayleigh(N,fd,Ts);h_re=real(h);h_im=imag(h);%comparing the PDF of real part of generated samples against the PDF of Gaussian distribution[val1,bin1]=hist(h_re,1000); % pdf of real part of generated Raleigh Fading Samplesfigure;plot(bin1,val1/max(val1));hold on;x=-2:0.1:2;y=normpdf(x,0,sqrt(0.5)); % theoretical gaussian pdfplot(x,y/max(y),'r');title('evaluate the pdfs of the real part');legend('Simulated pdf','Theoretical Gaussian pdf');%comparing the PDF of imag part of generated samples against the PDF of Gaussian distribution[val2,bin2]=hist(h_im,1000); % pdf of real part of generated Raleigh Fading Samplesfigure;plot(bin2,val2/max(val2));hold on;x=-2:0.1:2;y=normpdf(x,0,sqrt(0.5)); % theoretical gaussian pdfplot(x,y/max(y),'r');title('evaluate the pdfs of the imag part');legend('Simulated pdf','Theoretical Gaussian pdf');
Using the function pdf evaluate the pdf of the amplitude of the Rayleigh
fading samples. Plot the pdf. Plot the theoretical Rayleigh pdf in the same
figure. What value ofσ2=E(|h(t)|2) should be used in the theoretical
calculation?σ2=E(|h(t)|2)=1 In this step, we are going to evaluate the auto-correlation function.
a) Generate a flat Rayleigh fading process with parameters N = 1,000, Fd =180Hz, Ts = 0.0001. Assign the process to variable h.
b) Evaluate the time domain auto-correlation function with the Matlab function corr_mat(1, :) = xcorr(h). The correlation information is stored in the first row of the matrix corr_mat.
c) Use for loop, repeat the above two steps 100 times to generate 100 Rayleigh fading processes. For the kth loop, the correlation information is stored in the kth row of corr_mat.
d) Evaluate the ensemble average of the auto-correlation function by using
the command mean(corr_mat, 1). The second parameter ‘1’ tells Matlab
that the mean operation is performed column wise of the matrix.
e) Plot the ensemble average of the auto-correlation function.
f) plot the theoretical value of the autocorrelation function in the same
figure. The Matlab function besselj( ) corresponds to the Bessel function.clc;clear;N=1000; %number of samples to generatefd=180; % Maximum doppler spread in hertzTs=0.0001; % Sampling period in secondsfor k = [1:100] h=Rayleigh(N,fd,Ts); corr_mat(k,:) = xcorr(h);end mean_corr_mat = mean(corr_mat,1);plot(mean_corr_mat,'g');hold onx= 1:1000;J0 = besselj(0,2*pi*fd*Ts*x);plot(x,J0,'r');legend('the ensemble average of the auto-correlation function',' the theoretical value of the autocorrelation function');
Project: 8PSK Modulation and Demodulation
I. Objectives
- Understand the concepts of baseband complex modulation.
- Understand the process of modulation and demodulation in complex baseband.
- Learn to simulate communication system with flat Rayleigh fading and AWGN.
II. Theories
The constellation diagram of 16Q AM modulation is shown in the following figure
In 16Q AMmodulator, every 4 bits are mapped to one complex-valued 16Q AM symbol. The transmitted symbols are corrupted by both Rayleigh flat fading and additive white Gaussian noise.
where
In this project, we assume that the receiver can perfectly estimate the fading response
After fading compensation, we perform demodulation on the fading compensated symbol
III. Procedures
Write a function, Q AM_16_mod.m, to perform baseband 16Q AM modulation. The input of the function is a vector containing binary’0’s and ‘1’s, the output of the function is a vector containing the baseband complex 16QAM symbols. The energy of the output symbols is 1.
function Symbol=QAM_16_Mod(bit)% 16QAM调制% 16QAM: s3 s2 s1 s0 m1 mQ% 0 0 0 0 -6A -6A% 0 0 0 1 -2A -6A% 0 0 1 1 2A -6A% 0 0 1 0 6A -6A% 0 1 0 0 -6A -2A% 0 1 0 1 -2A -2A% 0 1 1 1 2A -2A% 0 1 1 0 6A -2A% 1 1 0 0 -6A 2A% 1 1 0 1 -2A 2A% 1 1 1 1 2A 2A% 1 1 1 0 6A 2A% 1 0 0 0 -6A 6A% 1 0 0 1 -2A 6A% 1 0 1 1 2A 6A% 1 0 1 0 6A 6A%% note : A=1/sqrt(10)%bitlength=length(bit);A=1/sqrt(10);%bit(ii*4)=s3,bit(ii*4-1)=s2,bit(ii*4-2)=s1,bit(ii*4-3)=s0for ii=1:bitlength/4 if bit(ii*4)==0 if bit(ii*4-1)==0 %00** if bit(ii*4-2)==0 if bit(ii*4-3)==0 Symbol(ii)=-6*A-6*A*j; else Symbol(ii)=-2*A-6*A*j; end else if bit(ii*4-3)==0 Symbol(ii)=6*A-6*A*j; else Symbol(ii)=2*A-6*A*j; end end else %01** if bit(ii*4-2)==0 if bit(ii*4-3)==0 Symbol(ii)=-6*A-2*j; else Symbol(ii)=-2*A-2*A*j; end else if bit(ii*4-3)==0 Symbol(ii)=6*A-2*A*j; else Symbol(ii)=2*A-2*A*j; end end end else if bit(ii*4-1)==0 %10** if bit(ii*4-2)==0 if bit(ii*4-3)==0 Symbol(ii)=-6*A+6*A*j; else Symbol(ii)=-2*A+6*A*j; end else if bit(ii*4-3)==0 Symbol(ii)=6*A+6*A*j; else Symbol(ii)=2*A+6*A*j; end end else %11** if bit(ii*4-2)==0 if bit(ii*4-3)==0 Symbol(ii)=-6*A+2*A*j; else Symbol(ii)=-2*A+2*A*j; end else if bit(ii*4-3)==0 Symbol(ii)=6*A+2*A*j; else Symbol(ii)=2*A+2*A*j; end end end endend
Write a function, Q AM_16_demod.m, to perform baseband 16Q AM demodulation. The input of the function is a vector containing baseband complex 16Q AM symbols, the output of the function is a vector containing the binary sequence.
function softbit=QAM_16_demod(symbol)% 16QAM解调% 16QAM: s3 s2 s1 s0 m1 mQ% 0 0 0 0 -6A -6A% 0 0 0 1 -2A -6A% 0 0 1 1 2A -6A% 0 0 1 0 6A -6A% 0 1 0 0 -6A -2A% 0 1 0 1 -2A -2A% 0 1 1 1 2A -2A% 0 1 1 0 6A -2A% 1 1 0 0 -6A 2A% 1 1 0 1 -2A 2A% 1 1 1 1 2A 2A% 1 1 1 0 6A 2A% 1 0 0 0 -6A 6A% 1 0 0 1 -2A 6A% 1 0 1 1 2A 6A% 1 0 1 0 6A 6A%% note : A=1/sqrt(10)%symlength=length(symbol);A=1/sqrt(10);%temp(ii*4)=s3,temp(ii*4-1)=s2,temp(ii*4-2)=s1,temp(ii*4-3)=s0for ii=1:symlength if real(symbol(ii))>=0 if imag(symbol(ii))>=0 %1#Quadrant if real(symbol(ii))>=4*A if imag(symbol(ii))>=4*A temp(ii*4)=1; temp(ii*4-1)=0; temp(ii*4-2)=1; temp(ii*4-3)=0; else temp(ii*4)=1; temp(ii*4-1)=1; temp(ii*4-2)=1; temp(ii*4-3)=0; end else if imag(symbol(ii))>=4*A temp(ii*4)=1; temp(ii*4-1)=0; temp(ii*4-2)=1; temp(ii*4-3)=1; else temp(ii*4)=1; temp(ii*4-1)=1; temp(ii*4-2)=1; temp(ii*4-3)=1; end end else %4#Quadrant if real(symbol(ii))>=4*A if imag(symbol(ii))>=-4*A temp(ii*4)=0; temp(ii*4-1)=1; temp(ii*4-2)=1; temp(ii*4-3)=0; else temp(ii*4)=0; temp(ii*4-1)=0; temp(ii*4-2)=1; temp(ii*4-3)=0; end else if imag(symbol(ii))>=-4*A temp(ii*4)=0; temp(ii*4-1)=1; temp(ii*4-2)=1; temp(ii*4-3)=1; else temp(ii*4)=0; temp(ii*4-1)=0; temp(ii*4-2)=1; temp(ii*4-3)=1; end end end else if imag(symbol(ii))>=0 %2#Quadrant if real(symbol(ii))>=-4*A if imag(symbol(ii))>=4*A temp(ii*4)=1; temp(ii*4-1)=0; temp(ii*4-2)=0; temp(ii*4-3)=1; else temp(ii*4)=1; temp(ii*4-1)=1; temp(ii*4-2)=0; temp(ii*4-3)=1; end else if imag(symbol(ii))>=4*A temp(ii*4)=1; temp(ii*4-1)=0; temp(ii*4-2)=0; temp(ii*4-3)=0; else temp(ii*4)=1; temp(ii*4-1)=1; temp(ii*4-2)=0; temp(ii*4-3)=0; end end else %3#Quadrant if real(symbol(ii))>=-4*A if imag(symbol(ii))>=-4*A temp(ii*4)=0; temp(ii*4-1)=1; temp(ii*4-2)=0; temp(ii*4-3)=1; else temp(ii*4)=0; temp(ii*4-1)=0; temp(ii*4-2)=0; temp(ii*4-3)=1; end else if imag(symbol(ii))>=-4*A temp(ii*4)=0; temp(ii*4-1)=1; temp(ii*4-2)=0; temp(ii*4-3)=0; else temp(ii*4)=0; temp(ii*4-1)=0; temp(ii*4-2)=0; temp(ii*4-3)=0; end end end endend[m,n] = size(temp);softbit = reshape(temp',n,m);
Test your modulator and demodulator by passing a short binary sequence through the modulator, and then pass the output of the modulator to the demodulator. Compare the original binary sequence and the output of the demodulator to make sure they are working properly.
M = 16; %信号星座大小k = log2(M); %每个符号的比特数量n = 30000; %位处理数量numSamplesPerSymbol = 1; %采样系数rng default %使用默认的随机数发生器dataIn = randi([0 1],n,1); %生成的二进制数据的载体%绘制二进制序列stem(dataIn(1:40),'filled');title('Random Bits');xlabel('Bit Index');ylabel('Binary Value');dataMod = QAM_16_mod (dataIn);figure;stem(dataMod(1:40),'filled');title('dataMod')dataDeMod = QAM_16_demod(dataMod);figure;stem(dataDeMod(1:40),'filled');title('dataDeMod');
In the simulation, we are going to use a slot structure similar to the second generation cellular standard IS-136. The symbols are transmitted in slots (bursts). Each slot has 162 symbols, with the symbol rate being 24.3ksym/s. We are going to find the BER at Eb/N0 = [0:5:25]dB. Step 5 through 12 describes how to find out the BER at Eb/N0 = 0dB.
- Generate a random binary sequence corresponding to the length of slot. The ‘1’s and ‘0’s are equi-probable. (How many bits need to be generated for a slot with 162 symbols and 16QAM modulation?)
162×4=648
Hint: A = (rand(1, 1) > 0.5) will give us a random variable A with equiprobable ‘0’ or ‘1’. - Pass the binary sequence through 16Q AM modulator by using the QAM_16_mod.m.
- The modulated symbols are passed through Rayleigh fading.
a) Using your Rayleigh.m function from Project 1 to generate 162 fading samples. The sampling period is equal to the system symbol period. Calculate the maximum Doppler shift for a system operating at 1800 MHz, and the mobile speed is 120km/hr.
b) Multiply the modulated symbol vector with the Rayleigh fading vector by using the dot operator “x.*h” in Matlab. Generate zero-mean AWGN. In Matlab, AWGN can be generated with the function randn(m, n). Since both the inphase component and quadrature
component of the signals are going to be corrupted by AWGN, the AWGN sequence should have complex-values.
a) Generate the complex valued AWGN sequence by using the following command
noise = noise_amplitude*(randn(1, N) + j*randn(1, N));
where N is the number of symbols per block. noise_amplitude depends on Eb/N0. What is the variance of the noise in terms of noise_amplitude?SNR=Eb/N0
noise_amplitude=sig_amplitude2/SNR−−−−−−−−−−−−−−−−−√
σ2=N0B. b) The relationship between noise variance and Eb/N0 can be expressed by the following equation
Eb/N0=Esnoise_variance×log2M
whereEs the energy of one symbol, andM is the modulation constellation size. What should be the noise_amplitude forEs=1,M=16 , andEb/N0=0dB ?Eb=Es/4=1/4
noise_amplitude=Eb/SNR−−−−−−−√=∞ c) Generate the noise component by using the noise_amplitude calculated from the previous step. Add the noise vector to the fading corrupted signal vector.
- After fading and AWGN, the signals are received by the receiver. Compensate the received signal vector by using fading vector (using the operator dot divide “./”). Assume the receiver has perfect knowledge of fading.
- Pass the fading compensated signal vector through the 16Q AM demodulator. The output of the demodulator is the binary information recovered at receiver.
- Compare the recovered binary sequence with the original binary sequence, and record the # of error bits. (Hint: sum(recovered_bin ~= original_bin))
Use a “for” loop to simulate 200 independent slots at Eb/N0 = 0dB. Find the bit error rate at 0 dB by using
BER = # of total error bits / # of total bits
The # of bits should be accumulated from all 200 slots.clc;clear;M = 16; k = log2(M); N = 648; Ns = 162;fd = 1800;Ts = 1/(24.3^3);Eb = 1/4;Es = 1;SNR = 0;rng defaultsumerrorbit = 0;for i=0:200dataIn = randi([0 1],N,1); %generate a random binary sequencedataMod = QAM_16_mod (dataIn);%pass binary sequence through 16QAM modulatroh=Rayleigh(Ns,fd,Ts); %generate 162 fading samplesdataMod_h = dataMod.*h; %multiply symbol vector with Rayleigh fading vectornoise_amplitude = sqrt(Es/SNR);noise = noise_amplitude*(randn(1,Ns) + j*randn(1,Ns));dataMod_h_noise = dataMod_h + noise;dataMod_noise_rec = dataMod_h_noise./h;dataDeMod_noise_rec = QAM_16_demod(dataMod_noise_rec);errorbit =sum(dataDeMod_noise_rec ~= dataIn);sumerrorbit = sumerrorbit + errorbit;endBER = sumerrorbit /(200*648)
BER =
0.5049
Use an outer for loop, repeat step 5 through 12 for Eb/N0 = [5, 10, 15, 20, 25] dB.
BER =
0.1297 ;5dB
BER =
0.0857 ;10dB
BER =
0.0667 ;15dB
BER =
0.0559 ;20dB
BER =
0.0484 ;25dB
- Using the function semilogy( ) plot BER v.s. Eb/N0. The x-axis, Eb/N0, should be in unit of dB. The function semilogy will set the y-axis in log-domain.
- On the same figure, plot the theorectical BER v.s Eb/N0 curve for 16QAM under AWGN channel.Please refer to the texbook or other book to find the theorectical equation.
clc;clear;M = 16; k = log2(M); N = 648; Ns = 162;fd = 1800;Ts = 1/(24.3^3);Eb = 1/4;Es = 1;BER = [];tBER = [];for SNR = [0,5,10,15,20,25],rng defaultsumerrorbit = 0;for i=0:200dataIn = randi([0 1],N,1); %generate a random binary sequencedataMod = QAM_16_mod (dataIn);%pass binary sequence through 16QAM modulatroh=Rayleigh(Ns,fd,Ts); %generate 162 fading samplesdataMod_h = dataMod.*h; %multiply symbol vector with Rayleigh fading vectornoise_amplitude = sqrt(Es/SNR);noise = noise_amplitude*(randn(1,Ns) + j*randn(1,Ns));dataMod_h_noise = dataMod_h + noise;dataMod_noise_rec = dataMod_h_noise./h;dataDeMod_noise_rec = QAM_16_demod(dataMod_noise_rec);errorbit =sum(dataDeMod_noise_rec ~= dataIn);sumerrorbit = sumerrorbit + errorbit;endBER = [BER sumerrorbit /(200*648)];tBER = [tBER 1/3*erfc(sqrt(SNR*3)*sin(pi/16))];endSNR = [0,5,10,15,20,25];semilogy(SNR,BER,'r-*');hold onsemilogy(SNR,tBER,'k-o');title('BER Vs Eb/N0 (dB) for 16-QAM');legend('Simulated','Theoretical');grid on;xlabel('Eb/N0 dB');ylabel('BER');grid on;
IV. Questions
- Write the equation describing the relationship between Eb/N0 (dB) and noise_amplitude used to generate AWGN as described in step 8.
SNR=Eb/N0
noise_amplitude=sig_amplitude2/SNR−−−−−−−−−−−−−−−−−√
- 无线通信
- 无线通信
- 无线通信
- 无线通信
- gprs 无线通信
- 无线通信系统
- 无线通信术语
- 无线通信技术
- 无线通信概述
- 无线通信技术
- 无线通信安全
- 《无源无线通信》
- 无线通信术语
- 无线通信基本原理
- 无线通信基础知识
- WIFI无线通信
- stm32_RFID_RCC522无线通信
- 开创无线通信新领域,埋葬传统无线通信运营商
- Mybatis多参数查询与列表查询不同方式实现
- 基于SpringBoot + Mybatis实现SpringMVC Web项目
- 强调在正则中只要单纯用了括号就会有捕获分组保存
- 焊接技巧 -- 拖焊
- C语言提取(key,value)键值对
- 无线通信
- 小技巧:使用Excel通过拼接文本批量生成代码
- css动画练习
- UVa 1585 Score
- nyoj18_The Triangle
- STM32循迹+蓝牙小车
- C++运算符优先级
- Android应用层View绘制流程与源码分析
- AD620AR: 仪表放大器