简体   繁体   English

BER图MATLAB校准

[英]BER graph MATLAB calibration

I'm doing a 16QAM system (transmitter, channel and receiver), and BER and PER curves of the results. 我正在做一个16QAM系统(发送器,信道和接收器),以及结果的BER和PER曲线。 However, I'm having some problems with noise at the receiver. 但是,我在接收器上遇到一些噪音问题。 I'm running the system inside two loops: for all the Eb/No values and for all the packets and I sent 200 symbols and 1000 packets but this still happens. 我在两个循环中运行系统:对于所有Eb / No值以及所有数据包,我发送了200个符号和1000个数据包,但这仍然会发生。 I would like to check whether the result from this code is correct or not: 我想检查一下这段代码的结果是否正确:

clear all
clc
numPkts=1000;

N = 200; % number of symbols
M = 16;   % constellation size
k = log2(M); % bits per symbol
pv=4; %prefix length


% defining the real and imaginary PAM constellation
% for 16-QAM
alphaRe = [-(2*sqrt(M)/2-1):2:-1 1:2:2*sqrt(M)/2-1];
alphaIm = [-(2*sqrt(M)/2-1):2:-1 1:2:2*sqrt(M)/2-1];
k_16QAM = 1/sqrt(10);

Eb_N0_dB  = [0:15]; % multiple Es/N0 values
Es_N0_dB  = Eb_N0_dB + 10*log10(k);
erTot=zeros(1,length(Eb_N0_dB));

% Mapping for binary <--> Gray code conversion
ref = [0:k-1];
map = bitxor(ref,floor(ref/2));
[tt ind] = sort(map);                                

for ii = 1:length(Eb_N0_dB)
for pktX=1:numPkts    
% symbol generation
% ------------------
ipBit = rand(1,N*k,1)>0.5; % random 1's and 0's
ipBitReshape = reshape(ipBit,k,N).';
bin2DecMatrix = ones(N,1)*(2.^[(k/2-1):-1:0]) ; % conversion from binary to decimal
% real
ipBitRe =  ipBitReshape(:,[1:k/2]);
ipDecRe = sum(ipBitRe.*bin2DecMatrix,2);
ipGrayDecRe = bitxor(ipDecRe,floor(ipDecRe/2));
% imaginary
ipBitIm =  ipBitReshape(:,[k/2+1:k]);
ipDecIm = sum(ipBitIm.*bin2DecMatrix,2);
ipGrayDecIm = bitxor(ipDecIm,floor(ipDecIm/2)); 
% mapping the Gray coded symbols into constellation
modRe = alphaRe(ipGrayDecRe+1);
modIm = alphaIm(ipGrayDecIm+1);
% complex constellation
mod = modRe + j*modIm;
s1 = k_16QAM*mod; % normalization of transmit power to one 

s=[s1(length(s1)-pv+1:end) s1]; %add prefix


% noise
% -----
EsNo=10^(Es_N0_dB(ii)/10);
stanDevNoise=sqrt((1)/(2*EsNo));

n =stanDevNoise *[randn(1,length(s)) + j*randn(1,length(s))]; % white guassian noise, 0dB variance 



h=(1/sqrt(2))*(randn+j*randn);
y1= conv(s,h) + n; % additive white gaussian noise



%removes prefix
        y1(1:pv) = [];   

y=y1/h;
% demodulation
% ------------
y_re = real(y)/k_16QAM; % real part
y_im = imag(y)/k_16QAM; % imaginary part

% rounding to the nearest alphabet
ipHatRe = 2*floor(y_re/2)+1;
ipHatRe(find(ipHatRe>max(alphaRe))) = max(alphaRe);
ipHatRe(find(ipHatRe<min(alphaRe))) = min(alphaRe);
ipHatIm = 2*floor(y_im/2)+1;
ipHatIm(find(ipHatIm>max(alphaIm))) = max(alphaIm);
ipHatIm(find(ipHatIm<min(alphaIm))) = min(alphaIm);

% Constellation to Decimal conversion
ipDecHatRe = ind(floor((ipHatRe+4)/2+1))-1; % LUT based
ipDecHatIm = ind(floor((ipHatIm+4)/2+1))-1; % LUT based

% converting to binary string
ipBinHatRe = dec2bin(ipDecHatRe,k/2);
ipBinHatIm = dec2bin(ipDecHatIm,k/2);

