Practical Controller Design for Dummies

December 1, 2016 | Author: Manraj Tatla | Category: N/A
Share Embed Donate


Short Description

practical controller design for dummies...

Description

Practical Controller Design For Dummies By Chris McClellan

1

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.

Figure 1.0 –Gratuitous Puppy Shot 2

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).

R(s)

I(s)

E(s)

+



U(s) P(s)

C(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.

3

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: 𝑛

∑ 𝑉𝑘 = 0 𝑘=1

Where: 𝑉𝑘 is the voltage across element k of n total elements.

4

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. 3) Zero steady-state error to a unit step input.

5

Identify Elements of System

Make Assumptions and Simplifications of System

Derive a Model for each Element Except for the Controller and Plant

Create Plant Model

Apply First Principles Modeling

Analyze Transient and Steady-State Response

Apply Data Driven Modeling Techniques

Techniques Test Model

Is Plant Model Accurate Enough?

No

Yes

Can the System be Simplified Further?

Yes

No

Figure 2.1 – System Identification Flow Chart

6

Figure 2.2 – Top View of Brushed DC Motor System

Motor

Optical Encoder

Figure 2.3 – Side View of Brushed DC Motor System

7

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.

8

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

𝑝𝑢𝑙𝑠𝑒𝑠 𝑐𝑜𝑢𝑛𝑡𝑠 1 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛 𝑐𝑜𝑢𝑛𝑡𝑠 ∙4 ∙ = 318.3 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛 𝑝𝑢𝑙𝑠𝑒 2𝜋 𝑟𝑎𝑑𝑖𝑎𝑛𝑠 𝑟𝑎𝑑𝑖𝑎𝑛

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

𝑝𝑢𝑙𝑠𝑒𝑠 𝑐𝑜𝑢𝑛𝑡𝑠 1 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛 𝑐𝑜𝑢𝑛𝑡𝑠 ∙4 ∙ = 318.3 𝑟𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛 𝑝𝑢𝑙𝑠𝑒 2𝜋 𝑟𝑎𝑑𝑖𝑎𝑛𝑠 𝑟𝑎𝑑𝑖𝑎𝑛

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.

9

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].

La

Ra

θm T

ia +

Va

+

.

~

e=Keθm

-

M -

Jm

.

bθm

(b)

(a)

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 𝑑𝑡

𝑅𝑎 𝑖𝑎 + 𝐿𝑎

(2.0)

Where:

Ra

is the resistance of the motor’s armature in ohms,

ia

is the current flowing through the motor’s armature in amps,

La

is the inductance of the motor’s armature in henrys,

Ke

is the back emf coefficient in s∙V/rad,

𝜃̇𝑚

is the rotational velocity of the motor’s rotor in rad/s,

Va

is the voltage applied to the motor in volts.

10

Using Newton’s second law of motion on the motor’s rotor results in: 𝐾𝑡 𝑖𝑎 − 𝑏𝜃̇𝑚 = 𝐽𝑚 𝜃̈𝑚

(2.1)

Where:

Kt

is the torque motor constant in N∙m/A,

b

is the viscous friction coefficient in N∙m∙s,

Jm

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 + (𝑏𝑅𝑎 + 𝐾𝑡 𝐾𝑒 )𝑠

(2.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:

JT

is the combined rotational inertia in kg∙m2,

Ja

is the rotational inertia of the arm in kg∙m2,

Je

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.4)

11

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) = = 1.38𝑥10−6 𝑁 ∙ 𝑚 ∙ 𝑠 880.7 𝜃̇𝑚 12

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: 𝑙𝑎 2 𝐽𝑎1 = 𝑚𝑎 𝑟𝑎 2 = 𝑚𝑎 ( ) 2

(2.6)

Where: 𝑚𝑎 = 0.049 𝑘𝑔 𝑙𝑎 = 0.123 𝑚 By substituting these values into Equation 2.6, we get the following: 0.123 2 𝐽𝑎1 = (0.049) ( ) = 1.85𝑥10−4 𝑘𝑔 ∙ 𝑚2 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: 𝐽𝑇 = 𝐽𝑚 + 𝐽𝑎 + 𝐽𝑒 =

𝐾𝑡 𝑖𝑎 − 𝑏𝜃̇𝑚 𝜃̈𝑚

(2.7)

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.

13

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.

14

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

Figure 2.8 – Plot of the Motor Output vs. Time 15

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: ℎ = 𝑆𝑎𝑚𝑝𝑙𝑖𝑛𝑔 𝑃𝑒𝑟𝑖𝑜𝑑 = 𝑑𝑒𝑙𝑡𝑎 𝑡𝑖𝑚𝑒

16

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.

Figure 2.10 – Plot of the Angular Velocity vs. Time

17

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.

Figure 2.12 – Plot of the Combined Inertias vs. Time 18

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. vector_in

is the input vector to be filtered.

19

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.

20

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. 21

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).

Figure 2.18 - Plot of the Combined Inertias vs. Time 22

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: 𝑃(𝑠) =

𝑠3

109348.9 + 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.

23

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: Mode = 0, Step_Input = 100, I_Gain = 318.3, Time = 5 and Period 10.

24

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.

25

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 26

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 (𝑠) =

𝑠2

16.45 + 0.652𝑠

(2.8)

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.

27

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 ) 𝑧2 ∙ 𝑧1 ∙ 𝑧0 = (0 + 𝑝3 )(0 + 𝑝2 )(0 + 𝑝1 )(0 + 𝑝0 ) 𝑝3 ∙ 𝑝2 ∙ 𝑝1 ∙ 𝑝0

When s = 0. And you recognize that 𝑝2 is greater than 𝑝3, 𝑝1 and 𝑝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 ) 28

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)

(2.9)

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.

29

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.

30

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:

𝐾 𝑇𝑠 + 1

1 𝑠

Figure 2.27 – Proposed Plant Model

Note –

1 𝑇

= 𝜎, or the real portion of the pole.

31

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. 32

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:

Figure 2.30 - Comparison Plot of Plant Model and Actual Plant when Subjected to a Step Input 33

Figure 2.31 - Comparison Plot of Plant Model and Actual Plant when Subjected to a Ramp Input

Figure 2.32 - Comparison Plot of Plant Model and Actual Plant when Subjected to a Chirp Input

34

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

(2.10)

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].

35

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:

R(s)

I(s)

E(s)

+



U(s)

P(s)

KP

.

Y(s)

-

H(s)

Figure 3.0 – System with Proportional Controller 36

Start with a Proportional Controller

1st Order System?

Yes

Apply 1st Order Transient Response Equation

Yes

Apply 2nd Order Transient Response Equations

No

nd

2 Order System?

No Order of System > 2

Apply Root Locus Method as a Starting Point

Trial and Error

Test

Figure 3.1 – Flow Chart of Proportional Controller Design

37

Which results in the following transfer function: 𝑇(𝑠) =

(3.0)

𝑌(𝑠) 𝐾𝑃 ∙ 𝑃(𝑠) = 𝐼(𝑠) ∙ 𝑅(𝑠) 1 + 𝐾𝑃 ∙ 𝑃(𝑠) ∙ 𝐻(𝑠)

Or the following block diagram:

R(s)

𝐼(𝑠) ∙

𝐾𝑃 ∙ 𝑃(𝑠) 1 + 𝐾𝑃 ∙ 𝑃(𝑠) ∙ 𝐻(𝑠)

Y(s)

Figure 3.2 – Simplified System with Proportional Controller

3.1.1 1st Order 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 + 𝐾𝑃 𝐾 ∙ 𝐻(𝑠)

(3.1)

And: 𝐾 ′ 𝜎 = 𝐾𝑃 𝐾 ∙ 𝐼(𝑠)

(3.2)

Using either the Transient Response Equation for 1% settling time to a step input [9]: 𝑡𝑠 =

4.6 𝜎

(3.3)

38

Or the Transient Response Equation for rise time for a step input [9]: 𝑡𝑟 =

2.2 𝜎

(3.4)

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 2nd Order 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 ) 𝑇(𝑠) = = 𝐼(𝑠) ∙ = 2 𝐾 𝑅(𝑠) 1 + 𝐾𝑃 ∙ ( ) ∙ 𝐻(𝑠) 𝑠 + (𝜎1 + 𝜎2 )𝑠 + (𝜎1 𝜎2 + 𝐾𝑃 𝐾 ∙ 𝐻(𝑠)) (𝑠 + 𝜎1 )(𝑠 + 𝜎2 ) Or in standard form: 𝑇(𝑠) =

