<<

AnalogAnalog && digitaldigital signalssignals

Analog Digital Continuous V of Discrete function Vk of continuous variable t (time, discrete sampling variable tk, space etc) : V(t). with k = integer: Vk= V(tk).

0.3 0.3 0.2 0.2 0.1 0.1 0 0 [V] Voltage [V] Voltage [V] -0.1 -0.1 ts ts -0.2 -0.2 0246810 0246810 time [ms] sampling time, tk [ms] Uniform (periodic) sampling. Sampling fS = 1/ tS

Slides adapted from ME Angoletta, CERN DigitalDigital vsvs analoganalog proc’ingproc’ing

Digital Processing (DSPing)

Advantages Limitations

• More flexible. • A/D & signal processors speed: wide-band still difficult to • Often easier system upgrade. treat (real-time systems). • Data easily stored. • Finite word-length effect. • Better control over accuracy • Obsolescence (analog requirements. electronics has it, too!). • Reproducibility.

Slides adapted from ME Angoletta, CERN DigitalDigital systemsystem exampleexample DOMAIN DOMAIN

V ANALOG ANALOG General scheme ms Filter V Antialiasing Sometimes steps missing ms A/D DOMAIN DIGITAL DOMAIN - Filter + A/D A DIGITAL (ex: economics); k - D/A + filter Digital Processing (ex: digital output wanted). A

k V D/A DOMAIN DOMAIN ANALOG ANALOG

ms V Filter Reconstruction

ms

Slides adapted from ME Angoletta, CERN DigitalDigital systemsystem implementationimplementation

KEY DECISION POINTS: ANALOG INPUT Analysis bandwidth,

Antialiasing • Pass / stop bands. Filter 1 • Sampling rate. A/D • No. of bits. Parameters. 2

Digital Processing • Digital format. 3 What to use for processing? See slide “DSPing aim & tools” DIGITAL OUTPUT

Slides adapted from ME Angoletta, CERN 1 SamplingSampling

How fast must we sample * a continuous signal to preserve its info content?

Ex: train wheels in a movie. 25 frames (=samples) per second.

Train starts wheels ‘go’ clockwise.

Train accelerates wheels ‘go’ counter-clockwise. Why? Frequency misidentification due to low sampling frequency.

* Sampling: independent variable (ex: time) continuous → discrete. Quantisation: dependent variable (ex: voltage) continuous → discrete. Here we’ll talk about uniform sampling.

Slides adapted from ME Angoletta, CERN 1 SamplingSampling -2-2

1.2 1 __ 0.8 s(t) = sin(2πf0t)

0.6

0.4 s(t) @ fS

0.2

0 f0 = 1 Hz, fS = 3 Hz -0.2 tt -0.4

-0.6

-0.8 __ -0.8 s1(t) = sin(8πf0t) -1 -1.2 __ s2(t) = sin(14πf0t)

s(t) @ fS represents exactly all sine- sk(t) defined by:

sk (t) = sin( 2π (f0 + k fS) t ) , ⏐k ⏐∈

Slides adapted from ME Angoletta, CERN 1 TheThe samplingsampling theoremtheorem

A signal s(t) with maximum frequency fMAX can be Theo* recovered if sampled at frequency fS > 2 fMAX .

* Multiple proposers: Whittaker(s), Nyquist, Shannon, Kotel’nikov.

Naming gets confusing ! Nyquist frequency (rate) fN = 2 fMAX or fMAX or fS,MIN or fS,MIN/2

Example s(t) = 3⋅cos(50 π t) +10⋅sin(300 π t) − cos(100π t) Condition on fS?

F1 F2 F3 f > 300 Hz F1=25 Hz, F2 = 150 Hz, F3 = 50 Hz S

fMAX

Slides adapted from ME Angoletta, CERN 1 FrequencyFrequency domaindomain (hints)(hints)

• Time & frequency: two complementary signal descriptions. Signals seen as “projected’ onto time or frequency domains. Example Ear + brain act as frequency analyser: audio spectrum split into many narrow bands low- detected out of loud background.

• Bandwidth: indicates rate of change of a signal. High bandwidth signal changes fast.

