Frequency Response

advertisement
Frequency Response
Hans-Petter Halvorsen, M.Sc.
Reguleringsteknikk
Spesialtilfelle
Tilstandsrommodeller
Differensial
-likninger
Laplace
K = Forsterkning
T=Tidskonstant
1.orden med tidsforsinkelse
Blokkdiagrammer
Tidsplanet
1.orden
Transferfunksjoner
Sprangrespons
S-planet
Serie, Parallel, Feedback
2.orden
Dataverktøy
Analyse/Design
MathScript
LabVIEW
StabilitetsDet komplekse plan
analyse
1. Systemets poler
Realisering/
Implementering
2. Frekvensrespons
Bodediagram
Det komplekse plan
Diskretisering
Reguleringssystem
Asymptotisk stabilt system
Air Heater
Tidsplanet
Ustabilt system
Marginalt stabilt system
Asymptotisk stabilt system
Marginalt stabilt system
Ustabilt system
Table of Contents
1. What is Frequency Response?
2. Bode Diagram
3. Frequency Response in MathScript
1. Using built-in functions
2. Create from “scratch”
Frequency Response
What is Frequency
Response?
Vizualization
Why do we need
Frequency Response?
Analysis and Design of
Control Systems
Bode Diagram
MathScript
Stability Analysis
Check if the system is
stable or not
Introduction
to
Frequency Response
Frequency Response Example
Outside Temperature
frequency 1 (year)
T = 1 year
frequency 2 (24 hours)
-> Only the gain and
phase are different
T = 24 hours
Assume the outdoor temperature is
varying like a sine function during a year
(frequency 1) or during 24 hours
(frequency 2).
Inside Temperature
frequency 1 (year)
frequency 2 (24 hours)
Then the indoor temperature will be a
sine as well, but with different gain. In
addition it will have a phase lag.
Frequency Response Example
Air Heater
Imput Signal
Output Signal
Dynamic
System
Amplitude
Frequency
Gain
(“forsterkning”)
Phase Lag
(“faseforskyvning”)
The frequency response of a system expresses how a sinusoidal signal of a given frequency on
the system input is transferred through the system.
Frequency Response - Definition
and the same for Frequency 3, 4, 5, 6, etc.
• 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) (“forsterkning”) and phase lag (Ο•) (“faseforskyvning”).
Frequency Response from Input-Output Signals
t
The gain is given by:
(“forsterkning”)
The phase lag is given by:
(“faseforskyvning”)
Exercise
t
Students:
Pen and paper: Find the gain (A) and the phase lag (Ο•) for this example
Solutions
From the Plot we get:
t
Cont. next page ->
Solutions
(“forsterkning”)
(“faseforskyvning”)
Bode Diagram
Bode Diagram
You can find the Bode diagram from experiments on the physical prosess or from the
transfer function (the model of the system).
A simple sketch of the Bode diagram for a given system:
πœ”π‘
βˆ†πΎ
πœ‘
πœ”180
πΏπ‘œπ‘” πœ”
ω [rad/s]
πΏπ‘œπ‘” πœ” ω [rad/s]
 The Bode diagram gives a simple Graphical overview of the Frequency Response for a given system.