𝑌(𝑠) 𝐾 ′ 𝜔𝑛2 = 2 𝑅(𝑠) 𝑠 + 2𝜉𝜔𝑛 𝑠 + 𝜔𝑛2

Where: 𝜔𝑛2 = 𝜎1 𝜎2 + 𝐾𝑃 𝐾 ∙ 𝐻(𝑠)

(3.5)

2𝜉𝜔𝑛 = 𝜎1 + 𝜎2

(3.6)

𝐾 ′ 𝜔𝑛2 = 𝐾𝑃 𝐾 ∙ 𝐼(𝑠)

(3.7)

And:

And:

39

Depending on which specifications are given, use the following Transient Response Equations for a step input [11]. For the rise time: 𝑡𝑟 =

1.8 𝜔𝑛

(3.8)

For an underdamped system, the percentage of overshoot: 2

𝑀𝑝 = 𝑒 −𝜋𝜉⁄√1−𝜉 , 0 ≤ 𝜉 < 1

(3.9)

Which occurs at the peak time of: 𝜋 𝜔𝑑

𝑡𝑝 =

(3.10)

Where: 𝜔𝑑 = 𝜔𝑛 √1 − 𝜉 2

(3.11)

For a 1% settling time: 4.6 𝜎

(3.12)

𝜎 = 𝜉𝜔𝑛

(3.13)

𝑡𝑠 = Where:

Im(s)

Im(s)

Im(s)

𝜃 = 𝑠𝑖𝑛−1 𝜉

𝜎

𝜔𝑛 Re(s)

Re(s)

Re(s)

Figure 3.3 – Graphs of Regions in the S-Plane for Rise Time, Overshoot and 1% Settling Time Respectively for a Step Input [11]

40

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.

41

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.

R(s)

I(s)

E(s)

+



P(s)

KP

.

Y(s)

-

H(s)

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)

< 𝐾𝑃(𝑠) ∙ 𝐻(𝑠) = ±180°(2𝑘 + 1)

(3.16)

And the angle:

42

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 ( ) 𝑎

(3.19)

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].

43

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 2𝜉

(3.20)

44

By substituting our values for 𝜎1 , 𝜎2 and 𝜉 into Equation 3.20 results in: 𝜔𝑛 =

0 + 0.935 = 0.67 𝑟𝑎𝑑/𝑠 2(0.7)

Rearranging Equation 3.5 for 𝐾𝑃 results in: 𝐾𝑃 =

𝜔𝑛2 − 𝜎1 𝜎2 𝐾 ∙ 𝐻(𝑠)

(3.21)

By substituting our values for 𝜔𝑛 , 𝜎1 , 𝜎2 , 𝐾 and 𝐻(𝑠) into Equation 3.21 results in: 𝐾𝑃 =

(0.67)2 − (0)(0.935) 𝑉 = 7.04𝑥10−5 19.9(318.3) 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠

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 2 nd Order Transient Response Equations for rise time and compare.

Figure 3.5 – Unit Step Response for KP of 7.04x10-5

45

3.1.6.2 𝑲𝑷 Calculation Based on Rise Time Rearranging Equation 3.8 for 𝜔𝑛 results in: 𝜔𝑛 =

1.8 𝑡𝑟

(3.22)

And substituting our value for 𝑡𝑟 into Equation 3.22 results in: 𝜔𝑛 =

1.8 = 18 𝑟𝑎𝑑/𝑠 0.1

And substituting our values for 𝜔𝑛 , 𝜎1 , 𝜎2 , 𝐾 and 𝐻(𝑠) into Equation 3.21 results in: 𝐾𝑃 =

(18)2 − (0)(0.935) 𝑉 = 0.051 19.9(318.3) 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠

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

46

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: 𝑠𝑑1,2 = −𝜎 ± 𝑗𝜔𝑑 = −𝜉𝜔𝑛 ± 𝑗𝜔𝑛 √1 − 𝜉 2

(3.23) 47

𝑠𝑑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 closedloop 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.

No Too much Overshoot?

Apply Proportional plus Integral Control

Yes

Too much Steady State Error?

No

Apply Proportional plus Derivative Control

Yes Apply PID Control

Figure 3.8 – Flowchart for PI, PD and PID Controller Design 48

nd

Apply 2 Order Transient Response Equations as a Starting Point

Yes Order = 2?

2 Specifications Given and No Zero in Plant?

No

Apply Root Contour Iteration

Yes

No Apply Root Contour Iteration

Apply Coefficient Mapping

Test

Trial and Error

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 closedloop poles. From the generic system model we have the following characteristic equation: 1 + 𝐶(𝑠) ∙ 𝑃(𝑠) ∙ 𝐻(𝑠) = 0

(3.24)

Where a PD Controller is: 𝐶(𝑠) = 𝐾𝑃 + 𝐾𝐷 𝑠

49

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𝑎 𝑑0 + 𝐻1 𝐾𝑃 𝐾 = 𝑎2 + 𝑏 2

(3.26) (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].

50

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 2(12.6) − 0.935 𝑉∙𝑠 = = 3.83𝑥10−3 𝐻1 𝐾 318.3(19.9) 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠

By using Equation 3.27 and rearranging for 𝐾𝑃 we get: 𝑎2 + 𝑏 2 − 𝑑0 (12.6)2 + (12.85)2 − 0 𝑉 𝐾𝑃 = = = 0.051 𝐻1 𝐾 318.3(19.9) 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠 Which gives us the following PD Controller: 𝐶(𝑠) = 𝐾𝑃 + 𝐾𝐷 𝑠 = 0.051 + 3.83𝑥10−3 𝑠

51

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 + 0.935𝑠 + 6336.3

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.

Figure 3.10 – Root Locus Plot with 𝑲𝑷 = 1 and 𝑲𝑫 Varied 52

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 𝑉∙𝑠 = 3.85𝑥10−3 6336.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𝐾𝑃 ∙

𝑠2

1 =0 + 25.2𝑠

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 𝑉 = 0.051 6336.3 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠

And the following PD Controller: 𝐶(𝑠) = 𝐾𝑃 + 𝐾𝐷 𝑠 = 0.051 + 3.85𝑥10−3 𝑠

53

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.

Figure 3.12 - Unit Step Response for PD Controlled System and 2nd Order Approximation 54

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.

Figure 3.13 – System Model 55

However, before I get into the problem, let me first explain the system model shown in Figure 3.13. I’ve created 3 separate models that get routed through a multiplexer to be plotted on the same graph. One of the quirks I found in Matlab is that a function block has to be proper. That means that the order of the denominator must be equal or greater than the order of the numerator. This means that you can’t implement a PD or PID Controller using a function block. To work around this, in the top model I switched the numerator of the Plant with the numerator of the Controller. A little confusing but it works. However, it creates another problem in that I can’t monitor the Controller Output Signal U(s). To work around this I created a second model using Matlab’s PD Controller transfer function. Now I’m sure you’re going to ask ‘Why didn’t I use it in the first place dummy?’. I would have liked to but Matlab implements their PD Controller using the following equation: 𝑃𝐷 𝐶𝑜𝑛𝑡𝑟𝑜𝑙𝑙𝑒𝑟 = 𝑃 + 𝐷

𝑁 1+𝑁

1 𝑠

Searching the documentation they call their Derivative implementation a ‘Filtered Derivative’ where N determines the pole location. This high-pass filter is used to get around the original quirk I found where the transfer function has to be proper. (This kind of Filtered Derivative is also called a Phase Lead Controller. See Section 4.3 for more information.) I was able to achieve matching results between the top two models when I set N to 1000, which puts the pole at 1000rad/s and well outside the system’s bandwidth. (For more information in system bandwidth see Section 5.1.1) Now that the second model works I was able to add a scope after the PD Controller function block and found the following:

Figure 3.14 – Controller Output Signal Response from Unit Step Input 56

It may be a little hard to tell by Figure 3.14 but the Controller Output Signal initially jumps to 1400V then settles out to something a little more reasonable. Realistically though, we don’t have a power supply that could source the lethal voltage of 1400V. Furthermore, even if we could find that kind of power, it would surely fry the motor controller and the motor itself. For our tests we’ve been running the motor off a 12V power supply so to model this physical limitation, as shown in Figure 3.15, I’ll add a saturation block after the Controller.

Figure 3.15 – Saturation Block in Simulink Model

As shown in the plot from the scope placed after the saturation block in Figure 3.16, the voltage supplied to the Plant is now limited to ±12V.

Figure 3.16 - Controller Output Signal Response After Saturation Block from Unit Step Input

However, as shown in Figure 3.17, the addition of the saturation block has a drastic effect on our system’s performance (shown in purple). Our system response to a step input with the addition of the saturation block now resembles the 2nd order approximation in that the overshoot is close to our specification but the rise time is quite sluggish. What do we do next? 57

3.2.7 Trial and Error Our first stab at developing a PD Controller was close but still needs some tweaking, but how? Since our most salient problem seems to be rise time, and since we know from Figure 3.3 the rise time is governed by the system’s natural frequency, let’s keep our damping frequency the same and increase 𝜔𝑛 . By increasing the natural frequency arbitrarily to 25 rad/s we get the following desired closed-loop poles: 𝑠𝑑1,2 = −𝜉𝜔𝑛 ± 𝑗𝜔𝑛 √1 − 𝜉 2 = −0.7(25) ± 𝑗25√1 − (0.7)2 = −17.5 ± 𝑗17.8

Figure 3.17 – Unit Step Response of PD Controlled System Without Saturation Block, With Saturation Block and 2nd Order Approximation Without Saturation Block

Using Equation 3.26 and rearranging for the Derivative gain we get: 𝐾𝐷 =

2𝑎 − 𝑑1 2(17.5) − 0.935 𝑉∙𝑠 = = 5.4𝑥10−3 𝐻1 𝐾 318.3(19.9) 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠

And using Equation 3.27 and rearranging for the Proportional gain we get: 𝐾𝑃 =

𝑎2 + 𝑏 2 − 𝑑0 (17.5) + (17.8)2 − 0 𝑉 = = 0.1 𝐻1 𝐾 318.3(19.9) 𝑒𝑛𝑐𝑜𝑑𝑒𝑟 𝑐𝑜𝑢𝑛𝑡𝑠

And the following PD Controller: 𝐶(𝑠) = 𝐾𝑃 + 𝐾𝐷 𝑠 = 0.1 + 5.4𝑥10−3 𝑠 58

As shown in Figure 3.18, our new PD Controller, shown in purple, meets all our specifications with an overshoot of 3.7% and a rise time of 0.9s. You’ll also notice that it has zero steady-state error for a step input. The next step is to validate our Controller by implementing it on our physical system and then to look into its stability. However, before we do that let’s talk about PI and PID control and then look into Phase Lead/Lag Controller Design and Feedforward Design.

Figure 3.18 – Unit Step Response of PD Controlled System Without Saturation Block, With Saturation Block and 2nd Order Approximation

3.3 Proportional plus Integral Control (PI Control) Following Figure 3.8, if your Proportional Controller produces too much steady state error but the overshoot is acceptable, apply Proportional plus Integral Control as shown in Figure 3.19. Since a PI Controller adds both a zero and a pole to the closed-loop transfer function, our 2nd 0rder Transient Response Equations do not directly apply; however, they can be used as a starting point. If you’ve been given 1 time domain specification to a step input you will end up with a region 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 first 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.

59

3.3.1 Integral Windup One of the unique side effects from the addition of the Integral term is something called Integral Windup. This applies to both PI and PID Controllers. Because the Integral term accumulates the error between the desired reference and the actual output, when a large change in set-point occurs, the output will continue to overshoot until the error accumulated before reaching the set-point equals the error accumulated while exceeding the set-point. There are many techniques to combat this phenomenon but they’re beyond the scope of this course.

nd

Apply 2 Order Transient Response Equations as a Starting Point

Yes Order = 1?

2 Specifications Given and No Zero in Plant?

No

Apply Root Contour Iteration

Yes

No Apply Root Contour Iteration

Apply Coefficient Mapping

Test

Trial and Error

Figure 3.19 – Flowchart for PI Controller Design

60

3.4 Proportional plus Integral plus Derivative Control (PID Control) Following Figure 3.8, if your Proportional Controller produces too much steady state error and too much overshoot, apply Proportional plus Integral plus Derivative Control as shown in Figure 3.20. Since a PID Controller adds a zero and two poles to the closed-loop transfer function, our 2nd order Transient Response Equations do not directly apply; however, they can be used as a starting point for Root Contour Iteration. Keep in mind that this method 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.

Aside - For another technique on tuning a PID Controller, try the Zeigler-Nichols Method.

nd

Apply 2 Order Transient Response Equations as a Starting Point

Apply Root Contour Iteration

Test

Trial and Error

Figure 3.20 – Flowchart for PID Controller Design

61

3.5 Steady State Error Design Using the Final Value Theorem we can calculate the Steady State Error, as shown below: 𝑒𝑠𝑠 = lim 𝑒(𝑡) = lim 𝑠𝐸(𝑠) = lim 𝑠[ 𝑅(𝑠)𝐼(𝑠) − 𝐻(𝑠)𝑌(𝑠)] 𝑡→∞

𝑠→0

𝑠→0

𝑒𝑠𝑠 = lim 𝑠 𝑅(𝑠)𝐼(𝑠) [1 − 𝑠→0

𝑒𝑠𝑠 = lim 𝑠 𝑅(𝑠)𝐼(𝑠) [ 𝑠→0

𝐻(𝑠) 𝐶(𝑠)𝑃(𝑠) ] 1 + 𝐶(𝑠)𝑃(𝑠)𝐻(𝑠)

1 ] 1 + 𝐶(𝑠)𝑃(𝑠)𝐻(𝑠)

Fortunately, this type of calculation is quite common and a table based on system Type for common inputs is available. As shown in Table 3.0 we have the Steady State Errors for Step inputs, Ramp Inputs and Parabola inputs based on the system Type. The system Type is based on the total number of poles at the origin or integrator terms in the Controller C(s), the Plant P(s) and the Feedback Transfer Function H(s).

System Type

Step Input

Ramp Input

𝐼(0) 1 + 𝐶(0)𝑃(0)𝐻(0)

Type 0 Type 1

0

Type 2

0

Parabola Input





𝐼(0) 𝐶(0)𝑃(0)𝐻(0)



0

𝐼(0) 𝐶(0)𝑃(0)𝐻(0)

Table 3.0 – Steady State Errors as a Transfer Function Type

62

4.0 Controller Design – Phase 2 Now that we’ve had a chance to try our hand at different forms of PID Controllers, let’s try some more advanced techniques. First, let’s try Phase Lead/Lag Controllers

4.1 Phase Lead/Lag Controllers Interestingly, a Phase Lead Controller is much like a PD Controller in that it acts to speed up response and increasing stability by shifting the Root Locus to the left. Furthermore, a Phase Lag Controller is much like a PI Controller in that it attempts to eliminate steady-state error by shifting the Root Locus to the right. For myself, I like to think of Phase Lead/Lag Controllers as hybrid Controllers. In the case of a Phase Lead Controller, we start with the following general equation but set p greater than z: 𝐶𝐿𝑒𝑎𝑑/𝐿𝑎𝑔 (𝑠) =

𝑠+𝑧 𝑠+𝑝

If we arbitrarily set z equal to 1 and p equal to 10 and compare it to a PD Controller with unity gains we get the following Bode Diagram:

PD Controller Phase Lead Controller

Figure 4.0 – Bode Diagram of Phase Lead Controller vs PD Controller 63