% converting binary string to number
ipBinHatRe = ipBinHatRe.';
ipBinHatRe = ipBinHatRe(1:end).';
ipBinHatRe = reshape(str2num(ipBinHatRe).',k/2,N).' ;

ipBinHatIm = ipBinHatIm.';
ipBinHatIm = ipBinHatIm(1:end).';
ipBinHatIm = reshape(str2num(ipBinHatIm).',k/2,N).' ;

% counting errors for real and imaginary
nBitErr(pktX) = size(find([ipBitRe- ipBinHatRe]),1) + size(find([ipBitIm - ipBinHatIm]),1) ;

end
erTot(ii)=erTot(ii)+sum(nBitErr); %total errors in all packets

simBer(ii)=(erTot(ii)/(N*k*numPkts)); %bit error rate

totPktErRate(ii)=(erTot(ii)/(numPkts)); 
end

theoryBer = (1/k)*3/2*erfc(sqrt(k*0.1*(10.^(Eb_N0_dB/10))));

close all; figure
semilogy(Eb_N0_dB,theoryBer,'bs-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);
axis([0 15 10^-5 1])
grid on
legend('theory', 'simulation');
xlabel('Eb/No, dB')
ylabel('Bit Error Rate')
title('Bit error probability curve for 16-QAM modulation')

Thanks! 谢谢!

The code provided makes the following assumptions: 提供的代码进行以下假设:

  • 16-QAM modulation using Gray-coding bit mapping 使用格雷码位映射的16-QAM调制
  • a flat slow/block Rayleigh fading channel model. 平坦的慢/块瑞利衰落信道模型。
  • coherent decoding under perfect channel state information estimation 完美信道状态信息估计下的相干解码

Due to it's similarity with the Additive-White-Gaussian-Noise (AWGN) channel, a logical first step in understanding and calibrating the system performance under the assumptions stated above is to evaluate its performance without fading (ie substituting the channel model with an AWGN channel by setting h=1 in the provided code). 由于它与“加性高斯白噪声”(AWGN)通道相似,因此在上述假设下理解和校准系统性能的逻辑第一步是评估其性能而不会褪色(即用AWGN代替通道模型)通过在提供的代码中设置h=1设置频道)。

AWGN channel AWGN频道

You may want to verify the calibration of Symbol-Error-Rate (SER) performance as this can have a large impact on the (BER) performance, and SER curves are readily available for coherent decoding of uncoded 16-QAM constellation (see eg dsplog , these lecture slides , this book , etc.) Those references also include the following approximation to the SER of 16-QAM: 您可能需要验证符号错误率(SER)性能的校准,因为这会严重影响(BER)性能,并且SER曲线可用于未编码的16-QAM星座的相干解码(请参见例如dsplog)这些演讲幻灯片本书等)。这些参考还包括对16-QAM SER的以下近似:

1.5*erfc(sqrt(EsN0/10)) 1.5 * ERFC(SQRT(EsN0 / 10))

where EsN0 = 10.^(0.1*EsN0_dB) . 其中EsN0 = 10.^(0.1*EsN0_dB)

Note that results may be equivalently provided in terms of either Es/N0 (the average energy per symbol) or Eb/N0 (the average energy per bit). 注意,可以等效地以Es / N0(每个符号的平均能量)或Eb / N0(每比特的平均能量)提供结果。 For a k-bits signal constellation (constellation size of 2 k ), the relationship between Es/N0 and Eb/N0 is given as 对于k位信号星座图(星座图大小为2 k ),Es / N0和Eb / N0之间的关系为

Es/N0 = k*Eb/N0 Es / N0 = k * Eb / N0

Thus for 16-QAM, Es/N0 = 4Eb/N0 (or Es/N0 dB = Eb/N0 dB + 6dB). 因此,对于16-QAM,Es / N0 = 4Eb / N0(或Es / N0 dB = Eb / N0 dB + 6dB)。

For a Gray coded scheme, a BER approximation for sufficiently high Eb/N0 can then be obtained from the fact that a symbol error translates into 1 bit in error (out of the k-bits in the symbol) most of the time, thus BER ~ SER/k (or again for 16-QAM: BER ~ SER/4). 对于格雷编码方案,然后可以从以下事实获得足够高的Eb / N0的BER近似值:符号错误大部分时间转换为1位错误(在符号的k位中)。 〜SER / k(或对于16-QAM:BER〜SER / 4)。

Es/N0 (dB)   Eb/N0 (dB)   SER      BER approx
15           9            1.8e-2   4.5e-3
16           10           7.0e-3   1.8e-3
18           12           5.5e-4   1.4e-4
20           14           1.2e-5   3.0e-6
25           19           2.7e-15  6.7e-16

As a side note, the confidence interval of simulation results using 2,000,000 symbols at SERs below approximately 10 -5 can start to be quite significant. 顺便提一句,使用2,000,000个符号的SER在大约10 -5以下的模拟结果的置信区间开始变得非常重要。 As an illustration, the following graph shows the SER of 16-QAM in blue, with the expected 95% confidence interval of a 2,000,000 symbols simulation in red: 作为说明,下图以蓝色显示了16-QAM的SER,以红色显示了2,000,000个符号模拟的预期95%置信区间: 在此处输入图片说明

Rayleigh block fading channel 瑞利块衰落信道

Once performance calibration has been established for the AWGN channel, we can get back to the Rayleigh block fading channel used in the posted code. 一旦为AWGN信道建立了性能校准,我们就可以返回到发布代码中使用的瑞利块衰落信道。

Assuming perfect channel state information estimation at the receiver and if there were no noise, it is possible to scale the received signal back exactly onto the original transmitted symbols using the transformation: 假设在接收机处进行了完美的信道状态信息估计,并且如果没有噪声,则可以使用以下转换将接收到的信号准确地缩放回原始传输的符号上:

y = y1/h; y = y1 / h;

When noise is present, this transformation unfortunately also scales the noise. 当存在噪声时,不幸的是,这种变换也会缩放噪声。 Fortunately, the noise remains white and Gaussian such that the basic derivation of AWGN channel equations can be reused with some work. 幸运的是,噪声保持白噪声和高斯噪声,因此可以通过一些工作来重用AWGN信道方程的基本推导。 Over independent packets, the statistical distribution of the scaling abs(h) follows a Rayleigh distribution (with parameter sigma 2 =1/2). 在独立数据包上,缩放abs(h)的统计分布遵循瑞利分布 (参数sigma 2 = 1/2)。 Thus to get the average effect of this scaling on SER, it is possible to compute the weighted sum (where the weight is the probability density function of the Rayleigh distribution) of the effects over the range of possible scaling values using the integral: 因此,为了获得此缩放对SER的平均效果,可以使用积分计算在可能的缩放值范围内的效果的加权总和(其中权重是瑞利分布的概率密度函数): 在此处输入图片说明

This can be done numerically with MATLAB using: 可以使用以下方法在MATLAB中通过数字方式完成:

function SER = AwgnSer(EsN0)
  SER = 1.5*erfc(sqrt(0.1*EsN0));
end
function f = WeightedAwgnSer(x)
  weight = 2*x.*exp(-x.*conj(x));
  f = weight*AwgnSer(EsN0*x.*conj(x));
end
function SER = BlockRayleighFadingSer(EsN0)
  for ii=1:length(EsN0)
    SER(ii) = quad(inline('WeightedAwgnSer(EsN0(ii),s)','s'), 0, inf);
  end
end

A similar derivation can be obtained for the BER: 对于BER,可以获得类似的推导:

function BER = AwgnBer(EsN0)
  x = sqrt(0.1*EsN0);
  q1 = 0.5*erfc(x);
  q3 = 0.5*erfc(3*x);
  q5 = 0.5*erfc(5*x);
  BER = (12*q1+8*q3-4*q5 - q1*(q1+q3-2*q5)+(q3-q5)*q5)/16;
end
function f = WeightedAwgnBer(x)
  weight = 2*x.*exp(-x.*conj(x));
  f = weight*AwgnBer(EsN0*x.*conj(x));
end
function SER = BlockRayleighFadingBer(EsN0)
  for ii=1:length(EsN0)
    SER(ii) = quad(inline('WeightedAwgnBer(EsN0(ii),s)','s'), 0, inf);
  end
end

Note that I've use an exact formula for the BER since the weighted average tends to be affected by low signal-to-noise ratio where the approximation is not very good. 请注意,由于误码率的近似值不太理想,因此加权平均值往往会受到信噪比较低的影响,因此我对BER使用了精确的公式。 It does not make a huge difference on the curve (~0.3dB at Eb/N0=10dB) but it is not something I want to worry about when calibrating performance curves. 它不会在曲线上产生很大的差异(在Eb / N0 = 10dB时约为0.3dB),但是在校准性能曲线时我不必担心。

This yields the following performance curves: 这将产生以下性能曲线: 在此处输入图片说明

Other considerations 其他注意事项

Decoding performance can be affected by a number of other factors which are beyond the scope of this answer. 解码性能可能会受到许多其他因素的影响,这些因素超出了此答案的范围。 The following thus only briefly touches on a few common ones and links to external references which may be used for additional information. 因此,以下内容仅简要介绍了一些常见的内容以及指向外部参考的链接,这些链接可用于其他信息。

The decoder in the posted code uses explicit knowledge of the fading effect (as evidenced from the line y=y1/h; ). 发布代码中的解码器使用了对衰落效果的明确了解(从y=y1/h;行中可以看出)。 It is generally not the case, and fading must first be estimated. 通常情况并非如此,并且必须首先估计衰落。 The estimation of the channel effect at the receiver is beyond the scope of this answer, but generally imperfect estimation result in some performance loss. 接收机处的信道效应的估计超出了此答案的范围,但通常不完善的估计会导致某些性能损失。 Performance curves of perfect knowledge are often used as a practical benchmark against which to compare performance under imperfect channel estimation. 完美知识的性能曲线通常被用作比较不完美信道估计下性能的实用基准。

Channel coding is often done to improve system performance. 经常进行信道编码以提高系统性能。 Common benchmarks used for coded modulation over the AWGN channel are: 用于AWGN信道上的编码调制的常见基准是:

  • Shannon's channel capacity 香农的渠道容量
  • Union upper bound (eg. these lectures notes ), and multiple other bounds found in research literature 联合上限(例如, 这些讲义 )和研究文献中的其他多个界限
  • Uncoded modulation performance (which we derived here) 未编码的调制性能(我们在此处得出)

Similarly for coded modulation over flat block Rayleigh fading channel, the following benchmarks are commonly used: 同样,对于平坦块瑞利衰落信道上的编码调制,通常使用以下基准:

  • Outage probability (see section 5.4.1 of this book ) 中断概率(请参见本书第5.4.1节)
  • Uncoded modulation performance (which we derived here) 未编码的调制性能(我们在此处得出)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM