0% found this document useful (0 votes)
101 views14 pages

Institutional PAASCU ECE515FL Activity1

This document describes an experiment on simulating analog-to-digital conversion (ADC) and digital-to-analog conversion (DAC) using Scilab. The experiment aims to demonstrate the ADC and DAC processes, and examine the effects of parameters like sampling frequency, quantization levels, and reference voltages. The document provides background on ADC concepts like sampling, quantization, encoding, and issues like quantization error. It also describes DAC concepts like reconstructing analog signals from digital numbers. The procedures section outlines solving problems to simulate an ADC sampling an input signal and completing a table of the ADC process values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views14 pages

Institutional PAASCU ECE515FL Activity1

This document describes an experiment on simulating analog-to-digital conversion (ADC) and digital-to-analog conversion (DAC) using Scilab. The experiment aims to demonstrate the ADC and DAC processes, and examine the effects of parameters like sampling frequency, quantization levels, and reference voltages. The document provides background on ADC concepts like sampling, quantization, encoding, and issues like quantization error. It also describes DAC concepts like reconstructing analog signals from digital numbers. The procedures section outlines solving problems to simulate an ADC sampling an input signal and completing a table of the ADC process values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Saint Louis University

SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

Experiment ECE 515FL - 01


Title: ADC AND DAC

TLO 1: Simulate Analog-to-digital Conversion (ADC) and Digital-to-analog Conversion


(DAC) using SCILAB.

At the end of this experiment, the student should be able to:


1. Demonstrate the ADC and DAC processes.
2. Demonstrate the effects of ADC parameters on the digital representation of an analog
signal.
3. Demonstrate the effects of DAC parameters on the reconstruction of an analog signal.

I. INTRODUCTION:

Digital signal processing generally involves the following: (1) representation of a


an input analog signal as sequence of numbers, (2) implementation of a computational
algorithm on the numbers representing the input signal, and (3) reconstruction of an
output analog signal from the numbers that results from the computations. The
mathematical operations done on the numbers is the signal processing. There is a wide
variety of goals for signal processing like enhancement of visual images, recognition of
speech, compression of data for storage and transmission, and removal of unwanted
noisy.

The process of representing an analog signal as a sequence of numbers is analog-


to-digital conversion (ADC) and it is done using an IC device called an analog-to-digital
converter. The reconstruction of an analog signal from a sequence of numbers is digital-
to-analog conversion (DAC) and it is done using a digital-to-analog converter. In some
cases, ADC and DAC are performed by a single IC device.

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 1


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

Analog-to-Digital Conversion (ADC)

The ADC process is divided into three sub-processes, namely: sampling,


quantization, and encoding. Sampling involves taking measurements of the input analog
signal at regular intervals and each measurement is referred to as a sample. The interval
between successive samples is the sampling interval and the number of samples taken
per unit time is the sampling frequency. The sampling frequency has the unit samples per
second which is commonly denoted with the unit Hz. Quantization is the rounding-off of
the measured value to the nearest quantization level. Encoding is the representation of
the sample with the binary code assigned to the quantization level it has been rounded
to.

The process of sampling can be mathematically presented as follows:

Let: x(t) - analog input signal


Fs - sampling frequency
Ts - sampling interval, with Ts = 1/Fs
xs(k) - be the kth sample with xs(1) being the first sample
ti - time at which the first sample is taken

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 2


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

The first sample is

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

x(k) = x(ti + (k-1)Ts)

For a given analog-to-digital converter, the number of bits used to represent a


sample is fixed (usually 8, 16, or 24 bits) and the binary numeric format is also specified
(usually signed 2's complement). The interval between quantization levels is also given.

Let: n - number of bits used to represent a sample

Vref - quantization interval (also called the reference voltage)

xq - quantized or rounded-off value of the sample

and xq = round(xs/Vref) * Vref

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

binary representation of sample = n-bit signed 2's complement of round(xs/Vref)

ADC Issues

To ensure that the numbers resulting from the ADC represents the input analog
signal, several considerations should be observed.

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 3


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

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.

Fs ≥ 2fmax, where fmax - highest frequency content of the analog signal

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.

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 4


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

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.

Digital-to-Analog Conversion (DAC)

The Digital-to-Analog Converter reconstructs an analog signal from a sequence of


numbers. It outputs a voltage level corresponding to the number.

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)