When comparing the Bode Diagrams in Figure 4.0 you’ll notice that both Magnitude plots start to ramp at 20dB per decade at 1rad/s or the location of the zero. However, because of the pole in the denominator of the Phase Lead Controller, its Magnitude plot levels off at 10rad/s where the Magnitude plot for the PD Controller continues to ramp indefinitely. You’ll also notice one of the drawbacks of the Phase Lead Controller in the reduction in magnitude at low frequencies. Furthermore, the Phase Lead Controller produces a hump in its Phase plot centered in between its zero and pole locations, starting at 0 degrees and ending at 0 degrees where the Phase plot for the PD Controller starts at 0 degrees and ramps up to 90 degrees where it levels off. The length, height and centre point of this hump is the focus of Phase Lead Controller design in the effort to increase Phase Margin. Conversely, a Phase Lag Controller produces a valley centered about its zero and pole locations (Figure 4.1). This is the consequence of having z greater than p. This valley is actually the main drawback of Phase Lag Controller design. Instead, the focus of Phase Lag Controller design is to balance the sideeffects of the phase lag distortion by appropriately designing the size and location of this valley in order to boost the gain of the system at low frequencies, thereby improving steady-state tracking performance and disturbance rejection. As shown in Figure 4.1, both Controllers boost low frequency gain.

PI Controller Phase Lag Controller

Figure 4.1 – Bode Diagram of Phase Lag Controller vs. PI Controller

64

4.1.2 Introduction to Gain and Phase Margins The concept of Gain and Phase Margins are best explained with the use of an example. Consider the following closed-loop system:

R(s)

1.5

+



1 𝑠+1

𝑠2

2 + 2𝑠 + 1

.

Y(s)

-

1.5

Figure 4.2 – Block Diagram of Example Closed-Loop System

Using Matlab’s margin(sys) function for an open-loop system where: 𝑠𝑦𝑠 = 𝐼(𝑠) ∙ 𝐶(𝑠) ∙ 𝑃(𝑠) And for our example: 𝑠𝑦𝑠 = 1.5 ∙

1 2 ∙ 2 𝑠 + 1 𝑠 + 2𝑠 + 1

We get the Bode Diagram shown in Figure 4.3. Matlab tells us that the Gain Margin is 8.52dB at the Phase Crossover Frequency 𝜔𝑐𝑝 of 1.73rad/s and I’ve added an arrow to indicate this. The Gain Margin is calculated using the following equation: 𝐺𝑎𝑖𝑛 𝑀𝑎𝑟𝑔𝑖𝑛 = 0𝑑𝐵 − 𝐺𝑎𝑖𝑛 Where Gain is the distance between the curve and 0dB at the Phase Crossover Frequency 𝜔𝑐𝑝 . Notice that if the Gain Margin is below 0dB at the Phase Crossover Frequency the Gain is negative resulting in a positive Gain Margin and if it’s above 0dB the Gain is positive, resulting in a Gain Margin that’s negative. If the Phase plot never dips below -180°, the Gain Margin is considered to be infinite. Matlab has also calculated our Phase Margin to be 41.7° at the Gain Crossover Frequency 𝜔𝑐𝑔 of 1.04 rad/s and I’ve added an arrow to indicate this. The Phase Margin is calculated using the following equation: 𝑃ℎ𝑎𝑠𝑒 𝑀𝑎𝑟𝑔𝑖𝑛 = 180° + 𝑃ℎ𝑎𝑠𝑒 Where Phase is the value of the curve at the Gain Crossover Frequency 𝜔𝑐𝑔 . Notice that if the Phase Margin is above -180° the Phase Margin is positive and if the Phase Margin is below -180° the Phase Margin is negative. If the Magnitude plot never dips below 0dB, the Phase Margin is considered to be infinite. 65

𝜔𝑐𝑔

Phase Margin

Gain Margin

𝜔𝑐𝑝

Figure 4.3 – Bode Diagram of Example Closed-Loop System

When designing a Controller, the conservative rule of thumb for stability margins are: 𝐺𝑎𝑖𝑛 𝑀𝑎𝑟𝑔𝑖𝑛 ≥ 10𝑑𝐵 and 𝑃ℎ𝑎𝑠𝑒 𝑀𝑎𝑟𝑔𝑖𝑛 ≥ 60° However, some texts promote typical stability margins as low as: 𝐺𝑎𝑖𝑛 𝑀𝑎𝑟𝑔𝑖𝑛 ≥ 6𝑑𝐵 and 𝑃ℎ𝑎𝑠𝑒 𝑀𝑎𝑟𝑔𝑖𝑛 ≥ 30° The idea behind the Gain and Phase Margins are that they provide a factor of safety. If you were walking along the a cliff, would you feel comfortable with walking right along the edge, or would say 10 feet from the edge make you feel more comfortable? With experience you’ll know when you can get away with less conservative stability margins but for now it would probably be wise to stick with the conservative approach. 66

4.1.3 Phase Lead Controller Design Following Figure 4.4, if your Proportional Controller produces too much overshoot but the steady state error is acceptable, apply Phase Lead Control.

No Apply Phase Lag Control

Too much Overshoot?

Yes

Too much Steady State Error?

No

Apply Phase Lead Control

Yes Apply Phase Lead and Lag Control

Figure 4.4 – Flowchart for Phase Lead/Lag Controller Design

Following the procedure laid out by Prof. Dan Davison in his SYDE 352 Course Notes [13], our objective is to satisfy the specifications using: 𝐶(𝑠) = 𝐾 ∙ 𝐶𝐿𝑒𝑎𝑑 (𝑠) = 𝐾

1 1 + 𝑎𝑇𝑠 √𝑎 1 + 𝑇𝑠

(4.0)

Where: K = Controller gain a = ratio of pole position to zero positon (a > 1) T = pole time constant (T > 0)

67

Which results in the following Bode Diagram:

20𝑙𝑜𝑔10 √𝑎

0

-20𝑙𝑜𝑔10 √𝑎 𝜙𝑚

0

1 𝑎𝑇

𝜔𝑚

1 𝑇

Figure 4.5 – Bode Diagram of General Phase Lead Controller

Step 1: Sketch the Bode plot of the open-loop system. As shown in Figure 2.0, our open-loop system will consist of: 𝑇𝑜𝑙 = 𝐼(𝑠) ∙ 𝐶(𝑠) ∙ 𝑃(𝑠) Where: 𝐶(𝑠) = 1 Step 2: If a desired Gain Crossover Frequency 𝜔𝑐𝑔 is known, adjust the gain K so that the Gain Crossover Frequency of K∙P(s) is equal to the desired Gain Crossover frequency. Accomplish this by trial and error with Matlab’s margin function or by inspection of the Bode Diagram and convert the value in dB using the following equation: 𝐾 = 10

(

𝑑𝐵 𝑣𝑎𝑙𝑢𝑒 ) 20

68

Set: 𝜔𝑚 = 𝜔𝑐𝑔 OrUsing the Final Value Theorem, calculate the gain K to meet the steady-state error specification and add a buffer of 10dB in anticipation of the decrease in gain that will result from the Lead Controller. Set: 𝜔𝑚 = 𝜔𝑐𝑔 OrIf no specifications are given that the gain can influence, set: 𝐾 = 1 𝑎𝑛𝑑 𝜔𝑚 = 𝜔𝑐𝑔 Step 3: Determine the Phase Margin of the augmented open-loop system where: 𝑠𝑦𝑠 = 𝐼(𝑠) ∙ 𝐾 ∙ 𝑃(𝑠) Step 4: Determine the additional phase lead 𝜙𝑚 required to meet the Phase Margin required. If no Phase Margin has been specified, use the following approximation to determine the desired Phase Margin for a Second Order System: 𝑃𝑀𝑑 ≈ 100𝜉,

𝑤ℎ𝑒𝑟𝑒 0 ≤ 𝜉 ≤ 0.7

Or the rule of thumb of: 𝑃𝑀𝑑 ≥ 60° If the phase lead 𝜙𝑚 is greater than 60̇°, using two Phase Lead Controllers, each contributing 𝜙𝑚 /2. Step 5: Use the phase lead 𝜙𝑚 to compute the ratio of the pole position to the zero position by: 𝑎=

1 + 𝑠𝑖𝑛𝜙𝑚 1 − 𝑠𝑖𝑛𝜙𝑚

(4.1)

Step 6: Compute the pole time constant using: 𝑇=

1 𝜔𝑚 √𝑎

(4.2)

Step 7: Test to see if specifications are met. If not, go back to Step 1.

69

