ECE 308 -3 ECE 308 Sampling of Analog Signals Quantization of Continuous-Amplitude Signals Z. Aliyazicioglu Electrical and Computer Engineering Department Cal Poly Pomona ECE 308-3 1 Sampling of Analog Signals Example: 1. 2. 3. 4. xa (t ) = 3cos100π t Find the minimum sampling rate required to avoid aliasing. If Fs = 200 Hz, What is the discrete-time signal after sampling? If Fs = 75Hz , What is the discrete-time signal after sampling? What is the frequency F of a sinusoidal that yields sampling identical to obtained in part c? Solution: a Ω = 100π F = 50 Hz The minimum sampling rate is Fs = 2 F = 100Hz and the discrete-time signal is x(n) = xa (nT ) = 3cos 100π 1 n = 3cosπ n = 3cos2π n 100 2 ECE 308-3 2 1 Sampling of Analog Signals Solution: b If Fs = 200 Hz , the discrete-time signal is x(n) = 3cos c If Fs = 75 Hz , x( n ) = 3cos 100π 100π π 1 n = 3cos n = 3cos 2π n 200 2 4 the discrete-time signal is n = 3cos 4π 75 c n = 3cos 2π − 3 2π 3 n = 3cos 2π 1 n 3 For the sampling rate Fs = 75 Hz , f = F = fFs = f 75 and F= 75 = 25Hz 3 1 3 in part in (c). Hence So, the analog sinusoidal signal is ya (t ) = 3cos 2π Ft = 3cos50π t ECE 308-3 3 The Sampling Theorem We must have some information about the analog signal especially the frequency content of the signal, to select the sampling period T or sampling rate Fs. For example A speech signal goes below around 20Khz. A TV signal is up to 5Mhz. Any analog signal can be represented as sum of sinusoids of different amplitudes, frequencies, and phases. N xa (t ) = ∑ Ai cos(2π Fi t + θ i ) i =1 where N the number of frequency components. Suppose that Nth frequency do not exceed the largest frequency Fmax Fi < Fmax ECE 308-3 4 2 The Sampling Theorem To avoid the aliasing problem, is selected so that Fs > 2 Fmax The analog signal should be in the range of F 1 1 − ≤ fi = i ≤ 2 Fs 2 or in radians −π ≤ ωi = 2π fi ≤ π The sampling rate FN = 2 Fmax is called the Nyquist rate. ECE 308-3 5 The Sampling Theorem Example: Consider an analog signal xa (t ) = 3cos50π t + 10sin 300π t + 3cos100π t Solution The frequencies in the analog signal F1 = 25Hz F2 = 150Hz F3 = 50Hz The largest frequency is Fmax = F2 = 150Hz The Nyquist rate is FN = 2 Fmax = 300 Hz ECE 308-3 6 3 The Sampling Theorem Example: The analog signal xa (t ) = 3cos 2000π t + 5sin 6000π t − 10cos12000π t 1. What is the Nyquist rate for this signal? 2. Using a sampling rate Fs = 5000 samples/s . What is the discrete-time signal obtained after sampling? 3. What is the analog signal ya (t ) we can reconstruct from the samples if we use ideal interpolation? Solution 1. The frequencies of the analog signal are F1 = 1 KHz F2 = 3 KHz The Nyquist rate is F3 = 6KHz FN = 2 Fmax = 12 KHz ECE 308-3 7 The Sampling Theorem n x( n ) = xa (nT ) = xa Fa 1 3 6 = 3cos 2π n + 5sin 2π n − 10cos 2π n 5 5 5 1 2 1 = 3cos 2π n + 5sin 2π 1 − n − 10cos 2π 1 + n 5 5 5 2. For Fs = 5KHz For Fs = 5KHz , the 1 2 1 = 3cos 2π n − 5sin 2π n − 10cos 2π n 5 5 5 1 2 = −7 cos 2π n − 5sin 2π n 5 5 F folding frequency is Fmax = s = 2.5KHz 2 Hence, F1 = 1 KHz is not effected by aliasing F2 = 3 KHz F3 = 6KHz is changed by the aliasing effect is changed by the aliasing effect So that normalize frequencies are f1 = 1 5 F2' = F2 − Fs = −2 KHz F3' = F3 − Fs = 1 KHz f2 = 2 5 f3 = 1 5 ECE 308-3 8 4 The Sampling Theorem Solution (cont) c. The analog signal that we can recover is ya (t ) = −7cos 2000π t − 5cos 4000π t which is different than the original signal xa (t ) ECE 308-3 9 Quantization of Continuous-Amplitude Signals • • Converting a discrete-time continuous-amplitude signal into a digital signal by expressing each sample value as a finite number of digits, is called quantization. The error between continuous-valued signal and a finite set of discrete value levels signal is called quantization error or quantization noise. The output of quantizer is xq (n) = Q [ x(n) ] The quantizer error is eq (n) = xq (n) − x( n) >> >> >> >> >> >> >> t=0:0.01:10; x=0.9.^t; plot (t,x) hold on n=0:10; x=0.9.^n; stem(t,x,'r') Example: Let’s consider the discrete-time signal as 0.9n x ( n) = 0 n≥0 n<0 The sampling frequency is Fs = 1Hz. ECE 308-3 10 5 Quantization of Continuous-Amplitude Signals n >> >> >> >> >> >> >> >> >> 0 1 2 3 4 5 6 7 8 9 10 t=0:0.01:10; x=0.9.^t; plot (t,x) hold on t=0:10; x=0.9.^t; y=0.1*round(10*x); stem(t,y,'r') grid on xq (n) eq (n) x ( n) 1.0000 1.0000 0.9000 0.9000 0.8000 0.8100 0.7000 0.7290 0.7000 0.6561 0.6000 0.5905 0.5000 0.5314 0.5000 0.4783 0.4000 0.4305 0.4000 0.3874 0.3000 0.3487 0.0000 0.0000 -0.0100 -0.0290 0.0439 0.0095 -0.0314 0.0217 -0.0305 0.0126 -0.0487 ECE 308-3 11 Quantization of Continuous-Amplitude Signals Using rounding process for quantization. The other method is truncation , which discards the excess digits. • The values allowed in the digital signal are called quantization level. • Distance ∆ between two quantization level is called quantization step size or resolution • If we use rounding process the quantization error is the range of − ∆ ∆ ≤ eq (n) ≤ 2 2 • If xmin and xmax represent the minimum and maximum value of x( n) and L is number of quantization level, then ∆= xmax − xmin L −1 ECE 308-3 12 6 Quantization of Continuous-Amplitude Signals In the example xmin = 0 , xmax = 1 , and, L = 11 , which leads to ∆ = 0.1 . Note: If L increases, ∆ decreases. Hence, the quantization error eq (n) decreases and the accuracy of the quantizer increases. ECE 308-3 13 Quantization of Sinusoidal Signal Let’s look at the quantizer error by quantizing the analog sinusoidal signal xa (t ). ECE 308-3 14 7 Quantization of Sinusoidal Signal The analog signal xa (t ) is almost linear between quantization levels. The quantization error eq (t ) = xa (t ) − xq (t ) eq(t) ∆/2 eq (t ) = Here t -τ 0 -∆/2 ∆ t 2τ τ −τ ≤ t ≤ τ The mean-square error power Pq is Find discrete time signal x1(n) and x2(n) Pq = 1 2τ τ 1 ∫ τ e (t )dt = τ ∫ − 2 q τ 0 eq2 (t )dt Pq = 1 τ∫ τ 0 1 ∆ t 3 τ ∆2 ∆ 2 = t dt = τ 2τ 3 0 12 2τ 2 2 ECE 308-3 15 Quantization of Sinusoidal Signal For b bit the all range is 2A, then ∆= 2A 2b Hence, the mean-square error power Pq for the signal xa (t ) is Pq = 4 A2 A2 = 2b (12)2 (3)22b The average power of the signal xa (t ) is Px = 1 Tp 2 A ∫ ( A cos Ωt ) dt = 2 Tp 2 0 The ratio of the signal average power to the noise power is the signal-quantization noise ratio (SQNR) gives SQNR = Px 3 2b = 2 Pq 2 In dB, SQNR(dB) = 10log10 SQNR = 1.76 + 6.02b ECE 308-3 16 8 Digital-to-Analog Conversion Some cases we may need to convert digital signal to analog signal again. The process of converting a digital signal into an analog signal is called Digital-to-Analog (DAC). All D/A converters use some kind of interpolation. A simple form of D/A conversion is zero-order hold or staircase approximation. Simply holds constant the value of one sample until the next one is received. ECE 308-3 17 Digital-to-Analog Conversion A Linear interpolation is connect successive samples with straitline. It needs T second delay so that has knowledge about next sample values. Better interpolation can be achieved by using more sophisticated high-order interpolation techniques. ECE 308-3 18 9 Problem Problem 1.7 • An analog signal contains frequencies up to 10Khz. a. What range of sampling frequencies allows exact reconstruction of this signal from the samples? b. Suppose that we sample this signal with a sampling frequency Fs=8 KHz. Examine what happens to the frequency F1=5Khz. c. Repeat part (b) for a frequency F2=9Khz. Solution 1.7 a Fmax = 10 Khz. b Fs = 8Khz. Fs ≥ 2 Fmax = 20 Khz. Ffold = Fs = 4 Khz. 2 So, F = 5 Khz will be alias of 3KHz c F = 9 Khzwill be alias of 1KHz. ECE 308-3 19 Problem Problem 1.15 xa (t ) = sin 2π F0t −∞ < t < ∞ and Fs = 5 Khz. x ( n ) = x ( nT ) = sin 2π F0 n Fs and F0 = 0.5 Khz. 0 ≤ n ≤ 99 Solution 1.15 >> n=0:99; >> x=sin(2*pi*0.1*n); >> stem (n,x) ECE 308-3 20 10