22
Colorado State University Dept of Electrical and Computer Engineering ECE423 – 1 / 22 Lecture 2 - Number Representations, Fundamental DSP Concepts James Barnes ([email protected]) Spring 2014

Lecture 2 - Number Representations, Fundamental DSP Concepts · PDF fileLecture 2 - Number Representations, Fundamental DSP Concepts James Barnes (James.Barnes@ ) Spring 2014. Number

Embed Size (px)

Citation preview

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 1 / 22

Lecture 2 - Number Representations, FundamentalDSP Concepts

James Barnes ([email protected])

Spring 2014

Number Representations

Number Representations

❖ DSK Hardware

❖ C6713 DSP Chip

❖ A C Program toGenerate a Sine Wave❖ The DSP Idea -Sampling, DigitalProcessing, andReconstruction❖ Intro to C LanguageData Types

❖ Fixed Point “Hazards” :Overflow

Representing AnalogSignals with Numbers

Fundamental DSPConcepts - Samplingand Reconstruction

Quantization

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 2 / 22

DSK Hardware

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 3 / 22

C6713 DSP Chip

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 4 / 22

A C Program to Generate a Sine Wave

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 5 / 22

The DSP Idea - Sampling, DigitalProcessing, and Reconstruction

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 6 / 22

Intro to C Language Data Types

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 7 / 22

Ref: (Tretter, on E-reserve)

● short - 16b signed (default) or unsigned (unsigned short). Most useful forthe DSK because we have a 16b ADC/DAC (codec)

● int, uint, uint32 - 32b integer (signed or unsigned).● float and double - 32b and 64b IEEE floating point signed number type.

✦ float gives 6-8 decimal places of precision, double 15-17 dec places.

● Integers (short,int ) used in fixed-point arithmetic.

✦ 2’s complement representation for signed numbers✦ There is no explicit radix point in the number representation – user must

keep track. Commonly, the radix point is imagined to lie to the left of theMSB for unsigned integer, to the right of the sign bit for signed.

✦ Arithmetic operations (+, X) can move the radix point.

Fixed Point “Hazards” : Overflow

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 8 / 22

Overflow behavior is different for unsigned and signed numbers. Consider 4 bitunsigned and signed numbers (not a standard C data type):

Test for overflow (works for both signed and unsigned numbers):overflow has occurred

● a and b are positive and the sum (a+ b) is negative, or● a and b are negative and the sum (a+ b) is positive.

Representing Analog Signals with Numbers

Number Representations

Representing AnalogSignals with Numbers

❖ PhasorRepresentation of SineFunction❖ Implications of PhasorRepresentation

Fundamental DSPConcepts - Samplingand Reconstruction

Quantization

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 9 / 22

Phasor Representation of Sine Function

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 10 / 22

● Continuous Time Function : y(t) = Aosin(θ(t)) = Aosin(2πf0t+ φ)● Discrete Time Sequence: y[n] = Aosin(θ[n]) = Aosin(2π

f0Fs

n+ φ)

Implications of Phasor Representation

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 11 / 22

● f0/Fs is often defined as the discrete-time frequency. This is the fraction ofthe circle per sample point. It is a unit-less fraction of the sampling frequency

✦ Nyquist Criteria limits fs/Fs to the range -0.5 to 0.5; frequencies outsidethis range are aliased into the range [-0.5,0.5]

● What about a non-integer divisor f0/Fs, i.e. 1/4.5 ?● What about finite precision in computing 2π f0

Fs

n ?

Fundamental DSP Concepts - Samplingand Reconstruction

Number Representations

Representing AnalogSignals with Numbers

Fundamental DSPConcepts - Samplingand Reconstruction❖ The DSP Idea -Sampling, DigitalProcessing, andReconstruction

❖ The Sampling Problem

❖ Sampling asMultiplication with theComb (”Shah”) Function

❖ Properties of theContinuous-time DeltaFunction❖ Sampled SignalFrequency DomainRepresentation

❖ Sampled SignalFrequency Spectrum

❖ Reconstruction FilterRequirements

❖ Shannon-WhitakerTheorem

Quantization

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 12 / 22

The DSP Idea - Sampling, DigitalProcessing, and Reconstruction

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 13 / 22

The Sampling Problem

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 14 / 22