4.1.4 Example Continued – Phase Lead Controller Design Since our P Controller produced too much overshoot but the steady-state error specification was met, let’s try a Phase Lead Controller. Following the procedure laid out in Section 4.1.3, our first step is to plot the Bode Diagram of our open-loop system. As shown in Figure 4.6, we have a: 𝐺𝑎𝑖𝑛 𝑀𝑎𝑟𝑔𝑖𝑛 = ∞ and 𝑃ℎ𝑎𝑠𝑒 𝑀𝑎𝑟𝑔𝑖𝑛 = 0.676° @79.2𝑟𝑎𝑑/𝑠

Figure 4.6 – Bode Diagram of Open-Loop Example System

Clearly our Phase Margin needs some adjustment. Since a Gain Crossover Frequency has not been given and our steady-state error for a step input has been satisfied by our Type 1 system, we’ll set: 𝐾 = 1 and 𝜔𝑚 = 𝜔𝑐𝑔 = 79.2𝑟𝑎𝑑/𝑠 Since we have a K value of 1, the augmented Phase Margin is the same as our original Phase Margin of: 𝑃ℎ𝑎𝑠𝑒 𝑀𝑎𝑟𝑔𝑖𝑛 = 0.676°

70

Since our Plant is second order, we can use the damping ratio based on the percentage of overshoot to calculate our desired Phase Margin of: 𝑃𝑀𝑑 ≈ 100𝜉 = 100(0.7) = 70° Therefore our additional phase lead required is: 𝜙𝑚 = 𝑃𝑀𝑑 − 𝑃𝑀 = 70° − 0.676° = 69.324° However, this additional phase lead is greater than 60°, so we’ll have to design for two Controllers, each contributing half the additional phase lead of: 𝜙𝑚 =

69.324° = 34.662° 2

Using Equation 4.1 we can compute the pole/zero ratio. 𝑎=

1 + 𝑠𝑖𝑛𝜙𝑚 1 + sin(34.662) = = 3.64 1 − 𝑠𝑖𝑛𝜙𝑚 1 − 𝑠𝑖𝑛(34.662)

Using Equation 4.2 we can compute the pole time constant. 𝑇=

1 𝜔𝑚 √𝑎

=

1 79.2√3.64

= 6.62𝑥10−3 𝑠𝑒𝑐𝑜𝑛𝑑𝑠

Using the parameters just calculated, we get the following Phase Lead Controller: 𝐶(𝑠) = 𝐾

1 1 + 𝑎𝑇𝑠 1 1 + 3.64(6.62𝑥10−3 )𝑠 1 + 0.024𝑠 = (1) = 0.52 −3 1 + 6.62𝑥10 𝑠 1 + 6.62𝑥10−3 𝑠 √𝑎 1 + 𝑇𝑠 √3.64

However, since we had to create two equal Controllers to get the additional phase lead required we’ll put them in series like this: 𝐶(𝑠) = 0.52

1 + 0.024𝑠 1 + 0.024𝑠 ∙ 0.52 −3 1 + 6.62𝑥10 𝑠 1 + 6.62𝑥10−3 𝑠

Or: 𝐶(𝑠) = 0.25

1 + 0.024𝑠 1 + 0.024𝑠 ∙ −3 1 + 6.62𝑥10 𝑠 1 + 6.62𝑥10−3 𝑠

By modifying the Simulink model called base_closed_loop_model created earlier, I tested our Phase Lead Controller versus the PD Controller designed earlier. As shown in Figure 4.7, the overshoot is approximately 3.6% and the rise time is 0.077s, both below the specifications and better than the PD Controller. You’ll also notice that both Controllers produce zero steady-state error for a step input.

71

Figure 4.7 - PD Controller vs Phase Lead Controller for a Step Input

Out of interest I rechecked the Gain and Phase Margins for our new Phase Lead Controller. As shown in Figure 4.8, our Gain Margin has stayed at infinity and our Phase Margin has increased to 69.6°. You’ll also notice that the Magnitude Plot of the open-loop system with the Controller has been shifted down before the Gain Crossover Frequency and shifted up after. This was one of the expected side effects of the Phase Lead Controller. However, the Phase Plot shows a pronounced hump at the Gain Crossover Frequency which created the boost in Phase Gain we were looking for.

Figure 4.8 – Bode Diagram of Open-Loop System With and Without Phase Lead Controller 72

We now have 2 Controllers we will need to validate, but before we do, let’s look at two more Controllers.

4.2 Phase Lag Controller Design Following Figure 4.4, if your Proportional Controller produces too much steady state error but the overshoot is acceptable, apply Phase Lag Control. Following the procedure laid out by Prof. Dan Davison in his SYDE 352 Course Notes [13], our objective is to satisfy the specifications using: (4.3) 1 + 𝑇𝑠 𝐶(𝑠) = 𝐾 ∙ 𝐶𝐿𝑎𝑔 (𝑠) = 𝐾𝑎 1 + 𝑎𝑇𝑠 Where: K = Controller gain a = ratio of zero position to pole positon (a > 1) T = zero time constant (T > 0)

Which results in the following Bode Diagram:

20𝑙𝑜𝑔10 𝑎

0 0 0

𝜙𝑚 1 𝑎𝑇

𝜔𝑚

1 𝑇

Figure 4.9 – Bode Diagram of General Phase Lag Controller 73

Step 1: Sketch the Bode plot of the open-loop system. As shown in Figure 2.0, our open-loop system will consist of: 𝑇𝑜𝑙 = 𝐼(𝑠) ∙ 𝐶(𝑠) ∙ 𝑃(𝑠) Where: 𝐶(𝑠) = 1 Step 2: If a desired Gain Crossover Frequency 𝜔𝑐𝑔 is known, adjust the gain K so that the Gain Crossover Frequency of K∙P(s) is equal to the desired Gain Crossover frequency. Accomplish this by trial and error with Matlab’s margin function or by inspection of the Bode Diagram and convert the value in dB using the following equation: 𝐾 = 10

(

𝑑𝐵 𝑣𝑎𝑙𝑢𝑒 ) 20

Set: 𝜔𝑚 = 𝜔𝑐𝑔 OrIf the desired Phase Margin is known, adjust the gain K so that Phase Margin of K∙P(s) is the desired value plus an extra 5° in anticipation of the loss of Phase Margin that will occur when we include the lag compensation. Set: 𝜔𝑚 = 𝜔𝑐𝑔 If no Phase Margin has been specified, use the following approximation to determine the desired Phase Margin for a Second Order System: 𝑃𝑀𝑑 ≈ 100𝜉,

𝑤ℎ𝑒𝑟𝑒 0 ≤ 𝜉 ≤ 0.7

Or the rule of thumb of: 𝑃𝑀𝑑 ≥ 60° If it is not possible to get the desired Phase Margin, then a Phase Lead Controller will be required to boost the Phase Margin. Skip to Section 4.3. Step 3: Using the Final Value Theorem, determine if the steady-state error has been satisfied by the augmented Plant K∙P(s). If it is, then you don’t need a Phase Lag Controller because a P Controller will suffice. Otherwise, determine the extra gain factor that you need to satisfy the steady-state error. This is the value of a. If a is greater than 15, use two Phase Lag Controllers, each contributing a gain factor of √𝑎.

74

Step 4: Use the Gain Crossover Frequency 𝜔𝑐𝑔 of K∙P(s) to calculate the zero time constant by: 10 (4.4) 𝑇= 𝜔𝑐𝑔 Step 5: Test to see if specifications are met. If not, go back to Step 1.

4.3 Phase Lead/Lag Controller Design Sometimes the Design Specifications cannot be met by using a Phase Lead Controller or a Phase Lag Controller alone, but only by using a combination of lead and lag compensation. The Phase Lag Controller is used at low frequencies to boost the Gain, and the Phase Lead Controller is used at midfrequencies (near the Gain Crossover Frequency) to improve Phase Margin [13]. Following the procedure laid out by Prof. Dan Davison in his SYDE 352 Course Notes [13], our objective is to satisfy the specifications using: 1 1 + 𝑎𝑇𝑠 1 + 𝑇′𝑠 𝐶(𝑠) = 𝐾 ∙ 𝐶𝐿𝑒𝑎𝑑 𝐶𝐿𝑎𝑔 = 𝐾 ( ) (𝑎′ ) 1 + 𝑎′𝑇′𝑠 √𝑎 1 + 𝑇𝑠

(4.5)