II. EQUIPMENT/ MATERIALS NEEDED:


Software Requirement
 Microsoft Windows XP (32 and 64 bits), Windows Vista (32 and 64 bits),
Windows 7 (32 and 64 bits), Windows 8 (32 and 64 bits)
 Scilab 5.4.1 with the Image Processing Display Toolbox (IPDT)
 Audio files and image files for the laboratory activities (to be provided in
class)

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

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 5


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

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.

x(t) - analog input signal


x[n] - value of nth sample
xqn[n] - quantized value of the nth sample
xenc[n] - 8-bit, signed 2's complement for the nth sample
(a) Complete the table below for the ADC process.
ADC Table:
n x[n], mV xq[n], Mv xenc[n]
1
2
3
4
5
6
7
8

(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:

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 6


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

2. Given an analog signal x(t) = 2 + 3sin(500πt) + sin(4000πt) volts.


(a) Determine the voltage range and frequency content of x(t).
Voltage range = __________ to _________ volts
Frequency content = _________, _________, __________ Hz
(b) Determine the minimum sampling frequency (Fsmin) to avoid aliasing and the
minimum reference voltage (Vrefmin) that should be used to prevent overflow
in the analog-to-digital conversion of x(t). Assume that 8-bit, signed 2's
complement is used.
Fsmin = __________ Hz Vrefmin = __________ volt

II. Laboratory Activities


1. Familiarization with SCILAB functions used for the simulation of ADC and DAC
(a) Open the SCILAB file ADC_DAC_functions.sce and familiarize with the user-
defined function functions used in the file. Understand their operation and the
syntax for calling them.
(b) Use the SCILAB functions declared in ADC_DAC_functions.sce to solve problem
1 of the problem set. Compare the results you get from using the SCILAB functions
with your answers.
Are the results obtained using the SCILAB functions similar to your answers?
_____
2. Simulation of the ADC/DAC process to demonstrate aliasing and overflow.
(a) Open the simulation program simulation1.sce.
(b) Go over the program and answer the following:

(b.1) What is the amplitude and frequency of the input signal?

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 7


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

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?

________________________________________________________________

(d.2) Is the reconstructed output an acceptable approximation of the input signal


in terms of (a) waveform, (b) amplitude, and (c) frequency?

________________________________________________________________
(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?

_______________________________________________________________

(e.2) Is the reconstructed output an acceptable approximation of the input signal


in terms of (a) waveform, (b) amplitude, and (c) frequency?

________________________________________________________________

(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?

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 8


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

________________________________________________________________

(f.2) Is the reconstructed output an acceptable approximation of the input signal


in terms of (a) waveform, (b) amplitude, and (c) frequency?

________________________________________________________________

3. Simulation of the ADC of audio signals and storing the ADC results as a wave file

(a) Open the simulation program simulation2.sce.


(b) Edit the PATH in the simulation program and then execute the program?
(b.1) Did it result to the playback of the sampled 500Hz tone?

________________________________________________________________

(b.2) Is the wave file created at the designated subdirectory?

________________________________________________________________

(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?

________________________________________________________________

________________ ENGINEERING DEPARTMENT COURSE #: DESCRIPTIVE TITLE: 9


Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

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?

________________________________________________________________

(d.2) Is the reconstructed output an acceptable approximation of the input signal


in terms of (a) waveform, (b) amplitude, and (c) frequency? if no, explain
why?

________________________________________________________________

________________________________________________________________

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.

1. ADC/DAC Functions (ADC_DAC_functions.sce)


//ADC FUNCTIONS
function [ts,xn]=sampling(Fs,ti,tdur)
//Function that simulates the sampling process
//Assumes that the input analog signal is described as a function x(t)
//ts-sampling instants
//xn-values of the samples
//ti - time at which sampling starts
//tdur - sampling duration
//Ts - sampling interval
Ts=1/Fs;
ts=ti:Ts:ti+tdur;
xn=x(ts);
endfunction;

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

COURSE #: DESCRIPTIVE TITLE:


________________ ENGINEERING DEPARTMENT
10
Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

//Vmax - maximum input voltage allowable to prevent overflow


//Vmin - minimum input voltage allowable to prevent overflow
Vmax=(2^(n-1)-1)*Vref;
Vmin=-(2^(n-1))*Vref;
[r,c]=size(xn)
for i=1:r
for j=1:c
// quantize the sample and check for overflow

if xn(i,j) > Vmax then


xqn(i,j)= Vmax; end;
if xn(i,j) < Vmin then
xqn(i,j)=Vmin; end;
if xn(i,j)>=Vmin & xn(i,j)<=Vmax then
xqn(i,j)=round(xn(i,j)/Vref)*Vref; end;
end;
end;
endfunction;

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

COURSE #: DESCRIPTIVE TITLE:


________________ ENGINEERING DEPARTMENT
11
Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

endfunction;

//DAC FUNCTIONS
function [tsd,xnd]=dac(xenc,Fsp,Vrefp,n)
//Function that simulates the decoding process

//Plots the staircase waveform of the DAC output


//Assumes an n-bit, signed 2's complement format
//Assumes that the first sample arrives at t=0
//xnd - decoded values of the samples
//xenc - samples represented as n-bit, signed 2's complement numbers
//Fsp - sample reconstruction rate
//Vrefp - reference voltage / resolution of the DAC
//n - number of bits
[r,c]=size(xenc);
//Decode the value of the sample from the signed, 2's complement numbers
for i=1:r
for j=1:c
//Check sign bit
if part(xenc(i,j),1)=='0' then
//Convert the signed, 2's complement number to decimal
xndecimal=bin2dec(part(xenc(i,j),2:n));
//Compute the quantized value
xnd(i,j)=xndecimal*Vrefp;
else
//Convert the signed, 2's complement number to decimal
xndecimal=-(2^(n-1)-bin2dec(part(xenc(i,j),2:n)));
xnd(i,j)=xndecimal*Vrefp;
end;
end;
end;
//Generate the time intervals for the samples
//Assumes that the first sample is reconstructed at t=0
dtp=1/Fsp;
tsd=0:dtp:(length(xnd)-1)*dtp;
//Plot the staircase waveform of the reconstructed analog signal
clf;plot2d2([tsd length(xnd)*dtp],[xnd xnd(length(xnd))]);xgrid();
endfunction;

1. Simulation1 (simulation1.sce)

//SCILAB program to simulate an ADC/DAC process

COURSE #: DESCRIPTIVE TITLE:


________________ ENGINEERING DEPARTMENT
12
Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

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;

//Simulate the ADC process


ti=0;
tdur=0.03; //tdur - sampling duration, in seconds
[ts,xn]=sampling(Fs,ti,tdur);
xqn=quantization(xn,Vref,n);
xenc=encoding(xqn,Vref,n);
//Simulate the DAC process
[tsd,xnd]=dac(xenc,Fsp,Vrefp,n);

2. Simulation 2 (simulation2.sce)

//SCILAB program to simulate the ADC process on an audio signal


//The samples are stored into an audio wave (.wav) file
//NOTES:
//The maximum value for a .wav file is 1 and the minimum value is -1.
//Values outside -1 to 1 results in overflow
//Declare sampling frequency of ADC
Fs=8000;
//Declare the input signal
function xa=x(t);
xa=0.5*sin(1000*%pi*t);
endfunction;
//Simulate the ADC
//Generate the values for the sampling instants for 5 seconds duration
ts=0:1/Fs:5;
//Generate the samples for x(t)
xn=x(ts);

COURSE #: DESCRIPTIVE TITLE:


________________ ENGINEERING DEPARTMENT
13
Saint Louis University
SCHOOL OF ENGINEERING AND ARCHITECTURE

LABORATORY MANUAL

//Playback the samples


playsnd(xn,Fs);
//Save the samples as a .wav file with filename tone500Hz_Fs8000_8bits
wavwrite('PATH\tone500Hz_Fs8000_16bits.wav',xn,Fsp,8);

IV. DATA AND RESULTS

V. DISCUSSION (observation/ interpretation of results):

VI. CONCLUSION (option of the department if this part will be included):

VII. REFERENCES:

COURSE #: DESCRIPTIVE TITLE:


________________ ENGINEERING DEPARTMENT
14

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy