Transcription
https://www.halvorsen.blogFrequency Responsewith MATLAB ExamplesControl Design and AnalysisHans-Petter Halvorsen
Contents Introduction to PID ControlIntroduction to Frequency ResponseFrequency Response using Bode DiagramIntroduction to Complex Numbers (which Frequency Response Theory isbased on)Frequency Response from Transfer FunctionsFrequency Response from Input/output SignalsPID Controller Design and Tuning (Theory)PID Controller Design and Tuning using MATLABStability Analysis using MATLABStability Analysis of Feedback SystemsStability Analysis of Feedback Systems β a Practical ExampleThe Bandwidth of the Control SystemPractical PI Controller Example
https://www.halvorsen.blogPID ControlHans-Petter Halvorsen
Control Systemππ ControllerFilteringπ’ActuatorsSensorsπ β Reference Value, SP (Set-point), SV (Set Value)π¦ β Measurement Value (MV), Process Value (PV)π β Error between the reference value and the measurement value (π π β π¦)π£ β Disturbance, makes it more complicated to control the processπ’ - Control Signal from the Controllerπ£Processπ¦
The PID Algorithmπ‘πΎπΰΆ± πππ πΎπ ππ παΆπ’ π‘ πΎπ π ππ 0Where π’ is the controller output and π is thecontrol error:π π‘ π π‘ π¦(π‘)π is the Reference Signal or Set-pointπ¦ is the Process value, i.e., the Measured valueTuning Parameters:πΎπππππProportional GainIntegral Time [sec. ]Derivative Time [sec. ]
The PI Algorithmπ‘πΎπΰΆ± ππππ’ π‘ πΎπ π ππ 0Where π’ is the controller output and π is thecontrol error:π π‘ π π‘ π¦(π‘)π is the Reference Signal or Set-pointπ¦ is the Process value, i.e., the Measured valueTuning Parameters:πΎπππProportional GainIntegral Time [sec. ]
PI(D) Algorithm in MATLAB We can use the pid() function in MATLAB We can define the PI(D) transfer functionusing the tf() function in MATLAB We can also define and implement a discretePI(D) algorithm
Discrete PI Controller AlgorithmWe start with:πΎπ π‘ΰΆ± πππππ 0In order to make a discrete version using, e.g., Euler, we can derive both sides of the equation:πΎππ’αΆ π’αΆ 0 πΎπ παΆ πππIf we use Euler Forward we get:π’π π’π 1 π’0,π π’0,π 1ππ ππ 1 πΎπ πΎπ πππ ππ ππ ππ πThen we get:πΎππ’π π’π 1 π’0,π π’0,π 1 πΎπ ππ ππ 1 ππππ π ππ’ π‘ π’0 πΎπ π π‘ Whereππ ππ π¦πWe can also split the equation above in 2 different parts by setting: π’π π’π π’π 1This gives the following PI control algorithm:ππ ππ π¦π π’π π’0,π π’0,π 1 πΎπ ππ ππ 1 π’π π’π 1 π’πThis algorithm can easily be implemented in MATLABπΎπππππ π π
Discrete PI Controller AlgorithmDiscrete PI control algorithm:ππ ππ π¦π π’π π’0,π π’0,π 1 πΎπ ππ ππ 1π’π π’π 1 π’ππΎπ ππ ππππ
PID Controller βTransfer FunctionWe have:πΎπ π‘π’ π‘ πΎπ π ΰΆ± πππ πΎπ ππ παΆππ 0Laplace gives:π»ππΌπ·πΎππ’(π )π πΎπ πΎπ ππ π π(π )ππ π π»ππΌπ·π’(π ) πΎπ (ππ ππ π 2 ππ π 1)π π(π )ππ π or:
PI Controller βTransfer FunctionWe have:πΎπ π‘π’ π‘ πΎπ π ΰΆ± πππππ 0Laplace gives:π»ππΌπΎπ πΎπ ππ π πΎπ πΎπ (ππ π 1)π’(π )π πΎπ π(π )ππ π ππ π ππ π Finally:π»ππΌπ’(π ) πΎπ (ππ π 1)π π(π )ππ π
Define PI Transfer function in MATLABclear, clcπ»ππΌπ’(π ) πΎπ (ππ π 1)π π(π )ππ π % PI Controller Transfer functionKp 0.52;Ti 18;num Kp*[Ti, 1];den [Ti, 0];Hpi tf(num,den).
PI Controller β State space modelGiven:πΎππ’ π πΎπ π π π π ππ π 1We set π§ π π π§ π π§αΆ ππ This gives:π§αΆ ππΎππ’ πΎπ π π§ππWhereπ π π¦
PI Controller β Discrete State space modelUsing Euler:π§αΆ Where ππ is the Sampling Time.This gives:π§π 1 π§πππ π§π 1 π§π ππππ πΎππ’π πΎπ ππ π§ππ πFinally:ππ ππ π¦ππΎππ’π πΎπ ππ π§ππ ππ§π 1 π§π ππ ππ
PI Controller β Discrete State space modelimplemented in MATLABclear, clc.for i 1:N.e r - y;u Kp*e z;z z dt*Kp*e/Ti;.endplot(.)
https://www.halvorsen.blogFrequency ResponseHans-Petter Halvorsen
Frequency ResponseTheory The frequency response of a system is a frequency dependentfunction which expresses how a sinusoidal signal of a given frequencyon the system input is transferred through the system. Eachfrequency component is a sinusoidal signal having certain amplitudeand a certain frequency. The frequency response is an important tool for analysis and designof signal filters and for analysis and design of control systems. The frequency response can be found experimentally or from atransfer function model. The frequency response of a system is defined as the steady-stateresponse of the system to a sinusoidal input signal. When the systemis in steady-state, it differs from the input signal only inamplitude/gain (A) and phase lag (π).
TheoryFrequencyResponseInput Signalπ’ π‘ π π ππππ‘AmplitudeInput SignalDynamicSystemOutput SignalOutput Signalπ¦ π‘ ππ΄ΰΈ π ππ(ππ‘ π)πFrequencyGainPhase LagThe frequency response of a system expresses how a sinusoidal signal of a given frequency on the systeminput is transferred through the system. The only difference is the gain and the phase lag.
Frequency Response - DefinitionTheoryπ¦ π‘ ππ΄ΰΈ π ππ(ππ‘ π)π’ π‘ π οΏ½οΏ½ 1 πππ/π and the same for Frequency 2, 3, 4, 5, 6, etc. π 1 πππ/π The frequency response of a system is defined as the steady-state response of the system to a sinusoidalinput signal.When the system is in steady-state, it differs from the input signal only in amplitude/gain (A) (Norwegian:βforsterkningβ) and phase lag (Ο) (Norwegian: βfaseforskyvningβ).
Frequency Response - Simple ExampleTheoryOutside TemperatureT 1 yearfrequency 1 (year)Dynamic Systemfrequency 1 (year)Inside TemperatureNote! Only thegain and phaseare differentAssume the outdoor temperature is varying like a sine function during a year (frequency 1) or during 24 hours (frequency 2).Then the indoor temperature will be a sine as well, but with different gain. In addition it will have a phase lag.
Frequency Response - Simple ExampleTheoryOutside TemperatureT 24 hoursfrequency 2 (24 hours)Dynamic SystemInside Temperaturefrequency 2 (24 hours)Note! Only the gain and phase are differentAssume the outdoor temperature is varying like a sine function during a year (frequency 1) or during 24 hours (frequency 2).Then the indoor temperature will be a sine as well, but with different gain. In addition it will have a phase lag.
https://www.halvorsen.blogFrequency Response usingBode DiagramHans-Petter Halvorsen
Bode DiagramYou can find the Bode diagram from experiments on the physical process or from the transfer function (the model of thesystem). A simple sketch of the Bode diagram for a given system:ππ0ππ΅ πΎπΏππ πΟ [rad/s]The Bode diagram gives a simple Graphicaloverview of the Frequency Response for agiven system. A Tool for Analyzing theStability properties of the Control System.With MATLAB you can easily create Bodediagram from the Transfer function modelusing the bode() functionππ180πΏππ πΟ [rad/s]
Bode Diagram from experimentsFind Data for different frequencies.Based on that we can plot theFrequency Response in a so-called BodeDiagram:We find π΄ and π for each of the frequencies,e.g.:
Bode DiagramThe x-scale is logarithmicGain (βForsterkningenβ)Note! The y-scale is in [ππ΅]π₯ ππ΅ 20πππ10 π₯Phase lag (βFaseforkyvningenβ)The y-scale is in [πππππππ ]2π πππ 360 Normally, the unit for frequency is Hertz [Hz], but in frequency response and Bodediagrams we use radians Ο [rad/s]. The relationship between these are as follows:π 2ππ
Frequency Response β MATLABTransfer Function:MATLAB Code:clearclcclose all% Define Transfer functionnum [1];den [1, 1];H tf(num, den)% Frequency Responsebode(H);grid onThe frequency response is an important tool for analysis and designof signal filters and for analysis and design of control systems.
Frequency Response β MATLABTransfer Function:clearclcclose allInstead of Plotting the Bode Diagram wecan also use the bode function forcalculation and showing the data as well:freq data 78.6901-84.2894-89.4271% Define Transfer functionnum [1];den [1, 1];H tf(num, den)% Frequency Responsebode(H);grid on% Get Freqquency Response Datawlist [0.01, 0.1, 1, 2 ,3 ,5 ,10, 100];[mag, phase, w] bode(H, wlist);for i 1:length(w)magw(i) mag(1,1,i);phasew(i) phase(1,1,i);endmagdB 20*log10(magw); % Convert to dBfreq data [wlist; magdB; phasew]'
Bode Diagram β MATLAB ExampleMATLAB Code:clear, clc% Transfer functionnum [1];den1 [1,0];den2 [1,1]den3 [1,1]den conv(den1,conv(den2,den3));H tf(num, den)clear, clc% Bode Diagrambode(H)subplot(2,1,1)grid onsubplot(2,1,2)grid on% Transfer functionnum [1];den [1,2,1,0];H tf(num, den)or:% Bode Diagrambode(H)subplot(2,1,1)grid onsubplot(2,1,2)grid on
ExampleWe will use the following system as an example:1π»π π (π 1)π»π πΎπππ Controllerπ’Sensors1π»π 3π 1Processπ¦
Bode Diagram β MATLAB ExampleMATLAB Code:clearclcnum 1;den [1,1,0];Hp tf(num,den)bode(Hp)grid on1π»π π (π 1)
https://www.halvorsen.blogComplex NumbersBackground Theory for Frequency ResponseHans-Petter Halvorsen
Complex NumbersA Complex Number is given by:π§ π ππWhereπ οΏ½οΏ½οΏ½ (πΌπ)We have that:π π π π§π§ π ππππ οΏ½(π π)
Complex Numbersπ 1Polar form:π§ ππ ππWhere:π2 π2ππ ππ‘ππππ π§ Note!π π cos οΏ½οΏ½π (πΌπ)π§ ππ πππππ π sin π)
Complex Numbers1Rectangular form of a complex ππ (πΌπ)2Exponential/polar form of a complex ππ (πΌπ)π§ π ππππ§ ππ οΏ½οΏ½οΏ½(π π)Length (βGainβ):π π§ π 1π0Angle (βPhaseβ):π2 π οΏ½π ππ‘πππ
https://www.halvorsen.blogFrequency response fromTransfer functionHans-Petter Halvorsen
Manually find the Frequency Responsefrom the Transfer FunctionTheoryFor 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 Bode diagram consists of 2 diagrams, the Bode magnitude diagram, π΄(π) and the Bode phase diagram,π(π).The Gain function:π΄ π π»(ππ)The Phase function:π π π»(ππ)The π΄(π)-axis is in decibel (dB), where the decibel value of x is calculated as: π₯ ππ΅ 20πππ10 π₯The π(π)-axis is in degrees (not radians!)
Mathematical expressions for π΄(π) and π(π)We find the Mathematical expressions for π΄(π) and π(π) by setting π ππ in the transfer functiongiven by:π¦(π )πΎπ» π π’(π ) ππ 1The Frequency Response (we replace π with ππ) then becomes:πΎπΎπ» ππ πππ 1 ΰΈ1 π ππΰΈπ ππΌπPolar form:πΎπ» ππ 12 πππΎ1 ππ2ππ2 π π ππππ‘ππ 1π π ππππ‘ππ(ππ)Finally:π» ππ πΎ1 ππ2π π ππππ‘ππ(ππ)cont. next page
cont. from previous pageThe Gain function becomes:π΄ π π»(ππ) πΎ1 ππ2Or in ππ΅ (used in the Bode Plot):π΄ π ππ΅ π»(ππ) ππ΅ 20ππππΎ 20πππ 1 ππ2The Phase function becomes ( πππ ):π π π» ππ πππ π» ππ ππππ‘ππ(ππ)Or in degrees (used in the Bode plot):π π π» ππ ππππ‘ππ(ππ) 180πNote: 2π πππ 360
π¨(π) og π(π):Transfer function:1π» π π 14π» π 2π 11π» π π π 1ππ΅ 20πππ1 20πππ (π)2 1 π»(ππ) arctan(π)π»(ππ)ππ΅ 20πππ4 20πππ (2π)2 1 π»(ππ) arctan(2π)π»(ππ)ππ΅ 20πππ5 20πππ (π)2 1 20πππ (10π)2 1 π»(ππ) arctan(π) arctan(10π)π»(ππ)ππ΅ 20πππ (π)2 2π₯20πππ (π)2 1 20ππππ 40πππ (π)2 12 π»(ππ) 90 2 arctan(π)3.2π 2π π» π 3π 15π 1π» π 2π 1 (10π 1)π»(ππ)ππ΅ 20πππ3.2 20πππ (3π)2 1 π»(ππ) 2π arctan(3π)π»(ππ)ππ΅ 20πππ (5π)2 1 20πππ (2π)2 1 20πππ (10π)2 1 π»(ππ) arctan(5π) arctan(2π) arctan(10π)Note! In order to find the phase in180degrees, we have to multiply with: π5π» π π 1 (10π 1)π»(ππ)
Manually find the Frequency Responsefrom the Transfer FunctionGiven the following transfer function:4π» π 2π 1Bode Plot:The mathematical expressions for π΄(π) andπ(π) become:π»(ππ)ππ΅ 20πππ4 20πππ (2π)2 1 π»(ππ) arctan(2π)These equations can easily be implemented in MATLAB (See next slide)
clearclc% Transfer functionnum [4];den [2, 1];H tf(num, den)% Bode Plotfigure(1)bode(H)grid on% Margins and Phases for given Frequencies% Alt 1: Use bode function directlydisp('----- Alternative 1 -----')w [0.1, 0.16, 0.25, 0.4, 0.625, 2.5, 10];[magw, phasew] bode(H, w);for i 1:length(w)mag(i) magw(1,1,i);phase(i) phasew(1,1,i);endmagdB 20*log10(mag); %convert to dBmag data [w; magdB]phase data [w; phase]MATLAB Codeclearclcw [0.1, 0.16, 0.25, 0.4, 0.625, 2.5, 10];% Alt 2: Use Mathematical expressions for H and Hdisp('----- Alternative 2 -----')gain 20*log10(4) - 20*log10(sqrt((2*w). 2 1));phase -atan(2*w);phasedeg phase * 180/pi; %convert to degreesmag data2 [w; gain]phase data2 [w; id onsubplot(2,1,2)semilogx(w,phasedeg)grid on
Transfer functionswith Time delay
Transfer functions with Time delayA general transfer function for a 1.order system with time delay is:π» π πΎπ ππ ππ 1Frequency Response functions for gain and phase margin becomes:π΄ π ππ΅ 20πππ(πΎ) 20πππ (ππ)2 1π π ππππ‘ππ ππ π πOr π π in degrees:180π π [πππππππ ] arctan ππ π ππ
Transfer functions with Time delay in MATLABDifferent ways to implement a time delay in MATLAB:Alt 1K 3.5;T 22;Tau 2;num [K];den [T, 1];H1 tf(num, den);s tf('s')H2 exp(-Tau*s);H H1 * H2bode(H)Alt 2K 3.5;T 22;Tau 2;num [K];den [T, 1];H1 tf(num, den);H set(H1,'inputdelay',Tau)bode(H);Alt 3K 3.5;T 22;Tau 2;s tf('s');H K*exp(-Tau*s)/(T*s 1)bode(H);Alt 4: Use Pade approximationK 3.5;T 22;Tau 2;num [K];den [T, 1];H1 tf(num, den);N 5;H2 pade(Tau, N)[num pade,den pade] pade(T,N)Hpade tf(num pade,den pade);H series(H1, Hpade);bode(H);
1. order system with Time delayGiven the following transfer function: 2π π» π 3.2π3π 1Poles:1π1 0.333Zeros:NoneThe mathematical expressions for π΄(π) and π(π):π»(ππ)ππ΅ 20πππ3.2 20πππ (3π)2 1 π»(ππ) 2π arctan(3π)Or in degrees: π» ππ 2π arctan(3π) Break frequency:π 1 1 0.33 πππ/π π 3180π
clear, clcor:clear, clcs tf('s');K 3.2;T 3;H1 tf(K/(T*s 1));delay 2;H set(H1,'inputdelay',delay)bode(H);p pole(H)z zero (H)H 3.2exp(-2*s) * ------3 s 1Continuous-time transfer function.p -0.3333z Empty matrix: 0-by-1s tf('s');K 3.2;T 3;Tau 2;num K;den [T, 1];H1 tf(num, den);s tf('s')H2 exp(-Tau*s);H H1 * H2bode(H);p pole(H)z zero (H)
https://www.halvorsen.blogFrequency response fromInput/Output SignalsHans-Petter Halvorsen
Frequency Response from sinusoidalinput and output signalsTheoryWe can find the frequency response of a systemby exciting the system (either the real system or amodel of the system) with a sinusoidal signal ofamplitude π΄ and frequency π [πππ/π ] (Note:π 2ππ) and observing the response in theoutput variable of the system.
Frequency Response - DefinitionTheoryπ¦ π‘ ππ΄ΰΈ π ππ(ππ‘ π)π’ π‘ π οΏ½οΏ½ 1 πππ/π π 1 πππ/π and the same for Frequency 2, 3, 4, 5, 6, etc. The frequency response of a system is defined as the steady-state response of the system to a sinusoidalinput signal.When the system is in steady-state, it differs from the input signal only in amplitude/gain (A) (Norwegian:βforsterkningβ) and phase lag (Ο) (Norwegian: βfaseforskyvningβ).
Frequency Response from sinusoidalinput and output signalsThe input signal is given by:π’ π‘ π π ππππ‘The steady-state output signal will then be:π¦ π‘ ππ΄ΰΈ π ππ(ππ‘ π)The gain is given by:ππ΄ ππThe phase lag is given by:π πΞπ‘ [πππ]Theory
Frequency Response from sinusoidalinput and output signalsTheoryYou will get plots like this for each frequency:The gain is given by:ππ΄ πThe phase lag is given by:π πΞπ‘ [πππ]t
Find the gain (π΄) and the phase (π) for the given frequency from the plotπ 1 rad/s
SolutionsFrom the Plot we get:tCont. next page -
Solutions
Conversion to dBπ΄ ππ΅ 20πππ(π΄)or the other way:Example:π΄ 0.68π΄ ππ΅ 20πππ(π΄) 20πππ(0.68) 3.35ππ΅Or the other way:π΄ ππ΅ 3.35ππ΅π΄ ππ΅ 3.3510 20 0.68π΄ π΄ ππ΅10 20
From the Bode diagram we can verify that our calculations are correct:π΄ 3.35 ππ΅π 45.9 π 1 rad/s
The following MATLAB Code is used to create the Plot:clear, clcK T numdenH 1;1; [K]; [T, 1];tf(num, den);figure(1)bode(H), grid on% Define input signalt [1: 0.1 : 12];w 1;U 1;u U*sin(w*t);figure(2)plot(t, u)% Output signalhold onlsim(H, ':r', u, t)grid onhold offlegend('input signal', 'output signal')We use the following transfer function:π» π 1π 1The Frequency used:π 1 rad/s
https://www.halvorsen.blogPID ControllerDesign/TuningHans-Petter Halvorsen
PID Controller DesignA lot of PID Tuning methods exist, e.g., Skogestad's method Ziegler-Nicholsβ methods Trial and Error Methods PID Tuning functionality built into MATLAB Auto-tuning built into commercial PID controllers .
Skogestadβs method The Skogestadβs method assumes you apply a step on the input (π’)and then observe the response and the output (π¦), as shown below. If we have a model of the system (which we have in our case), we canuse the following Skogestadβs formulas for finding the PI(D)parameters directly.ππ is the time-constant of the control system whichthe user must specifyFigure: F. Haugen, Advanced Dynamics and Control: TechTeach, 2010.Originally, Skogestad defined the factor π 4. This givesgood set-point tracking. But the disturbancecompensation may become quite sluggish. To obtainfaster disturbance compensation, you can use π 1.5
ZieglerβNichols Frequency Response methodTheoryAssume you use a P controller only ππ , ππ 0. Then you need to find forwhich πΎπ the closed loop system is a marginally stable system (ππ π180 ). This πΎπis called πΎπ (critical gain). The ππ (critical period) can be found from the dampedoscillations of the closed loop system. Then calculate the PI(D) parameters usingthe formulas below.Marginally stable system:ControllerπππππΎπππ π180P0.5πΎπ οΏ½οΏ½π PID0.6πΎππ180ππ82πΎπ - Critical Gainππ - Critical ols method
https://www.halvorsen.blogController Design/Tuningusing MATLABHans-Petter Halvorsen
Controller Design/Tuning using MATLAB Frequency Design and Analysispidtune() MATLAB functionPID Tuner (Interactive Tools).Validate with simulations!
pidtune() MATLAB functionclear, clc%Define Processnum 1;den [1,1,0];Hp tf(num,den)% Find PI Controller[Hpi,info] pidtune(Hp,'PI')%Bode Plotsfigure(1)bode(Hp)grid onfigure(2)bode(Hpi)grid on% Feedback SystemT feedback(Hpi*Hp, 1);figure(3)step(T)πΎπ 0.3311ππ 43.5π πΎπ 0.023
pidtune() MATLAB functionTo improve the response time, you can set a highertarget crossover frequency than the result that pidtune()automatically selects, 0.32. Increase the crossoverfrequency to 1.0.[Hpi,info] pidtune(Hp,'PI', 1.0)The new controller achieves the highercrossover frequency, but at the cost of areduced phase margin.
MATLAB PID TunerDefine Controller TypeTuningDefine yourProcessAdd AdditionalPlotsStep Response and otherPlots can be shownPID Parameters
https://www.halvorsen.blogStability Analysisusing MATLABHans-Petter Halvorsen
Stability AnalysisHow do we figure out that the Feedback Systemis stable before we test it on the real System?1. Poles2. Frequency Response/Bode3. Simulations (Step Response)We will do all these things using MATLAB
3 Time domainStability Analysis2 Frequency domainAsymptotically stable systemlim π¦ π‘ ππ‘ ally stable systemUnstable system1 The Complex domainPolesTrackingtransferfunctionFigure: F. Haugen, Advanced Dynamics and Control: TechTeach, 2010.Asymptotically stable system: ππ π180Marginally stable system: ππ π180Unstable system: ππ π180
1 Asymptotically stable system:PolesEach of the poles of the transfer function lies strictly in theleft half plane (has strictly negative real part).3 Unstable system:2 Marginally stable system:One or more poles lies on the imaginary axis(have real part equal to zero), and all thesepoles are distinct. Besides, no poles lie in theright half plane.At least one pole lies in the right halfplane (has real part greater than zero).Or: There are multiple and coincidentpoles on the imaginary axis.1Example: double integrator π»(π ) π 2
TheoryStability AnalysisAsymptotically stable system:Marginally stable system:Unstable system:lim π¦ π‘ lim π¦ π‘ ππ‘ π‘ Figures: F. Haugen, Advanced Dynamics and Control: TechTeach, 2010.0 lim π¦ π‘ π‘ At least one pole lies in the right half plane (hasreal part greater than zero).Each of the poles of the transfer function liesstrictly in the left half plane (has strictly negativereal part).One or more poles lies on the imaginary axis (havereal part equal to zero), and all these poles aredistinct. Besides, no poles lie in the right half plane.Or: There are multiple and coincident poleson the imaginary axis. Example: double1integrator π»(π ) 2π
https://www.halvorsen.blogStability Analysis ofFeedback SystemsHans-Petter Halvorsen
Stability Analysis ofFeedback Systems1Loop Transfer Function(βSlΓΈyfetransferfunksjonenβ):Hr .Hp .Hm .L series(series(Hr, Hp), Hm)2The Tracking Function (βFΓΈlgeforholdetβ):L .T feedback(L, 1)3The Sensitivity Function (βSensitivitetsfunksjonenβ):T .S 1-TTheory
Frequency Response and Stability AnalysisBode DiagramTheoryππ and π180 are called the crossover-frequencies(βkryssfrekvensβ)ΞπΎ is the gain margin (GM) of the system (βForsterkningsmarginβ).How much the loop gain can increase before the system becomesunstableπ is the phase margin (PM) of the system (βFasemarginβ).How much phase shift the system can tolerate before it becomesunstable.Asymptotically stable system: ππ π180Marginally stable system: ππ π180Unstable system: ππ π180
Frequency Response and Stability AnalysisTheoryThe definitions are as follows:Gain Crossover-frequency - ππ :πΏ ππππ180 is the gain margin frequency, inradians/second. A gain margin frequency indicateswhere the model phase crosses -180 degrees. 1 0ππ΅Phase Crossover-frequency - π180 : πΏ ππ180 ππ is phase margin frequency, in radians/second. Aphase margin frequency indicates where themodel magnitude crosses 0 decibels. 180πGain Margin - GM (π₯πΎ):πΊπ ππ΅ πΏ ππ180GM (ΞπΎ) is the gain margin of the system.PM (π) is the phase margin of the system.ππ΅Phase margin PM (π):ππ 180π πΏ(πππ )We have that:1. Asymptotically stable system: ππ π1802. Marginally stable system: ππ π1803. Unstable system: ππ π180
https://www.halvorsen.blogStability Analysis ofFeedback System - ExampleHans-Petter Halvorsen
ExampleWe will use the following system as an example:1π»π π (π 1)π»π πΎπππ Controllerπ’Sensors1π»π 3π 1π¦Process
Analysis of the Feedback SystemLoop transfer function: π³(π)We need to find the Loop transfer function πΏ(π ) using MATLAB.The Loop transfer function is defined as:πΏ π π»π π»π π»πWe will use the built-in function series() in MATLAB.Tracking transfer function: π»(π)We need to find the Tracking transfer function π(π ) using MATLAB.The Tracking transfer function is defined as:π π π¦(π )π(π )π»π π»π π»π 1 π»π π»π π»ππΏ(π ) 1 πΏ(π )We will use the built-in function feedback() in MATLAB.Sensitivity transfer function: πΊ(π)We need to find the Sensitivity transfer function π(π ) using MATLAB.The Sensitivity transfer function is defined as:π(π )1π π π(π ) 1 πΏ(π ) 1 π(π )
Stability Analysis Plot the Bode plot for the system using e.g., the bode()function in MATLAB Find the crossover-frequencies (π180 , ππ ) and stabilitymargins GM (π΄(π)), PM (π(π)) of the system (πΏ(π )) fromthe Bode plot. Plot also Bode diagram where the crossover-frequencies,GM and PM are illustrated. Tip! Use the margin() functionin MATLAB. Use also the margin() function in order to find values forπ180 , ππ , π΄(π), π(π) directly. You should compare and discuss the results. How much can you increase πΎπ before the systembecomes unstable?
MATLAB Code:clear, clc, clfbode(L)% The Process Transfer function Hp(s)num p [1];den1 [1, 0];den2 [1, 1];den p conv(den1,den2);Hp tf(num p, den p)% The Measurement Transfer function Hm(s)num m [1];den m [3, 1];Hm tf(num m, den m)margin(L)% The Controller Transfer function Hr(s)Kp 0.35;Hr tf(Kp)% The Loop Transfer functionL series(series(Hr, Hp), Hm)% Bode Diagramfigure(1)bode(L),grid onfigure(2)margin(L)[gm, pm, w180, wc] margin(L);wcw180gmgmdB 20*log10(gm)pmwcw180gmgmdBpm 0.2649 rad/s0.5774 rad/s3.809511.6174 dB36.6917 degrees
From the Bode plot we can get: πΎ 11.6 ππ΅ππ 0.26π 37 0.10.30.2π180 0.5810.510
Stable vs. Unstable System We will find and use different values of πΎπ where we get a marginallystable system, an asymptotically stable system and an unstable system. We will Plot the time response for the tracking function using the step()function in MATLAB for all these 3 categories. How can we use the stepresponse to determine the stability of the system? We will find π180 , ππ , π΄ π and π(π) in all 3 cases. We will see howwe use ππ and π180 to determine the stability of the system. We will find and plot the poles and zeros for the system for all the 3categories mentioned above. We will see how we can we use the polesto determine the stability of the system. Bandwidth: We will plot the Loop transfer function πΏ(π ), the Trackingtransfer function π(π ) and the Sensitivity transfer function π(π ) in aBode diagram for the system for all the 3 categories mentioned above.
Stable SystemπΎπ 0.35For what πΎπ becomes the system marginally stable?πΎππ 0.35 ΞπΎ 0.35 3.8 1,32ππ π180wcw180gmgmdBpmlim π¦ π‘ 1π‘ 0.2649 rad/s0.5774 rad/s3.809511.6174 dB36.6917 degreesPoles in the left half plane
Marginally Stable SystemπΎπ 1.32ππ π1800 lim π¦ π‘ π‘ wcw180gmgmdBpm oles at the imaginary axis
Unstable SystemπΎπ 2ππ π180lim π¦ π‘ π‘ wcw180gmgmdBpm 0.7020 0.5774 0.6667 -3.5218 -9.6664Poles in the right half plane
MATLAB Codeclear, clc, clf% The Process Transfer function Hp(s)num p [1];den1 [1, 0];den2 [1, 1];den p conv(den1,den2);Hp tf(num p, den p)% The Measurement Transfer function Hm(s)num m [1];den m [3, 1];Hm tf(num m, den m)% The Controller Transfer function Hr(s)Kp 0.35; % Stable System%Kp 1.32; % Marginally Stable System%Kp 2; % Unstable SystemHr tf(Kp)% The Loop Transfer functionL series(series(Hr, Hp), Hm)% Tracking transfer functionT feedback(L,1);% Sensitivity transfer functionS 1-T;.% Bode Diagramfigure(1)bode(L), grid onfigure(2)margin(L), grid on[gm, pm, w180, wc] margin(L);wcw180gmgmdB 20*log10(gm)pm% Simulating step response for control system(tracking transfer function)figure(3)step(T)% Polespole(T)figure(4)pzmap(T)% Bandwidthfigure(5)bodemag(L,T,S), grid on
βGolden rulesβ of Stability Marginsfor a Control SystemTheoryReference: F. Haugen, Advanced Dynamics and Control: TechTeach, 2010.Gain Margin (GM): (Norwegian: βForsterkningsmarginβ)Phase Margin (PM): (Norwegian: βFasemarginβ)
https://www.halvorsen.blogThe Bandwidth ofthe Control SystemHans-Petter Halvorsen
The Bandwidth of the Control SystemπΏππ You should plot the Loop transfer functionπΏ(π ), the Tracking transfer function π(π )and the Sensitivity transfer function π(π ) inthe same Bode diagram. Use, e.g., the bodemag() function inMATLAB (only the gain diagram is ofinterest in this case, not the phasediagram). Use the values for πΎπ and ππ found in aprevious Tasks. You need to find the different bandwidthsππ , ππ , ππ (see the sketch below).
The Bandwidth of the Control SystemTheoryThe bandwidth of a control system is the frequency which divides the frequencyrange of good tracking and poor tracking.3 different Bandwidth Good Set-point Tracking: π(ππ) 1, π (ππ) 1, πΏ(ππ) 1
πΎπ 0.35Good Set-point Tracking: π(ππ) 1, π (ππ) 1, πΏ(ππ) 1πΏππππ 0.0920.050.1ππ 0.270.20.3ππ‘ 0.461
https://www.halvorsen.blogPI ControllerExampleHans-Petter Halvorsen
PI Controller - ExampleWe will use the following system as an example:πΎπ (ππ π 1)π»π ππ π ππ Controllerπ’Sensors1π»π 3π 11π»π π (π 1)Processπ¦
ZieglerβNichols Frequency Response methodTheoryAssume you use a P controller only ππ , ππ 0. Then you need to find forwhich πΎπ the closed loop system is a marginally stable system (ππ π180 ). This πΎπis called πΎπ (critical gain). The ππ (critical period) can be found from the dampedoscillations of the closed loop system. Then calculate the PI(D) parameters usingthe formulas below.Marginally stable system:ControllerπππππΎπππ π180P0.5πΎπ οΏ½οΏ½π PID0.6πΎππ180ππ82πΎπ - Critical Gainππ - Critical ols method
PI Controller using ZieglerβNicholsZieglerβNichols (PI Controller):πΎπ 0.45πΎπππππ 1.2From previous Simulations:πΎπ 1.322π2πππ π180 0.58This gives the following PI Parameters:πΎπ 0.45πΎπ 0.45 1.32 0.62πππππ 0.58 9π 1.21.2
Skogestadβs method The Skogestadβs method assumes you apply a step on the input (π’) and thenobserve the response and the output (π¦), as shown below. If we have a model of the system (which we have in our case), we can use thefollowing Skogestadβs formulas for finding the PI(D) parameters directly.Figure: F. Haugen, Advanced Dynamics and Control: TechTeach, 2010.Our Process:1π»π π (π 1)ππ is the time-constant of the control system which the user must specifyWe set, e.g., ππΆ 5 π and π 1.5:πΎπ 111 0.2πΎ(ππ π) 1(10 0) 5πΎ 1, π 1, π 0ππ π ππ π 1.5 5 0 7.5π
MATLABZieglerβNichols and Skogestadβs Formulas:% Ziegler-Nicols MethodKc 1.32; % Critical GainTc 2*pi/w180; % Tc - Critical PeriodKp 0.45 * KcTi Tc/1.2% Skogestad's MethodTc 5; % time-constant of
Frequency Response βMATLAB clear clc close all % Define Transfer function num [1]; den [1, 1]; H tf(num, den) % Frequency Response bode(H); grid on The frequency response is an important tool for analysis and design of signal filters and for analysis and design of control