(22)以RS码为例说明信道编码AWGN信道的Eb/N0设置
文章目录
- 前言
- 一、编码Eb/N0与未编码Eb/N0及编码码率
- 二、仿真代码
- 三、仿真结果
前言
本文说明了如何为采用信道编码的通信链路设置Eb/N0(比特能量与噪声功率谱密度比)。
一、编码Eb/N0与未编码Eb/N0及编码码率
在通信系统仿真中,如果采用了FEC编码,则在设置AWGN信道Eb/N0时,需要考虑FEC编码码率R=K/N的影响。其中K为码字中信息码元的个数;N为码字的编码码元个数,也即信息码元数加校验码元数。
当通信链路中采用了信道编码, 编码的Eb/N0设置方法为:
CodedEbNo = UncodedEbNo + 10*log10(codeRate)
下面给出MATLAB仿真代码。
二、仿真代码
下面的MATLAB代码建立了一个“(15,9)RS码+8PSK”编码调制通信系统,显示了如何为采用信道编码的通信链路设置Eb/N0。
仿真中,通过设置不同的Eb/N0,绘制了系统的性能曲线。
N = 15; % R-S codeword length in symbols
K = 9; % R-S message length in symbols
num = 1e3; % R-S codeword number in symbols
M = 8; % Modulation order% Construct a (15,9) Reed-Solomon encoder and a 8-PSK modulator.
rsEncoder = comm.RSEncoder('CodewordLength',N,'MessageLength',K,'BitInput',true);
pskModulator = comm.PSKModulator('ModulationOrder',M,'BitInput',true);% Create the corresponding Reed-Solomon decoder and 8-PSK demodulator objects.
rsDecoder = comm.RSDecoder('CodewordLength',N,'MessageLength',K,'BitInput',true);
pskDemodulator = comm.PSKDemodulator('ModulationOrder',M,'BitOutput',true);% Calculate the Reed-Solomon code rate based on the ratio of message symbols to the codeword length.
codeRate = K/N;
bitsPerSymbol = log2(M);% Specify the uncoded Eb/No in dB. Convert the uncoded Eb/No to the corresponding coded Eb/No using the code rate.
UncodedEbNo = 0:2:16;
CodedEbNo = UncodedEbNo + 10*log10(codeRate);% Construct an AWGN channel taking into account the number of bits per symbol. Set the EbNo property of channel to the coded Eb/No.
channel = comm.AWGNChannel('BitsPerSymbol',bitsPerSymbol);
% channel.EbNo = CodedEbNo;% Set the total number of errors and bits for the simulation.
% For accuracy, the simulation should run until a sufficient number of bit errors are encountered.
% The number of total bits is used to ensure that the simulation does not run too long.
totalErrors = 100;
totalBits = 1e6;% Construct an error rate calculator System object and initialize the error rate vector.
errorRate = comm.ErrorRate;
ber = zeros(length(UncodedEbNo),1);for R = 1:length(UncodedEbNo)reset(errorRate);errorVec = zeros(3,1);channel.EbNo = CodedEbNo(R);% Run the simulation to determine the BER. while errorVec(2) < totalErrors && errorVec(3) < totalBits% Generate random bitsdataIn = randi([0,1],num*K,1);% Use the RS (15,9) encoder to add error correction capabilitydataEnc = rsEncoder(dataIn);% Apply 8-PSK modulationtxSig = pskModulator(dataIn);% Pass the modulated data through the AWGN channelrxSig = channel(txSig);% Demodulate the received signaldemodData = pskDemodulator(rxSig);% Decode the demodulated data with the RS (15,9) decoderdataOut = rsDecoder(demodData);% Collect error statisticserrorVec = errorRate(dataIn,demodData);end% Display the resultant bit error rate.ber(R) = errorVec(1);
endfigure()
semilogy(UncodedEbNo,ber,'ro-','LineWidth',1.5);
grid on;
xlabel('UncodedEbNo(dB)');
ylabel('BER');
title('8-PSK over AWGN Channels with RS Coding');
三、仿真结果
仿真结果如下: