ELEC207 Coursework (v5: 15 March 2021)

Page 3
1. Mathematical Modelling
A Segway (as shown in figure 1) is a physical system that can be modelled as an inverted
pendulum.

Figure 1: A Segway

More specifically, we will assume that the pendulum can be approximated as a point mass,
of mass m, at a distance, l, and at a (small) angle, θ(t), defined clockwise from vertical.
Gravity is assumed to act downwards and exert an acceleration of g. A motor provides a
torque, T(t). The actuator that converts the Torque control signal to the physical Torque can
be assumed to have a gain of unity. The angular acceleration of the pendulum can then be
approximated as being defined by:

θ(t) + T(t) =
2θ(t)
2

Our task as an engineer designing the controller for the Martian Segway is to optimise the
time-response to changes to an input, X(t), which defines the desired values for θ(t). We will
consider this design criterion to be achieved if the settling time is equal to ts.
x l is the day of the month when you were born (where l is in metres);
x m is the month of the year when you were born (where m is in kg);
x ts is the year when you were born divided by 250 (where ts is in seconds).
A) Please define the values for l, m and ts that you will use for your coursework. [1E]
B) Now derive the transfer function, () = () ()⁄ , of the Segway in terms of l, m
and g. [1E]
C) Using your values for l and m along with g=3.711 ms-2, write the transfer function
with the denominator and numerator of your transfer function in polynomial form. [1E]
D) Calculate the position of the poles for your Segway and plot the poles on the
complex plane. [1E]

ELEC207 Coursework (v5: 15 March 2021)

Page 4
2. Validating that the Open-loop System is Unstable
With no controller, the system is believed to be unstable. We can use Simulink to validate
this. Open MATLAB R2020a or later (as available using Apps Anywhere or the Remote
Teaching Centre Service2) and then click Simulink. Information is available online (at:
supporting materials available in your Canvas lab module page). Here we provide a brief
description of what is needed for our purposes:
1. Press “Blank Model”;
2. Click the “Library Browser” button, ;
3. Search for a step function by entering “Step” into the box where it says “enter search
term”;
4. Drag and drop the “Step” block onto the Simulink Editor;
5. Click the “Library Browser” button again;
6. Search for “Transfer Fcn” and drag and drop the “Transfer Fcn” block onto the
Simulink Editor. Be careful to select the continuous-time transfer function block
(parameterised by s) and not the discrete-time transfer function block (parameterised
by z);
7. Double click the “Transfer Fcn” block on the Simulink Editor and enter the
polynomials that you calculated above. Be careful that any coefficients of zero need
to be explicitly entered (ie coefficients of [1 0 2] describe s2+2 but coefficients of [1 2]
describe s+2);
8. Click on the triangle on the right of the “Step” block such that an arrow appears;
9. Connect the output signal from the “Step” block to the input signal for the “Transfer
Fcn” block;
11. Connect the output signal from the “Transfer Fcn” block to the input signal for the
“Outport” block;
12. Selecting the signal that connects the “Transfer Fcn” block to the input for the
“Outport” block such that it turns blue;
13. Click “Add viewer” (under “Simulation” and “Prepare”) and select “Scope”;
14. Press “Run” (under “Simulation” and “Simulate”). You should now see a graph
showing the time-response of your Segway to a unit-step.
15. Press “File” -> “Print” -> “Microsoft Print to PDF” -> “OK” and save the time-response
to a convenient location.
E) Insert a picture of the time-response of your Segway to the unit-step. [2E]
F) Comment on whether this time-response indicates that the open-loop system is
stable. [1M]

3. Ensuring that the Closed-loop System is Stable Using PID Control
We will now add a cascade controller, as explained in lecture 7. We will use a combination of
Proportional, Integral and Derivative control, ie a PID controller. The transfer function of a
PID controller is:

ELEC207 Coursework (v5: 15 March 2021)

Page 5
() = +

+ =
+ + 2

where Kp, KI and KD are respectively the proportional, integral and derivative control
constants. We know that the closed-loop transfer function for a negative feedback system
with open-loop transfer function of C(s)H(s) and that relates the input, X(s), to the output,
θ(s), is:
()
()
=
()()
1 + ()()