Slides adapted from ME Angoletta, CERN 1 SamplingSampling low-passlow-pass signalssignals

Continuous spectrum (a) (a) Band-limited signal: in [-B, B] (fMAX = B).

-B 0 B f

(b) Discrete spectrum No aliasing (b) Time sampling frequency repetition.

fS > 2 B no aliasing.

-B 0 B fS/2 f

Discrete spectrum (c) Aliasing & corruption (c) fS 2 B aliasing !

Aliasing: signal ambiguity 0 fS/2 f in

Slides adapted from ME Angoletta, CERN 1 AntialiasingAntialiasing filter filter

(a) Signal of interest (a),(b) Out-of-band can alias Out of band Out of band noise into band of interest. Filter it before! noise

(c) Antialiasing filter -B 0 B f Antialiasing filter

(b) Passband: depends on bandwidth of interest.

Attenuation AMIN : depends on

-B 0 B fS/2 • ADC resolution ( number of bits N). (c) f AMIN, dB ~ 6.02 N + 1.76 Antialiasing • Out-of-band noise magnitude. Passband filter frequency Other parameters: ripple, stopband frequency... -B 0 B f

Slides adapted from ME Angoletta, CERN 2 ADCADC -- Number Number ofof bitsbits NN Continuous input signal digitized into 2N levels.

1113 Uniform, bipolar (N=3)

2 V 1 Quantization step q = FSR N 0 2 -4-3-2-101234 -1 V Ex: VFSR = 1V , N = 12 q = 244.1 µV

010 -2

001 -3 Voltage ( = q) 000 -4 LSB N VFSR LSB Scale factor (= 1 / 2 )

1 q / 2 Percentage (= 100 / 2N ) 0.5

0 -4 -3 -2 -1 0 1 2 3 4 -0.5 - q / 2 Quantisation error -1

Slides adapted from ME Angoletta, CERN 2 ADCADC -- Quantisation Quantisation errorerror

0.3

0.2 • Quantisation Error eq in

0.1 [-0.5 q, +0.5 q].

0 • eq limits ability to resolve Voltage [V] 0246810 small signal. -0.1

-0.2 • Higher resolution means time [ms] lower eq.

Slides adapted from ME Angoletta, CERN FrequencyFrequency analysis:analysis: why?why?

• Fast & efficient insight on signal’s building blocks. • Simplifies original problem - ex.: solving Part. Diff. Eqns. (PDE). • Powerful & complementary to time domain analysis techniques. • The brain does it?

General Transform as problem-solving tool analysis time, t frequency, f F s(t), S(f) : s(t) S(f) = [s(t)] F Transform Pair synthesis

Slides adapted from ME Angoletta, CERN FourierFourier analysisanalysis -- tools tools Input Time Signal Frequency spectrum 2.5

2

1.5 1 T 0.5 1 0 −jk ω t 012345678 Periodic ck = ⋅ s(t)⋅e dt time, t FS Discrete T ∫ (period T) 0

2.5 Continuous j2π f t 2 +∞ − 1.5 Aperiodic Continuous S(f) = s(t)⋅e dt 1 FT ∫−∞ 0.5

0 024681012 time, t

2.5 N−1 2πk n 2 ~ 1 −j 1.5 c = s[n]⋅e N 1 k Periodic ** Discrete N ∑ 0.5 DFS n=0 0 012345678 (period T) time, tk +∞ Discrete S(f) = ∑s[n]⋅e−j2π f n 2.5 DTFT Continuous 2 n=−∞ 1.5 Aperiodic 1 2πk n 0.5 1 N−1 −j 0 ~ N 024681012time, t DFT** ck = s[n]⋅e k DFT Discrete N ∑ n=0 Note: j =√-1, ω = 2π/T, s[n]=s(tn), N = No. of samples ** Calculated via FFT Slides adapted from ME Angoletta, CERN AA littlelittle historyhistory

¾ Astronomic predictions by Babylonians/Egyptians likely via trigonometric sums.

¾ 1669: Newton stumbles upon spectra (specter = ghost) but fails to recognise “frequency” concept (corpuscular theory of light, & no waves).