Where: K = Controller gain a = ratio of pole position to zero positon (a > 1) T = pole time constant (T > 0) a’ = ratio of zero position to pole positon (a’ > 1) T’ = zero time constant (T’ > 0)

Step 1: Sketch the Bode plot of the open-loop system. As shown in Figure 2.0, our open-loop system will consist of: 𝑇𝑜𝑙 = 𝐼(𝑠) ∙ 𝐶(𝑠) ∙ 𝑃(𝑠) Where: 𝐶(𝑠) = 1 Step 2: If a desired Gain Crossover Frequency 𝜔𝑐𝑔 is known, adjust the gain K so that the Gain Crossover Frequency of K∙P(s) is equal to the desired Gain Crossover frequency. Accomplish this by trial and error with Matlab’s margin function or by inspection of the Bode Diagram and convert the value in dB using 75

the following equation: 𝐾 = 10

(

𝑑𝐵 𝑣𝑎𝑙𝑢𝑒 ) 20

Set: 𝜔𝑚 = 𝜔𝑐𝑔 OrUsing the Final Value Theorem, calculate the gain K to meet the steady-state error specification and add a buffer of 10dB in anticipation of the decrease in gain that will result from the Lead Controller. Set: 𝜔𝑚 = 𝜔𝑐𝑔 OrIf no specifications are given that the gain can influence, set: 𝐾 = 1 𝑎𝑛𝑑 𝜔𝑚 = 𝜔𝑐𝑔 Step 3: Determine the Phase Margin of the augmented open-loop system where: 𝑠𝑦𝑠 = 𝐼(𝑠) ∙ 𝐾 ∙ 𝑃(𝑠) Step 4: Determine the additional phase lead 𝜙𝑚 required to meet the Phase Margin required. Be sure to add an extra 5° to offset the effects of the Phase Lag Controller. If no Phase Margin has been specified, use the following approximation to determine the desired Phase Margin for a Second Order System: 𝑃𝑀𝑑 ≈ 100𝜉,

𝑤ℎ𝑒𝑟𝑒 0 ≤ 𝜉 ≤ 0.7

Or the rule of thumb of: 𝑃𝑀𝑑 ≥ 60° If the phase lead 𝜙𝑚 is greater than 60̇°, using two Phase Lead Controllers, each contributing 𝜙𝑚 /2. Step 5: Use Equation 4.1 to compute the ratio of the pole position to the zero position. Step 6: Use Equation 4.2 to compute the pole time constant. Step 7: Using the Final Value Theorem, determine the extra gain factor that you need to satisfy the steady-state error for the augmented Plant 𝐾 ∙ 𝐶𝐿𝑒𝑎𝑑 . This is the value of a’. If a’ is greater than 15, use two Phase Lag Controllers, each contributing a gain factor of √𝑎.

76

Step 8: Use the Gain Crossover Frequency 𝜔𝑐𝑔 of 𝐾 ∙ 𝐶𝐿𝑒𝑎𝑑 to calculate the zero time constant by: 𝑇′ =

10 𝜔𝑐𝑔

(4.6)

Step 9: Test to see if specifications are met. If not, go back to Step 1.

4.4 Feedforward Design There seems to be two very different topologies that are considered Feedforward Design. The one topology attempts to read and react to disturbances in an effort to account for future deviations. Basically, this topology attempts to control the disturbances. I would consider this a multi input, single output system and not a true Feedforward system. Instead we’ll consider the following arrangement:

F(s)

R(s)

.

I(s)

E(s)

+ ∑

C(s)

+

+ P(s)



.

Y(s)

U(s)

-

H(s)

Figure 4.10 – Typical Feedforward Control Topology

With this topology, a transfer function connects the Reference Input Signal R(s) with the Controller Output Signal U(s). By adding the Feedforward transfer function in parallel with the Controller, a second degree of freedom is added to the system, meaning that the Controller and the Feedforward transfer functions can be designed separately. In comparison, the topology previously discussed in Figure 2.0 is considered a one degree of freedom system. By adding the second degree of freedom, the Controller can be designed so that the error transfer function has certain desirable characteristics where the Feedforward transfer function can be selected to help satisfy the performance requirements with reference to the input/output relationship. Other benefits to this design are that it unburdens the Controller feedback loop because, under ideal circumstances, the Feedforward path generates most of the signal, thereby allowing the Controller to provide only corrections and to respond to disturbances or

77

modelling inaccuracies. Problems with the Feedforward topology include requiring accurate knowledge of the system to be controlled and extra computation requirements. By looking at the closed-loop transfer function shown below: 𝑇(𝑠) =

𝑌(𝑠) (𝐹(𝑠) + 𝐶(𝑠)) ∙ 𝑃(𝑠) = 𝐼(𝑠) ∙ 𝑅(𝑠) 1 + 𝐶(𝑠) ∙ 𝑃(𝑠) ∙ 𝐻(𝑠)

(4.7)

You’ll notice that the Characteristic Equation is the same as the one degree of system we looked at earlier. Therefore, our Controller can be designed using the methods outlined earlier. This also means that our Feedforward transfer function can be non-linear and not affect how we design our Controller. But how do we design the transfer function for the Feedforward term? Well, that’s only possible for a process that is well understood. Usually it’s the inverse of the Plant or a portion of the Plant. Let’s revisit our brushed DC motor system example to see how this works.

4.4.1 Example Continued – Feedforward Controller Design By combining Equation 2.0 and 2.1, assuming the inductance to be negligible and applying Laplace transforms assuming initial conditions of zero, we get the following equation: 𝑉𝑎 𝐾𝑡 − 𝑏𝑅𝑎 𝜃𝑚 𝑠 − 𝐾𝑡 𝐾𝑒 𝜃𝑚 𝑠 = 𝐽𝑚 𝑅𝑎 𝜃𝑚 𝑠 2

(4.8)

Now, this is where the art of Feedforward Design begins. We know from Section 2.2.1 where we identified the system elements that the Controller Output Signal U(s) will be in volts, so let’s rearrange Equation 4.8 to be in terms of volts. 𝑉𝑎 =

𝐽𝑚 𝑅𝑎 𝐾𝑡 𝐾𝑒 +𝑏𝑅𝑎 𝜃𝑚 𝑠 2 + 𝜃𝑚 𝑠 𝐾𝑡 𝐾𝑡

(4.9)

In general, each of the two terms on the right side of Equation 4.9 could be used independently or together for our Feedforward transfer function. However, since we’re looking to develop a Controller for a step input, the first term will attempt to differentiate a step input twice. The first differentiation will produce an impulse and the second differentiation will result in a doublet, which in this case is effectively zero, making this option useless. The second term will produce an impulse, giving the system a boost as the step input is applied but after that it will go back to zero. Since the addition of the Feedforward term doesn’t affect our Controller design, I’ll reuse the PD Controller designed earlier in Section 3.2.6. As shown in Figure 4.11, we have the original one degree of freedom design with a PD Controller and our only viable Feedforward design with the same PD Controller. As mentioned in Section 3.2.6, Matlab won’t implement a pure derivative term because it’s an improper transfer function. To get around this quirk I applied the solution they used for their PID Controller function block by implementing a normalized high pass filter with a pole at 1000rad/s.

78

Figure 4.11 – Matlab Models of Original One Degree of Freedom Design Compared to Feedforward Design

Interestingly, both models produce the same result. Why is that? Since our model is in continuous time, there is no noticeable delay between the application of the step input and an error being produced for the Controller to react to. And since the Controller has its largest output, basically at the same time as impulse from the Feedforward term, and both outputs are greater than our physical saturation limit of ±12V, there is no difference in input to the Plant and its output. Obviously this wasn’t the best example to apply Feedforward design to. My hope was that it would show you how to apply the technique. Though Feedforward design is not that common, there are a bunch of examples where it can come in handy. A useful instance is when you have a gravity term affecting position control. You will be looking at this more in-depth with the inverted pendulum lab.

79

5.0 Controller Validation Controller Validation is broken into two parts, Physical Testing and Stability Analysis. For Physical Testing, you’ll implement your Controller on the actual system and run the required tests based on the Design Specifications in order to determine if the specifications are met. This will also further confirm the accuracy of your model. If the Physical Testing goes well, you’ll next look at the stability of your system using your derived model. If your system meets the stability criterion, you can be confident that your Controller will perform as required.