● The sampling problem can be stated: ”Under what conditions willx̂(t) = x(t)”. The Shannon-Whitaker Theorem will tell us that.

● We can ignore the Quantizer Q because it can be modeled as a white noisesource which can have minimal impact with a sufficient number of bits (later).Without the Quantizer, can drop the DAC.

● Note that xs(t) is a continuous time signal but only defined at times nTs (wedon’t know what the value of x(t) is between sample times. In this analysis,assume xs(t) is zero between sampling points, as would be the case in aphysical circuit with a weak pulldown resistor to ground.

Sampling as Multiplication with the Comb(”Shah”) Function

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 15 / 22

● Model sampling as multiplication with the Comb or ”Shah” function

✦ xs(t) = x(t)∑

n=−∞δ(t− nTs), where δ(t) is the Dirac delta function.

✦ Note that xs(t) is still a continuous function, but all the information is containedwithin a set of discrete time points.

Properties of the Continuous-time DeltaFunction

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 16 / 22

● δ(τ ) = 0 for τ 6= 0, undefined at τ = 0

ǫ∫−ǫ

δ(τ )dτ = 1 for ǫ > 0

● ”Infinite height, zero width, unit area”● Not really a true function. Actually defined as a distribution.

● Also called the ”sifting function” :∞∫

−∞

x(t)δ(t− T0)dt = x(T0)

Sampled Signal Frequency DomainRepresentation

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 17 / 22

● Comparing the frequency domain representation of xs(t) with x(t) will tell uswhat reconstruction filter needed so that x̂(t) = x(t).

● Convolution Theorem: xs(t) = x(t)s(t) ⇔ Xs(f) = X(f)⊗ S(f), where ⊗ isthe convolution operator

● To perform the convolution, we need the Fourier Transform S(f) of the ShahFunction. It can be shown that

S(f) = Fs

∞∑n=−∞

δ(f + nFs). (1)

See http://www.engr.colostate.edu/ECE423/docs/ftrans_sample_fn.pdf.

Sampled Signal Frequency Spectrum

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 18 / 22

Xs(f) = X(f)⊗ S(f)

=

∫∞

−∞

X(f)S(f + f ′)d(f ′)

= Fs

∫∞

−∞

X(f)∞∑

n=−∞

δ(f + nFs + f ′)df ′

= Fs

∞∑n=−∞

X(f + nFs) (2)

Therefore, sampling produces an infinite number of replicas (”images”) of the unsampledspectrum, spaced Fs apart. The original spectrum is periodically-extended.

Reconstruction Filter Requirements

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 19 / 22

● If the images can be filtered out, the original spectrum can be recovered and thereforethe original signal through inverse Fourier Transform. This is the job of thereconstruction filter.

● The ideal reconstruction filter is a brick wall filter of width [−Fs/2, Fs/2] and height 1

Fs

,with unit area.

● The output X̂(f) of the sampled signal AFTER reconstruction filter is:

X̂(f) =1

FsXs(f) |F | ≤ Fs/2

= 0 |F | > Fs/2 (3)

Shannon-Whitaker Theorem

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 20 / 22

Get x̂(t) by inverse transform of X̂(f), taking into account the effect of thereconstruction filter:

x̂(t) = 1/Fs

∫ Fs/2

−Fs/2

Xs(f)ej2πftdf

But Xs(f) is periodic in frequency with period Fs, and therefore can beexpanded as a Fourier Series:

Xs(f) = Fs

∞∑−∞

cne−j2πnf/Fs

where cn = x[n] = x(nTs). From this we get

x̂(t) =

∫ Fs/2

−Fs/2

[

∞∑n=−∞

x(nTs)e−j2πnf/Fs ]ej2πftdf

=

∞∑n=−∞

x(nTs)sin(πFs(t− n/Fs))

πFs(t− n/Fs)(4)

Quantization

Number Representations

Representing AnalogSignals with Numbers

Fundamental DSPConcepts - Samplingand Reconstruction

Quantization❖ Quantization:Irreversable InformationLoss

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 21 / 22

Quantization: Irreversable Information Loss

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 22 / 22

● Divide voltage range VR into 2M levels. M=# of bits.● Least Significant Bit (LSB) ∆ = VR/2

M

● For DSK, ∆ = 3.3/65536 = 50µV