A Tool for Analyzing the Stability properties of the Control System
Find Data
Bode Diagram
We find A and Ο• for each of the frequencies,
e.g.:
The same for frequency 3, 4, …, n
Based on that we can plot the Frequency Response in a so-called Bode Diagram:
Cont. next page->
Bode Diagram
The x-scale is logarithmic
Gain (“Forsterkningen”)
The y-scale is in [dB]
Phase lag (“Faseforkyvningen”)
The y-scale is in [degrees]
Vanligvis er enheten for frekvens Hertz [Hz], men i
frekvensrespons/Bodediagram brukes radianer ω [rad/s]. Sammenhengen
Using MathScript to calculate and
plot the Frequency Response in a
Bode Diagram
Bode Diagram – MathScript Example
Given the following transfer function:
We will use MathScript to find the
Frequency Response/Bode Diagram:
% 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
Students: Implement this example in MathScript
Cont. on bext page->
Bode Diagram – MathScript Example cont.
Given the following transfer function:
Instead of Plotting the Bode Diagram we can also use the bode function for
calculation and showing the data as well:
...
wlist = [0.01, 0.1, 1,
100];[mag, phase, w] =
magdB = 20*log10(mag);
freq_data = [w, magdB,
2 ,3 ,5 ,10,
bode(H, wlist);
% Convert to dB
phase]
MathScript gives the following results:
Students: Try this code also
Bode Diagram – MathScript Example cont.
w
We see that the Calculated Data and the
Bode Diagram gives the same values
A(w) [dB]
Ο•(w) [deg.]
Bode Diagram – MathScript Example
Given the following transfer function:
Students: Plot the Bode Diagram for the given transfer function using MathScript
Bode Diagram – MathScript Example - Solutions
or:
clear, clc
% Transfer function
num=[1];
den1=[1,0];
den2=[1,1]
den3=[1,1]
den = conv(den1,conv(den2,den3));
H = tf(num, den)
% Bode Diagram
bode(H)
subplot(2,1,1)
grid on
subplot(2,1,2)
grid on
or:
clear, clc
% Transfer function
num=[1];
den=[1,2,1,0];
H = tf(num, den)
% Bode Diagram
bode(H)
subplot(2,1,1)
grid on
subplot(2,1,2)
grid on
How-To Manually find the
Frequency Response from the
Transfer Function
Frequency Response from the Transfer function
A and Ο• is a function of the frequency ω so we may write A = A(ω), Ο• = Ο•(ω)
We want to manually find mathematical expressions for A(ω) and Ο•(ω) (assuming the
bode function does not exist, actually, this is how the bode function does it.)
s=jω
Where H(jω) is the frequency response of the system, i.e., we may find the frequency
response by setting s=jω in the transfer function. This mean we have to deal with complex
numbers!
The Gain function is defined as:
Length (“Gain”)
Length
Angle
The Phase function is defined as:
Angle (“Phase”)
Complex Numbers
Rectangular form of a complex number
Length (“Gain”):
Angle (“Phase”):
Exponential/polar form of a complex number
Mathematical expressions
for A(ω) and Ο•(ω)
We find the Mathematical expressions for A(ω) and Ο•(ω) by setting s=jω in the transfer function
cont. next page ->
<- cont. from previous page
 Disse funksjonene kan vi enkelt implementere i MathScript eller andre programmeringsspråk
Mathematical expressions
for A(ω) and Ο•(ω) - Example
Given the following transfer function:
Students: Find the Mathematical expressions for A(ω) and Ο•(ω) (Pen & Paper)
Mathematical expressions
for A(ω) and Ο•(ω) - Solutions
We find the Mathematical expressions for A(ω) and Ο•(ω) by setting s=jω in the transfer function
[dB]
Gain:
Phase:
[rad]
Students: Implement these equations in MathScript and find
the Frequency Response for different frequencies, i.e find
values for A(ω) and Ο•(ω) for different frequencies (e.g,
w=0.01, 0.1, 1, 2, 5 ,10, 100). Plot the Frequency Response as
well based on the calculated values for A(ω) and Ο•(ω).
MathScript functions needed:
• atan
• log10
• sqrt
• pi
• subplot
• semilogx
MathScript Solutions
Method 1:
We find A(ω) and Ο•(ω) for w=0.01, 0.1, 1, 2, 5 ,10, 100, etc.
w=1;
gain = 20*log10(1) - 20*log10(sqrt(w^2+1))
phase = -atan(w) * 180/pi
Method 2 (recommended):
We find A(ω) and Ο•(ω) for w=0.01, 0.1, 1, 2, 5 ,10, 100, etc.
using a For Loop
We find the values for A and Ο• for different
frequencies and write them manually into a
table
w = [0.01, 0.1, 1, 10, 100];
N = length(w);
for i=1:N
gain(i) = 20*log10(1) - 20*log10(sqrt(w(i)^2+1));
phase(i) = -atan(w(i)) * 180/pi;
%Gain Plot
end
subplot(2,1,1)
semilogx(w, gain), grid
%Phase Plot
Plotting: subplot(2,1,2)
semilogx(w, phasedeg), grid
MathScript Solutions
The bode function is used
directly on the transfer function
H(s)
The mathematical expressions for
A(ω) and Ο•(ω) are used together
with the subplot and semilogx
functions
Conclusion: We get the same results (of
course).
If we had plotted more frequencies, the
results would be even closer.
More Examples…
Mathematical expressions
for A(ω) and Ο•(ω)
We find the Mathematical expressions for A(ω) and Ο•(ω) by setting s=jω in the transfer function
cont. next page ->
Complex Numbers
Given 2 Complex Numbers:
and
Multiplikasjon:
Divisjon:
<- cont. from previous page
Mathematical expressions for A(ω) and Ο•(ω) - Example
Students: Find the Mathematical expressions for A(ω) and Ο•(ω) for the different
transfer functions below using pen and paper
Mathematical expressions for A(ω) and Ο•(ω) - Examples
Solutions:
Students: Implment them in MathScript and plot the Bode
diagram. Compare with the built-in bode function.
Hans-Petter Halvorsen, M.Sc.
Telemark University College
Faculty of Technology
Department of Electrical Engineering, Information Technology and Cybernetics
E-mail: hans.p.halvorsen@hit.no
Blog: http://home.hit.no/~hansha/
38
Download