¾ 18th century: two outstanding problems → celestial bodies orbits: Lagrange, Euler & Clairaut approximate observation data with linear combination of periodic functions; Clairaut,1754(!) first DFT formula. → vibrating strings: Euler describes vibrating string by sinusoids ( equation).

¾ 1807: Fourier presents his work on heat conduction ⇒ born. → Diffusion equation ⇔ series (infinite) of sines & cosines. Strong criticism by peers blocks publication. Work published, 1822 (“Theorie Analytique de la chaleur”).

Slides adapted from ME Angoletta, CERN AA littlelittle historyhistory -2-2

¾ 19th / 20th century: two paths for Fourier analysis - Continuous & Discrete.

CONTINUOUS → Fourier extends the analysis to arbitrary function (Fourier Transform). → Dirichlet, Poisson, Riemann, Lebesgue address FS convergence. → Other FT variants born from varied needs (ex.: Short Time FT - speech analysis).

DISCRETE: Fast calculation methods (FFT) → 1805 - Gauss, first usage of FFT (manuscript in Latin went unnoticed!!! Published 1866). → 1965 - IBM’s Cooley & Tukey “rediscover” FFT algorithm (“An algorithm for the machine calculation of complex Fourier series”). → Other DFT variants for different applications (ex.: Warped DFT - filter design & signal compression).

→ FFT algorithm refined & modified for most platforms.

Slides adapted from ME Angoletta, CERN FourierFourier SeriesSeries (FS)(FS)

A periodic function s(t) satisfying Dirichlet’’s conditions * can be expressed as a Fourier series, with harmonically related sine/cosine terms.

sis a , a , b : Fourier coefficients. es +∞ 0 k k th yn s(t) = a0 + []ak ⋅cos(k ω t) −bk ⋅sin(k ω t) : harmonic number, sy ∑ k k=1 For all t but discontinuities T: period, ω = 2π/T s si ys al na T an 1 (signal average over a pe a0 = ⋅ s(t)dt T ∫ zero-frequency component.) 0 T 2 riod, i.e. DC term & ak = ⋅ s(t)⋅cos(k ω t)dt T ∫ Note: {cos(kωt), sin(kωt) } 0 k form orthogonal base of T 2 function space. -bk = ⋅ s(t)⋅sin(k ω t)dt T ∫ 0 * see next slide

Slides adapted from ME Angoletta, CERN FSFS convergenceconvergence

Dirichlet conditions (a) s(t) piecewise-continuous;

(b) s(t) piecewise-monotonic; In any period: T (c) s(t) absolutely integrable , ∫ s(t) dt < ∞ 0

T Rate of convergence Example: if s(t) discontinuous then square wave |ak|0)

s(t)

T

(a) (b) (c)

Slides adapted from ME Angoletta, CERN FSFS analysisanalysis -- 1 1

1.5 FS of odd* function: square wave. 2 π 1 T = 2π ⇒ ω = 1 0.5 ⎧π 2π ⎫ 1 ⎪ ⎪ 0 a0 = ⋅⎨ ∫∫dt + (−1)dt⎬ = 0 (zero average) 2π ⎪ ⎪ 0246810t ⎩0 π ⎭ -0.5 ⎧π 2π ⎫ 1 -1 ⎪ ⎪ square signal, sw(t) ak = ⋅⎨ coskt dt − coskt dt⎬ = 0 π ∫∫ ⎩⎪0 π ⎭⎪ (odd function) -1.5

⎧π 2π ⎫ 1 ⎪ ⎪ 2 -bk = ⋅⎨ ∫∫sinkt dt − sinkt dt⎬ = ... = ⋅{}1− coskπ = * Even & Odd functions π ⎪ ⎪ k ⋅π ⎩0 π ⎭ s(x)

⎧ 4 Even : , k odd ⎪ k ⋅π ⎪ s(-x) = s(x) = ⎨ x ⎪ 0 , k even ⎪ ⎩ s(x)

4 4 4 Odd : sw(t) = ⋅sin t + ⋅sin 3⋅t + ⋅sin 5⋅t +... x π 3⋅π 5⋅π s(-x) = -s(x)

