EE4107 -­β Cybernetics Advanced Exercise 8: Frequency Response Introduction We can find the frequency response of a system by exciting the system with a sinusoidal signal of amplitude A and frequency ω [rad/s] (Note: π = 2ππ) and observing the response in the output variable of the system. The frequency response of a system is defined as the steady-­βstate response of the system to a sinusoidal input signal. When the system is in steady-­βstate it differs from the input signal only in amplitude/gain (A) and phase lag (π) (faseforskyvning). If we have the input signal: π’ π‘ = π π ππππ‘ The steady-­βstate output signal will be: π¦ π‘ = ππ΄ sin (ππ‘ + π) ! Where π΄ = ! ! is the ratio between the amplitudes of the output signal and the input signal (in steady-­βstate). This can be illustrated like this: Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01 2 The gain is given by: π΄= π π The phase lag is given by: π = −πΔπ‘ [πππ] Find the Frequency Response from the Transfer function A and π is a function of the frequency π so we may write π΄ = π΄ π , π = π(π) For a transfer function: π» π = π¦(π ) π’(π ) We have that: π» ππ = π»(ππ) π !∠!(!") Where π» (ππ) is the frequency response of the system, i.e., we may find the frequency response by setting π = ππ in the transfer function. Bode diagrams are useful in frequency response analysis. The Gain function is defined as: π΄ π = π»(ππ) EE4107 -­β Cybernetics Advanced 3 The Phase function is defined as: π π = ∠π»(ππ) This can be illustrated in the complex plane like this: Bode Diagram We normally use a Bode diagram to draw the frequency response for a given system. The Bode diagram consists of 2 diagrams, the Bode magnitude diagram, π΄(π) and the Bode phase diagram, π(π). Below we see an example of a Bode diagram: The π΄(π)-­βaxis is in decibel (dB), where the decibel value of x is calculated as: π₯ ππ΅ = 20πππ!" π₯ The π (π)-­βaxis is in degrees (not radians!). We use logarithmic scale on the π₯ -­βaxes. Complex Numbers A complex number is defined like this: π§ = π + ππ EE4107 -­β Cybernetics Advanced 4 The imaginary unit π is defined as: π = −1 Where π is called the real part of π§ and π is called the imaginary part of π§ π π(π§) = π, πΌπ(π§) = π You may also imaginary numbers on exponential/polar form: π§ = ππ !" Where: π= π§ = π ! + π ! π π = ππ‘ππ π Note that π = π cos π and π = π sin π Rectangular form of a complex number Exponential/polar form of a complex number MathScript MathScript has several built-­βin functions for Frequency response, e.g.: Function tf bode bodemag semilogx log10 atan Description Creates system model in transfer function form. You also can use this function to state-­βspace models to transfer function form. Creates the Bode magnitude and Bode phase plots of a system model. You also can use this function to return the magnitude and phase values of a model at frequencies you specify. If you do not specify an output, this function creates a plot. Creates the Bode magnitude plot of a system model. If you do not specify an output, this function creates a plot. Generates a plot with a logarithmic x-­βscale. Computes the base 10 logarithm of the input elements. The base 10 logarithm of zero is -­βinf. Computes the arctangent of x EE4107 -­β Cybernetics Advanced Example >num=[1]; >den=[1, 1, 1]; >H = tf(num, den) >num=[4]; >den=[2, 1]; >H = tf(num, den) >bode(H) >[mag, wout] >[mag, wout] [wmin wmax]) >[mag, wout] wlist) >semilogx(w, >log(x) >atan(x) = bodemag(SysIn) = bodemag(SysIn, = bodemag(SysIn, gain) 5 Example: We have the following transfer function: π» π = π¦(π ) 1 = π’(π ) π + 1 Below we see the script for creating the frequency response of the system in a Bode plot using the bode function in MathScript. Use the grid function to apply a grid to the plot. % We define the transfer function: K = 1; T = 1; num = [K]; den = [T, 1]; H = tf(num, den) % We plot the Bode diagram: bode(H); % We add grid to the plot: subplot(2,1,1) grid on subplot(2,1,2) grid on This gives the following Bode plot: EE4107 -­β Cybernetics Advanced 6 Task 1: Frequency Response Given the following system: π» π = 1. 2. 3. 4. 5. 4 2π + 1 Find the mathematical expressions for π΄ π [ππ΅] and π (π) using “pen & paper”. Find the break frequencies (Norwegian: “knekkfrekvenser”) using “pen & paper” Find poles and zeroes for the system (check your answer using MathScript) Plot the Bode plot using MathScript Find π΄ π [ππ΅] and π (π) for the following frequencies (both manually using your calculator (or use MathScript as calculator) and compare using e.g. the bode function in MathScript): π΄ π [ππ΅] π 0.1 0.16 0.25 0.4 0.625 2.5 π π (πππππππ ) Compare the calculated values with the plot – are they the same? Task 2: Bode Diagrams Do the following for the systems given below. 1. 2. 3. 4. Find the mathematical expressions for π΄ π [ππ΅] and π (π) using “pen & paper”. Find the break frequencies (Norwegian: “knekkfrekvenser”) using “pen & paper” Plot the Bode plot using MathScript (Use the bode() function) Find poles and zeroes for the system (check your answer using MathScript) Task 2.1 Given the following transfer function: π» π = 5 π + 1 (10π + 1) Task 2.2 Given the following transfer function: π» π = 1 π π +1 ! EE4107 -­β Cybernetics Advanced 7 Task 2.3 Given the following transfer function: π» π = 3.2π !!! 3π + 1 Task 2.4 Given the following transfer function: π» π = (5π + 1) 2π + 1 (10π + 1) Task 3: Steady-­βstate Response Given the following system: π» π = π¦(π ) 1 = π’(π ) π + 1 The frequency response for the system is then: (You may use MathScript to see if you get the same frequency response) For a given input signal: π’ π‘ = π π ππππ‘ EE4107 -­β Cybernetics Advanced 8 The steady-­βstate output signal will be: π¦ π‘ = ππ΄ π ππ (ππ‘ + π) Task 3.1 Assume the input signal π’ to the system is a sinusoidal with amplitude π = 0.8 and frequency π = 1.0 πππ/π . Find the steady-­βstate output signal. Task 4: Given the following transfer function: π» π = π¦(π ) πΎ = π’(π ) (π! π + 1)(π! π + 1) Task 4.1 Find the mathematical expressions for π΄(π) and π (π) Task 5: Sinusoidal input and output signals Given the following plot of the sinusoidal input and output signal for a given system: The input signal is given by: EE4107 -­β Cybernetics Advanced 9 π’ π‘ = π π ππππ‘ The steady-­βstate output signal will then be: π¦ π‘ = ππ΄ π ππ (ππ‘ + π) ! The gain is given by: π΄= π π The phase lag is given by: π = −πΔπ‘ [πππ] Task 5.1 What is the frequency of the signal in π»π§ and in πππ/π ? Task 5.2 Calculate the amplitude gain (π΄) and the phase lag (π) at the frequency found in Task 5.1. What is the amplitude gain in dB? What is the phase lag in degrees? Task 5.3 What is the steady-­βstate output response? Task 5.4 The transfer function for the system is actually: π»= 1 π +1 Use MathScript to plot the Bode diagram. From the plot, find the amplitude gain (π΄) and the phase lag (π) at the frequency found in Task 5.1. Do you get the same results? Additional Resources • http://home.hit.no/~hansha/?lab=mathscript Here you will find tutorials, additional exercises, etc. EE4107 -­β Cybernetics Advanced