Creating an ACM system for DVB-S2
Show older comments
Hi,
I am currently working on a project to create a ACM techquie function as per the instruction below:
Design an ACM technique for the DVB‐S2 transmission by adding a MATLAB function to the simulator developed in Task 3, selecting the modulation and code rates adaptively according to the LDPC rate table given in Task 3 Question 1.
The table for the LDPC rates are as follows:

The current code I have is as follows:
clc
clear all
close all
tic
%Elapsed time is 6860.512059 seconds.
N_iter=100; % number of iterations for each SNR
figure(1)
for codecase=1:4
[R, nBCH, kBCH, genBCH, M] = getbchparameters(codecase);
fprintf("Case %d: LDPC code rate =%s %dPSK",codecase, rats(R),M);
switch codecase
case 1
Eb_N0=[(-4:1:-1),(-0.9:0.1:0),(0.1:0.05:0.4),(0.41:0.01:0.5)];
case 2
Eb_N0=[(-4:1:3),(3.1:0.1:3.6),(3.61:0.01:3.7),(3.705:0.005:3.8)];
case 3
Eb_N0=[(-4:1:3),(3.1:0.1:3.5),(3.51:0.01:4)];
case 4
Eb_N0=[(-4:1:5),(5.2:0.2:6.2),(6.21:0.01:6.34),(6.345:0.005:6.400)];
end
% BCH Encoding and Decoding Objects
% Encoding
hBCHEnc=comm.BCHEncoder();
hBCHEnc.CodewordLength = nBCH;
hBCHEnc.MessageLength = kBCH;
hBCHEnc.PrimitivePolynomialSource='Property';
hBCHEnc.GeneratorPolynomialSource='Property';
hBCHEnc.GeneratorPolynomial = genBCH;
hBCHEnc.PrimitivePolynomial = de2bi(65581, 'left-msb');
hBCHEnc.CheckGeneratorPolynomial= false;
% Decoding
hBCHDec=comm.BCHDecoder();
hBCHDec.CodewordLength = nBCH;
hBCHDec.MessageLength = kBCH;
hBCHDec.PrimitivePolynomialSource='Property';
hBCHDec.GeneratorPolynomialSource='Property';
hBCHDec.GeneratorPolynomial = genBCH;
hBCHDec.PrimitivePolynomial = de2bi(65581, 'left-msb');
hBCHDec.CheckGeneratorPolynomial= false;
% LDPC Encoding and Decoding Objects
hEnc = comm.LDPCEncoder('ParityCheckMatrix',dvbs2ldpc(R));
hDec = comm.LDPCDecoder('ParityCheckMatrix',dvbs2ldpc(R));
% Modulation Object
hMod = comm.PSKModulator(M, 'BitInput',true);
n=1;
BER=zeros(size(Eb_N0));
for eb_no=Eb_N0
[R, eb_no, M]
gamma=eb_no+10*log10(log2(M)*R);
% AWGN
hChan = comm.AWGNChannel(...
'NoiseMethod','Signal to noise ratio (SNR)','SNR',gamma);
% Demodulation
hDemod = comm.PSKDemodulator(M, 'BitOutput',true,...
'DecisionMethod','Approximate log-likelihood ratio', ...
'Variance', 1/10^(hChan.SNR/10));
% For BER calculations
hError = comm.ErrorRate;
EE=zeros(1,N_iter);
for counter = 1:N_iter
reset(hBCHEnc);
reset(hBCHDec);
reset(hEnc);
reset(hDec);
%reset(hInt);
%reset(hDeint);
reset(hError);
%data = logical(randi([0,1],k_1dpc, 1)); % Random bit generation
data = logical(randi([0,1],kBCH, 1));
BCHdata=step(hBCHEnc,data); % BCH encoding
%encodedData = step(hEnc,data); % LDPC encoding
%encodedData = step(hEnc,BCHdata); % LDPC encoding
LDPCData = step(hEnc,BCHdata);
interleaverData = matintrlv(LDPCData, 21600, 3);
%encodedData = step(hInt,LDPCData) % Interleaver
modSignal = step(hMod, interleaverData); % Modulation
receivedSignal = step(hChan, modSignal); % Transmission over the channel
demodSignal = step(hDemod, receivedSignal); % Demodulation
%RBits=step(hDec, demodSignal); % BHC decoding
%Deint = step(hDeint, demodSignal); % Deinterleaver
DeinterleaverData = matdeintrlv(demodSignal, 21600, 3);
LDPCBits = step(hDec, DeinterleaverData); % LDPC decoding
RBits=step(hBCHDec,LDPCBits); % BHC decoding
errorStats = step(hError, data, RBits); % BER calculations
EE(1,counter)=errorStats(1);
end
BER(1,n)=mean(EE(1,:)); % Averaging over iterations
n=n+1;
end
semilogy(Eb_N0,BER)
hold on
end
%Case 5&6:Uncoded
for codecase=5:6
switch codecase
case 5
Eb_N0=(-4:1:13);
M=4;
case 6
Eb_N0=(-4:1:13);
M=8;
end
fprintf("Case %d:Uncoded, %dPSK",codecase,M);
% Modulation Object
hMod = comm.PSKModulator(M, 'BitInput',true);
n=1;
BER=zeros(size(Eb_N0));
for eb_no=Eb_N0
[1, gamma, M]
gamma=eb_no+10*log10(log2(M));
hChan = comm.AWGNChannel(...
'NoiseMethod','Signal to noise ratio (SNR)','SNR',gamma);
hDemod = comm.PSKDemodulator(M, 'BitOutput',true,...
'DecisionMethod','Approximate log-likelihood ratio', ...
'Variance', 1/10^(hChan.SNR/10));
hError = comm.ErrorRate; % For BER calculations
EE=zeros(1,N_iter);
for counter = 1:N_iter
reset(hError);
data = logical(randi([0,1],64800, 1)); % Random bit generation
encodedData = data;
modSignal = step(hMod, encodedData); % Modulation
receivedSignal = step(hChan, modSignal); % Transmission over the channel
demodSignal = step(hDemod, receivedSignal); % Demodulation
hard_symbols = (demodSignal > 0) + (demodSignal <= 0).*(-1); % Hard Decoding without LDPC
demodSignal = (hard_symbols == -1);
receivedBits = demodSignal;
errorStats = step(hError, data, receivedBits); % BER calculations
EE(1,counter)=errorStats(1);
end
BER(1,n)=mean(EE(1,:)); % Averaging over iterations
n=n+1;
end
semilogy(Eb_N0,BER)
hold on
end
grid on;
title('LDPC simulation'); xlabel('Eb/N_0 [dB]'); ylabel('BER');
legend('R=2/5,QPSK','R=9/10,QPSK','R=2/3,8PSK','R=8/9,8PSK','Uncoded, QPSK','Uncoded, 8PSK');
toc
%--------------------------------------------------------------------------
function [R, nBCH, kBCH, genBCH, M] = getbchparameters(i)
table6a = [2/5 25728 25920 12 64800 4
9/10 58192 58320 8 64800 4
2/3 43040 43200 10 64800 8
8/9 57472 57600 8 64800 8];
R = table6a(i,1);
kBCH = table6a(i,2);
nBCH = table6a(i,3);
tBCH = table6a(i,4);
M = table6a(i,6);
BCH_PriPoly=[1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1;...
1 0 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1;...
1 0 0 0 0 1 1 1 1 1 0 1 1 1 1 0 1;...
1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1;...
1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1;...
1 1 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1;...
1 1 0 1 0 1 1 1 1 0 1 1 0 0 1 0 1;...
1 0 1 1 1 0 0 1 1 0 1 1 0 0 1 1 1;...
1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1;...
1 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 1;...
1 0 0 1 1 1 0 1 0 0 0 1 0 1 1 0 1;...
1 0 0 0 1 1 0 1 0 1 1 1 0 0 0 1 1];
genBCH=BCH_PriPoly(1,:);
for i=1:tBCH-1
genBCH=conv(genBCH,BCH_PriPoly(i+1,:));
end
genBCH=mod(genBCH,2);
end
Any help with this would be appreciated.
Answers (0)
Categories
Find more on Error Detection and Correction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!