Slides adapted from ME Angoletta, CERN FSFS synthesissynthesis

Square wave reconstruction from spectral terms

1.5

1

1573911 0.5 sw111735(t)(t)(t)=== [][]-[]--[]b-bbkbkk⋅⋅⋅sin(kt)sin(kt)⋅sin(kt)sin(kt) 9 ∑∑∑ k 0 kkk===1=111 -0.5-0.5 square signal, sw(t) signal, square square signal, sw(t) sw(t) sw(t) sw(t) sw(t) signal, signal, signal, signal, signal, square square square square square square signal, sw(t) signal, square -1-1

-1.5-1.5 0246810 t Convergence may be slow (~1/k) - ideally need infinite terms. Practically, series truncated when remainder below computer tolerance (⇒ error). BUT … Gibbs’ Phenomenon.

Slides adapted from ME Angoletta, CERN GibbsGibbs phenomenonphenomenon

1.5

Overshoot exist @ 1 each discontinuity 0.5

0 79 -0.5 sw79(t) = ∑[]-bk ⋅sin(kt)

k=1 square signal, sw(t) -1

-1.5 0246810 t • First observed by Michelson, 1898. Explained by Gibbs. • Max overshoot pk-to-pk = 8.95% of discontinuity magnitude. Just a minor annoyance. • FS converges to (-1+1)/2 = 0 @ discontinuities, in this case.

Slides adapted from ME Angoletta, CERN FSFS timetime shiftingshifting

1.5 FS of even function: 2 π π/2-advanced square-wave 1 0.5 (zero average) 0 a = 0 0 0246810t -0.5

-1 ⎧ 4 square signal, sw(t) , k odd, k = 1, 5, 9... ⎪ k ⋅π ⎪ -1.5 ⎪ 4 ak = ⎨ − , k odd, k = 3, 7,11... ⎪ k ⋅π rk ⎪ 4/π ⎪ ⎩ 0 , k even. tude llii 4/3π p -bk = 0 (even function) am f 3f 5f 7f f θk 1 1 1 1

π Note: amplitudes unchanged BUT phases advance by k⋅π/2. ase h p f1 3f1 5f1 7f1 f

Slides adapted from ME Angoletta, CERN ComplexComplex FSFS

Euler’s notation: ejt + e−jt ejt − e−jt e-jt = (ejt)* = cos(t) - j·sin(t) “phasor” cos(t) = sin(t) = 2 2⋅ j is si T ly 1 al -jk ω t n ck = ⋅ s(t)⋅e dt a T ∫ 0 Complex form of FS (Laplace 1782). Harmonics sis ck separated by ∆f = 1/T on frequency plot. es th ∞ yn jk ωt sy s(t) = ∑ck ⋅e k=−∞

jθ Note: c-k = (ck)* z = r e 2 2 Link to FS real coeffs. r r = a + b b θ c0 = a0 θ = arctan(b/a) a 1 1 ck = ⋅()ak + j⋅bk = ⋅()a−k − j⋅b−k 2 2

Slides adapted from ME Angoletta, CERN FSFS propertiesproperties Time Frequency Homogeneity a·s(t) a·S(k)

Additivity s(t) + u(t) S(k)+U(k)

Linearity a·s(t) + b·u(t) a·S(k)+b·U(k)

Time reversal s(-t) S(-k) ∞ Multiplication * s(t)·u(t) ∑S(k −m)U(m) T m=−∞ 1 ⋅ s(t − t)⋅u(t)dt * T ∫ S(k)·U(k) 0 2π k⋅t s(t − t) −j Time shifting e T ⋅S(k) 2π m t +j Frequency shifting e T ⋅s(t) S(k - m) *

Slides adapted from ME Angoletta, CERN FSFS -- “oddities” “oddities”

Orthonormal base

Fourier components {uk} form orthonormal base of signal space: T u = (1/√T) exp(jkωt) (|k| = 0,1 2, …+∞) Def.: Internal product ⊗: * k uk ⊗um = ∫uk ⋅um dt o jt -jt uk ⊗ um = δk,m (1 if k = m, 0 otherwise). (Remember (e )* = e )

