首页 文章

BER图MATLAB校准

提问于
浏览
1

我正在做一个16QAM系统(发射机,信道和接收机),以及结果的BER和PER曲线 . 但是,我在接收器上遇到了一些噪音问题 . 我在两个循环中运行系统:对于所有Eb / No值和所有数据包,我发送了200个符号和1000个数据包,但这仍然会发生 . 我想检查一下这段代码的结果是否正确:

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')

谢谢!

1 回答

  • 2

    提供的代码做出以下假设:

    • 使用格雷编码位映射的16-QAM调制

    • 平缓慢/块瑞利衰落信道模型 .

    • 完美channel state information估计下的相干解码

    由于它与加性 - 白高斯 - 噪声(AWGN)信道的相似性,在上述假设下理解和校准系统性能的逻辑第一步是评估其性能而不衰落(即用AWGN代替信道模型)通过在提供的代码中设置 h=1 来进行通道 .

    AWGN channel

    您可能需要验证符号误码率(SER)性能的校准,因为这会对(BER)性能产生很大影响,并且SER曲线可用于未编码16-QAM星座的相干解码(参见例如dsplog) ,these lecture slidesthis book等 . 这些参考文献还包括以下对16-QAM SER的近似:

    1.5 * erfc(sqrt(EsN0 / 10))

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

    注意,结果可以根据Es / N0(每个符号的平均能量)或Eb / N0(每比特的平均能量)等效地提供 . 对于k比特信号星座(星座大小为2k),Es / N0和Eb / N0之间的关系给出为

    Es / N0 = k * Eb / N0

    因此,对于16-QAM,Es / N0 = 4Eb / N0(或Es / N0dB = Eb / N0dB 6dB) .

    对于格雷编码方案,可以从大部分时间符号误差转换为误差1位(符号中的k位)的事实中获得足够高的Eb / N0的BER近似,从而得到BER ~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
    

    作为旁注,在低于大约10-5的SER下使用2,000,000个符号的模拟结果的置信区间可能开始非常显着 . 作为说明,下图显示蓝色的16-QAM SER,红色的2,000,000个符号模拟的预期95%置信区间:
    enter image description here

    Rayleigh block fading channel

    一旦为AWGN信道 Build 了性能校准,我们就可以回到发布代码中使用的瑞利模块衰落信道 .

    假设在接收器处进行完美的信道状态信息估计,并且如果没有噪声,则可以使用变换将接收到的信号精确地缩放回原始发送的符号:

    y = y1 / h;

    当存在噪声时,不幸的是,这种转换也会降低噪声 . 幸运的是,噪声仍然是白色和高斯噪声,因此AWGN信道方程的基本推导可以通过一些工作重复使用 . 在独立分组上,缩放 abs(h) 的统计分布遵循Rayleigh distribution(参数sigma2 = 1/2) . 因此,为了获得该缩放对SER的平均效果,可以使用积分计算在可能的缩放值范围内的效果的加权和(其中权重是瑞利分布的概率密度函数):
    enter image description here

    这可以使用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
    

    可以获得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
    

    请注意,我使用了精确的BER公式,因为加权平均值往往受到低信噪比的影响,其中近似值不是很好 . 它在曲线上没有很大的差异(在Eb / N0 = 10dB时为~0.3dB)但是在校准性能曲线时我不想担心这个问题 .

    这会产生以下性能曲线:
    enter image description here

    Other considerations

    解码性能可能受到许多其他因素的影响,这些因素超出了本答案的范围 . 因此,以下仅简要介绍一些常见的和外部参考的链接,这些参考可用于附加信息 .

    发布代码中的解码器使用衰落效应的显式知识(如行 y=y1/h; 所示) . 通常情况并非如此,首先必须估计衰落 . 接收器处的信道效应的估计超出了该答案的范围,但是通常不完美的估计导致一些性能损失 . 完美知识的性能曲线通常用作比较不完美信道估计下的性能的实用基准 .

    Channel coding通常用于提高系统性能 . 用于AWGN信道上的编码调制的通用基准是:

    类似地用于编码调制在平坦块瑞利衰落信道上,通常使用以下基准:

    • 中断概率(见this book第5.4.1节)

    • 未编码的调制性能(我们在此处得出)

相关问题