EGB345
EGB345 Control and Dynamic Systems JJF/28.08.2018
1
Practical Worksheet – Prelab
Important Assessment Instructions:
• At the start of your submission:
o You must fully acknowledge all assistance, if any, you receive from others (any
person or other information source) beyond the teaching staff or material of this
unit.
• WARNING: Students MUST NOT share data, generated data, code and/or modules, screen
captures, or diagrams. Any unexplained similarities between students (or past students)
will be considered prima facie evidence of plagiarism. Note that QUT’s policy on plagiarism
applies to this assessment: http://www.library.qut.edu.au/subjectpath/plagiarism.jsp.
• Attempts to subvert Turnitin will be considered academic misconduct.
• You must include references to any literature (books or websites) that you used. This
includes providing suitable traceability for all formula/results used. This unit has a
preference for the QUT Numbered Reference System, with square brackets for in-text
references (see QUT citewrite guide at
http://www.citewrite.qut.edu.au/cite/numbered/in-text.jsp).
• Units of all physical quantities must be specified.
• WARNING: QUT has a late assessment policy at.
http://www.mopp.qut.edu.au/E/E_06_08.jsp. Contact the SEF Enquires for extensions
application (not the teaching staff of this unit). The SEF policy for assignments can be found
at: http://www.student.qut.edu.au/about/faculties-institutes-and-
divisions/faculties/science-and-engineering/assignment-submission-and-results
• Note: Assessment work submitted after the due date will be marked only with an
approved extension from SEF Enquires.
Executive Summary
This lab will aim to connect material covered in lectures, tutorials and computer labs with the physical
implementation of a control loop involving hardware and electronic components. In this prac you will
develop fundamental skills in control system design and synthesis by implementing your first control
system. Specifically, you will implement a custom-built motor control system.
Some of the key learning concepts are:
• Physical systems are not ideal, and often must be experimentally characterised through
measurement of their response to the provided input signals.
• An experimental characterisation may not be perfect, but still is useful.
• Abstract control block diagram elements (signal, systems and transfer functions) have
physical interpretation in a particular control loop (measured quantities, motors/op-
amps/potentiometers, and their input/output behaviours, respectively).
• Depending on the input signals and the output quantities being measured, one physical
system might have several different transfer function representations (i.e. Transfer function
of input voltage to shaft position, and transfer function of input voltage to shaft speed).
After completing this practical lab, students should be able to:
• Use lab equipment to apply input signals and capture output signals (and plot them in
MATLAB).
http://www.library.qut.edu.au/subjectpath/plagiarism.jsp
http://www.citewrite.qut.edu.au/cite/numbered/in-text.jsp
http://www.mopp.qut.edu.au/E/E_06_08.jsp
http://www.student.qut.edu.au/about/faculties-institutes-and-divisions/faculties/science-and-engineering/assignment-submission-and-results
http://www.student.qut.edu.au/about/faculties-institutes-and-divisions/faculties/science-and-engineering/assignment-submission-and-results
EGB345 Control and Dynamic Systems
2
• Build a transfer function description of a specific motor estimated from measurements of
the motor.
• Build a motor servo position control system (involving op amps, resistor, and a servo motor) and
investigate a simple proportional controller 𝑢(𝑡) = 𝐾𝑐(𝑣(𝑡) − 𝑣
∗)
• Use both the “transfer function of input voltage to shaft position” and “transfer function of input
voltage to shaft speed” to describe a motor system.
The remainder of this document is structured as follows:
• Pre-lab reading: What is this prac about?
• Practical Activity and Assessment instructions
• Prac work activity
o Part A – Pre lab activity (must be completed and submitted prior to prac).
o Parts B, C and D – during experiment activity, and analysis. This is described in file
EGB345_Prac_SystemModelling_LabWorkSheet (not this document)
Pre-lab reading: What is this prac about?
Background: Servo motors are everywhere.
Many modern machines require small servos or motors to operate. For example, consider a small
unmanned aircraft (and its elevator actuator). If we desire a constant angle of deflection in the elevator
(to pitch the aircraft upwards) then the elevator’s deflection is typically controlled using a servo motor
that holds the elevator at a constant angle. However, this is a little complicated to achieve because when
a constant voltage is applied to the servo motor, the motors shaft turns with constant angular velocity
(i.e. does not hold at a constant angle, as might be desired). Luckily, using feedback control ideas, we can
create a position error feedback system for the servo motor that does hold the servo motor’s shaft angle
at a constant value.
The importance of understanding servo motors is not limited to small robotic aircraft. Some other
examples of servo motor position control systems include:
• Rudder or wheel position control surface on your remote-control aircraft model boat or car.
• Engine throttle in a motor vehicle.
• Just about everywhere in a modern aircraft (fly-by wire).
• Robotics (wherever there is motion of arms etc.).
• DVD or Blue-ray disc players.
• And many others.
In summary, we typically seek utility or autonomy from our servo motors in the sense that we require the
motor shaft position to be controlled or regulated to some desired angle.
Hardware
The standard lab equipment
In this experiment, you will work with the following standard pieces of lab equipment shown below:
a power supply, a function generator and a DSO (digital storage oscilloscope).
EGB345 Control and Dynamic Systems
3
Figure 1: Power Supply Figure 2: Function Generator
Figure 3: DSO
The servo motor and components (Breadboard in Session 1 changed to PCB in session 2).
For your experiments, the usual internal electronics of the servo have been removed and leads have been
brought out from the internal motor and potentiometer. The motor is mounted in a prototyping board,
along with a breadboard. The latter will be used to implement your control system and develop a
controller for the motor. The arrangement is shown in Figure 4. The arrangement with leads attached is
shown in Figure 5. The overall experiment setup will look something like Figure 6.
Figure 4: Left shows motor and potentiometer (black box), mounting board (blue), breadboard (cream)
and associated leads and terminals used in session 1. Right shows PCB used in session 2 to replace
breadboard (motor on left will still be used). Note motors may look different (upgraded)
EGB345 Control and Dynamic Systems
4
Figure 5: Your overall completed breadboard circuit might look like this (circuit blacked out – you
need to build on basis of circuit diagrams). Session 1 only (PCB replaces breadboard in session 2).
Figure 6: Overall experiment setup (note neat cables and arrangement). Session 1 only. (PCB
replaces breadboard in session 2).
EGB345 Control and Dynamic Systems
5
The motor has two connections (red and black) supplying power. Test carefully to see which polarity
causes the motor to turn in which direction as the motors are inconsistent. The feedback potentiometer
has three connections: the two outside connections are orange and brown, and the third connection is
called the wiper and is red (the wiper voltage varies with motor position between the voltages at the
brown and orange wires). The potentiometer has a value of 5kΩ. Schematically, the servo motor looks
like Figure 7.
Figure 7: Schematic of servo motor (note that the potentiometer is actually inside the motor, and you only have
access to the wires).
Modelling the Servo motor
This system is based around a servo motor mechanism commonly used in remote control aircraft. Simply
speaking, the servo system has a motor, arm, potentiometer and a set of internal electronics. The motor
is used to induce rotary (or linear) motion of the arm which in turn alters the displacement of the
potentiometer wiper. So the potentiometer acts like a sensor, used to indicate arm displacement in the
form of an output voltage 𝑣𝑝(𝑡).
Figure 8: Servo System Plant
We could separate the potentiometer (sensor) from the plant and produce a typical functional diagram
or include it in the plant as shown in Figure 8. However, this is not necessary in this prac (but please
remember you are using potentiometer voltage to measure motor position).
Step 1: Transfer function modelling (input voltage to motor shaft velocity)
To write down a general transfer function model of input voltage to motor shaft velocity we note that the
servo has a fixed field (permanent magnet) DC motor that drives a high reduction gearbox. Permanent
magnet DC motors can be modelled using a 2nd order transfer function (input voltage to shaft speed) of
the form
MOTOR POTENTIOMETER
𝑉𝑚(𝑠) 𝑉𝑝(𝑠)
EGB345 Control and Dynamic Systems
6
𝐺(𝑠) =
𝐾𝑚
(𝑠 + 𝛼)(𝑠 + 𝛽)
Here, is related to the mechanical time constant and 𝛽 the electrical time constant.
Useful approximation: If |𝛽| > 10||, the electrical time constant is at least an order of magnitude faster
than the mechanical time constant and the transient response will be dominated by .
Transfer function 1: (simplified) Input voltage to motor shaft velocity: The input voltage to motor shaft
velocity transfer function could then be approximated by
𝐺(𝑠) =
𝐾𝑚
(𝑠 + 𝛼)
where the relationship defines the ratio between the output motor speed and input voltage 𝑉𝑚(𝑠).
Transfer function 2: (simplified) Input voltage to motor shaft angle: Notice the output shaft is connected
directly to a potentiometer such that the output voltage indicates the shaft angle position (this provides
a signal for position feedback). This means that the potentiometer measures shaft angle position not
shaft velocity (transfer function includes by (1/s) factor) and we can write the input voltage to motor shaft
angle transfer function (i.e. transfer function for the motor and pot system):
𝐺𝑜(𝑠) =
𝑉𝑝(𝑠)
𝑉𝑚(𝑠)
=
𝐾𝑚
𝑠(𝑠 + 𝛼)
Important: In previous years students have been confused about these two transfer functions. In the
prac, you will work with quantities related to 𝐺𝑜(𝑠). It is also important to note that if a fixed voltage is
applied to the motor, the wiper voltage across the pot 𝑉𝑝(𝑠) will increase (or decrease) as the motor arm
spins at relatively constant velocity (it is easier to measure the wiper voltage across the pot than directly
measuring motor speed). Importantly, a fixed input voltage results in constant motor velocity (not
constant position). Note, the term “steady state” refers to behaviour once initial effects have
disappeared (and in the open-loop system in this experiment steady state corresponds to constant motor
shaft velocity, not constant position).
Step 2: Experiment-based system modelling:
The above simplified transfer function descriptions mean that the servo motor system can be
characterised by two numbers, 𝐾𝑚 and . (This is typical of many simple electromechanical systems.)
However, we do not know any of the constants associated with these parameters such as motor
constants, inertia of the load and the gear ratio. We will need to treat the system as a black box from
which we expect a particular response, and we will estimate the unknown parameters using experiment-
based system modelling.
To do such modelling, you will need to record the system response to a step input. This is referred to as
the open loop time response of the motor system and is measured in terms of how the voltage applied
to the motor affects the voltage seen at the potentiometer (constant voltage input should result in
constant shaft speed). Then, to match with our model for 𝐺𝑜(𝑠), you will derive a good approximation to
the servo motor system transfer function by selecting the best values that you can find for 𝐾𝑚 and .
EGB345 Control and Dynamic Systems
7
System Identification
In general, when working with a real physical system, we may start with an approximate model of the
system, but typically do not know the exact parameters of the model. We must therefore perform some
experimental process to estimate the model parameters, which we can then use for tasks such as
designing a closed-loop system and a simple gain controller.
This can be summarised in three basic conceptual steps:
1. Mathematical modelling: using modelling techniques of EGB345, we have developed an
approximate transfer function description of the system. In this prac, this is given to you.
2. Data capture: apply some known input to the system (in this prac, this is a step input) and capture
the system’s response.
3. Model estimation: simulate the step response of the transfer function from our mathematical
modelling for a variety of parameters. Select the set of parameters leading to the closest match to
the captured system response.
Closed-loop Response and Design
It would be very difficult to set the position of the output using open loop control. Based on the model
produced, we would need to switch the motor on and off at quite precise times to achieve open loop
position control. Furthermore, any disturbance to the system (such as a change in load or damping) would
destroy the calibration required for open loop control.
Closed loop control will relieve these problems but introduces a new level of complexity to the system.
We still need to model the other components in the control system functional diagram and realise them
to complete the feedback loop. We can use mathematical analysis to design a simple gain controller to
achieve a specified desired percentage overshoot. We can then test the closed loop response of the
system and subsequently improve our controller design.
Advanced Closed-loop Response and Design
Having completed a closed-loop design, it is interesting to examine how the closed loop system
behaves; in particular, how the response changes for different types of input signals. We can also
investigate different experimental methods for estimating the parameters of the physical servo
motor and build a Simulink model of the system based on these estimated parameters so that we
have a virtual representation of our physical system that we can study in simulations. This virtual
representation can be used to quickly prototype new control designs in an easy way, before we
construct them in electronics.
Summary of Experimental Activity during this Practical
Part A: Pre-lab activity
Involves:
• Mathematical modelling of the servo motor (input voltage to motor shaft angle)
• Simulation modelling of the servo motor and measurement system
EGB345 Control and Dynamic Systems
8
• Development of MATLAB code to estimate parameters of a fictitious/artificial servo motor based
on data provided (this code will be used in the practical to estimate the real motor)
• Answering questions that demonstrate ability to perform the sort of MATLAB data manipulation
required during your practical
NOTE: Part A must be completed and submitted on blackboard prior to entering prac lab session. Please
refer to pre-lab worksheet.
Part B: Modelling the system
Involves:
• Building circuitry and connecting to standard lab equipment to prepare for data capture.
• Executing an experiment to capture data suitable for estimating parameters of your servo motor.
• Estimating the parameters of your servo motor using MATLAB scripts you developed in Part A.
Part C: Closed-loop response and design
Involves:
• Building closed-loop circuitry.
• Determining a gain, and hence resistor values that achieve a requested overshoot in the closed-
loop response.
• Implementing this gain using resistors
• Performing experiment and capturing data confirming that your design works.
• Iterating your design as required.
Part D: Advanced closed-loop response and design
Involves:
• Proposal and execution of alternative method for estimating servo motor parameters
• Measurement of closed loop behaviour for different input signals.
• Measurement of closed loop behaviour with different gain values.
• Building Simulink model that replicates your physical servo model, and compare and contrast with
your captured data
• Proposing and evaluating a controller more complex that the simple gain controller used until this
point.
Part A – Pre-Labs
Experimental preparation aspects:
Familiarise yourself with hardware and laboratory equipment aspects. You must review the
LabWorkSheet to developed a plan of how to perform the experiment (there are questions in step
3 below). You should note all warnings about safe performance of the experiment. You must also
watch the Oscilloscope videos on blackboard about how to use the oscilloscope functions, such as
triggering (there is a question in step 3 below). You should review the mentioned op-amp and
resister data sheets.
The practical demonstrator will only be able to provide limited assistance and will not assist
students that are not prepared.
EGB345 Control and Dynamic Systems
9
Please bring a USB stick to the lab (should be FAT32 format), and remember every student should
take a copy of their data (don’t rely on your group members).
MATLAB and analysis preparation aspects:
Below are 2 MATLAB analysis steps you must complete in this pre-lab to prepare for the
experimental sessions. Step 3 has some short questions assessing your preparation and
understanding.
Step 1: Confirmation of estimation technique on known input voltage to motor shaft angle model
from self-generated data (assessing skills developed in Computer Labs).
In this step, you will use a provided data generation function to create your own data and estimate
the parameters from this model (this will let you confirm to yourself that your estimation approach
is valid). You will use MATLAB to generate data corresponding to an input voltage to motor shaft
angle model with parameter values that you know (you will be randomly assigned these parameters
so that your data and your submission will be unique from other students). Your randomly assigned
data can be created using the following MATLAB commands:
>> rng(‘shuffle’)
>> format long;
>> alpha=1+rand;
>> Km=1+rand;
>> yn_own=GenerateSystemResponse(alpha,Km);
>> save(‘prelabdata_yn_own.txt’,’yn_own’,’-ascii’)
(or save prelabdata_yn_own.txt yn_own –asci, if you have an old version of MATLAB)
Note that the step response is plotted with a time vector from 0 to 10, with time period of 0.1, before
the shifts and offsets are added.
Note: you must use exactly this save commands for reporting purposes. Also include the below plots
saved from MATLAB (not screen captures).
Now use the techniques you learned in Computer Lab 1 to remove offsets and delays. You may
assume the motor was initially in zero angle position, before there is a step input that causes the
motor to start moving. You are asked to remove the voltage offset and shift the data’s time index
so that the motor’s step response starts at approximately the 10th time step. Create a MATLAB
script that records the MATLAB commands that shifted your data set. The correctly shifted data
should be named ‘yn_own_fixed’.
>> save(‘prelabdata_yn_own_fixed.txt’,’yn_own_fixed’,’-ascii’)
Proceed using an approach similar to Computer Lab 4. That is, compose some MATLAB code able to
simulate the motor’s shaft angle for various values for 𝐾𝑚 and .
[This will include setting up a time vector 𝑡 and creating the transfer function 𝐺𝑜(𝑠). You can then
simulate the time response data using the step function in MATLAB. In the following we will call this
simulated response 𝑦𝑠(𝑡). You may need to change the time vector until it is clear you are observing
the transient and steady state response.]
EGB345 Control and Dynamic Systems
10
Change values 𝐾𝑚 and in your MATLAB code until your simulated data matches the test data. You
may use trial and error, or exhaustive search using for loops, to compare based on RMS error.
However, it is recommended you create a function to do this (see template for estmotor.m on
blackboard). The values of closest match are called your estimated values of these parameters.
Use this estimation technique on the data yn_own_fixed and confirm that you can recover your
randomly assigned values of alpha and Km you used to generate the data yn_own.
You are to create three plots:
1) Plot yn_own (plotted in red) and the data in EGB345TestData from Blackboard (plotted in blue).
This shows the difference in scale between these two sets of data.
2) Plot yn_own (plotted in red) and yn_own_fixed (plotted in blue).
3) Plot yn_own_fixed (plotted in red) and the estimated model (plotted in blue).
Submit your
• true 𝐾𝑚 and values (in the provided report template).
• generated noisy yn_own data (attached).
• shifted yn_own_fixed data (attached).
• your estimated 𝐾𝑚 and estimates (in the provided report template).
• the 3 requested plots (in the provided report template).
• your MATLAB code for estimating parameters (attached)
Step 2: Estimating a model from provided data (assessing skills developed in Lab 1, 4 & 5).
On blackboard, you are provided a test data set (EGB345TestData). You are told this data describes
the unit step response of an ideal servo model as modelled by the 𝐺𝑜(𝑠). NOTE: This data is not
from a real servo and is supplied for testing purposes only. The “true” parameters for 𝑲𝒎 and
will be from a different range to those in Step 1.
You are required to conduct data analysis and estimate the model parameters that generated the
test data set EGB345TestData. This will test whether your estimation process in Step 1 generalises
to other sets of data.
>> load EGB345TestData
>> [alpha_est,K_est]=estmotor(t,y1);
Plot both your 𝑦𝑠(𝑡) (plotted in red) and the data 𝑦1(𝑡) in EGB345TestData (plotted in blue) to
highlight how well they match.
Submit your
• Estimates of the 𝐾𝑚 and parameters used to generate EGB345TestData (in the provided report
template).
• The requested plot (in the provided report template).
Step 3: Short answer (assessing completion of earlier computer labs, your Prac Session 1
planning and your understanding the pre-lab learning objectives, the Prac Overview sheet, and
the Prac LabWork Sheet).
EGB345 Control and Dynamic Systems
11
Please provide short answers for the following 10 questions:
1. [Prac sheet understanding] True/False: with respect to the above Pre-lab modelling information
provided above answer the questions: In open loop, the servo input to shaft position transfer
function 𝐺𝑜(𝑠) is stable (true/false)? In open loop, the input to shaft velocity transfer function
𝐺(𝑠) is stable (true/false)?
2. [Prac sheet understanding – Prac session preparation from LabWorkSheet] True/False: According
to the Prac LabWorkSheet I need to bring the following items to my prac sessions: a USB stick
(true/false), my student card (true/false), my Matlab code for estimating 𝐾𝑚 and parameters
(true/false), my worked answer to Tutorial 4 (true/false).
3. [Prac sheet understanding – Preplanning your prac session activity from LabWorkSheet] Please list
the specific prac LabWorkSheet steps that: i) you need to complete during your session 1 (i.e. “We
will need to complete Steps B1, B2, [Insert you answer here] during session 1”) and ii) can be
completed after session 1 (i.e. “We can complete Steps [Insert you answer here] after session 1”).
Then provide a prediction how many minutes you will need to complete each of the following
stages of the prac: i) Steps B.1 to B.5 ii) Steps B.6 to B.9, and iii) Steps C.5 to C.9.
4. [Pre-prac understanding Step 1 and 2] In your own words, explain the strategy being used in the
process to estimate the system parameters (you answer should highlight the sense in which the
produced estimates are meaningful). Your answer should make reference to parameters,
responses and the measurement data involved.
5. [Pre-prac understanding Step 1 and 2] Provide a mathematical expression for slope of the input
voltage to motor shaft angle response in terms of 𝐾𝑚 and . Hint: you can determine this
mathematical or by investigating the slope that results for different values of 𝐾𝑚 and .
6. [Pre-prac understanding Step 1 and 2] Based on the accuracy of your estimation in Step 1 (with
ground truth parameters known), how accurate do you think your estimation of EGB345TestData
is in Step 2? Provide a number.
7. [Prac preparation videos watched] You have watched the “oscilloscope: Triggering video”
video. Imagine you have reached Step C.5 in the practical session and are attempting to
measure the input waveform (a 0.5 V square wave). The oscilloscope is set to Auto triggering
mode (in trigger menu you can see the oscilloscope is set to Edge trigger mode channel 1,
rising edge). You see the “ghost” of a wave form on the display, but the signal is not triggered
(the waveform is not stationary). You can see both the top and bottom of the “ghost” signal
(i.e. the scale is correct). Provide one reason why the oscilloscope is not triggering (and
how to achieve triggering).
8. [Computer lab 1 – Needed in Prac] What is the MATLAB command for loading data from an
.cvs spreadsheet file, but skips the first 3 lines?
EGB345 Control and Dynamic Systems
12
9. [Computer lab 1– Needed in Prac] Consider a MATLAB vector voltagedata that is 1000
elements long. What are some MATLAB commands to: i) find the of the first element greater
than 0.1 (use the variable indexup for this index), and ii) create a new vector voltagedata2
containing the elements of voltagedata shift to the left so that the first element greater than
0.1 is the first element of voltagedata2 (with earlier vector elements being discarded).
Additionally, what is the length of the voltagedata2 vector expressed in terms of the above
information and variables.
10. [Computer lab 4– Needed in Prac]] You modify your pre-lab Part A system identification code
to achieve Steps B.6 and B.7 in the prac LabWorkSheet. In Step B.6, you have experientially
captured a step response ye from the servo motor, saved the response, uploaded it into
MATLAB. In Step B.8 so need to compare to an ys created by GenerateSystemResponse.
Unfortunately, ye and ys don’t have the same scale or time index. You attempt to
manipulate ye so the start of both step responses is roughly aligned (same start point and
voltage level). However, when attempting to confirm alignment of the responses, the
MATLAB command
plot(te,ys,te,ye)
returns the error message
Error using plot
Vectors must be the same length.
What MATLAB commands could you use and how would you use them to help you diagnose
and correct the error? (less than 5 sentences).
Submission aspects (Do not submit as a zip file):
This multiple part assessment submission is very short, but each of the assessment submission parts
must be scannable by the Turnitin system (attempts to subvert Turnitin will be considered academic
misconduct). Submitted code must be executable. Data and text must be ascii and editable.
Do not submit as a zip file.
Submission part i) [Document]
Use the provided word document template: Includes text and plots. Replace yellow with your
submissions. Submit the word document. You must not submit ZIP files or pdf documents. You
must use the template.
Submission part ii) [File attached submissions, 3 parts]
1. [File submission/attachment] From steps 1 and 2 above, Provide the MATLAB code you used
to estimate the parameters. That is, attach this code as separate submission item in your
Turnitin submission. This code must be executable, as in, no errors. Submitting a function is
fine.
2. [File submission/attachment] From step 1 above, provide the self-generated data. That is,
attached “prelabdata_yn_own.txt” data file (must be in the .txt format and editable).
EGB345 Control and Dynamic Systems
13
3. [File submissions/attachments] From step 1 above, provide the self-generated data with
offsets and delays removed. That is, the “prelabdata_yn_delay_fixed.txt” data file (must be
in the .txt format and editable).
Warning: Turnitin will alert if you submit the same data or text as another student, and this
will be evidence of academic misconduct. You must not submit ZIP files or pdf documents.
Practical Worksheet – Prelab
Executive Summary
Pre-lab reading: What is this prac about?
Background: Servo motors are everywhere.
Hardware
Modelling the Servo motor
System Identification
Closed-loop Response and Design
Advanced Closed-loop Response and Design
Part A – Pre-Labs
Experimental preparation aspects:
MATLAB and analysis preparation aspects:
Submission aspects (Do not submit as a zip file):
Submission part i) [Document]
Submission part ii) [File attached submissions, 3 parts]