Then ck = (1/√T) s(t) ⊗ uk i.e. (1/√T) times projection of signal s(t) on component uk

Negative frequencies & time reversal k = - ∞, … -2,-1,0,1,2, …+ ∞, ωk = kω, φk = ωkt, phasor turns anti-clockwise.

Negative k ⇒ phasor turns clockwise (negative phase φk ), equivalent to negative time t, ⇒ time reversal. Careful: phases important when combining several signals!

Slides adapted from ME Angoletta, CERN FSFS -- power power T 1 2 W = s(t) dt ≡ s(t) ⊗ s(t) Average power W : T ∫ o Parseval • FS convergence ~1/k ∞ ’’s Theorem ∞ 2 1 ⇒ lower frequency terms W = c = a 2 + ⎛ a 2 + b 2 ⎞ ∑ k 0 ∑ ⎜ k k ⎟ 2 2 ⎝ ⎠ Wk = |ck| carry most power. k=−∞ k=1 • Wk vs. ωk: Power density spectrum.

Example 2 Wk/W0 1 Pulse train, duty cycle δ = 2 τ / T -1 2 10 W = 2 W sync (k δ) k 0 s(t) 2 τ

T 10-2

10-3 k f t 0 50 100 150 200

bk = 0 a0 = δ sMAX 2 ⎧ ∞ ⎫ W0 = (δ sMAX) ⎪ Wk ⎪ W = W0 ⋅⎨1+ ⎬ a = 2δs sync(k δ) sync(u) = sin(π u)/(π u) ∑ W k MAX ⎩⎪ k=1 0 ⎭⎪

Slides adapted from ME Angoletta, CERN FSFS ofof mainmain waveformswaveforms

Slides adapted from ME Angoletta, CERN DiscreteDiscrete FourierFourier SeriesSeries (DFS)(DFS)

Band-limited signal s[n], period = N. DFS generate periodic ck with same signal period DFS defined as:

is Orthogonality in DFS: si 2πkn ly al N−1 −j n ~ 1 2π n(k-m) a ck = s[n]⋅e N N−1 j N ∑ 1 e N = δ k,m n=0 N ∑ ~ ~ n=0 Note: ck+N = ck ⇔ same period N i.e. time periodicity propagates to frequencies! Kronecker’s delta

sis es th 2πkn nt N−1 yn j N consecutive samples of s[n] s s[n] = c~ ⋅e N ∑ k completely describe s in time k=0 or frequency domains. Synthesis: finite sum ⇐ band-limited s[n]

Slides adapted from ME Angoletta, CERN DFSDFS analysisanalysis

s[n] DFS of periodic discrete 1 1-Volt square-wave

s[n]: period N,N duty factor L/N -5 0 1 2 3 4 5 6 7 8 9 10 n 0 L N

⎧ L tude 1 1 , k = 0, +N, ± 2N,... llii ~ ⎪ N p 0.6 0.6 ck 0.6 0.6 ⎪ am ⎪ 0.24 0.24 0.24 0.24 ~ ⎪ 0.2 c = ⎨ k πk(L−1) ⎛ π kL ⎞ ⎪ −j sin⎜ ⎟ e N N 0 1 2 3 4 5 6 7 8 9 10 k ⎪ ⋅ ⎝ ⎠ , otherwise ⎪ N ⎛ π k ⎞ ⎪ sin⎜ ⎟ ⎩ ⎝ N ⎠ θk 0.4π ase 0.4π h p 0.2π 0.2π

