1
Practical Controller Design
For Dummies
2
1.0 Introduction
Welcome to the Practical Controller Design for Dummies. This manual presents the field of Classical Control Theory as taught in SYDE 352. This manual is intended as a basic framework for designing a controller; with more experience and knowledge you can fill out this framework with more complex techniques. It is broken in to 3 sections: System Identification, Controller Design and Controller Validation. A simple brushed DC motor system is used as an example to illustrate the framework. I would like to thank Dr. Eric ‘The Tool Man’ Kubica for freeing me from the deep, murky, nebulous hole that is MME. I would also like to thank him for the opportunity to create this manual and for his guidance and expertise on this project. I would also like to thank Professor Dan Davison, Professor Glenn Heppler and Professor Nasser Lashgarian Azad for their support in making this manual possible. I would also like to thank the good people at For Dummies for the use of their logo.
3
2.0 System Identification
Shown below in Figure 2.0 is the typical feedback system. In general, this system consists of a Reference Input Signal R(s), an Input Filter Transfer Function I(s), a Controller Transfer Function C(s), a Controller Output Signal U(s), a Plant Transfer Function P(s), a Feedback Transfer Function H(s) and an Output Signal Y(s). Also note the summation point where the Error Transfer Function E(s) is equal to R(s)∙I(s). – Y(s)∙H(s).
Figure 2.0 – Typical Feedback System
The goal of System Identification is to derive a mathematical model for each of the following elements: Reference Input Signal R(s) – The Reference Input Signal is the desired set-point(s) as requested by the operator of the system. This input can take many forms, including impulse signals, step signals, ramp signals, acceleration signals, sinusoidal signals etc [1]. Your goal is to identify the typical Reference Input Signal(s) for your system and design a controller to adequately respond to these desired inputs.
Input Filter Transfer Function I(s) – The role of the Input Filter is to convert the Input Signal into a form that is usable by the Controller Transfer Function. In most cases the Input Filter Transfer Function is a gain but can sometimes take the form of a transfer function that filters the input in ways that improve the system response.
Error Signal E(s) – The Error Signal is calculated by subtracting the output of the Feedback Transfer Function from the output of the Input Filter Transfer Function. Though you don’t need to derive a model for this part of the system, it’s important to know the units of this signal.
Controller Transfer Function C(s) – The Controller Transfer Function is the brains of your system and the goal of Controller Design in Section 3.0. It takes the Error Signal and computes the Controller Output Signal. The Controller can take many forms, but for this course we’ll focus on Proportional (P) Controllers, Proportional plus Integral (PI) Controllers, Proportional plus Derivative (PD) Controllers, Proportional plus Integral plus Derivative (PID) Controllers, Phase Lead Controllers, Phase Lag Controllers and Feedforward Controllers.
.
P(s) C(s) H(s) Y(s) + R(s) - ∑ E(s) I(s) U(s)4 Controller Output Signal U(s) – The Controller Output Signal is the signal that the Controller calculates and applies to the Plant. Though you don’t need to derive a model for this part of the system, it’s important to know the units of this signal. It also should be noted that sometimes when running experiments on the model of your system, a limit function may be added here to replicate the real world limits of your system. See Section 3.2.6 for more information.
Plant Transfer Function P(s) – The Plant Transfer Function generally consists of an actuator and the process being controlled. Generally the most difficult task in designing a Controller is to come up with an accurate model of the Plant. For our purposes, there are 2 main methods for developing a model of the Plant. The first approach is to Apply First Principles Techniques. For a mechanical system, this will start with drawing a Free-Body Diagram where we can apply Newton’s Second Law of Motion for linear motion where:
𝐹⃑ = 𝑚𝑎⃑ Where:
𝐹⃑ is the net force acting on an object, 𝑚 is the mass of the object and 𝑎⃑ is the acceleration of the object. Or for rotational motion where:
𝑇⃑⃑ = 𝐼𝛼⃑ Where:
𝑇⃑⃑ is the net torque applied to an object about an axis of rotation, 𝐼 is the inertia of the object about the same axis of rotation and 𝛼⃑ is the angular acceleration of the object about the same axis of rotation.
If you have an electrical system, Kirchhoff’s voltage law (KVL) may be applied where:
∑ 𝑉𝑘 𝑛 𝑘=1
= 0
Where:
5 Of course there are many other equations that could be used to predict the response of your Plant. This technique can be used for any order of Plant but it does require complete knowledge of the Plant. The second approach, Transient and Steady-State Response Analysis, is great for Plants where little is known about the Plant. However, this technique is limited to first and second order Plants. The technique is to apply a known input to your Plant and analyze the transient and steady-state response. Section 2.2.7 goes into more detail on this approach.
The third approach, Data Driven Modeling, sometimes called gray box modeling, is a very effective tool when attempting to model a Plant when very little is known, much like training a fuzzy-neural network, but is beyond the scope of this course.
Feedback Transfer Function H(s) – The Feedback Transfer Function generally is a model of the sensor used to measure the output of your Plant. In most cases this transfer function is modeled as a gain. Output Signal Y(s) – The Output Signal is the physical variable being controlled. Though you don’t need to derive a model for this part of the system, it’s important to know the units of this signal.
2.1 System Identification Flow Chart
Figure 2.1 is the flow chart for System Identification. Follow through it to derive a model for each of the system components.
2.2 System Identification Example
In order to illustrate the process for System Identification, we’ll look at a brushed DC motor system. Shown in Figure 2.2 is the top view of said system. You’ll notice there is a steel arm attached directly to the motor in which we will control. The desired performance specifications for this system are:
1) Maximum overshoot of 5% for a unit step input. 2) Rise time of 0.1s for a unit step input.
6 Figure 2.1 – System Identification Flow Chart
Yes Identify Elements of System
Make Assumptions and Simplifications of System
Apply Data Driven Modeling Techniques Create Plant Model
Apply First Principles Modeling
Techniques
Test Model
Is Plant Model Accurate Enough?
Can the System be Simplified Further?
Yes No
No Analyze Transient and Steady-State Response Derive a Model for each Element Except for the
7 Figure 2.2 – Top View of Brushed DC Motor System
Figure 2.3 – Side View of Brushed DC Motor System Motor
8
2.2.1 Step 1 – Identify Elements of System
For our system:
R(s) Since our performance specifications are solely for a step input, our typical Reference Input Signal will be the desired angle of rotation of the motor’s shaft, measured in radians.
I(s) A coeficient that converts the desired angle of rotation in radians to encoder counts. E(s) The Error Signal will be in encoder counts.
C(s) A Controller implemented on an Arduino Mega in series with a Dual MC33926 Motor Driver. U(s) The Controller Output Signal will be in volts.
P(s) A brushed DC motor (Maxon 2332.968-51.236.200), as shown in Figure 2.3, with a steel arm attached. Also, the slotted disk (See Figure 2.4) of the optical encoder is attached to the same motor shaft.
Figure 2.4 – Optical Encoder Disk and Sensor
H(s) An optical encoder (HEDS-5540 A11), as shown in Figures 2.2 and 2.4, and an encoder counter (HCTL-2022) that converts the angular position of the motor’s shaft in radians to encoder counts.
Y(s) The angular position of the motor’s shaft, measured in radians.
2.2.2 Step 2 - Simplify System
Assumption #1 - We will assume the system is linear and time invariant.
Simplification #1 - We will add the effect of the arm and encoder wheel to the inertia of the motor model.
9
2.2.3 Step 3 – Create Model of each Element Except for Controller and Plant
Feedback Transfer Function H(s) -Encoder
From the data sheet for the HEDS-5540 A11 optical encoder, it has a resolution of 500 CPR (Counts Per Revolution) [2]. In order to free the Arduino Mega from the intensive task of counting the pulses generated by the optical encoder, an encoder counter is used to count and store the current angular position. From the data sheet for the HCTL-2022 encoder counter, it states that it has quadrature decoding capabilities, meaning it can read the two out-of-phase pulse trains and increase the resolution by a factor of 4 [3]. Therefore: 𝐻(𝑠) = 500 𝑝𝑢𝑙𝑠𝑒𝑠 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛∙ 4 𝑐𝑜𝑢𝑛𝑡𝑠 𝑝𝑢𝑙𝑠𝑒 ∙ 1 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛 2𝜋 𝑟𝑎𝑑𝑖𝑎𝑛𝑠 = 318.3 𝑐𝑜𝑢𝑛𝑡𝑠 𝑟𝑎𝑑𝑖𝑎𝑛
Input Filter Transfer Function I(s)
The Input Filter is required to convert the desired angle of rotation of the motor’s shaft in radians to encoder counts. Therefore, like the Encoder Model:
𝐼(𝑠) = 500 𝑝𝑢𝑙𝑠𝑒𝑠 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛∙ 4 𝑐𝑜𝑢𝑛𝑡𝑠 𝑝𝑢𝑙𝑠𝑒 ∙ 1 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛 2𝜋 𝑟𝑎𝑑𝑖𝑎𝑛𝑠 = 318.3 𝑐𝑜𝑢𝑛𝑡𝑠 𝑟𝑎𝑑𝑖𝑎𝑛
Aside – Because the encoder/encoder counter combination can’t read fractional counts, a Floor Rounding Function, that rounds down to the lowest integer value, will be added after the H(s) and I(s) transfer functions to emulate this characteristic.
2.2.4 Step 4 – Create Plant Model
We have a choice on how to model our Plant. As mentioned, for this course, only First Principles Modeling and Transient and Steady-State Response Analysis will be used. First Principles Techniques are useful for any order of system; however, it requires complete knowledge of the system. In our case, all of the parameters of the motor are available from its data sheet making this method possible. However, if we had an unknown motor, this technique would not be possible. For the sake of interest, let’s start with First Principles Techniques then confirm our model using Transient and Steady-State Response Analysis.
10
2.2.4.1 Modeling Approach #1 – Apply First Principles Modeling
Using First Principle Techniques, we’ll start with the typical model of a brushed DC motor. Shown in Figure 2.5 is the typical electrical circuit of the armature and the free-body diagram of the rotor [4].
Figure 2.5 – DC Motor: (a) Electric circuit of armature; (b) Free-body diagram of rotor [4]
Applying
Kirchhoff’s voltage law (KVL) to the motor’s armature circuit results in: 𝑅𝑎𝑖𝑎+ 𝐿𝑎𝑑𝑖𝑎𝑑𝑡 + 𝐾𝑒𝜃̇𝑚− 𝑉𝑎= 0 Where:
R
a is the resistance of the motor’s armature in ohms,i
a is the current flowing through the motor’s armature in amps,L
a is the inductance of the motor’s armature in henrys,K
e is the back emf coefficient in s∙V/rad,𝜃̇𝑚 is the rotational velocity of the motor’s rotor in rad/s,
V
a is the voltage applied to the motor in volts.R
aL
a + - - +V
ai
ae=K
eθ
m . M~
θ
mbθ
m . TJ
m (b) (a) (2.0)11 Using Newton’s second law of motion on the motor’s rotor results in:
𝐾𝑡𝑖𝑎− 𝑏𝜃̇𝑚 = 𝐽𝑚𝜃̈𝑚
Where:
K
t is the torque motor constant in N∙m/A,b
is the viscous friction coefficient in N∙m∙s,J
m is the rotational inertia of the motor’s shaft and rotor in kg∙m2,𝜃̈𝑚 is the rotational acceleration of the motor’s rotor in rad/s2.
Combining Equations 2.0 and 2.1 and applying Laplace transforms with initial conditions of zero results in the motor’s transfer function:
𝜃𝑚(𝑠) 𝑉𝑎(𝑠) =
𝐾𝑡
𝐽𝑚𝐿𝑎𝑠3+ (𝐽𝑚𝑅𝑎+ 𝑏𝐿𝑎)𝑠2+ (𝑏𝑅𝑎+ 𝐾𝑡𝐾𝑒)𝑠
Applying Simplification #1 in which the rotational inertia of the arm and encoder disk is added to the rotor’s rotational inertia results in:
𝐽𝑇 = 𝐽𝑚+ 𝐽𝑎+ 𝐽𝑒 (2.3) Where:
J
T is the combined rotational inertia in kg∙m2,J
a is the rotational inertia of the arm in kg∙m2,J
e is the rotational inertia of the encoder disk in kg∙m2.By combining Equations 2.2 and 2.3 our Plant Transfer Function is:
𝑃(𝑠) = 𝐾𝑡 (𝐽𝑚+ 𝐽𝑎+ 𝐽𝑒)𝐿𝑎𝑠3+ ((𝐽 𝑚+ 𝐽𝑎+ 𝐽𝑒)𝑅𝑎+ 𝑏𝐿𝑎)𝑠2+ (𝑏𝑅𝑎+ 𝐾𝑡𝐾𝑒)𝑠 (2.1) (2.2) (2.4)
12 From the motor’s data sheet, the following is given:
𝑅𝑎= 7.94 Ω 𝐿𝑎= 1.50 𝑚𝐻 𝐾𝑡 = 39.3 𝑚𝑁 ∙ 𝑚/𝐴
𝐽𝑚 = 27.8 𝑔 ∙ 𝑐𝑚2
𝐾𝑒−1= 243 𝑟𝑝𝑚/𝑉
However, using a multimeter I checked the resistance across the leads of the motor to find the combined resistance to be:
𝑅𝑚𝑜𝑡𝑜𝑟+𝑙𝑒𝑎𝑑𝑠 = 9.52 Ω
Furthermore, checking the data sheet of the MC33926 motor driver, it states its H-bridge mosfet has a maximum on-resistance of:
𝑅𝑚𝑜𝑠𝑓𝑒𝑡 = 225 𝑚Ω
And since there is 2 mosfets in operation at any given time, we’ll combine the resistance of the motor, the leads and the 2 mosfets to get a total resistance of:
𝑅𝑇 = 9.97 Ω
2.2.4.2 Calculating the Viscous Friction Coefficient
The last motor specification we require is b, the viscous friction coefficient, and unfortunately the manufacturer does not list it. The viscous friction coefficient is used in Equation 2.1, and if we were to run the motor at a constant speed, this equation simplifies to:
𝐾𝑡𝑖𝑎= 𝑏𝜃̇𝑚 (2.5) And by the motor specification, with no load:
𝜃̇𝑚 = 8410 𝑟𝑝𝑚 𝑜𝑟 880.7 𝑟𝑎𝑑/𝑠 𝑖𝑎 = 30.9 𝑚𝐴 𝑜𝑟 0.0309 𝐴
By submitting the aforementioned values into Equation 2.5 and rearranging for b we get: 𝑏 =𝐾𝑡𝑖𝑎
𝜃̇𝑚 =
(0.0393)(0.0309)
13
2.2.4.3 Estimating the Inertia of the Arm and Encoder Disk
The last pieces of information we need to complete our model of the Plant are the rotational inertias of the arm and the encoder disk. There are a number of ways to do this, here are just 2 ways.
Estimating Approach #1 – Assume the effect of the encoder disk is negligible and model the arm as a point mass located at half the arm’s length.
By finding the mass of the arm and its length, the following equation can be used:
𝐽𝑎1= 𝑚𝑎𝑟𝑎2= 𝑚𝑎( 𝑙𝑎 2) 2 Where: 𝑚𝑎 = 0.049 𝑘𝑔 𝑙𝑎= 0.123 𝑚
By substituting these values into Equation 2.6, we get the following: 𝐽𝑎1= (0.049) (0.123
2 )
2
= 1.85𝑥10−4 𝑘𝑔 ∙ 𝑚2
Therefore, using Equation 2.3:
𝐽𝑇 = 𝐽𝑚+ 𝐽𝑎+ 𝐽𝑒= 2.78𝑥10−6+ 1.85𝑥10−4+ 0 = 1.8778𝑥10−4 𝑘𝑔 ∙ 𝑚2
Estimating Approach #2 – Find the inertias of the both the encoder wheel and arm empirically. By rearranging Equation 2.1 for JT, we get:
𝐽𝑇 = 𝐽𝑚+ 𝐽𝑎+ 𝐽𝑒=𝐾𝑡𝑖𝑎− 𝑏𝜃̇𝑚 𝜃̈𝑚
Therefore, if we collect the motor’s angular position and current and differentiate the angular position twice to get 𝜃̇𝑚 and 𝜃̈𝑚 respectively, we can calculate the combined inertia at each time step. Since the
motor specifications are averages over its operating speeds anyways, we should be able to apply a ramp function to the motor to get a range of results to average.
(2.7) (2.6)
14 To do this, first, we’ll open the ControlsLabBaseCode.ino1 file and program the Arduino Mega 2560 for Open Loop Ramp mode where:
Mode = 1, Ramp_Final = 200, I_Gain = 318.3, Time = 5 and Period = 10.
This puts the Mega into Mode 1 for Open-Loop Ramp Input operation that will output a linearly varying voltage ramp to the motor for a Time of 5.0s with a Period of 10 ms. This ramp will start at the default value of 0% duty cycle or 0 V and end at the Ramp_Final value of 200, which is the raw analogWrite value that represents a duty cycle of (200/255)∙100% = 78.4% or a voltage of (200/255)∙12V or 9.4V. The I_Gain value is the Input Filter Gain that converts radians to encoder counts. By uploading this file, the Mega is ready to go and a test can be initiated by pressing the Start button. Remember, to keep your hand close to the Stop but in case your test gets out of hand. To collect data, the collect.m Matlab script should be used. It returns the following vectors:
R(t) is the Reference Input Signal vector. In Open Loop mode it represents a voltage and is the raw analogWrite value. It ranges from 0 – 255 and its the duty cycle of the Pulse Width Modulated (PWM) signal where 0 represents a 0% duty cycle (always off), 127 represents a 50% duty cycle (on half the time) and 255 represents a 100% duty cycle (always on). In Closed Loop mode it represents the desired angle in radians.
Y(t) is the Output Signal vector, which in this case is the angular position of the motor in radians. I(t) is the current vector 𝑖𝑎 in amps flowing through the motor’s armature. It is important to note
that this value is always positive, regardless of the direction of the flow of current.
Aside – the collect.m script will prompt you for which communication port that the Arduino Mega is currently connected to. To determine which port is being used, open the Device Manager and look under Ports (COM & LPT), as shown in Figure 2.6.
Figure 2.6 –Device Manager Hardware Tree
1
This Arduino file, as well all the other Arduino and Matlab files used in this manual can be found on the C: drive of your lab computer under SYDE 352/SYDE Code.
15 By running collect.m, 4 different plots are created, only 3 of which are important to us at this point.
Figure 2.7 – Plot of the Reference Input vs. Time
16 Figure 2.9 – Plot of the Motor Current vs. Time
Shown in Figure 2.7 is the plot of the Reference Input vs. Time. As expected, the analogWrite signal that represents the duty cycle of the PWM signal sent to the motor varies linearly from 0 to 200 over the 5 second duration. The Angular Position of the motor shown in Figure 2.8 exhibits a non-linear output for the entire test, the worst section being the first 3.5 seconds of the test. Even though we’ve assumed our system to be linear, and the input to the systems is a linear ramp, this clearly is not the case. A red line has been added to the plot to mark the region we’ll consider as linear for our calculation of the combined inertias. The plot of the motor current shown in Figure 2.9 is very noisy. It should be noted that an averaging filter has been added to the ControlsLabBaseCode.ino file to help with the noise issue from the current feedback and this plot is a vast improvement over what is was.
To calculate the angular velocity and acceleration of the motor, the angular position needs to be differentiated. To help with this, a Matlab function called differ was created that employs the following simple two-point estimation:
𝑦̇(𝑡) =𝑦(𝑡 + ℎ) − 𝑦(𝑡) ℎ Where:
17 The differ function has the following syntax:
[data_vector_dot, time_vector_dot] = differ(data_vector, time_vector, freq) Where:
data_vector_dot is the returned differentiated data vector.
time_vector_dot is the returned time vector used for plotting data_vector_dot vs. Time. data_vector is the input data vector to be differentiated.
time_vector is the input time vector to be truncated by one sample point.
Shown in Figure 2.10 is the plot of the Angular Velocity vs Time. The signal exhibits a small amount of noise but overall it is fairly smooth and should produce a decent result when using Equation 2.7. However, this small amount of noise is greatly amplified in the signal of the Angular Acceleration, as shown in Figure 2.11. This signal is basically a blur and will not produce an acceptable result when using Equation 2.7.
18 Figure 2.11 – Plot of the Angular Acceleration vs. Time
Out of curiosity, I created another Matlab script called J_calculation.m based on Equation 2.7 and applied our vectors. Shown below in Figure 2.12 is the result.
19 Even when we zoom-in on the region after 3.5s, the result is way off, as shown below in Figure 2.13. Not surprising, the average combined inertias over this time period using this script results is an infinite value.
Figure 2.13 –Plot of the Combined Inertias vs. Time from 3.5s to 5.0s
Post Process Filtering
It’s clear we’re going to do some post process filtering to get a decent result. I’ve created a function called data_filter that uses Matlab’s butter function that returns the transfer function coefficients of an nth-order low-pass Butterworth filter with a normalized cutoff frequency of Wn. These coefficients are then applied using Matlab’s filter function. The user has the choice of 3 normalized cutoff frequencies to expedite the process of finding the appropriate cutoff frequency. The order of the filter has been hard-coded to be a second order low-pass filter. The data_filter function has the following syntax: [v_f1, v_f2, vf_3] = data_filter(f1_n, f2_n, f3_n, vector_in)
Where:
v_f1, v_f2, v_f3 are the three returned vectors of the filtered vector_in at the normalized frequencies f1, f2 and f3 respectively
f1_n, f2_n, f3_n are the user defined normalized cutoff frequencies. These cutoff frequencies must lie between 0 and 1, where 1 corresponds to the Nyquist rate of half the sample rate.
20 By applying the aforementioned data_filter function to the angular velocity with arbitrarily determined normalized cutoff frequencies of 0.2, 0.1 and 0.02, the following plot was created (Figure 2.14). With a sampling period of 10ms, our sampling frequency is 100Hz and our Nyquist rate is 50 Hz. Therefore the cutoff frequencies trialed correspond to 10Hz, 5Hz and 1Hz respectively.
Figure 2.14 – Data_filter Function Output of Angular Velocity with Cutoff Frequencies of 10Hz, 5Hz and 1Hz
Though it’s slightly difficult to see from the plot shown in Figure 2.14, all 3 cutoff frequencies do a nice job of smoothing out the noise in the Ydot vector. However, the third cutoff frequency of 1Hz adds a very noticeable shift to the data due to the aggressive 2nd order Butterworth filter being too close to the cutoff frequency of the system which is not desired. To minimize this effect, the vector filtered at the second cutoff frequency of 5Hz will be used. Applying the differ function on this new vector results in plot shown below in Figure 2.15.
Clearly the result shown in Figure 2.15 when compared to the plot in Figure 2.11 is much better, but still exhibits a fair amount of noise. Using the data_filter function with the same cutoff frequencies produced the plot shown in Figure 2.16.
21 Figure 2.15 - Plot of the Angular Acceleration vs. Time
Figure 2.16 - Data_filter Function Output of Angular Acceleration with cutoff frequencies of 10Hz, 5Hz and 1Hz
This time the cutoff frequencies of 10Hz and 5Hz did not do an adequate job where the cutoff frequency of 1Hz did a nice job in smoothing the data but once again added a significant shift. A second trial with normalized cutoff frequencies of 0.08, 0.04 and 0.02 were used to produce the plot shown in Figure 2.17.
22 Figure 2.17 - Data_filter Function Output of Angular Acceleration with Cutoff Frequencies of 4Hz, 2Hz
and 1Hz
The second cutoff frequency of 2Hz appears to do the best job of filtering the Angular Acceleration because it produces the smoothest signal without adding a delay to the data and will be used to calculate the combine inertias. Using the J_calculation script resulted in the following plot (Figure 2.18).
23 The average combined inertias over the time period of 3.5s to 5.0s was calculated to be:
𝐽𝑇 = 𝐽𝑚+ 𝐽𝑎+ 𝐽𝑒= 2.4𝑥10−4 𝑘𝑔 ∙ 𝑚2
It was expected that the result of the first approach would yield a conservative estimate because it did not consider the exact geometry of the arm or the inertia of the encoder wheel. Comparing the combined inertias value just calculated with the value found using the first approach and we have a value 28% greater. I’m very comfortable with the estimate of the second approach because I expected it to be larger, but not drastically larger and I will continue with it.
Substituting all our Plant values into Equation 2.4, we now have a complete model of our Plant.
𝑃(𝑠) = 0.0393
3.594𝑥10−7𝑠3+ 0.002389𝑠2+ 0.001558𝑠
Or in normalized form:
𝑃(𝑠) = 109348.9
𝑠3+ 6647.1𝑠2+ 4335𝑠
2.2.5 Step 5 – Test Model
To test the model of our system, we will subject our Plant model and actual Plant to a number of different inputs and compare the results. In order to help with this a Simulink model called
base_open_loop_model has been created. Since we already have captured the data for a ramp input to
our actual Plant in the Matlab workspace, let’s apply it to our Simulink model and compare.
Note 1 – Our Simulink model reads in both the Time vector T and Reference Input vector R to run through our Plant model and compares it to the Output vector Y. However, to do this successfully, T, R and Y each need to be converted from a single row vector to a single column vector using the transpose operator “ ‘ “.
Note 2 – As shown in Figure 2.19, I had to add a Zero-Order Hold and Quantizer function block to
base_open_loop_model. Since we’re using a microcontroller to implement our Controller, we are
actually implementing a discrete control system where this course deals strictly with systems in the continuous time domain. In order to get the two systems to work together, the Zero-Order Hold function block takes discrete data and converts it to continuous data where the Quantizer function block converts continuous data to discrete data.
24 Figure 2.19 – Simulink base_open_loop_model
Shown in Figure 2.20 is the Angular Position vs Time plot generated by the Scope function block in
base_open_loop_model. It compares the results of our Plant model with the actual Plant when
subjected to a ramp input. The results are very encouraging.
Figure 2.20 – Comparison Plot of Plant Model and Actual Plant when Subjected to a Ramp Input
Let’s compare step input results. To do so we’ll open the ControlsLabBaseCode.ino file and program the Arduino Mega for Open Loop Step mode where:
25 This will output a step voltage of (100/255)∙12V or 4.7V for the entire test duration. Using the collect.m Matlab script to collect the test data, transposing vectors T, R and Y, and running it through our
base_open_loop_model yielded the plot shown in Figure 2.21. Again, the results are very encouraging.
Figure 2.21 - Comparison Plot of Plant Model and Actual Plant when Subjected to a Step Input
One more test; let’s try a chirp input. A chirp is a signal in which the frequency increases (‘up-chirp’) or decreases (‘down-chirp’) with time. The term chirp is used interchangeably with sweep signal [5]. Open the ControlsLabBaseCode.ino file and program the Arduino Mega for Open Loop Chirp mode where:
Mode = 2, Freq_Final = 2, PWM_Amp = 50, I_Gain = 318.3, Time = 10 and Period = 10.
This will output a sinusoidal signal that will range between +/- (50/255)∙12V or +/- 2.35V with the frequency linearly increasing from 0 to 2Hz. Using the collect.m Matlab script to collect the test data, transposing vectors T, R and Y, and running it through our base_open_loop_model yielded the plot shown in Figure 2.22.
26 Figure 2.22 - Comparison Plot of Plant Model and Actual Plant when Subjected to a Chirp Input Again, the results are very similar but it’s obvious the motor is struggling with oscillating the system’s inertia at this frequency by the drift in the position and the reduction in magnitudes of the oscillations as the frequency increases. Out of curiosity, I’ll perform the same test without the arm attached. By changing the J value for our Plant model, the two results can be compared. As shown in Figure 2.23, the motor does a lot better job in keeping up with the commanded chirp signal and the Plant model accurately predicts this result.
There is no standard way of concluding whether a model is accurate enough. However, upon visual inspection, the results are very similar and I’m comfortable with concluding that this model is sufficiently accurate to proceed. However, can it be simplified?
Figure 2.23 - Comparison Plot of Unloaded Plant Model and Actual Unloaded Plant when Subjected to a Chirp Input
27
2.2.6 Step 6 – Simplification
It would be nice to reduce the order of our model to a second order model so that we can use standard second order methods to develop a Controller. Presented are two approaches for accomplishing this.
2.2.6.1 Simplification Approach #1
For many DC motor models, the relative effect of the inductance is considered negligible compared to the mechanical time constant and can be neglected. Let’s test this out.
By setting:
𝐿𝑎= 0
We get the following new Plant model, where:
𝑃𝑛𝑒𝑤1(𝑠) = 0.0393
0.002389𝑠2+ 0.001558𝑠
Or in normalized form:
𝑃𝑛𝑒𝑤1(𝑠) = 16.45 𝑠2+ 0.652𝑠
Interestingly, the denominator of the old Plant model and new Plant model, before converting to normalized form, are the same except for the missing 𝑠3 term. By using Matlab’s bode function to create a Bode Diagram of both Plant models, as shown in Figure 2.24, we can see that they’re almost identical, except for a slight difference in phase at higher frequencies.
Based on the Bode Diagram, I’m very comfortable with this simplification and require no further testing to verify its validity.
28 Figure 2.24 – Bode Diagram Comparing the Original Plant Model with the New Plant Model
2.2.6.2 Simplification Approach #2
Another approach to reducing the order of the system is by Model Reduction. This method looks at the Plant’s poles and zeros that are a factor of 10 or greater than the dominant poles and zeros and replaces them with a DC gain (i.e. when s = 0).
For example, if you have a transfer function such as:
𝑇𝐹(𝑠) = (𝑠 + 𝑧2)(𝑠 + 𝑧1)(𝑠 + 𝑧0) (𝑠 + 𝑝3)(𝑠 + 𝑝2)(𝑠 + 𝑝1)(𝑠 + 𝑝0) Which has a value of:
𝑇𝐹(0) = (0 + 𝑧2)(0 + 𝑧1)(0 + 𝑧0) (0 + 𝑝3)(0 + 𝑝2)(0 + 𝑝1)(0 + 𝑝0)=
𝑧2∙ 𝑧1∙ 𝑧0
𝑝3∙ 𝑝2∙ 𝑝1∙ 𝑝0
When s = 0. And you recognize that 𝑝2 is greater than 𝑝3, 𝑝1and 𝑝0 by a factor of 10 or greater, you can
replace (𝑠 + 𝑝2) with 𝑝2. Thereby simplifying our example transfer function to:
𝑇𝐹𝑛𝑒𝑤(𝑠) = (𝑠 + 𝑧2)(𝑠 + 𝑧1)(𝑠 + 𝑧0) (𝑠 + 𝑝3) ∙ 𝑝2∙ (𝑠 + 𝑝1)(𝑠 + 𝑝0)
29 Which has the same value as the original transfer function when s = 0 and at low frequencies. Of course, at high frequencies there will be slight differences, but it will be negligible because the lower frequency poles will dominate the response of the transfer function.
This method is effective for systems with a low bandwidth. However, if you’re looking to create a system with a high bandwidth, those high frequency poles and zeros may be very important. Another approach is to look at the Plant’s poles and zeros to see if there are any poles and zeros that can cancel each other.
Using Matlab’s pole function, the Plant’s poles were found at:
P1 @ 0, P2 @ -0.652 and P3 @ -6646 Since there are no s terms in the Plant numerator, there are no zeros.
Shown in Figure 2.25 is a plot of the Plant model’s poles and zeros using Matlab’s pzmap function. Fortunately none of the poles lie in the unstable Right Half Plane (RHP), however, it does have a pole directly on the Imaginary axis. Furthermore, none of the poles have any imaginary components, meaning the system is critically damped or over-damped. Since none of the poles are at the same location, the system is considered overdamped. Interestingly, there is a very high frequency pole at -6646 which should have very little effect on how the model performs. By removing this pole and replacing it with a DC gain, our new Plant model is the following:
𝑃𝑛𝑒𝑤2(𝑠) = 109348.9 𝑠(𝑠 + 0.6523)(6646) Or:
𝑃𝑛𝑒𝑤2(𝑠) = 16.45 𝑠(𝑠 + 0.652)
This new Plant model is identical to the result obtained from the Approach #1. Let’s try the transient and steady-state response analysis technique to verify this result.
30 Figure 2.25 – Plot of Plant Model’s Poles and Zeros
2.2.7 Modeling Approach #2 –Transient and Steady State Response
The goal of this approach is to apply different Reference Input Signals into the open-loop system you want to model to gain insight into what order it is, and hopefully derive some values for this model. A good starting point is to apply a step input into your system and see how it reacts. Reusing the test data collected earlier, shown in Figure 2.26 is a step input of (100/255)∙12V or 4.7V.
31 Figure 2.26 – Open-Loop Step Response
There are 2 things to note from this open-loop step response. First, the slope at t = 0 is zero, which indicates that the system must be second order system or higher. Oscillations in the output would have also indicated a second order system or higher. Second, the output position does not reach a steady state. Instead a steady velocity is reached. This indicates that our system may look like a first order system with an integrator term after, as shown in Figure 2.27:
Figure 2.27 – Proposed Plant Model
Note – 1𝑇 = 𝜎, or the real portion of the pole.
1 𝑠 𝐾
32 If we differentiate the position output to get velocity, we get the following plot shown in Figure 2.28:
Figure 2.28 – Differentiated Position Output
As you can tell in Figure 2.28, the output does have a slope greater than zero at t = 0, there are no oscillations and the output reaches a steady state, indicating a first order system. Based on the knowledge that a first order system reaches 63.2% of its final value after 1 time constant T [6], we can find our time constant T when the response has reached 63.2% of its final value of 100rad/s or 63.2rad/s. As shown on the same plot, red lines have been added to indicate this intersection which is when T = 1.07s. Also, since our gain K is the steady state result divided by the gain of the open-loop step input, our gain K is 100/4.7 or 21.3. Therefore our Plant model is:
𝑃(𝑠) = 21.3
𝑠(1.07𝑠 + 1)
Rearranging the result in Modeling Approach #1 into the same form as just derived results in: 𝑃(𝑠) = 25.27
𝑠(1.53𝑠 + 1)
Creating Bode Diagrams to compare both Plant models results in the plots shown in Figure 2.29. As you can see, they are very close. There is a slight difference in the Phase plot but the Magnitude plot is almost identical.
33 Figure 2.29 – Bode Diagram Comparison between Both Plant Models
Using the data collected earlier to run through our Simulink base_open_loop_model resulted in the following plots:
34 Figure 2.31 - Comparison Plot of Plant Model and Actual Plant when Subjected to a Ramp Input
35
2.2.7.1 Conclusion
Both approaches yield acceptable models. However, with Approach #2, Transient and Steady-State Response Analysis, was much easier and far quicker. Comparing Figures 2.20-22 and Figure 2.30-32, the results are very similar, with neither being perfect. Since our intended purpose for this system is for position control, we’ll proceed with the Plant model derived by Approach #2 because its step input result is better. This concludes the System Identification portion and we’ll proceed to Controller Design.
Aside – If our Plant was a typical second order system such as: 𝑃(𝑠) = 𝐾′𝜔𝑛2
𝑠2+ 2𝜉𝜔
𝑛𝑠 + 𝑤𝑛2
And was underdamped, the damping ratio could be calculated from the percent overshoot (%OS) from a step input by using [7]:
𝜉 = −𝑙𝑛 (
%𝑂𝑆 100 ) √𝜋2+ 𝑙𝑛2(%𝑂𝑆
100 )
Furthermore, the damped natural frequency can be measured off the plot of the step response using the equation shown below, where Δ𝑡 is the time interval between two consecutive peaks [7]:
𝜔𝑑 =2𝜋 Δt The natural frequency can then be calculated using [7];
𝜔𝑛= 𝜔𝑑 √1 − 𝜉2
The DC gain K is calculated as before using [7]:
𝐾 =𝑠𝑡𝑒𝑎𝑑𝑦 𝑠𝑡𝑎𝑡𝑒 𝑠𝑡𝑒𝑝 𝑟𝑒𝑠𝑝𝑜𝑛𝑠𝑒 𝑚𝑎𝑔𝑛𝑖𝑡𝑢𝑑𝑒 𝑜𝑓 𝑠𝑡𝑒𝑝 𝑖𝑛𝑝𝑢𝑡
A similar approach can be taken using a chirp input to create a Bode Plot. See Extras: System Identification for more information [7].
36
3.0 Controller Design – Phase 1
There are numerous techniques available, which range in complexity, to design a Controller. However, this course is an introductory course and can’t possibly cover every technique. Instead, we’ll break our design approach into two phases. The first phase will focus on creating a Proportional (P), Proportional plus Derivative (PD), Proportional plus Integral (PI) and Proportional plus Derivative plus Integral (PID) Controller using Transient Response Equations to a step input and the Root Locus method which is a graphical method for examining how the roots or poles of a system change with variation of a certain system parameter, commonly a gain within a feedback system [8]. As we continue to gain more understanding, in the second phase we’ll apply Phase Lead-Lag Control and Feed Forward Control techniques. You will notice that most of the techniques employed are for first and second order systems. Higher order systems are beyond the scope of this course. Of course, if your career as an engineer involves Controller design, you can add to the framework presented here. More importantly, it is hoped that the concepts demonstrated here will give you a solid understanding and intuition into Controller design.
It should also be mentioned that the Transient Response Equations shown in Section 3.1.1 and 3.1.2 deal strictly with time domain response to step inputs. Unfortunately, this course doesn’t have any techniques for designing a Controller for other inputs such as a ramp or impulse, and doing a survey of many textbooks, very few techniques exist. Since a step input involves a wide range of frequencies, there is a good chance that a Controller designed for a step input would also react well to other inputs. However, if you’re given only specifications that relate to inputs other than a step input, the only technique you have is trial and error by intuition.
3.1 Proportional Control (P Control)
Presented in Figures 3.1,8,9,18 and 19 is the framework for P, PD, PI and PID Controller design based on the curriculum taught in this course. The starting framework in Figure 3.1 attempts to find an appropriate Proportional Controller. The system will look like this:
Figure 3.0 – System with Proportional Controller
.
P(s) KP H(s) Y(s) + R(s) - ∑ E(s) I(s) U(s)37 Figure 3.1 – Flow Chart of Proportional Controller Design
1st Order System?
2nd Order System? Start with a Proportional
Controller No Yes Order of System > 2 Yes No
Apply 1st Order Transient Response Equation
Apply 2nd Order Transient Response Equations
Apply Root Locus Method as a Starting Point
Trial and Error
38 Which results in the following transfer function:
𝑇(𝑠) =𝑌(𝑠)
𝑅(𝑠)= 𝐼(𝑠) ∙
𝐾𝑃∙ 𝑃(𝑠) 1 + 𝐾𝑃∙ 𝑃(𝑠) ∙ 𝐻(𝑠) Or the following block diagram:
Figure 3.2 – Simplified System with Proportional Controller
3.1.1 1
stOrder Transient Response Equations to a Step Input
Based on the Equation 3.0, a 1st Order System without a zero with a Proportional Controller will look like the following: 𝑇(𝑠) =𝑌(𝑠) 𝑅(𝑠)= 𝐼(𝑠) ∙ 𝐾𝑃∙ (𝑠 + 𝜎𝐾 1) 1 + 𝐾𝑃∙ (𝑠 + 𝜎𝐾 1) ∙ 𝐻(𝑠) = 𝐾𝑃𝐾 ∙ 𝐼(𝑠) 𝑠 + 𝜎1+ 𝐾𝑃𝐾 ∙ 𝐻(𝑠) Or in standard form: 𝑇(𝑠) =𝑌(𝑠) 𝑅(𝑠)= 𝐾′𝜎 𝑠 + 𝜎 Where: 𝜎 = 𝜎1+ 𝐾𝑃𝐾 ∙ 𝐻(𝑠) And: 𝐾′𝜎 = 𝐾 𝑃𝐾 ∙ 𝐼(𝑠) (3.2)
Using either the Transient Response Equation for 1% settling time to a step input [9]: 𝑡𝑠 = 4.6 𝜎 (3.1) (3.3) 𝐼(𝑠) ∙ 𝐾𝑃∙ 𝑃(𝑠) 1 + 𝐾𝑃∙ 𝑃(𝑠) ∙ 𝐻(𝑠) Y(s) R(s) (3.0)
39 Or the Transient Response Equation for rise time for a step input [9]:
𝑡𝑟 =2.2 𝜎
We can back calculate for 𝜎 and then back calculate for 𝐾𝑃 using Equation 3.1.
If your Plant has a zero in the numerator, temporarily ignore it and apply the above equations as a starting point. Afterwards, iteratively tune your Controller by trial and error with the zero included.
Aside - For a first order system, no overshoot is possible, therefore 𝑀𝑝= 0. This is because the one
pole for a 1st order system must lie on the real axis. To have any kind of overshoot, a system must have poles that have an imaginary component. However, since complex poles, which have an imaginary component, only come in pairs, it’s impossible for a 1st order system to have a lone complex pole to produce overshoot.
3.1.2 2
ndOrder Transient Response Equations to a Step Input
Based on the Equation 3.0, a 2nd Order System without a zero with a Proportional Controller will look like the following: 𝑇(𝑠) =𝑌(𝑠) 𝑅(𝑠)= 𝐼(𝑠) ∙ 𝐾𝑃∙ ((𝑠 + 𝜎 𝐾 1)(𝑠 + 𝜎2)) 1 + 𝐾𝑃∙ ((𝑠 + 𝜎 𝐾 1)(𝑠 + 𝜎2)) ∙ 𝐻(𝑠) = 𝐾𝑃𝐾 ∙ 𝐼(𝑠) 𝑠2+ (𝜎 1+ 𝜎2)𝑠 + (𝜎1𝜎2+ 𝐾𝑃𝐾 ∙ 𝐻(𝑠)) Or in standard form: 𝑇(𝑠) =𝑌(𝑠) 𝑅(𝑠)= 𝐾′𝜔 𝑛2 𝑠2+ 2𝜉𝜔 𝑛𝑠 + 𝜔𝑛2 Where: 𝜔𝑛2 = 𝜎 1𝜎2+ 𝐾𝑃𝐾 ∙ 𝐻(𝑠) (3.5) And: 2𝜉𝜔𝑛= 𝜎1+ 𝜎2 (3.6) And: 𝐾′𝜔 𝑛2= 𝐾𝑃𝐾 ∙ 𝐼(𝑠) (3.7) (3.4)
40 Depending on which specifications are given, use the following Transient Response Equations for a step input [11]. For the rise time:
𝑡𝑟 =
1.8 𝜔𝑛
For an underdamped system, the percentage of overshoot: 𝑀𝑝= 𝑒−𝜋𝜉 √1−𝜉⁄ 2
, 0 ≤ 𝜉 < 1 (3.9) Which occurs at the peak time of:
𝑡𝑝= 𝜋 𝜔𝑑
Where:
𝜔𝑑 = 𝜔𝑛√1 − 𝜉2 (3.11)
For a 1% settling time:
𝑡𝑠 =4.6 𝜎 Where:
𝜎 = 𝜉𝜔𝑛 (3.13)
Figure 3.3 – Graphs of Regions in the S-Plane for Rise Time, Overshoot and 1% Settling Time Respectively for a Step Input [11]
(3.8) (3.10) (3.12) Re(s) Im(s) 𝜔𝑛 Re(s) Im(s) 𝜎 Re(s) Im(s) 𝜃 = 𝑠𝑖𝑛−1𝜉
41 Shown in Figure 3.3 are the graphs of regions in the s-plane that are produced by the aforementioned Transient Response Equations for rise time, overshoot and 1% settling time for a step input.
For an undamped and underdamped 2nd order system, the resulting poles will be at: 𝑠1,2= −𝜎 ± 𝑗𝜔𝑑 𝑤ℎ𝑒𝑛 0 ≤ 𝜉 < 1
For a critically damped 2nd order system, both poles will be at: 𝑠1,2= −𝜎 𝑤ℎ𝑒𝑛 𝜉 = 1
For an overdamped 2nd order system, both poles will be unique but lie on the Real axis.
If your Plant has one or more zeros in the numerator, temporarily ignore it/them and apply the above equations as a starting point. Afterwards, iteratively tune your Controller by trial and error with the zero(s) included. Know that a zero in the Left Half Plane (LHP) of the s-plane will increase the overshoot to a step response if the zero is within a factor of 4 of the real part of the complex poles, and a zero in the RHP will suppress the overshoot but may cause the step response to start out in the wrong direction [12].
Note 1 – For the derivations in Sections 3.1.1 and 3.1.2, it was assumed that I(s) and H(s) were strictly gains.
Note 2 - It should be noted that these equations are qualitative guides and not precise design formulas. They are meant as a starting point for design iteration [10]. For tuning the Controller for a 2nd Order System, if the system is responding too slow, increase the natural frequency 𝜔𝑛. If there is too much
overshoot, increase the damping coefficient 𝜉. If the transients persist too long, move the pole 𝜎 left in the s-plane. [9].
Note 3 – If you are given 1 specification to a step input, using the Transient Response Equations for a second order system will result in one unique value for 𝐾𝑝. If you have been given 2 specifications to a
step input, each will produce a value for 𝐾𝑝 and it most cases, each value will be unique and produce
transient responses that do not satisfy both specifications. If you were to combine specifications and combine the regions shown in Figure 3.3, you will get a unique set of poles to meet the specifications. However, there is a good chance that a Proportional Controller will not be able to produce that desired result. This can be verified by plotting the system’s Root Locus.
42
3.1.3 Root Locus Method
As mentioned earlier, the Root Locus Method is a technique that shows how change in one system parameter will modify the roots of the system’s characteristic equation. It’s a powerful technique that can be used for any order of system comprised of both poles and zeros where the number of poles is equal to or greater than the number of zeros. The only stipulation is that only one parameter can be modified at one time. It’s beyond the scope of this guide to go into the details of drawing a Root Locus by hand. Instead, we’ll focus on some of the equations derived from the formation of a Root Locus and how to use Matlab to expedite the drawing process.
As shown in Figure 3.4, the typical focus of the Root Locus method are the elements inscribed within the red box. It consists of the Controller 𝐾𝑃, the Plant P(s) and the Feedback Transfer Function H(s). It
should be noted that this method can be applied to any variable within a system but in this course, we’ll only focus on Controller variables.
Figure 3.4 – Focus of Typical Root Locus Shown in Red
This results in the characteristic equation of:
1 + 𝐾𝑃𝑃(𝑠) ∙ 𝐻(𝑠) = 0 (3.14)
And if you vary 𝐾𝑃 from zero to infinity, you will create the system’s Root Locus.
Breaking Equation 3.14 into its complex components you have the equation for the magnitude:
|𝐾𝑃𝑃(𝑠) ∙ 𝐻(𝑠)| = 1 (3.15)
And the angle:
< 𝐾𝑃(𝑠) ∙ 𝐻(𝑠) = ±180°(2𝑘 + 1) (3.16)
.
P(s) KP H(s) Y(s) + R(s) - ∑ E(s) I(s)43 Or: ∑𝑚 < (𝑠 + 𝑧𝑖) + 𝑖=1 ∑𝑛𝑗=1< (𝑠 + 𝑝𝑗)= ±180°(2𝑘 + 1) (3.17) Where: k = # of poles − # of zeros − 1 (3.18) And for a pole or zero with the form 𝑠 = 𝑎 + 𝑗𝑏, the angle is computed using the following:
< 𝑠 = tan−1(𝑏
𝑎)
When using the Root Locus method for a multi-order system, this technique will only help you to visualize the system and how it changes with different values of 𝐾𝑃. This will allow you to see which
values of 𝐾𝑃 produce a stable system whereby the system’s poles exist in the LHP but it will not allow
you to estimate its performance characteristics such as rise time, overshoot and settling time. These features can only be determined by simulation in Simulink or testing on the physical system.
Aside - When using the Root Locus function rlocus(sys) in Matlab, keep in mind that: 𝑠𝑦𝑠 = 𝑃(𝑠) ∗ 𝐻(𝑠)
3.1.4 A Note on Higher-Order Systems
In some instances, it may be possible to temporarily reduce the order of the system to second order by ignoring some of the system’s poles if they are much larger and less dominant than two of the slower poles. Unlike the method of Model Reduction mentioned earlier where you replace high frequency poles and zeros with a DC gain, you are temporarily ignoring them so that you can then use the 2nd order Transient Response Equations shown earlier to give you a starting point. However, trial and error are required to further tune the Controller when the other poles are reintroduced. Keep in mind that an additional pole in the LHP will increase the rise time to a step response significantly if the extra pole is within a factor of 4 of the real part of the complex poles [12].
44
3.1.5 Test
If the Proportional Controller meets the specifications given you can skip to the Section 5.0, Controller Validation. Following Figure 3.8, if the Proportional Controller produces too much overshoot, proceed to Proportional plus Derivative Control. If your Controller produces too much steady state error, skip to Proportional plus Integral Control. If instead your Controller produces too much overshoot and steady state error, skip to PID Control.
3.1.6 Example Continued – P Controller Design
As mentioned in Section 2.2, the desired performance specifications for this system are: 1) Maximum overshoot of 5% for a unit step input.
2) Rise time of 0.1s for a unit step input. 3) Zero steady-state error to a unit step input.
Since we have reduced our Plant Transfer Function to a second order system, and because a Proportional Controller does not add a pole or zero to our closed-loop transfer function, we can apply the 2nd Order Transient Response Equations presented in Section 3.1.2. But first we need to rearrange our Plant Transfer Function to look like the following:
𝑃(𝑠) = 𝐾
(𝑠 + 𝜎1)(𝑠 + 𝜎2) Therefore our Plant Transfer Function, in the above form is:
𝑃(𝑠) = 19.9
(𝑠 + 0)(𝑠 + 0.935)
3.1.6.1 𝑲
𝑷Calculation Based on Overshoot Specification
We could try to rearrange Equation 3.9 to find the damping coefficient, but fortunately someone else already did this and created a graph of this relationship. Using Figure 3.23 on page 118 of Feedback Control of Dynamic Systems [11], a 5% overshoot results in a damping coefficient of:
𝜉 = 0.7 Rearranging Equation 3.6 for 𝜔𝑛 results in:
𝜔𝑛=𝜎1+ 𝜎2
45 By substituting our values for 𝜎1, 𝜎2and 𝜉 into Equation 3.20 results in:
𝜔𝑛=
0 + 0.935
2(0.7) = 0.67 𝑟𝑎𝑑/𝑠 Rearranging Equation 3.5 for 𝐾𝑃 results in:
𝐾𝑃=𝜔𝑛2− 𝜎1𝜎2 𝐾 ∙ 𝐻(𝑠)
By substituting our values for 𝜔𝑛, 𝜎1, 𝜎2, 𝐾 and 𝐻(𝑠) into Equation 3.21 results in:
𝐾𝑃=
(0.67)2− (0)(0.935)
19.9(318.3) = 7.04𝑥10−5
𝑉
𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠
In order to test this result, I’ve created a Simulink model called base_closed_loop_model and added the model elements particular to this example. I then setup a unit step input to inject into our model to see the result. Shown in Figure 3.5 is a very smooth but slow response to a step input. Though it meets our overshoot specification of 5%, it in no way comes close to our target rise time of 0.1s. Let’s apply the 2nd Order Transient Response Equations for rise time and compare.
Figure 3.5 – Unit Step Response for KP of 7.04x10-5
46
3.1.6.2 𝑲
𝑷Calculation Based on Rise Time
Rearranging Equation 3.8 for 𝜔𝑛 results in:
𝜔𝑛=
1.8 𝑡𝑟 And substituting our value for 𝑡𝑟 into Equation 3.22 results in:
𝜔𝑛=1.8
0.1= 18 𝑟𝑎𝑑/𝑠
And substituting our values for 𝜔𝑛, 𝜎1, 𝜎2, 𝐾 and 𝐻(𝑠) into Equation 3.21 results in:
𝐾𝑃=(18)
2− (0)(0.935)
19.9(318.3) = 0.051
𝑉
𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠
Substituting this new value for 𝐾𝑃 into our Simulink model resulted in the unit step response shown in
Figure 3.6. Yikes!
Figure 3.6 – Unit Step Response for KP of 0.051
47
3.1.6.3 𝑲
𝑷Calculation for Zero Steady-State Error
Fortunately no calculation is required to find our system’s steady-state error. Since our system is a Type 1 system, and because it has one integrator term in the denominator, it inherently has zero steady-state error for a step input regardless of the Controller chosen.
Aside – For more information on system Types and Steady-State Error Design, see Section 3.5.
3.1.6.4 Conclusion
We can only meet 2 of the 3 Design Specifications. As expected, the overshoot and rise time specification conflict with each other. Out of interest I plotted the Root Locus using Matlab to see what is really going on. As you can see from Figure 3.7, as you increase the value for 𝜔𝑛 greater than 0.4675,
the value for 𝜉decreases, so when we tried to decrease our rise time by increasing 𝜔𝑛, the value for
𝜉decreased creating a no-win situation.
Figure 3.7 – Root Locus of our Plant
To further understand why the Proportional Controller failed, let’s use the damping ratio of 0.7 that results from the overshoot specification and the natural frequency of 18 rad/s that results from the rise time specification to calculate the desired closed-loop poles where:
48 𝑠𝑑1,2= −12.6 ± 𝑗12.85
This produces the same result as combining the regions shown in Figure 3.3 to create a unique set of poles. It should be obvious by our Root Locus, as shown in Figure 3.7, that no value for 𝐾𝑃 will intersect
with these locations.
Since we met our steady-state specification, we’ll try a Proportional plus Derivative Controller.
3.2 Proportional plus Derivative Control (PD Control)
Following Figure 3.8, if your Proportional Controller produces too much overshoot but the steady state error is acceptable, apply Proportional plus Derivative Control as shown in Figure 3.9. As a starting point, apply the 2nd Order Transient Response Equations. If you’ve been given 1 time domain specification to a step input you will end up with a region as in Figure 3.3 or if you’ve been given 2 time domain specifications to a step input you can calculate 𝜔𝑛 and 𝜉 in order to calculate the desired
closed-loop poles with Equation 3.23. If you have a second order system and you’ve been given 2 time domain specifications for a step input and there are no zeros in your Plant, apply Coefficient Mapping otherwise apply Root Contour Iteration. Keep in mind that both of these methods will not produce the desired Controller after one iteration. It is meant as a starting point to an iterative approach driven by intuition and trial and error.
Figure 3.8 – Flowchart for PI, PD and PID Controller Design
Apply Proportional plus Derivative Control Too much Overshoot?
Too much Steady State Error?
Apply Proportional plus Integral Control
Yes
No
Apply PID Control Yes
49 Figure 3.9 – Flowchart for PD Controller Design
3.2.1 Coefficient Mapping
Coefficient Mapping is a simple method to find Controller gains whereby you compare the terms of the characteristic equation of a second order system with like terms of the polynomial of the desired closed-loop poles. From the generic system model we have the following characteristic equation:
1 + 𝐶(𝑠) ∙ 𝑃(𝑠) ∙ 𝐻(𝑠) = 0 (3.24) Where a PD Controller is:
𝐶(𝑠) = 𝐾𝑃+ 𝐾𝐷𝑠
Apply Root Contour Iteration Order = 2?
2 Specifications Given and No Zero in
Plant? Apply 2nd Order Transient
Response Equations as a Starting Point
Yes
No
Apply Root Contour Iteration
Yes
No
Trial and Error Test
Apply Coefficient Mapping
50 And for a normalized 2nd order system without any zeros:
𝑃(𝑠) =𝑁(𝑠) 𝐷(𝑠)=
𝐾 𝑠2+ 𝑑
1𝑠 + 𝑑0
And the Feedback Transfer Function is assumed to be a gain, where: 𝐻(𝑠) = 𝐻1
We now can rearrange Equation 3.24 to look like the following: 𝐷(𝑠) + 𝐻1(𝐾𝑃+ 𝐾𝐷𝑠) ∙ 𝑁(𝑠) = 0
And if we substitute our equations we get: 𝑠2+ (𝑑
1+ 𝐻1𝐾𝐷𝐾)𝑠 + (𝑑0+ 𝐻1𝐾𝑃𝐾) = 0 (3.25)
Which we can equate to our desired closed-loop poles of: 𝑠𝑑1,2= −𝑎 ± 𝑗𝑏 We get:
𝑠2+ (𝑑
1+ 𝐻1𝐾𝐷𝐾)𝑠 + (𝑑0+ 𝐻1𝐾𝑃𝐾) = (𝑠 + 𝑎 + 𝑗𝑏)(𝑠 + 𝑎 − 𝑗𝑏) = 𝑠2+ 2𝑎𝑠 + (𝑎2+ 𝑏2)
Now if we match coefficients, we get the following equations:
𝑑1+ 𝐻1𝐾𝐷𝐾 = 2𝑎 (3.26)
𝑑0+ 𝐻1𝐾𝑃𝐾 = 𝑎2+ 𝑏2 (3.27)
And rearranging Equations 3.26 and 3.27 will give us our gains for our PD Controller.
3.2.2 Root Contour Iteration
Root Contour Iteration is an iterative approach to applying Root Locus methods. It’s best suited for situations where you have one or two or (at most) three parameters that you want to vary, i.e. in a PID Controller. The basic idea is to successively hold all but one of the parameters in the Controller constant, and vary the one parameter that is not fixed via a Root Locus plot to see the effect on the desired closed-loop region or poles. The parameter that was varied is then fixed, and another parameter is varied in the same way. This process continues until your Root Locus intersects with the desired closed-loop region or poles [13].
51
3.2.3 Trial and Error
Both Coefficient Mapping and Root Contour Iteration will get you into the ball park but will not directly get you to the Controller you want. However, with experience you can take the results of an iteration and apply your intuition to move the desired closed-loop region or poles to improve system response.
3.2.4 Example Continued – PD Controller Design
Since our P Controller produced too much overshoot but the steady error specification was met, let’s try a PD Controller. Fortunately, since we have a second order Plant with no zeros and a have been given 2 time domain specifications to a step input we have two methods available. We’ll start with Coefficient Mapping and then try Root Contour Iteration to verify our results.
3.2.4.1 PD Controller Design Approach #1 - Coefficient Mapping
In Section 3.1.6.4 we calculated our desired closed-loop poles as:𝑠𝑑1,2= −12.6 ± 𝑗12.85
Following the instructions in Section 3.2.1, we get the following characteristic equation: 𝑠2+ (0.935 + (318.3)𝐾
𝐷(19.9))𝑠 + (0 + (318.3)𝐾𝑃(19.9)) =
𝑠2+ (0.935 + 6336.3𝐾
𝐷)𝑠 + 6336.3𝐾𝑃
Which we’ll equate with our desired characteristic equation:
(𝑠 + 12.6 + 𝑗12.85)(𝑠 + 12.6 − 𝑗12.85) = 𝑠2+ 25.2𝑠 + 324
By using Equation 3.26 and rearranging for 𝐾𝐷 we get:
𝐾𝐷=2𝑎 − 𝑑1 𝐻1𝐾 = 2(12.6) − 0.935 318.3(19.9) = 3.83𝑥10−3 𝑉 ∙ 𝑠 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠 By using Equation 3.27 and rearranging for 𝐾𝑃 we get:
𝐾𝑃 =𝑎2+ 𝑏2− 𝑑0 𝐻1𝐾 = (12.6)2+ (12.85)2− 0 318.3(19.9) = 0.051 𝑉 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠 Which gives us the following PD Controller:
52
3.2.4.2 PD Controller Design Approach #2 – Root Contour Iteration
1st Iteration - Since there is no defined starting point for this method, I’ll arbitrarily set 𝐾𝑃 to 1 and vary
𝐾𝐷. This results in the following characteristic equation: 𝑠2+ (0.935 + (318.3)𝐾
𝐷(19.9))𝑠 + (0 + (318.3)(1)(19.9)) = 𝑠2+ (0.935 + 6336.3𝐾𝐷)𝑠 + 6336.3
Now if we arrange our characteristic equation into the following form: 1 + 𝐾 ∙𝑛(𝑠) 𝑑(𝑠)= 0 We get: 1 + 6336.3𝐾𝐷∙ 𝑠 𝑠2+ 0.935𝑠 + 6336.3= 0
Using Matlab’s rlocus(sys) function make sure that: 𝑠𝑦𝑠 =𝑛(𝑠)
𝑑(𝑠)=
𝑠
𝑠2+ 0.935𝑠 + 6336.3
Doing so we get the Root Locus plot shown in Figure 3.10 where I’ve found the closest points of intersection. Note the desired closed-loop poles in red.
53 Note that both the positive and negative real components of our desired closed loop poles result in approximately the same gain value of:
𝐾 = 24.4 And this produces a Derivative gain value of:
𝐾𝐷= 24.4
6336.3= 3.85𝑥10−3
𝑉 ∙ 𝑠 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠
2nd Iteration - Now let’s set 𝐾𝐷 to 3.85x10-3 and vary 𝐾𝑃. . This results in the following characteristic
equation: 𝑠2+ (0.935 + (318.3)(3.85𝑥10−3)(19.9))𝑠 + (0 + (318.3)𝐾 𝑃(19.9)) = 𝑠2+ 25.2𝑠 + 6336.3𝐾𝑃 Or: 1 + 6336.3𝐾𝑃∙ 1 𝑠2+ 25.2𝑠= 0
Using Matlab’s rlocus function where:
𝑠𝑦𝑠 = 1
𝑠2+ 25.2𝑠
We get the Root Locus plot shown in Figure 3.11. As you can see, this Root Locus plot goes through our desired closed-loop poles, which are estimated by Matlab to produce 4.57% of overshoot with a damping ratio of approximately 0.7 and natural frequency of 18rad/s. Our gain for these points is found to be:
𝐾 = 323 Which results in the Proportional gain of:
𝐾𝑃= 323
6336.3= 0.051
𝑉
𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠 And the following PD Controller:
54 Figure 3.11 – Root Locus Plot with 𝑲𝑫 = 3.85x10-3 and 𝑲𝑷 Varied
3.2.5 Conclusion
As expected, both methods produced almost identical gains for our PD Controller. Now let’s test our Controller. By modifying the Simulink model called base_closed_loop_model created earlier I got the results shown in Figure 3.12. I also added the 2nd order approximation as a means of comparison.
55 With respect to our PD Controller, the result shown in yellow in Figure 3.12 shows 20% overshoot but a rise time of 0.05s. This leads us to ask why our rise time is easily met but our overshoot is off when we designed our PD Controller to match the characteristics of our desired closed-loop poles. The short answer is that we didn’t factor in the result of our added zero by the addition of the Derivative term. Looking at the poles and zeros of our closed-loop system we get:
P1 and P2 @ -12.6 ± j12.82 and Z1 @ -13.32
As you’ll notice, the real portion of the poles and the zero are very close which would account for greater overshoot. As mentioned previously in Section 3.1.2, any additional zero within a factor of 4 of the real component of the nearest pole will have a noticeable effect. Comparing the rise times between the PD controlled system with the result of the 2nd order approximation, the PD controlled system is much quicker, which is a nice bonus of the additional zero.
With respect to the 2nd order approximation results, you’ll notice that the overshoot specification is met but the rise time is not. As mentioned previously, the 2nd Order Transient Response equations are an approximation and we’re noticing this inaccuracy. You’ll also notice that we now have a steady state error which was not there previously. Why is that? It’s because our 2nd order approximation, with its two complex poles has lost its zero in the denominator, reducing it to a Type 0 system.
3.2.6 Reality Check - Saturation
Digging a little deeper into our model highlights a problem with the physical limits of our system.