G) Write the closed-loop transfer function for your Segway in terms of Kp, KI and KD as
a ratio of polynomials in s. Ensure that the highest order term in s in the denominator
has a coefficient of unity. [3M]
To ensure that the system is stable, we start by placing the poles at s=-1, s=-2 and s=-3.
H) What is the characteristic polynomial that would result in these pole positions?
[1M]
I) By equating the coefficients in the closed-loop transfer function’s denominator and
this characteristic function, deduce values for Kp, KI and KD which will ensure that the
closed-loop system is stable. [3M]

4. Validating That the Closed-loop System is Stable
Simulink includes a “Subtract” block and a “PID” block. Use these blocks (with the
parameters of the PID controller that you have defined) to simulate the time-response from a
stable closed-loop system.
J) Insert a picture of the time-response of your closed-loop system to the unit-step.
[2M]

5. Optimising the Time-Response Using Root Locus
The open-loop system has poles and zeros that are the union of those associated with the
plant and those associated with the PID controller.
K) Calculate the positions of the open-loop zeros (ie the zeros of ()()) for the
values of l, m, Kp, KI and KD that you have used. [1M]
Recall that the PID controller has a pole at the origin and the Segway has poles that you
have calculated above.
L) State the positions of the open-loop poles (ie the poles of ()()) for the values
of l and m that you have used. [2E]
We are going to use the root locus to choose the open-loop gain to achieve the time-
response we want. More specifically, we are going to move the closed-loop poles along the
root locus such that we can achieve the settling time that you have defined at the start of this
coursework assignment.
ELEC207 Coursework (v5: 15 March 2021)

Page 6
As explained in lecture 6, the settling time for a generalised second-order system with
natural frequency, β, and damping coefficient, ω, is ≈ 4 β⁄ . As explained in lecture 5, the
real part of the location of the poles of a generalised second-order system is () = −β.
We therefore want to ensure that the dominant poles (the poles that are closest to the
imaginary axis) are located such that () = −4 ⁄ . We can understand how to achieve
this by sketching the root locus for the open-loop system with the compensator.
M) Sketch the root locus for ()() and identify the points on the root locus that are
such that () = − ⁄ . [3M]
We now want to calculate the value of the open-loop gain that will ensure that the closed-
loop poles are such that we achieve the desired time-response.
N) Write the open-loop transfer function, ()(), as a ratio of polynomials in . [1H]
If the numerator of the open-loop transfer function is () and the denominator of the open-
loop transfer function is (), ie ()() = () ()⁄ , then the closed-loop poles occur
when () + () = 0.
O) Write () + () = as a polynomial in involving . [1H]
To identify the value of , we need to re-express this polynomial as a polynomial in ̃ = +
4 ⁄ . We can achieve this by substituting = ̃ − 4 ⁄ (using your value for ) and
simplifying.
P) Write (̃) + (̃) = as a polynomial in ̃ involving . [1H]
As explained in lecture 9, we can then use Routh-Hurwitz to deduce the value of that is
such that ̃ is on the imaginary axis (ie when () = −4 ⁄ and so we achieve our desired
time-response). We achieve this by choosing to be such that there is a row of zeros.
Q) Complete a Routh table for (̃) + (̃). Deduce the value of that is such that
() = − ⁄ [3H]

6. Validating the Response of Optimised System
You can now use Simulink to simulate the time-response from the closed-loop system with
the gain you have chosen, . Note that there is a “Gain” block that you may find useful.
R) Insert a picture of the time-response of your improved closed-loop system to the
unit-step. [2H]
7. Further Directions for Private Study (Not Assessed)
Should you find this coursework assignment interesting and wish to continue to work on
designing a Martian Segway, it might be interesting to consider:
1) Using a compensator (eg a PD controller) to ensure that the overshoot adheres to
some design criterion;
2) Using a further compensator (eg a PI controller) to ensure that the steady-state error
is reduced.
For the avoidance of doubt, your mark for the coursework will not be affected by whether you
design these compensators.  