Institutional PAASCU ECE515FL Activity1
Institutional PAASCU ECE515FL Activity1
LABORATORY MANUAL
I. INTRODUCTION:
LABORATORY MANUAL
LABORATORY MANUAL
x(1) = x(ti)
and the succeeding samples x(2), x(3), x(4) are
x(2) = x(ti + Ts)
x(3) = x(ti + 2Ts)
x(4) = x(ti + 3Ts)
Hence, the kth sample is
with round( ) being a rounding-off function that rounds-off the argument xs/Vref.
Assuming signed 2's complement is used, the sample is represented in binary format as
ADC Issues
To ensure that the numbers resulting from the ADC represents the input analog
signal, several considerations should be observed.
LABORATORY MANUAL
According to the Nyquist sampling theorem, the sampling frequency used in the
ADC process should be at least twice the highest frequency of the input analog signal to
ensure that the spectral content of the analog signal is represented by the samples.
If the sampling frequency is less than that specified by the Nyquist limit, the samples will
not represent the analog signal. The samples will represent a different signal called an
alias. The Nyquist sampling theorem also implies that the highest frequency represented
is Fs/2. Any frequency content of the analog signal that is higher than Fs/2 is not
represented by the samples.
Sampling at the Nyquist rate can create a good approximation of the original signal.
Oversampling can also create the same approximation, but it is redundant and
unnecessary.
With quantization, the total voltage range is subdivided into several quantization
levels. The magnitude difference between adjacent quantization levels is called the
quantization interval or resolution. The likelihood of a sample voltage being equal to one
of the quantization levels is remote. Therefore, each sample voltage is rounded off to the
closest available quantization level. The difference between the sample voltage and the
closest available quantization level is called the quantization error. For a given voltage
range, more quantization levels will produce quantized values closer to the sampled
values thus, smaller quantization error. The smaller the quantization error, the more
accurately the quantized signal will resemble the original analog sample.
When the amplitude of the signal is high, all samples higher than the highest
quantization level are quantized to the highest quantization level and a condition called
overflow occurs. With overflow, numbers resulting from the ADC process do not represent
the actual variations of the analog signal. The numbers represent a signal whose
amplitude is clipped at the highest quantization level. A similar condition occurs when
samples are lower than the lowest quantization level.
LABORATORY MANUAL
Thus, to ensure that the numbers resulting from the ADC process represent
correctly the input analog signal, the sampling frequency should satisfy Nyquist sampling
theorem and overflow should not occur.
DAC output = number x Vref' , where Vref' is the reference voltage of the DAC.
The duration of each voltage level is the same as the interval Ts' at which the numbers
are sent to the DAC input.
To ensure that the correct signal is reconstructed by the DAC, its reference voltage
Vref' should be equal to the reference voltage Vref of the DAC. Also, the reconstruction
frequency Fs' of the DAC should be equal to the sampling frequency Fs of the ADC. If Fs
is not equal to Fs', the frequency of the reconstructed signal is the frequency represented
by the numbers scaled by a factor (Fs'/Fs). If Vref is not equal to Vref', the amplitude of
the reconstructed signal is the amplitude represented by the numbers scaled by a factor
(Vref'/Vref)
Hardware Requirement
Pentium IV class (or equivalent)
2 GB RAM (1 GB minimum)
600 MB hard disk space
SVGA monitor
Audio card
Stereo Headset (with microphone); 0-20kHz frequency response
LABORATORY MANUAL
III. PROCEDURES:
From the concepts presented in the background, solve the following problems.
1. The ADC shown samples at 8000 samples/second and uses 8-bit, signed 2's complement
encoding. Its reference voltage is 10mV. The input signal is defined as
x(t)=1.5sin(2000πt)volts and the sampling starts at t=0.
(b) The output of the ADC process is applied as input to an DAC process as shown at a
rate of 8000 samples/second. The DAC has a resolution of 25mV and also uses 8-bit,
signed 2's complement format.
Sketch the staircase waveform of the output signal of the DAC. Indicate all significant
amplitude values and time values.
DAC Output Waveform:
LABORATORY MANUAL
LABORATORY MANUAL
________________________________________________________________
(b.2) What should be the highest frequency content of the input analog signal to
avoid aliasing?
________________________________________________________________
(b.3) What should be the range of the input voltage to the ADC to avoid overflow?
________________________________________________________________
(c) Execute the simulation program. Observe the signal reconstructed at the DAC
output
(c.1) Is the reconstructed output an acceptable approximation of the input signal
in terms of (a) waveform, (b) amplitude, and (c)
frequency?
__________________________________________________________
(d) Edit the simulation program to make the frequency of the input signal be 7800Hz
and then execute the simulation program.
(d.1) What is the amplitude and frequency of the reconstructed signal?
________________________________________________________________
________________________________________________________________
(e) Edit the simulation program to make the frequency of the input signal be 100Hz
and its amplitude be 5volts and then execute the simulation program.
(e.1) What is the amplitude and frequency of the reconstructed signal?
_______________________________________________________________
________________________________________________________________
(f) Edit the simulation program to make the frequency of the input signal be 8100Hz
and its amplitude be 5volts and then execute the simulation program.
(f.1) What is the amplitude and frequency of the reconstructed signal?
LABORATORY MANUAL
________________________________________________________________
________________________________________________________________
3. Simulation of the ADC of audio signals and storing the ADC results as a wave file
________________________________________________________________
________________________________________________________________
(b.3) Playback the wave file with Goldwave. Does the playback of the wave file
sounded similar to the 500Hz tone during the execution of the simulation
program?
________________________________________________________________
(c) Create 4 wave files by simulating an ADC process in which the 500Hz input is
sampled at Fsmin, 2Fsmin, 5Fsmin, 10Fsmin with Fsmin being the minimum sampling
frequency as prescribed by the Nyquist sampling theorem. Name the wave files
according to the convention used in the program. Open the wave files
simultaneously using Goldwave. Expand the the displayed waveforms by pressing
SHIFT + to observe the reconstructed signals.
(c.1) Which wave file has the best reconstruction of the 500Hz tone?
________________________________________________________________
(c.2) Do all the reconstructed signals sound similar? If no, which signals sound
signals sound similar?
________________________________________________________________
LABORATORY MANUAL
(d) Edit the simulation program to make the frequency of the input signal be 7800Hz
with an amplitude of 2.5volts. Reset the sampling frequency to 8000Hz and then
execute the simulation program. Open the resulting wave file using Goldwave.
(d.1) What is the amplitude and frequency of the reconstructed signal?
________________________________________________________________
________________________________________________________________
________________________________________________________________
SCILAB PROGRAMS
The following are the SCILAB programs for the laboratory activities. The
programs can be executed by copying them and pasting them on the Scilab command
console or in the Scilab editor.
function xqn=quantization(xn,Vref,n)
//Function that simulates the quantization process
//Assumes an n-bit, signed 2's complement format
//xqn - quantized values of the samples
//xn - values of the samples to be quantized
//Vref - reference voltage / resolution of the ADC
//n - number of bits
LABORATORY MANUAL
function xenc=encoding(xqn,Vref,n)
//Function that simulates the encoding process
//xenc - n-bit, signed, 2's complement representation of the values of xqn
//xqn - quantized values of the samples
//Vref - reference voltage / resolution of the ADC
//n - number of bits
//bin - n-bit, signed 2's complement representation of the current value of xqn
[r,c]=size(xqn);
for i=1:r
for j=1:c
if xqn(i,j) >= 0 then
sign_bit='0';
magnitude=round(xqn(i,j)/Vref);
magnitude_bits=dec2bin(magnitude,n-1);
bin=sign_bit + magnitude_bits;
else
sign_bit='1';
magnitude=round(abs(xqn(i,j))/Vref);
magnitude_bits=dec2bin((2^(n-1))-magnitude,n-1);
bin=sign_bit + magnitude_bits;
end;
xenc(i,j)=bin;
end
end
LABORATORY MANUAL
endfunction;
//DAC FUNCTIONS
function [tsd,xnd]=dac(xenc,Fsp,Vrefp,n)
//Function that simulates the decoding process
1. Simulation1 (simulation1.sce)
LABORATORY MANUAL
//Clear the all previous variables and clear the command window
clear;clc;
//Clear all previous plots in the graphics window
clf;
//Load the SCILAB functions for ADC/DAC
exec('PATH/adc_dac_functions.sce'); //Edit the PATH accordingly
//Declare the ADC parameters
Fs=8000; Vref=0.025; n=8;
//Declare the DAC parameters
Fsp=8000; Vrefp=0.025;
//Declare the input signal as a Scilab function
function xa=x(t)
xa=0.5*cos(200*%pi*t);
endfunction;
2. Simulation 2 (simulation2.sce)
LABORATORY MANUAL
VII. REFERENCES: