16 bit 4th order delta sigma adc in matlab in matlab

To simulate a 16-bit 4th order Delta-Sigma ADC in MATLAB, you can use the Delta-Sigma Toolbox. The following code demonstrates how to set up the system parameters and simulate the ADC:

main.m
% Define the system parameters
osr = 128; % oversampling ratio
order = 4; % order
quant = 16; % number of ADC bits
f0 = 0; % input signal frequency
fs = osr*f0; % sampling frequency
fbin = fs/2^order; % bin frequency

% Define the input and noise signals
N = 2^15; % number of samples
n = randn(1,N); % noise signal
u = sin(2*pi*f0/fs*(0:N-1)); % input signal

% Initialize the Delta-Sigma modulator
h = synthesizeNTF(order, osr); % create NTF object
v = zeros(1,order); % initialize state variable
y = zeros(1,N); % initialize output

% Run the simulation
for i=1:N
    d = round(u(i)*2^quant); % quantize input signal
    [v,y(1,i)] = simulateDSM(d,h,v); % simulate Delta-Sigma modulator
end
694 chars
24 lines

Note that this code assumes that the Delta-Sigma Toolbox is installed and added to the MATLAB path. The resulting y vector contains the digital output of the ADC. To plot the FFT of the output, you can use the following code:

main.m
% Plot the FFT of the output
Y = fftshift(fft(y));
freq = -fs/2:fbin:fs/2-fbin;
plot(freq, 20*log10(abs(Y)/max(abs(Y))));
xlabel('Frequency (Hz)');
ylabel('Magnitude (dBFS)');
title('ADC Output Spectrum');
206 chars
8 lines

This will plot the FFT of the ADC output in dBFS (decibels full scale) as a function of frequency.

gistlibby LogSnag