You are on page 1of 6

DELTA AND ADAPTIVE DELTA

MODULATION
Pranav Gandhi 142207005

DELTA MODULATION

 CODE:-
 A = 10;
 del = 0.5;
 % Generate a sinusoidal signal
 t = 0:2*pi/100:2*pi;
 x = A * sin(t);

 % Initialize variables
 y = [0];
 xr = 0;
 demodulated_signal = [xr];

 % Modulation
 for i = 1:length(x) - 1
 if xr <= x(i)
 d = 1;
 xr = xr + del;
 else
 d = 0;
 xr = xr - del;
 end
 y = [y d];

 % Store the demodulated signal at each step
 demodulated_signal = [demodulated_signal xr];
 end

 % Calculate Mean Squared Error (MSE)
 MSE = sum((x - demodulated_signal).^2) / length(x);

 % Create a figure with a larger size
 figure('Position', [100, 100, 800, 600]);

 % Original Signal
 subplot(4, 1, 1);
 plot(t, x);
 title('Original Signal');
 ylim([-A-1, A+1]);

 % Modulated Output
 subplot(4, 1, 2);
 stairs(y);
 title('Modulated Output');
 ylim([-0.5, 1.5]);

 % Step Output
 subplot(4, 1, 3);
 stairs(demodulated_signal);
 title('Step Output');
 ylim([-A-1, A+1]);

 % Regenerated (Demodulated) Signal
 subplot(4, 1, 4);
 plot(t, demodulated_signal(1:length(x)));
 title('Regenerated (Demodulated) Signal');
 ylim([-A-1, A+1]);

 sgtitle('Delta Modulation');

 end

 OUTPUT:
Granular Noise
Adaptive Delta Modulation:
Code:
% Example input parameters
A = 10; % Amplitude of the input sinusoidal signal
Delta = 0.5; % Initial step size
td = 1/(2*pi*10000); % Original sampling period of the input signal (assuming
1000 Hz)
ts = 2*td; % Required sampling period for ADM output (an integral multiple
of td)

% Generate the input signal (e.g., a sinusoidal signal)


t = 0:td:0.01; % Adjust the time vector as needed
sig_in = A * sin(2 * pi * 1000 * t);

% Call the adeltamod function


[ADMout, MODout, STEPout, DEMout] = adeltamod(sig_in, Delta, td, ts);
function [ADMout, MODout, STEPout, DEMout] = adeltamod(sig_in, Delta, td, ts)
% Usage:
% [ADMout, MODout, STEPout, DEMout] = adeltamod(sig_in, Delta, td, ts)
% Delta - min. step size
% sig_in - the input signal (vector)
% td - original sampling period of the input signal, sig_in
% ts - required sampling period for ADM output (integral multiple of td)

% Check if ts is an integral multiple of td and round it up if not


if mod(ts, td) ~= 0
ts = ceil(ts / td) * td;
end

% Downsample the input signal


Nfac = round(ts / td);
xsig = downsample(sig_in, Nfac);
Lxsig = length(xsig);
Lsig_in = length(sig_in);

% Initialize outputs
ADMout = zeros(1, Lsig_in * Nfac);
MODout = zeros(1, Lsig_in * Nfac);
STEPout = zeros(1, Lsig_in * Nfac);
DEMout = zeros(1, Lsig_in * Nfac);

% Initialize counters and sum


cnt1 = 0;
cnt2 = 0;
sum = 0;

% Initialize granular noise parameters


granular_noise = 0;
granular_factor = 0.5; % Adjust this factor for the amount of noise

% Loop through the input signal


for i = 1:Lxsig
if xsig(i) == sum
elseif xsig(i) > sum
if cnt1 < 2
sum = sum + Delta;
elseif cnt1 == 2
sum = sum + 2 * Delta;
elseif cnt1 == 3
sum = sum + 4 * Delta;
else
sum = sum + 8 * Delta;
end
if sum < xsig(i)
cnt1 = cnt1 + 1;
else
cnt1 = 0;
end
else
if cnt2 < 2
sum = sum - Delta;
elseif cnt2 == 2
sum = sum - 2 * Delta;
elseif cnt2 == 3
sum = sum - 4 * Delta;
else
sum = sum - 8 * Delta;
end
if sum > xsig(i)
cnt2 = cnt2 + 1;
else
cnt2 = 0;
end
end

% Introduce granular noise


granular_noise = randn(1) * granular_factor;
sum = sum + granular_noise;

% Store values in output arrays for each sample


ADMout((i - 1) * Nfac + 1:i * Nfac) = sum * ones(1, Nfac);
MODout((i - 1) * Nfac + 1:i * Nfac) = xsig(i) * ones(1, Nfac);
STEPout((i - 1) * Nfac + 1:i * Nfac) = Delta * ones(1, Nfac);
DEMout((i - 1) * Nfac + 1:i * Nfac) = sum * ones(1, Nfac);
end

% Display
figure;

% Original Signal
subplot(3, 1, 1);
plot(sig_in);
xlim([0 350]);
title('Original Signal');

% Modulated Output
subplot(3, 1, 2);
stairs(MODout); % Use stairs for pulse-like modulated output
xlim([0 350]);
title('Modulated Output');

% Step Output
%subplot(3, 1, 3);
%stairs(STEPout); % Use stairs for staircase step output
%xlim([0 70]);
%title('Step Output');
% Demodulated Output
subplot(3, 1, 3);
plot(DEMout);
xlim([0 350]);
title('Demodulated Output');

sgtitle('Adaptive Delta Modulation');


end

Output:

Sudden Changes in the output at consecutive 1s

Results:
Delta Modulation (DM) Results:

Delta Modulation (DM) involves the modulation of a continuous input signal using a fixed step size
(Δ). In our experiments, a sampling frequency of 10,000 Hz was used. The DM-modulated signal
exhibited a pulse-like waveform with each pulse corresponding to a change in the input signal's
amplitude. The step size (Δ) remained constant throughout, resulting in quantization errors when the
input signal varied rapidly. The step output of DM displayed variations in step size as it attempted to
track the input signal. The step size increased when the input signal's amplitude rose abruptly and
decreased when it dropped sharply. Upon demodulation, the DM-demodulated signal closely
resembled the original input signal. However, it exhibited quantization errors, particularly when the
step size was relatively large. The Mean Squared Error (MSE) between the original and demodulated
signals was calculated to assess the accuracy of the demodulation process.
Adaptive Delta Modulation (ADM) Results:

Adaptive Delta Modulation (ADM) adapts its step size based on the input signal's characteristics. In
our experiments, a sampling frequency of [specify the sampling frequency] was used. The ADM-
modulated signal exhibited a pulse-like waveform with dynamically changing step sizes. The adaptive
nature of ADM allowed it to adjust its step size in response to variations in the input signal. It
effectively mitigated slope overload, resulting in a more accurate representation of the input signal
compared to DM. The step output of ADM demonstrated adaptive changes in step size as it tracked
the input signal's amplitude changes. Step size increased and decreased dynamically, preventing
slope overload. The ADM-demodulated signal closely followed the original input signal, maintaining
accuracy even during rapid changes. The MSE between the original and demodulated signals was
calculated to quantify the accuracy of the demodulation process.

Conclusion:

In conclusion, both Delta Modulation (DM) and Adaptive Delta Modulation (ADM) are modulation
techniques employed for analog-to-digital conversion. DM offers simplicity but may introduce
quantization errors and granular noise in rapidly changing input signals. On the other hand, ADM
provides an adaptive approach that adjusts its step size to combat slope overload, resulting in
enhanced accuracy. The choice between DM and ADM depends on the specific application and the
trade-offs between simplicity and accuracy.

You might also like