Anda di halaman 1dari 4

AMSD Assignment 15VL01F 2016

1.

Plot vin, vSAH and vout

N = 8; % ADC size given in question


Vref=2; % Specification given in question
PI = 3.14159;
fm = 500; % Let input frequency be 500 Hz

M = 1024; %FFT length in order to separate frequency bins by fin/4

fs = 256*fm; % Sampling frequency as per problem requirement


n=0:1:(M)-1;

Vin=(1+sin(2*PI*fm*n*(1/fs))); % Input signal


plot(n/fs,Vin);
title('Input signal Vin')
xlabel('Freq')
ylabel('Vin')
figure;

% VSAH calculation
stem(n/fs,Vin);
grid on;
hold on
stairs(n/fs,Vin)
hold off
title('VSAH with Fs = 128 kHz')
xlabel('Frequency in Hz')
ylabel('VSAH in V')
figure;

% Vout calculation
Vlsb = (Vref/(2^N)) ;
x = fix(Vin/Vlsb); % Decimal equivalent code
Vout = ((x)*Vlsb); % Quantiser output
plot(n/fs,Vout);
title('Vout')
Dept. of ECE, NITK Surathkal

Page 1

AMSD Assignment 15VL01F 2016


xlabel('Frequency in Hz')
ylabel('Vout in V')
figure;
%Part b: Finding single sided amplitude spectrum of Vout
NFFT = 2^nextpow2(M); % Next power of 2 from length of Vout
f = fs/2*linspace(0,1,NFFT/2); % f is x axis for plot
Y = fft(Vout,NFFT)/M; % Calculate the FFT of Vout
dBFS = 20*log10(abs(Y(1:NFFT/2))); %convert FFT to dB scale
plot(f,dBFS)
title('Single-Sided Amplitude Spectrum of Vout')
xlabel('Frequency in Hz')
ylabel('Amplitude in dB')

Plots:
Vin plot

Dept. of ECE, NITK Surathkal

Page 2

AMSD Assignment 15VL01F 2016

VSAH plot

Vout plot

Dept. of ECE, NITK Surathkal

Page 3

AMSD Assignment 15VL01F 2016

2.

Plot the one-sided frequency spectrum of vout (with log-y axis and
linear-x axis). The frequency bins should have a separation of
fin/4. Compute the signal-to-noise ratio of vout . Comment on your
observation.

Dept. of ECE, NITK Surathkal

Page 4

Anda mungkin juga menyukai