You are on page 1of 4

# Digital Signal Processing Lab S2

2.SamplingofAnalogSignals:

Mostsignalsofpracticalinterest,suchasspeech,biologicalsignals,seismicsignals,radarsignals,
sonar signals, and various communications signals such as audio and video signals, are analog.
Toprocessanalogsignalsbydigitalmeans,itisfirstnecessarytoconvertthemintodigitalform,
that is, to convert them to a sequence of numbers having finite precision. This procedure is
called analogtodigital (A/D) conversion, and the corresponding devices are called A/D
converters(ADCs)

Conceptually, we view A/D conversion as a three step process. This process is illustrated in
figure2.1

1. Sampling
Thisistheconversionofacontinuoustimesignaltoadiscretetimesignalobtainedbytaking
samplesofcontinuoustimesignalatdiscretetimeinstants.Thus,ifx
a
(t)istheinputtothe
sampler,theoutputisx
a
(nT)x(n),whereTiscalledthesamplinginterval.

2. Quantization
Thisistheconversionofdiscretetimecontinuousvaluedsignalintoadiscretetimediscrete
valued (digital) signal. The value of each signal sample is represented by a value selected
from a finite set of possible values. The difference between the unquantized sample x(n)
andthequantizedoutputx
q
(n)iscalledthequantizederror.

3. Coding
Inthecodingprocess,eachdiscretevaluex
q
(n)isrepresentedbyabbitbinarysequence.

Sir Syed University of Engineering & Technology

x
q
(n)
x(n) x
a
(t)

Coder Quantizer Sampler
01010...

Analog
signal
Discrete
time signal
Digital
signal
Quantized
signal

Figure2.1:Basicpartsofananalogtodigital(A/D)converter.

Therearemanywaystosampleananalogsignal.Welimitourdiscussiontoperiodicoruniform
sampling, which is the type of sampling used most often in practice. This is described by the
relation

( ) < < = n n x n x
a
, ) (

Digital Signal Processing Lab S2

Where x(n) is the discrete time signal obtained by taking samples of the analog signal ( ) t x
a

every T seconds. This procedure is illustrated in figure 2.2. The time interval T between
successive samples is called the sampling period or sample interval and its reciprocal 1/T=F
s
is
calledthesamplingrate(samplespersecond)orthesamplingfrequency(hertz).

x
a
(t)

1 23 4 5 6 7 8 9

T 2T 5T9T t=nT
t
x
a
(t)
x(n)=x
a
(nT)
n
0
x(n)

Figure2.2:Periodicsamplingofananalogsignal

Periodic sampling establishes a relationship between the time variables t and n of continuous
timeanddiscretetimesignalsrespectively.Indeed, thesevariablesarelinearlyrelatedthrough
thesamplingperiodTor,equivalently,throughthesamplingrateF
s
=1/T,as

s
F
n
nT t = =

There exists a relationship between the variables F (or ) for analog signals and the frequency
variable (or ) for discrete time signals. To establish this relationship, consider an analog
sinusoidalsignaloftheform

( ) ) 2 cos( + = Ft A t x
a

Which,whensampledperiodicallyatarate =1/Tsamplespersecond,yields
s
F

( ) ) 2 cos( ) ( + = FnT A n x nT x
a

)
2
cos(

+ =
s
F
nF
A

ThefrequencyvariablesFandarelinearlyrelatedas

s
F
F
f =
(2.1)
or,equivalently,as

T =
(2.2)

## Sir Syed University of Engineering & Technology

Digital Signal Processing Lab S2

Therelationin(2.1)justifiesthenamerelativeornormalizedfrequency,whichissometimes
usedtodescribethefrequencyvariable .As(2.1)implies,wecanuse todeterminethe
frequencyFinhertzonlyifthesamplingfrequency isknown.
f f
s
F

TherangeofthefrequencyvariableForforcontinuoustimesinusoidsare

< < F

< <
(2.3)

However,thesituationisdifferentfordiscretetimesinusoids.
2
1
2
1
< <

< <
(2.4)

Bysubstitutingfrom(2.1)and(2.2)into(2.4),wefindthatthefrequencyofthecontinuoustime
sinusoidwhensampledatarateFs=1/Tmustfallintherange

T
F
F
F
T
s s
2
1
2 2 2
1
= =
(2.5)

Or,equivalently,

T
F F
T
s s

= =
(2.6)

Fromtheserelationsweobservethatthefundamentaldifferencebetweenthecontinuoustime
anddiscretetimesignalsisintheirrangeofvaluesofthefrequencyvariablesFand ,orand
. Periodic sampling of a continuous time signal implies a mapping of the infinite frequency
rangeforthevariableF(or)intoafinitefrequencyrangeforthevariable (or).Sincethe
highest frequency in a discrete time signal is =
f
f

## or =1/2, it follows that, with a sampling

rateFs,thecorrespondinghighestvaluesofFandare
f

T
F
F
s
2
1
2
max
= =

T
F
s

= =
max

Sir Syed University of Engineering & Technology
Digital Signal Processing Lab S2

Exercise:

Task#1:Writeascripttogenerateacontinuoustimesinusoidsignalwithamplitude=2foratime
0to1secandtakenthefrequencyasauserinputbyusinginputcommand.

Task#2: Writeascripttoconvertcontinuoustimesignaloftask#1toadiscretetimesignaland
take the sampling frequency as input which should be less than twice the maximum
signalfrequencyinHertz.

Task#3: Writeascripttoconvertcontinuoustimesignaloftask#1toadiscretetimesignaland
take the sampling frequency as input which should be equal to twice the maximum
signalfrequencyinHertz.

Task#4: Writeascripttoconvertcontinuoustimesignaloftask#1toadiscretetimesignaland
takethesamplingfrequencyasinputwhichshouldbegreaterthantwicethemaximum
signalfrequencyinHertz.

Task#5: Write a script using subplot command to generate task #1, task#2, task#3 and task#4
plots.Analyzethefourplots,whathappenbyincreasingthesamplingfrequency?

Task#6:Considertheanalogsignal

( ) ) 100 cos( 3 t t x
a
=

(i) Determinetheminimumsamplingraterequiredtoavoidaliasing.
(ii) Suppose that the signal is sampled at the rate Fs=200 Hz. What is the discrete
timesignalobtainedaftersampling?Plotthediscretetimesignal.
(iii) Suppose that the signal is sampled at the rate Fs=75 Hz. What is the discrete
timesignalobtainedaftersampling?Plotthediscretetimesignal.
(iv) What is the frequency 0<F<Fs/2 of a sinusoid that yields samples identical to
thoseobtainedinpart(iii)?GiveyourobservationregardingAliasingeffect.