Configure Eb/No for AWGN Channels with Coding
This example shows how to set the bit energy to noise density ratio (Eb/No) for communication links employing channel coding.
Specify the codeword and message length for a Reed-Solomon code. Specify the modulation order.
N = 15; % R-S codeword length in symbols K = 9; % R-S message length in symbols M = 16; % Modulation order bps = log2(M); % Bits per symbol
Construct a (15,9) Reed-Solomon encoder and a 16-PSK modulator. Specify the objects so that they accept bit inputs.
rsEncoder = comm.RSEncoder( ... CodewordLength=N, ... MessageLength=K, ... BitInput=true);
Create the corresponding Reed-Solomon decoder and 16-PSK demodulator objects.
rsDecoder = comm.RSDecoder( ... CodewordLength=N, ... MessageLength=K, ... BitInput=true);
Calculate the Reed-Solomon code rate based on the ratio of message symbols to the codeword length.
codeRate = K/N;
Specify the uncoded Eb/No in dB. Convert the uncoded Eb/No to the corresponding SNR using the code rate and bits per symbol.
UncodedEbNo = 6; SNR = convertSNR(UncodedEbNo,"ebno","SNR", ... BitsPerSymbol=bps, ... CodingRate=codeRate);
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; errorVec = zeros(3,1);
Run the simulation to determine the BER.
while errorVec(2) < totalErrors && errorVec(3) < totalBits % Generate random bits dataIn = randi([0,1],360,1); % Add error correction capability by using the RS (15,9) encoder dataEnc = rsEncoder(dataIn); % Apply 16-PSK modulation txSig = pskmod(dataIn,M,InputType="bit"); % Pass the modulated data through an AWGN channel rxSig = awgn(txSig,SNR); % Demodulate the received signal demodData = pskdemod(rxSig,M,OutputType="bit"); % Decode the demodulated data with the RS (15,9) decoder dataOut = rsDecoder(demodData); % Collect error statistics errorVec = errorRate(dataIn,demodData); end
Display the resultant bit error rate.
ber = errorVec(1)
ber = 0.0935