Discrete signals ⇒ periodic frequency spectra. Compare to continuous rectangular function 0 2 4 5 6 7 8 9 10 n (slide # 10, “FS analysis - 1”) -0.2π -0.2π -0.4π -0.4π

Slides adapted from ME Angoletta, CERN DFSDFS propertiesproperties Time Frequency Homogeneity a·s[n] a·S(k)

Additivity s[n] + u[n] S(k)+U(k)

Linearity a·s[n] + b·u[n] a·S(k)+b·U(k)

1 N−1 Multiplication * s[n] ·u[n] ⋅ ∑S(h)U(k -h) N h=0 N−1 Convolution * ∑s[m] ⋅u[n −m] S(k)·U(k) m=0 2π k⋅m Time shifting s[n - m] −j e T ⋅S(k) 2π h t Frequency shifting +j S(k - h) e T ⋅s[n]

Slides adapted from ME Angoletta, CERN DFTDFT –– Window Window characteristicscharacteristics

• Finite discrete sequence ⇒ spectrum convoluted with rectangular window spectrum. • Leakage amount depends on chosen window & on how signal fits into the window.

(1) Resolution: capability to distinguish different tones. Inversely proportional to main- lobe width. Wish: as high as possible. (2) Peak-sidelobe level: maximum response outside the main lobe. Determines if small signals are hidden by nearby stronger ones. (1) Wish: as low as possible. (3) (2) (3) Sidelobe roll-off: sidelobe decay per decade. Trade-off with (2).

Several windows used (application- dependent): Hamming, Hanning, Rectangular window Blackman, Kaiser ...

Slides adapted from ME Angoletta, CERN DFTDFT ofof mainmain windowswindows

Windowing reduces leakage by minimising sidelobes magnitude.

In time it reduces end- points discontinuities.

Sampled sequence

Non windowed

Windowed

Some window functions

Slides adapted from ME Angoletta, CERN DFTDFT -- Window Window choicechoice

Common windows characteristics

Window type -3 dB Main- -6 dB Main- Max sidelobe Sidelobe roll-off lobe width lobe width level [dB/decade] [bins] [bins] [dB] Rectangular 0.89 1.21 -13.2 20

Hamming 1.3 1.81 - 41.9 20 Hanning 1.44 2 - 31.6 60 Blackman 1.68 2.35 -58 60

Observed signal Window wish list Far & strong interfering components ⇒ high roll-off rate. Near & strong interfering components ⇒ small max sidelobe level. Accuracy measure of single tone ⇒ wide main-lobe

NB: Strong DC component can shadow nearby small signals. Remove it!

Slides adapted from ME Angoletta, CERN DFTDFT -- Window Window lossloss remedialremedial

Smooth data-tapering windows cause loss near edges.

2 x N samples (input signal) Solution: sliding (overlapping) DFTs. DFT #1

• Attenuated inputs get next DFT #2 window’s full & leakage reduced. • Usually 50% or 75% overlap DFT #3 (depends on main lobe width).

Drawback: increased total processing time. DFT AVERAGING

Slides adapted from ME Angoletta, CERN DFTDFT -- parabolic parabolic interpolationinterpolation

Rectangular window Hanning window

1.968 0.977

1.967

1.966 0.976

1.965

1.964 0.975

1.963

1.962 198 199 200 201 202 203 0.974 199 200 201 202 203 204

¾ Parabolic interpolation often enough to find position of peak (i.e. frequency). ¾ Other algorithms available depending on data.

Slides adapted from ME Angoletta, CERN SystemsSystems spectralspectral analysisanalysis (hints)(hints)

System analysis: measure input-output relationship.

Linear Time Invariant δ DIGITAL LTI [n] h[n] x[n] y[n] 1 DIGITAL SYSTEM LTI SYSTEM h[n] 0 n 0 n h[t] = impulse response

∞ x[n] h[n] y[n] = x[n]∗ h[n]= ∑ x[n −m]⋅h[m] y[n] predicted from { x[n], h[t] } m=0

X(f) H(f) Y(f) = X(f) · H(f) H(f) : LTI transfer function

Transfer function can be estimated by Y(f) / X(f)

Slides adapted from ME Angoletta, CERN EstimatingEstimating H(f)H(f) (hints)(hints)

* Power Spectral Density of x[t] Gxx(f) = X(f)⋅ X (f) (FT of ).

* Cross Power Spectrum of x[t] & y[t] Gyx(f) = Y(f)⋅ X (f) (FT of cross-correlation).

* Y(f) Y(f)⋅ X (f) Gyx H(f) = = = Transfer Function * X(f) X(f)⋅ X (f) Gxx (ex: beam !)

It is a check on H(f) validity!

Slides adapted from ME Angoletta, CERN