Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment: Delta Sigma Modulation

Muhaiminul Islam Akash


ID: 201716050

MATLAB Code:
%% initiate interface
clc;
clear all;
close all;
%% declare and assign known variables
fc = 400;
fs = (50+10)*fc; %%% last 2 digit of roll number = 50
t = 0:1/fs:2/fc;
n = length(t);
x = (sin(2*pi*fc*t)).^2;
%% initiate unknown variables with zero
dlt = max(diff(x));
xqint = zeros(1, n);
eq = zeros(1, n);
%% delta sigma intermediate signal assigning
xint(1) = x(1);
%% assign the fist value manually
e(1) = xint(1);
eq(1)= dlt*sign(e(1));
xqint(1)= eq(1);

%% modul:ate the signal delta sigma


for i = 2:n
xint(i) = x(i) + xint(i-1);
e(i) = xint(i) - xqint(i-1); %error signal = input signal - quantized
signal
eq(i) = dlt*sign(e(i)); %from the nature of error find quantized error
signal
xqint(i) = xqint(i-1) + eq(i); %buid the accumulator
end

%% visualize Original and modulated signal

plot(t, x, '-black')
hold on
stairs(t, eq, '-red')
hold on
stairs(t, xqint, '-blue')
title('Original and modulated signal')
xlabel('time')
ylabel('amplitude')
Figure:
The below figure contains
Input signal – black color, error q signal – red color, input q signal – blue color of sigma delta
modulation.

You might also like