TMMS04 Lesson 2 – Signal Processing 2014 HT-1 1. This task will demonstrate aliasing when sampling the sinus wave shown in Figure 1. Sinus at 9 Hz 1 0.8 0.6 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 0 0.1 0.2 0.3 0.4 0.5 Time [s] 0.6 0.7 0.8 0.9 1 Figure 1: y = sin(2π 9 t + π) (a) Sample the signal manually with a sample rate of 10Hz. Mark each samples with a cross. The cross mark samples will form a lower frequency sinus wave. What is its apparent frequency? Solution: y = sin(2π9t + π) Sampled at 10Hz, results in alias frequency at 1Hz Sinus at 9 Hz, Sampled at 10 Hz, Alias at 1 Hz 1 0.8 0.6 0.4 Value [−] Value [−] 0.4 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 0 0.1 0.2 0.3 0.4 0.5 Time [s] 0.6 0.7 0.8 0.9 1 (b) Do the same thing, but this time sample at 12Hz. Mark the new samples with some other symbol. What frequency does the new samples seem to indicate? Solution: y = sin(2π9t + π) Sampled at 12Hz, results in alias frequency at 3Hz 1 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 Sinus at 9 Hz, Sampled at 12 Hz, Alias at 3 Hz 1 0.8 0.6 Value [−] 0.4 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 0 0.1 0.2 0.3 0.4 0.5 Time [s] 0.6 0.7 0.8 0.9 1 (c) Comment on the two different sampled curve frequencies. How do they relate to the sample frequency, Nyquist frequency and folding. Solution: In the 10Hz sample case, the spectrum of the 9Hz signal copied to each multiple of the sampling frequency resulting in an alias frequency of 1Hz, [−9, +9]+10 = [1, 19]. In the 12Hz case, spectrum copied to each multiple of the sampling frequency resulting in an alias frequency of 3Hz, [−9, +9] + 12 = [3, 21]. 2 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 (d) If a 60Hz sinusoidal signal is sampled at 100Hz, is there risk for aliasing? Why? Solution: Yes! And it is not only a risk – it will occur. The signal frequency is higher then the Nyquist frequency, fS = 60Hz > fn = 50Hz (e) If a 50Hz sinusoidal signal is sampled at 200Hz, is there risk for aliasing? Why? Solution: No! The signal frequency is lower then the Nyquist frequency, fS = 50Hz < fn = 100Hz 2. Figure 2 shows the amplification and phase shift of a low-pass filter. (a) What is the “order” of the filter in Figure 2? Determine the filter’s corner frequency (sometimes also called cut-off frequency or break frequency) ωc , the amplification and the phaseshift at that frequency. Hint: Recall the asymptotic approximation of Bode plots. Solution: This is the Bode plot of a first order system since the phase shift for f ⇒ ∞ goes to 90◦ and the amplification goes down with 20dB per decade or 1 : 1 in linear scale. For a first order system ωc can be found at φc = 45◦ = 90◦ /2 and is ωc = 100rad/s for this filter. A fist order system’s amplification at ωc is √12 ≈ 0.707 or −3dB. 3 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 Bode Diagram Magnitude (dB) 0 −10 −20 −30 Phase (deg) −40 0 −45 −90 0 10 1 2 10 3 10 Frequency (rad/s) 10 4 10 Figure 2: Amplification and phase shift of a low-pass filter (b) What is the filter transfer function G (s) in the frequency plane? Calculate the filter amplification at the frequency ω = 5.0 ωc . Solution: G (s) = amp = |G (s)| = |1| 500i 100 s ωc 1 1 +1 1 = √ = √ = 0.196 = −14.1dB 26 52 + 1 2 + 1 3. For the following questions assume an ideal low-pass filter. An ideal low-pass filter is a simplification of real filters like the one in the question block before. An ideal low-pass filter eliminates all frequency components above the cutoff frequency while leaving those below unchanged. (a) Assume that the low-pass filter will be used as an “anti-alias” filter in a digital control system. Calculate the highest allowed cutoff frequency ωc in rad s when the control system sample time period is T = 50ms. Solution: fs = 1 1 = = 20Hz T 0.050s ωs = 2π20Hz = 126rad/s We must remove all signal components above the Nyquist frequency. ωc ≤ ωn = ωs = 63rad/s 2 (b) Assume that the bandwidth in a control system is ωb = 32rad/s. How should the sample frequency ωs and the “anti-alias” filter cutoff frequency be adapted to the bandwidth? Solution: Bandwidth is here interpreted as the highest relevant frequency component of the signal coming (measured) from the system. Accordion to a rule-of-thumb, ωs shall 4 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 be at least ωs ≥ 10 ωb or ωs ≥ 20 ωb . ωs = 20ωb = 640rad/s 20 × 32 ωn = = 320rad/s 2 The cutoff frequency shall be selected according to ωb ωc ωn . 4. A signal containing three distinct frequency components and noise is shown in Figure 3. This is similar to the signal in the last question in lesson 1, except that the frequency has been increased. By the use of fast Fourier transform FFT, a frequency spectrum for the signal has been created. It is shown in Figure 4. 2 1.5 Signal 1 0.5 0 −0.5 0 0.5 1 1.5 2 Time [s] 2.5 3 3.5 4 Figure 3: This signal contains three major signal component at different frequencies as well as noise. Periodogram Using FFT 10 0 Power/Frequency (dB/Hz) −10 −20 −30 −40 −50 −60 −70 −80 0 2 4 6 8 10 Frequency (Hz) 12 14 16 18 20 Figure 4: The frequency spectrum for the signal in Figure 3. (a) In Figure 3, draw the “curves” for the two lowest frequency signal components. Solution: The signal contains a constant value, a low-frequent sinus and a high-frequent sinus. 5 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 2 Signal Low−frequent signal component DC−level (Frequency = 0 Hz) 1.5 Signal 1 0.5 0 −0.5 0 0.5 1 1.5 2 Time [s] 2.5 3 3.5 4 (b) Design a first-order high-pass filter that preserves the highest frequency component (transfer function). What will the amplification for that frequency be? Sketch the Bode plot of this filter by asymptotic approximation. Solution: GHP = s ωc s ωc +1 Now choose a “suitable” corner frequency fc . With fc = 5Hz and f = 10Hz and ω = 2π f and s = jω. r 10 5 2 |GHP (10Hz)| = r 2 10 5 + 02 + 12 2 = √ = 0.894 5 (c) Design a first-order low-pass filter that preserves the constant level of the signal. What will the amplification for the middle frequency component become? Approximately what amplitude will the suppressed “middle frequency” sinus have? Sketch the Bode plot of this filter by asymptotic approximation. Solution: With fc = 1Hz (You can choose a different value) and the middle frequency with f = 2Hz 1 1 1 1 |GLP (2Hz)| = s = √ = 0.45 = 2i = √ + 1 1 + 1 5 22 + 1 ωc 1 1 |GLP (0Hz)| = s =0 =1 +1 + 1 ωc 1 With fc = 1Hz the filtered signal will contain the constant level and also contain 45% of the low-frequent sinus amplitude. A ≈ 0.25 · 0.45 ≈ 0.113 (d) Now try to use a second-order low-pass filter with the same corner frequency on the following 6 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 √ form, with the damping factor ζ = 2 2 . 1 s ωc 2 (1) + 2ζ ωsc + 1 Now what will the amplification be for the middle frequency signal component. Is this better then in the first-order filter case? Sketch the Bode plot of this filter by asymptotic approximation. Solution: With fc = 1Hz (You can choose a different value) and the middle frequency with f = 2Hz 1 |GLP 2 (2Hz)| = 2 ≈ 0.243 √ 2i 1 + 2 22 2i + 1 1 The low-frequency sinus will now be more suppressed then in the first-order filter case. A ≈ 0.25 · 0.243 ≈ 0.061 5. (a) Create a simple band-pass filter transfer function by cascading (multiplying) a low-pass and a high-pass filter of the first order. Write your answer on the following form, where ωc , ωcx , and ζ are combinations of ωcl and ωch . GBP (s) = s ωcx s ωc 2 (2) + 2ζ ωsc + 1 Sketch the Bode plot of this filter by asymptotic approximation. Solution: 1 · s ωcl + 1 ωcx = ωch s ωch s ωch +1 ωc = = √ s2 ωcl ωch ωcl ωch + s ωch s s ωcl + ωch ζ= +1 1 ωcl + ωch √ 2 ωcl ωch (b) Choose high and low corner frequencies to isolate the “strongest” signal component in the PSD in Figure 5. What is the approximate amplification (suppression) at the three strongest frequency components with your selection? Sketch the Bode plot of this filter by asymptotic approximation. Solution: The three strongest frequency components are at f ≈ 10Hz, f ≈ 70Hz, and f ≈ 170Hz where the one at f ≈ 70Hz is the strongest and desired signal √ component. ωch = 50 Hz and ωcl = 100 Hz are chosen for no particular reason. But note 50 · 100 ≈ 70. At f ≈ 10 Hz, Amplification ≈ 0.20 At f ≈ 70 Hz, Amplification ≈ 0.67 (This is the desired signal component) At f ≈ 170 Hz, Amplification ≈ 0.49 7 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 Periodogram Using FFT 20 Power/Frequency (dB/Hz) 10 0 −10 −20 −30 −40 −50 −60 0 50 100 150 200 250 Frequency (Hz) 300 350 400 450 500 Figure 5: Frequency spectrum of signal from a sensor affected by vibrations. Luckily the lower frequency span containing the desired signal is relatively clean. Periodogram Using FFT 20 Power/Frequency (dB/Hz) 10 0 −10 −20 −30 −40 −50 1 2 10 10 Frequency (Hz) 6. The A/D-converter in Figure 6 has a resolution of 8 bits. And the analog input port has a voltage range 0-10V. Hint: Do the job graphically with 2 bit before. Analog signal 0 - 10 V US Anti-alias LP-filter Sample and Hold Analog/Digital Converter Digital signal Figure 6: The signal processing chain for reading and converting an analog signal into a measurement system (computer). (a) What is the digital output signal resolution (expressed in Volts)? Solution: 10 10 = = 0.0392V 28 − 1 255 8 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 (b) What is the binary output value from the ADC when the input signal is 7.0V. Solution: The ADC has 2n different levels and 2n−1 intervals. In this case 28 = 256 levels and 255 intervals. 7V round 10V × 255 = 178.5 ⇒ 179 Answer: 10110011 179 = 27 + 0 · 26 + 25 + 24 + 0 · 23 + 0 · 22 + 21 + 20 (c) What is the binary output value from the ADC when the input signal is 9.96V. Solution: 254: 11111110 (d) Determine the required ADC resolution in number of bits if you want to be able to distinguish a difference ∆Us = 0.001V on the analog input signal. Solution: 10 ≤ 0.001 −1 2n n = log2 10 log10 0.001 +1 10 +1 = = 13.3 ⇒ 14 0.001 log10 (2) 7. Usually filtering prior to sampling is used to remove high frequent noise in a signal (Anti-alias filtering). Additional filtering might, however, be required in software for further more advanced signal processing. The faster a computer is, the more processor cycles are available each second for calculations. The amount of cycles is, however, discrete and that is why a software filter in the form of a continuous transfer-function needs to be transformed into a time-discrete version. (a) Use bi-linear transform (Tustin’s method), (4), to transform the first-order low-pass filter (3), into its time-discreet version. 1 GLP (s) = s (3) ωc + 1 s= Solution: With: b1 = 2 z−1 T z+1 (4) 1 ωc HLP (z) = = 1 2b1 (z−1) T (z+1) = +1 T (z + 1) 2b1 (z − 1) + T (z + 1) T z −1 + T Tz + T = (2b1 + T ) z + T − 2b1 (T − 2b1 ) z −1 + (2b1 + T ) (b) Realize this z transfer function in an equation suitable for usual programming languages. The equation shall show how to calculate the current output value based on the current and past input values and past output values. Note! z −1 means one time step delay. 9 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 Solution: b1 z −1 + b0 a1 z −1 + a0 Y (z) H (z) = U (z) H (z) = uk . . . current input, uk−1 . . . last time step input, yk . . . current output, yk−1 . . . last time step output. yk a1 z −1 + a0 = uk b1 z −1 + b0 yk = 1 (b0 uk + b1 uk−1 − a1 yk−1 ) a0 8. Comprehension questions (a) Filters can be implemented in software, so called discrete filters. Is it possible to implement anti-aliasing filter as such discrete filter or is it inevitable to implement them in analog technology, e.g. with operational amplifier, capacitor, and so on? Justify your answer. Solution: Anti-aliasing filter have to be implemented in analog technology, because the aliasing effect can not be reversed after sampling. The information is lost. But: There is a technique called over-sampling where a much higher sampling frequency is used and than the sampled signal is decremented with the help of discrete filters to the desired sampling rate. Also in this case the anti-aliasing filter before the actual sampling has to be implemented in analog technology. Further on in some cases where additional knowledge about the signal is available a anti-aliasing filter may not be necessary at all. (b) Is it possible to prevent aliasing entirely? What are the consequences? Solution: No. Real world filters are not able to suppress any frequency entirely; magnitude = −∞ in the bode plot. Thus aliasing will always add distortion to the sampled signal. Luckily this distortion will not influence our signal as long as this distortion is much smaller as the quantization error. (c) In which trade-off do you run into when designing anti-aliasing filter for feedback control? What is the difference to a pure measurement? Hint: Phase shift of the filter. Solution: Phase shift. Every causal filter adds phase shift to the signal. For measurement the phase shift is no problem as long it is known and linear; linear phase shift: 6 (f ) = k f . In feedback control an additional phase shift may destabilize the system, see phase / gain margin criteria. If the sampling rate is much faster as the system dynamics than this 10 TMMS04 Lesson 2 – Signal Processing 2014 HT-1 problem can be solved by designing a reasonable anti-aliasing filter accepting minimal aliasing. The filter dynamics may has to be considered by the controller design. For fast systems, e.g. electrical motors, other ways has to be found. GLP1 (s) = GHP1 (s) = s ωc 1 +1 first order transfer function with low-pass characteristic s ωc s ωc GLP2 (s) = first order transfer function with high-pass characteristic +1 1 s ωc 2 + 2ζ ωsc +1 second order transfer function with lowpass characteristic Table 1: Cheat Sheet 11
© Copyright 2025 Paperzz