5.1 Physical Testing In order to implement your Controller design, program the Arduino Mega 2560 by augmenting the ControlsLabBaseCode.ino code. Using Mode 3 will allow you to implement a PID Controller and Mode 4 has been left blank for you to write your own code for other Controller types. In order to record your system’s performance and validate your Controller design, use the Matlab program collect.m created earlier.

5.1.1 Choosing the Proper Control Loop Frequency This course only deals with control systems in the continuous time domain that we describe using the Laplace operator s. This kind of system is generally built using analog electronics but this usually isn’t the case in practice today. Usually you’ll be dealing with discrete systems implemented on microcontrollers that operate at a controlled frequency fast enough to emulate analog control. This kind of analysis uses the Z-transform as a mathematical tool. As a control engineer you’ll need to define an appropriate Control Loop Frequency. A general rule of thumb is to use a frequency that is a factor of 10 or larger than the -3db cutoff point of the system. Of course, if you can operate at frequencies greater than that, system performance will improve. When using the ControlsLabBaseCode.ino code on the Arduino Mega 2560, each Mode has an input for the Control Loop Frequency by the input variable Period. When setting the input variable Period, you are selecting the Control Loop Period, which is the inverse of the Control Loop Frequency, in milliseconds.

5.1.2 Example Continued – Physical Testing of PD Controller We have 2 Controllers we want to validate, a PD Controller and a Phase Lead Controller, but first, we’ll implement the PD Controller where: 𝐶(𝑠) = 𝐾𝑃 + 𝐾𝐷 𝑠 = 0.1 + 5.4𝑥10−3 𝑠 80

To do so we’ll open the ControlsLabBaseCode.ino file and program the Arduino Mega for PID Closed Loop Control for a Step Input mode where: Mode = 3, Kp = 0.1, Ki = 0, Kd = 0.0054, Reference_Input = 1, I_Gain = 318.3, V_In = 12, Time = 5 and Period 2. Based on the discussion in Section 5.1.1 about Choosing the Proper Control Loop Frequency, I chose a Control Loop Frequency of 500Hz. As shown in Figure 5.0, the bandwidth of the closed-loop system with the PD Controller designed in Section 3.2.7 is 50.95Hz. (This same value can be verified using Matlab’s bandwidth(sys) function.) Based on the prescribed rule of thumb of a factor of 10, we get a Control Loop Frequency of 508Hz which we’ll approximate as 500Hz.

-3db

50.95Hz

Figure 5.0 – Bode Diagram of Example Closed-Loop System using PD Controller

Using the collect.m function created in Matlab, I was able to record and plot the response for a unit step input of our system with the PD Controller devised earlier. As shown in Figure 5.1, the unit step response looks good. It has a 2.7% overshoot, a rise time of 0.092s and zero steady-state error.

81

Figure 5.1 – Step Response for Example Closed-Loop System using PD Controller

Since we’ve met our Design Specifications, no more tests need to run. However, there is one last thing I would like to do. I’d like to compare the response of our physical system with our modeled response. Using the Simulink model I created called base_closed_loop_model_test, I was able to compare both results. This program is very similar to the program created in Section 2.2.5 to compare open loop results. As shown in Figure 5.2 our modeled response shown in yellow is very close to the actual response shown in purple. I’m very confident our model is accurate enough to predict the system’s stability in the Section 5.2.

5.1.3 Example Continued – Physical Testing of Phase Lead Controller Using the ControlsLabBaseCode.ino file to program the Arduino Mega for Mode 4 operation, I wrote my own code to implement the following Phase Lead Controller devised in Section 4.1.4: 𝐶(𝑠) = 0.25

1 + 0.024𝑠 1 + 0.024𝑠 ∙ −3 1 + 6.62𝑥10 𝑠 1 + 6.62𝑥10−3 𝑠 82

Figure 5.2 – Comparison Plot of Unit Step Response of Modeled System vs. Actual System using a PD Controller

However, to write the code for this Controller requires the Controller Transfer Function to be first converted from the Laplace domain to the discrete domain and then into a difference equation. To convert from the Laplace domain to the z-domain, I used the following equation to convert its zeros and poles: 𝑧 = 𝑒 𝑠𝑇

(5.0)

Where T is the Control Loop Period in seconds. However, before we can go any further, we’ll need to decide on the Control Loop Frequency for this system using the Phase Lead Controller. Using Matlab’s bode function, the figure shown in Figure 5.3 was plotted and the closed-loop bandwidth was found to be 111.1Hz. Using the rule of thumb of a factor of 10, we get a Control Loop Frequency of 1111Hz. Unfortunately, as mentioned in the previous section, our Arduino Mega can only operate up to 1000Hz so we’re stuck with the Control Loop Period of: 𝑇 = 0.001𝑠 We’ll see what affect this has on the system’s performance.

83

-3db

111.1Hz

Stupid Matlab

Figure 5.3 – Bode Diagram of Example Closed-Loop System using Phase Lead Controller

Rearranging our Phase Lead Controller Transfer Function in terms of zeros and poles, we get the following: 𝐶(𝑠) =

3.29(𝑠 + 41.6667)(𝑠 + 41.6667) (𝑠 + 151.0574)(𝑠 + 151.0574)

Using Equation 5.0, we can covert our Laplace domain zeros to z-domain zeros as follows: 𝑧 = 𝑒 𝑠𝑇 = 𝑒 −41.6667(0.001) = 0.9592 Using Equation 5.0, we can covert our Laplace domain poles to z-domain poles as follows: 𝑧 = 𝑒 𝑠𝑇 = 𝑒 −151.0574(0.001) = 0.8598 This leaves us with the following transfer function: 𝐶(𝑧) =

𝑘(𝑧 − 0.9592) (𝑧 − 0.9592) (𝑧 − 0.8598)(𝑧 − 0.8598)

84

To calculate the value of k, the usual method is to equate the DC gain when s = 0 and z = 1. This results in: 3.29(0 + 41.6667)(0 + 41.6667) 𝑘(1 − 0.9592) (1 − 0.9592) = (0 + 151.0574)(0 + 151.0574) (1 − 0.8598)(1 − 0.8598) Which gives us: 𝑘 = 2.96 And the following discrete Controller: 𝐶(𝑧) =

2.96(𝑧 − 0.9592) (𝑧 − 0.9592) (𝑧 − 0.8598)(𝑧 − 0.8598)

Or in normalized form: 𝐶(𝑧) =

2.96𝑧 2 − 5.678𝑧 + 2.723 𝑧 2 − 1.72𝑧 + 0.7393

Now that our Controller is in the z-domain, our next step is to convert it into a difference equation. Following the procedure laid out by Silvano Balemi [14], where he converts the general discrete Controller: 𝑈(𝑧) 𝑏𝑛 ∙ 𝑧 𝑛 + 𝑏𝑛−1 ∙ 𝑧 𝑛−1 + 𝑏𝑛−2 ∙ 𝑧 𝑛−2 + ⋯ 𝑏1 ∙ 𝑧 + 𝑏0 𝐶(𝑧) = = 𝐸(𝑧) 𝑧 𝑛 + 𝑎𝑛−1 ∙ 𝑧 𝑛−1 + 𝑎𝑛−2 ∙ 𝑧 𝑛−2 + ⋯ 𝑎1 ∙ 𝑧 + 𝑎0 Into the following form: 𝑢𝑘 = −𝑎𝑛−1 ∙ 𝑢𝑘−1 − ⋯ −𝑎0 ∙ 𝑢𝑘−𝑛 + 𝑏𝑛 ∙ 𝑒𝑘 + ⋯ + 𝑏1 ∙ 𝑒𝑘−𝑛+1 + 𝑏0 ∙ 𝑒𝑘−𝑛 Where in this case k represents the discrete time step, we get the following Phase Lead Controller in difference equation: 𝑢𝑘 = 1.72𝑢𝑘−1 − 0.7393𝑢𝑘−2 + 2.96𝑒𝑘 − 5.678𝑒𝑘−1 + 2.723𝑒𝑘−2

Coding and uploading this equation into the Arduino Mega and using the collect.m function in Matlab to record and plot the response for a unit step input of our system results in the plot shown in Figure 5.4. The unit step response looks good as well, with a 3.36% overshoot, a rise time of 0.095s and zero steady-state error. Interestingly, the Phase Lead Controller did not perform as well on the physical system as the PD Controller, which does not match our simulation results. Why is that? It’s most likely because we were not able to implement our Phase Lead Controller at the required Control Loop Frequency of 1111Hz.

85

Figure 5.4 – Step Response for Example Closed-Loop System using Phase Lead Controller

Since we’ve met our Design Specifications, no more tests need to run. However, again, I’d like to compare the response of our physical system with our modeled response. As shown in Figure 5.5, the actual response shown in purple seems to lag noticeably to the modeled response shown in yellow. Fortunately, this deviation is most likely a result of the Control Loop Frequency implemented on the Arduino Mega being lower then desired. I’m still very confident our model is accurate enough to predict the system’s stability.

5.2 Stability Analysis There are a number of ways to analyse the stability of your system but the best way to determine how stable your system is, is to determine its Gain and Phase margins. In this course we’ll focus on two methods. The first method, which I prefer, uses a Bode Diagram of the open-loop system and in Matlab the margin function will plot the Bode Diagram and calculate the margins for you. The second method uses a Nyquist Plot of the open-loop system, and I think it was devised by Electrical Engineers to punish the world. Matlab has a nyquist function that draws the Nyquist Plot but you have to determine the margins from the plot. Nyquist Plots are preferred when your system has a delay in it. You might be asking, if our closed-loop poles are in the LHP, aren’t we good? Yes and no. If your system was able to exist under perfect conditions and not change with time, then yes, it would remain stable. 86

Unfortunately, stupid reality gets in the way. The main culprits are model inaccuracies, aging, noise and disturbances. Remember, the poles represent physical properties, and as a system ages, the properties change and so do the locations of the poles. Likewise, noise and disturbances can push a stable pole to the right of the Imaginary Axis and cause the system to go unstable. As a result, the best way to protect your system from going unstable is to insure it has a sufficiently large stability margin.

Figure 5.5 – Comparison Plot of Unit Step Response of Modeled System vs. Actual System using a Phase Lead Controller

5.2.1 Stability Analysis using Bode Diagrams As discussed in Section 4.1.2, Bode Diagrams can be used to determine the Gain and Phase Margins so I won’t go into further detail other than reiterating that the conservative rule of thumb for stability margins are: 𝐺𝑎𝑖𝑛 𝑀𝑎𝑟𝑔𝑖𝑛 ≥ 10𝑑𝐵 and 𝑃ℎ𝑎𝑠𝑒 𝑀𝑎𝑟𝑔𝑖𝑛 ≥ 60°

87

5.2.1.1 Example Continued - Stability Analysis using Bode Diagrams for System with PD Controller Using Matlab’s margin function for an open-loop system with the PD Controller, the following Bode Diagram was plotted:

Figure 5.6 – Bode Diagram of Example System with a PD Controller

Using this function, Matlab calculates a Gain Margin of infinity and a Phase Margin of 65.5° at 38rad/s. Both values exceed our conservative rule of thumb for Gain and Phase Margins so I’m confident our PD Controller will remain stable regardless of aging, noise and/or disturbances.

5.2.1.2 Example Continued – Stability Analysis using Bode Diagrams for System with Phase Lead Controller Using Matlab’s margin function for an open-loop system with the PD Controller, the Bode Diagram in Figure 5.7 was plotted.

88

Figure 5.7 – Bode Diagram of Example System with a Phase Lead Controller

Using this function, Matlab calculates a Gain Margin of infinity and a Phase Margin of 69.9° at 71.4rad/s. Both values exceed our conservative rule of thumb for Gain and Phase Margins so I’m confident our Phase Lead Controller will remain stable regardless of aging, noise and/or disturbances.

5.2.1 Stability Analysis using Nyquist Plots Using Matlab’s nyquist function to draw our Nyquist Plot, we’re left to determine the Gain and Phase margins ourselves. For Nyquist Plots, the Gain Margin is defined as the amount that the Nyquist Plot would have to increase to intersect the (-1, 0) point. On a Nyquist Plot, the distance along the negative real axis is measured between the origin and the intersection of the Nyquist Plot and the negative real axis. This distance is the inverse of the Gain Factor. The Gain Margin, expressed in decibels, is calculated using the following: 𝐺𝑎𝑖𝑛 𝑀𝑎𝑟𝑔𝑖𝑛(𝑑𝐵) = 20𝑙𝑜𝑔10 (

1 ) = 20𝑙𝑜𝑔10 (𝐺𝑎𝑖𝑛 𝐹𝑎𝑐𝑡𝑜𝑟) 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑

(5.1)

89

If the Nyquist Plot intersects the real axis at the origin or on the positive real axis, the Gain Margin is considered infinite. Similarly, the Phase Margin is defined as the angle that the Nyquist Plot would have to change to move to intersect the (-1, 0) point. On a Nyquist Plot, the angle is measured from the negative real axis about the origin towards the intersection between the Nyquist Plot and the unit circle. If the angle is counterclockwise direction, it is considered positive. If the Nyquist Plot never intersects the unit circle, the Phase Margin is considered infinite. As shown below in Figure 5.8, the Sample Nyquist Plot has a Phase Margin of 112°. It also has a Distance of 0.2, and using Equation 5.1, the Gain Margin is: 𝐺𝑎𝑖𝑛 𝑀𝑎𝑟𝑔𝑖𝑛(𝑑𝐵) = 20𝑙𝑜𝑔10 (

1 ) = 20𝑙𝑜𝑔10 (5) = 15𝑑𝐵 0.2

Unit Circle

Distance = 0.2

Phase Margin = 112°

Figure 5.8 – Sample Nyquist Plot

We’ll use the same conservative rule of thumb for Gain and Phase margins that we used stability analysis using Bode Diagrams. 90

6.0 References [1] Ogata, Katsuhiko, “Modern Control Engineering”, page 159, Prentice Hall, New Jersey, 5th Edition, 2010. [2] “Avago Download Page”, Accessed June 1st, 2015, http://www.avagotech.com/docs/AV02-1046EN. [3] “Avago Download Page”, Accessed June 1st 2015, http://www.avagotech.com/docs/AV02-0096EN. [4] Franklin, Gene and Powell, J. David and Emami-Naeini, Abbas,”Feedback Control of Dynamic Systems”, page 48, Prentice Hall, New Jersey, 6th Edition, 2010. [5] “Chirp”, Wikipedia: The Free Encyclopedia, Wikimedia Foundation Inc., May 5, 2015, Accessed June 12th, 2015, http://en.wikipedia.org/wiki/Chirp. [6] Ogata, Katsuhiko, “Modern Control Engineering”, page 161, Prentice Hall, New Jersey, 5 th Edition, 2010. [7] “Extras: System Identification”, Accessed http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Identification.

13th,

June

[8] “Root Locus”, Wikipedia: The Free Encyclopedia, Wikimedia Foundation Inc., January 24, 2015, Accessed June 20th, 2015, http://en.wikipedia.org/wiki/Root_locus. [9] Franklin, Gene and Powell, J. David and Emami-Naeini, Abbas, ”Feedback Control of Dynamic Systems”, page 120, Prentice Hall, New Jersey, 6th Edition, 2010. [10] Franklin, Gene and Powell, J. David and Emami-Naeini, Abbas, ”Feedback Control of Dynamic Systems”, page 119, Prentice Hall, New Jersey, 6th Edition, 2010. [11] Franklin, Gene and Powell, J. David and Emami-Naeini, Abbas, ”Feedback Control of Dynamic Systems”, pages 116-119, Prentice Hall, New Jersey, 6th Edition, 2010. [12] Franklin, Gene and Powell, J. David and Emami-Naeini, Abbas, ”Feedback Control of Dynamic Systems”, page 129, Prentice Hall, New Jersey, 6th Edition, 2010. [13] SYDE 352, Introduction to Control Systems, Course Notes, Package 2 of 2, Winter 2006, Prof. Dan Davison, Dept. of Electrical and Computer Engineering, University of Waterloo. [14] Balemi, Silvano, “Advanced Control”, June http://www.dti.supsi.ch/~smt/courses/DigImpl.pdf.

3,

2011,

Accessed

August

13,

2015,

91

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF