You are on page 1of 17

4K410: Motion Control

Exercises and experiments

Compilation date: February 10, 2015

Before you start, read this first!


This document contains the exercises and experiment assignments for the course Motion
Control (4K410). To complete the course you are expected to make all of them. To finish
the course write a report on these exercises and experimental results, demonstrating your
knowledge of control theory. Exercises marked with a * do not have to be included in the
report, although making these exercises is highly recommended, as they provide some background for the other exercises.
The final exam is an oral exam in groups of 2 students. Hence, form a group of 2, do
all exercises and experiments together, and write the report together. An appointment with
Prof. Steinbuch for the oral exam can be made at the DCT secretary (Petra Aspers, Gem-Z
0.143), where you can also hand in your report in his mailbox.

Hints and tips


Before you continue, consider the following tips.
Using Matlab. Perform and save all your Matlab operations in m-files. Also, consider
creating functions for routines you often use. It will save you time!
Important Matlab routines. When designing and/or analyzing controllers make use of
standard Matlab functions like tf.m, bode.m and nyquist.m. For FRF measurements
you will need functions like cpsd.m, tfestimate.m and mscohere.m. Get familiar with
these functions, by reading the corresponding Matlab help files first!
Making Bode diagrams. You might want to use functions like freqresp.m, abs.m, db.m,
angle.m and semilogx.m instead of bode.m to have complete control over your figures.
Again, read the help files first! To change the default frequency axis of Bode plots from
rad/s to Hz, type ltiview, and choose File - Toolbox Preferences.
PD control in Simulink. Implementing a PD controller in Simulink is often done with the
PID Controller block in Simulink Extras. Since this block contains a pure Derivative
block this could sometimes yield very inaccurate time responses. If so, use the PID
Controller (with Approximate Derivative) block instead.

Gert Witvoet
G.Witvoet@tue.nl
Gert.Witvoet@tno.nl
2

Exercise

Systems and controller design


1.1

Interpreting a transfer function *

Consider the system described by the following transfer function


P (s) =

(s + 2)2
s2 (s + 3)(s2 + s + 25)

(1.1)

a) How many poles and zeros does this system have?


b) What is the order of this system? What is its relative degree?
c) An integrator is formally defined as a pole at s = 0. How many integrators does the
system have?
In general, the frequency response of a system can simply be obtained by substituting s = j
into the transfer function. For system (1.1) this results in
P (j) =

(j + 2)2
,
2 (j + 3)( 2 + j + 25)

(1.2)

which is a complex function. The expressions for the magnitude and phase of its real and
imaginary parts are the exact definitions of the Bode diagrams. These expressions can be very
complicated (you might want to try this yourself as an exercise). Fortunately, the asymptotes
(slopes) for limit cases like 0 and can also be determined directly from P (s)
with s 0 and s .
d) For the limit case 0, determine the asymptote of P (s) in terms of s. To what
slope does this correspond?
e) For the limit case , determine the asymptote of P (s) in terms of s. To what
slope does this correspond?
f) Compare the answers to b, c with d, e and draw your conclusions.
g) Verify your results by drawing a Bode diagram.

1.2

Interpreting a Bode diagram

Exercise 1.1 indicated that you can predict parts of the Bode diagram by using system properties like the number of poles or the relative degree. Now lets turn this around.
For the Bode diagrams below, determine
3

the relative degree


the number of integrators
the total number of poles and zeros
Motivate your answers (e.g. point out at which frequencies the poles and zeros are located).
Bode diagram
Magnitude [dB]

Magnitude [dB]

Bode diagram

180
Phase [degrees]

Phase [degrees]

90

90
0
90
180

180
Frequency [Hz]

Frequency [Hz]

(a) System H1 (s)

(b) System H2 (s)

Download the frequency response fitting toolbox frffit.zip from OASE, extract the files
to a Matlab directory (e.g. $matlabroot\toolbox\frffit) and add this directory to the
Matlab path (e.g. by using pathtool.m). In the end type >>rehash toolbox.

1.3

Estimating transfer functions

Download frfdata.mat from OASE and load it in your workspace. It contains two plant
measurements, stored in a frequency vector hz and complex response vectors H1 and H2.
Plot the frequency reponses of both measurements in a Bode diagram. Which of the
two plants is unstable? Predict the location of the unstable poles (in Hz) from the Bode
diagram.
Make models of the two measurements using either frsfit.m (stable fit) or frfit.m
(possibly unstable fit). Choose an appropriate structure (number of poles, zeros and
integrators) and choose an inverse weighting function (type >>help frsfit first).
What are the unstable poles of your model? Does this match your previous result?
Create a system from the obtained model parameters (e.g. by using ss.m or tf.m).
Plot your systems together with the data in a Bode diagram and comment on them.
Without designing a controller, which of the two plants do you think is easier to control
(i.e. with a small controller order) to a 20Hz bandwidth? Explain why.

Exercise

Frequency response measurements


For all exercises you will need a Windows or Linux pc with Matlab/Simulink installed.

2.1

Frequency Response Function of a notch filter *

A notch filter is a controller element which is meant to suppress a very specific frequency. It
is defined, in continuous-time, as
1
s2 +
(2f1 )2
F (s) =
1
s2 +
(2f2 )2

21
s+1
2f1
,
22
s+1
2f2

where f1 and f2 are the locations of the zeros and poles (in Hz) respectively, and 1 and 2
are the dampings of these zeros and poles. For a pure notch filter f1 = f2 .
a. Create a Simulink model with a notch filter, e.g. with a standard Transfer Fcn-block
from the Simulink library. Apply a broadband noise (Random number) as input to
the filter. Place the zeros (numerator) and the poles (denominator) of the notch at
40 Hz, with a damping of 0.01 for the zeros and a damping of 1 for the poles.
b. Simulate the notch over a time interval of 30 s with a fixed step solver (e.g. ode1 or
ode3) with a step size of 0.001 s. Save both the input and output of the filter to the
Matlab workspace. Compare the filter response with its input in time domain. Do
you see any difference?
c. Compare the input and output in frequency domain by calculating their auto power
spectral densities. What do you see now? Hint: see Matlab functions fft.m, pwelch.m
or periodogram.m.
d. Determine the FRF of the notch filter using the ratio between the appropriate cross and
auto power spectral densities. Also, determine the corresponding coherence function.
Does the outcome match your expectation? Hint: see Matlab functions cpsd.m and
mscohere.m.
e. Increase the damping of the zeros by a factor 10. How do the FRF and coherence
change? Explain what you see.

2.2

Frequency Response Function of a mass system

In this exercise you will perform a closed-loop FRF measurement of a simple mass, controlled
by a PD. Mathematically, this plant and controller are defined as
H(s) =

1
ms2

and

C(s) = P + Ds,

where s is the Laplace variable.


a. Assume the mass is 1 kg. Using the above definitions, calculate appropriate P and
D so that the bandwidth (cross-over frequency of the open loop C(s)H(s)) is 10 Hz.
To this end, place the zero of the controller at the desired bandwidth, then adjust
the controller gain so that the open-loop gain is 1 (i.e. 0 dB) at the same frequency.
Demonstrate your design by making a Bode plot of the open loop C(s)H(s).
b. Create a Simulink model with a 1 kg mass and your calculated PD-controller. Inject
a noise signal in the closed loop just behind the controller block.
c. Simulate the model over 120 s with the fixed step Euler solver with step size 0.001 s.
Save the relevant signals for a closed-loop sensitivity FRF measurement to the Matlab
workspace. Study these signals in both time domain and frequency domain.
d. Determine the coherence function and the FRF from the data obtained in part b.
Does the outcome match your expectation?
e. Compute the open-loop FRF from the sensitivity FRF. How does it compare to your
design of C(s)H(s) in part a.? Explain what happens with the phase of the FRF for
high frequencies.
f. Perform a separate FRF-measurement of the PD-controller only and determine the
quotient of the open-loop FRF from part d. and the newly measured controller FRF.
To what extend does the obtained result resemble a double integrator behavior?

2.3

Closed loop FRF measurement

Download the Simulink file frf_ex3.mdl from OASE (this file is meant for Matlab r2006b
or higher; Matlab 7.0.4 users can download frf_ex3_m7.mdl, Matlab 6.1 users can download
frf_ex3_m6.mdl).
1. Open the Simulink file frf_ex3.mdl. This model simulates a real experiment, where the
plant FRF has to be determined. It contains an unknown low-bandwidth controller, and
an unknown plant. Assume that the controller cannot be measured separately. Check
whether the simulation parameters are set to the right values: fixed-step solver, ode1
(Euler), simulation time of 30 seconds with a step size of 0.001.
2. Determine the sensitivity of the closed loop system by performing an FRF measurement,
i.e. by inserting noise at the right place and measuring the right signals. Use the
Matlab function tfe.m or tfestimate.m, and choose nfft such that the resolution of
the frequency vector is 0.25 Hz. Choose noverlap to be half this size. Make sure to plot
6

the amplitude, the phase and the coherence of the sensitivity. Why is the coherence
not equal to 1 at low frequencies? So between which frequencies is this measurement
reliable?
3. Which signals have to be measured to determine the process sensitivity of the closed
loop? Perform this measurement. Make sure to plot the amplitude, the phase and the
coherence of the process sensitivity. What happens to the coherence at high frequencies?
Can you explain this? Between which frequencies is this measurement reliable?
4. How can you determine the plant dynamics using only sensitivity and process sensitivity
(without measuring the controller)? Determine the plant FRF and plot amplitude and
phase. Keeping in mind that this is a simulation of a real experiment, what could cause
the two high frequent phenomena: bad amplitude estimate and phase drop? How much
is this phase drop and can you explain this?
5. Repeat this exercise with different values for nfft en different simulation times in
Simulink. What differences do you notice and how can you explain these differences?

Exercise

Stability
3.1

Modelling and control of a motion system

Consider the classic mass-spring-damper-mass system, depicted in figure 3.1. A motor applies
a force F to a mass m1 , resulting in translations x1 and x2 of both masses m1 and m2 .

x1
F

x2

m1

m2
d

Figure 3.1: Mass-spring-damper-mass system


Model this system and derive the transfer function H1 (s) from F to x1 . This situation
is called co-location, since actuation and measurement is on the same side.
Derive the expression for the resonance and anti-resonance of the system.
Derive the transfer function H2 (s) from F to x2 . Now there is dynamics between
actuation and measurement, so we speak of non co-location (or load feedback).
Now take m1 = 0.015kg, m2 = 0.045kg, d = 0.4Ns/m and k = 2200N/m.
Draw the Bode diagrams of H1 (s) and H2 (s) in one figure, and explain the similarities
and differences between the two.
For the remainder of this exercise we consider the motor feedback case, i.e. the input is F
and the output is x1 .
Make a simple stabilizing controller for this system such that a bandwidth (0db of openloop) of 20 Hz is achieved, and |S| < 6dB (and reasonable phase and gain margins).
Implement the system and the controller in a Simulink (closed loop) block scheme.
Hint: you can use blocks like Transfer Fcn (in Simulink - Continuous) or LTI system
(in Control System Toolbox)
Use a step as a reference signal, and perform a simulation. Plot the resulting error.
Try to find out what the influence of the frequency domain specifications bandwidth and
phase margin is on time domain performance like overshoot, rise time and settling time.
Do this by designing and applying different controllers (with varying bandwidth and
phase margins) and comparing the resulting error plots. Try to explain these influences.
8

3.2

Inverted pendulum

Consider the inverted pendulum problem, see figure 3.2. The objective of this problem is to
keep the pendulum in upward vertical position = 0, by only applying a horizontal force F
to the cart. It is easy to see that this system is non-linear. However, around the equilibrium
= 0 the system can be linearized, resulting in the following transfer function (you might
want to show this yourself):
H(s) =

(s)
s
= 1
,
2
3
F (s)
6 (4M + m)Ls 3 Lbs2 + g(M + m)s + gb

(3.1)

where L is the length of the pendulum and b is the friction between the cart and the floor.
Furthermore, assume that
M = 0.05,

m = 0.04,

b = 0.02,

g = 9.81,

L = 0.15.

Now answer the following questions:


a) Draw a Bode diagram of this system. By looking at this plot, argue whether this system
is stable or unstable. Verify your result by calculating the poles of (3.1).
b) Consider the simple controllers C1 = 1 and C2 = 0.55. Draw the Nyquist plots of the
open loops C1 H and C2 H. Would you label the closed loops stable or unstable? Why?
Ci H
.
Check your answer by making time plots of the step response of the closed loop Ti = 1+C
iH
Hint: read Section 6.3 (Nyquist Stability Criterion) of the book of Franklin and Powell.
c) Design a stabilizing controller with a bandwidth of 10 Hz. Prove the closed loop stability
by making a step response plot and analyzing the Nyquist plot properly.
Hint: use Franklins formula Z = N + P , and design your controller such that you have
the right amount of counterclockwise encirclements of the point -1.
d) Suppose the cart is on a slope with a small (unknown but constant) angle, causing the cart
to drift away. Show how this changes the closed loop by drawing a block scheme. Does
this change the closed loop stability? Is your controller still able to keep the pendulum in
upright position?

Fg = mg

M
x

Figure 3.2: Schematic of the inverted pendulum example


9

3.3

Non-minimum phase systems

Consider the following third order systems


H1 (s) = 1000

s3

s+6
+ 20s2 + 5000s

and H2 (s) = 1000

s3

s6
.
+ 20s2 + 5000s

Draw the frequency response of both systems in one Bode diagram.


Compare the magnitude and phase diagrams. What difference do you notice? Explain
what causes this difference.
System H2 is called non-minimum phase. Explain why.
Design a simple stabilizing controller C1 for H1 . Put the bandwidth around 30Hz and
attain a robustness margin |S| < 3.5dB. Whats your phase margin?
Apply the same controller C1 to H2 and draw the open loop Bode diagram. Whats the
phase margin?
Draw the Nyquist curve of C1 (j)H2 (j). Would you label this system stable or unstable? Why? Verify your result by drawing a time response plot.
Design a new stabilizing controller C2 for H2 . Try to achieve a high as possible bandwidth while attaining |S| < 6dB. What is the bandwidth-limiting factor in this case?

10

Exercise

Design for performance


Install the student version of the design tool ShapeIt on your computer:
Download shapeit_student_version.zip from the ShapeIt homepage:
http://cstwiki.wtb.tue.nl/index.php?title=Home_of_ShapeIt
Unzip the files into a directory e.g. $matlabroot\toolbox\shapeit
Open Matlab, go to this directory and run: shapeit_setup_runonce.p
In case you encounter problems with ShapeIt, see the online FAQ first:
http://cstwiki.wtb.tue.nl/index.php?title=FAQ_of_shapeit

4.1

Load feedback with constraints

Download modl.mat from OASE. It contains an actual measurement of a CD-player, stored


in a frequency vector and a complex response vector.
Load modl.mat and make a stable model for the measurements (hz,fr_l) using frsfit.m;
in case of problems, a model is also provided (al,bl,cl,dl).
Make a stabilizing controller for this model with a high as possible bandwidth (0db
of open-loop) using just a lead filter and a gain (no notch), satisfying the robustness
margin |S| < 6dB. What part of the plant is limiting your bandwidth? Explain why.
Show stability of your closed loop by drawing a Nyquist plot and simulating a closed
loop step response.
Now include a notch filter and design a controller which achieves a 20 Hz bandwidth.
Again prove closed loop stability by showing Nyquist and a step response.
Suppose the measurement (and thus your model) denotes a transfer from a voltage [V]
to a translation [mm]. Assume the actuator (which is in the plant) can not handle
voltages higher than 10V. Design a controller with a high as possible bandwidth, with
the constraint that the maximum control signal u due to a step reference r = 1mm may
not exceed this 10V limit. Verify your results by making time plots.
Hint: what is the transfer from r to u? Determine its initial and steady-state output
from the Bode diagram. What are thus the trivial constraints on this Bode diagram?
Can a lowpass filter help to better the performance?

11

4.2

Non-collocated plant

Start ShapeIt and select 2 mass non-collocated as plant (load feedback).


Design a stabilizing controller with bandwidth of approximately 10 Hz.
Save your controller to a .mat file, and load this file in your workspace. Your data can
be found in the structure shapeit_data:
The controller parameters are stored in shapeit_data.C.block; type denotes
its building blocks (analogous to ShapeIt: 1=gain, 2=integrator, 3=lead/lag, etc.)
and param contains the corresponding parameter choices. A transfer function (sysobject) of C is stored in shapeit_data.C_tf.
A sys-object of the plant P is given in shapeit_data.P.sys
Suppose a sine (cosine) wave disturbance of amplitude 1 and with frequency 2 Hz is
applied to the system, between controller and plant:

r
-

d
C

What is the transfer function between d and e?


Construct this transfer with the sys-objects of P and C, and apply the defined disturbance to it (e.g. using lsim.m). What is the response and can you explain this?
Redesign and improve the controller to achieve the disturbance rejection specification: error
less then 0.01 within 0.5 sec. Assume, due to uncertainties and measurement noise, that
the bandwidth may not be higher than 100Hz. Show the improved transfer from d to e and
the new response. What would you have to do to let the error converge to zero? Show
your obtained controller and time response, and comment on them.

12

4.3

Wafer stage exercise

For this exercise you will need the ShapeIt-toolbox installed. The ShapeIt-toolbox can be
downloaded for free from the CSTwiki http://cstwiki.wtb.tue.nl. You also need to download waferstage.mat from OASE.
1. Load waferstage.mat in your workspace. It
contains a specific FRF-measurement (hz,frf)
of a wafer stage.
2. Use frsfit.m to make a model of this measurement. Make an appropriate estimation of
struc = [nden,nnum,nint] beforehand and use
an inverse weighting function.
3. Use either your model or the FRF-measurements
in ShapeIt to design a controller (and answer the
questions) in the following steps:
Try to obtain a high as possible bandwidth (400Hz should be possible!), maintaining a robustness margin |S| < 10dB, phase margin over 30 and gain margin of at
least 6dB.
A typical control scheme for this system is shown below:

em

r
-

d
C

ym

The goal of controller design is usually to minimize e = ry (6= em ). With this the
influence of the various input signals can be derived:
e = r y = r CP em d = r CP (e ) d
Which transfer function thus denotes the influence of the measurement error ?
Assume that this measurement error contains frequencies of 100Hz and higher.
These frequencies should thus be suppressed (smaller than 0dB) by the transfer
function of the previous question. Is your high-bandwidth controller capable to do
so? Why (not)?
Again design a controller with a high as possible bandwidth, but now also suppressing measurement errors of 100Hz and higher.

Play around with ShapeIt and try to get used to the toolbox. Try to import your own systems, design different controllers and compare them, export your controller to Simulink, etc.
Convince yourself that ShapeIt can save you time, especially during the experiments.

13

Exercise

Feedforward control
5.1

Mass feedforward design

Install the third-degree path generator (Ref3) on your computer:


Download Ref3.zip from http://cstwiki.wtb.tue.nl/index.php?title=Ref3.
Unzip the files into a directory, preferably in $matlabroot\toolbox\, which is the
Matlab toolbox directory.
Open Matlab, go to this directory and run: install_ref3.m.
See ref3_example.mdl for an example of how to use Ref3.
For more information on Ref3, see http://www.dct.tue.nl/home_of_ref3.htm
Make a simulink block diagram with as system
G(s) =

1000 3202
.
+ 20s + 3202)

s2 (s2

Design a stabilizing controller with a bandwidth of 10 Hz. Use a third order setpoint and
apply an acceleration feedforward to achieve the lowest tracking error possible. Can you
explain this acceleration feedforward by looking at the transfer function?

5.2

Feedback control for feedforward *

Open ShapeIt and choose the first example (mass) as plant. Assume that this plant represents a rotating mass connected to a DC-motor. The transfer function is thus from a motor
voltage in [mV] to a rotation in [rad]. Furthermore assume that this rotation is measured
with an encoder with 8000 pulses per revolution.
Determine the resolution of the measurements in [rad].
Design three simple controllers (lead-filters) yielding bandwidths of 1 Hz, 10 Hz and
100 Hz, each one with the same robustness margins.
Choose the default 3rd order setpoint in ShapeIt as the reference and compare the time
responses of each of the closed loops. Which controller would you prefer for feedforward
design? Explain why.

14

5.3

ShapeIt and feedforward *

ShapeIt is a very useful tool to design both a suitable trajectory and an appropriate controller
for eventual feedforward tuning. A good exercise is the following.
Load the viscous damping example, and design a controller and a 3rd degree setpoint,
such that the error profile has the desired shape (and magnitude) to accurately tune the
feedforward terms kf a and kf v later on. Export the plant and the controller, implement them
in a Simulink closed loop scheme, and tune these feedforward terms to suppress the error.
Note that you still need the Ref3-toolbox to implement your designed reference trajectory.

5.4

Feedforward design

You should have the Ref3-toolbox installed for this exercise.


Download the Simulink file feedforward.mdl from OASE (Matlab r2006b). Students with
Matlab 6.1 can download feedforward_m6.mdl, students with Matlab 7.0.4 can use feedforward_m7.mdl.
The file contains an unknown plant and a low bandwidth controller, which is already tuned
correctly.
Explain why we need a (relatively) low bandwidth controller for feedforward design.
Create a challenging reference trajectory for this plant. Create it such that the three
phenomena (mass acceleration, viscous damping and dry friction) are clearly visible in
the error signal.
Tune the three feedforward terms in the right order. Compare the resulting error signal
with the initial error.

15

Experiments

Experiments on the motion setup


Make sure to read MC_experiments_manual.pdf first!

X.1

Time domain tuning *

Connect the setup for the motor-feedback case. Replace ref3 for a constant 0 for this exercise.
a. Start with Kp = Kd = 0; carefully increase Kp . Feel stiffness.
b. Start with Kp = Kd = 0; carefully increase Kd . Feel damping.
c. Alternately increase Kp and Kd , without the system getting unstable. Feel the influence of each change. Use the error signal for evaluation of the found values for Kp and
Kd , and try to find an optimal setting.
d. Is it theoretically possible for the system to become unstable? Does this correspond
to your observations? Explain why (not).

X.2

Frequency Response Measurements

For parts a, b and c use the closed loop Simulink scheme. Connect the setup in the motorfeedback case.
a. Determine the plant FRF using a sampling frequency of 4000 Hz. What do you
observe? Try to relate all (anti-)resonances and phase phenomena to the setup.
b. Change the sampling frequency to 2000 Hz and 1000 Hz respectively and again determine the plant FRF. Compare the measurements. What do you observe?
c. Design 2 or 3 different PD-controllers with significantly different bandwidths and measure the sensitivity and plant FRF of the system for each controller. Interpret results,
and determine the influence of the bandwidth on your measurements.
d. Measure again the plant FRF, but now in open-loop using QadScope. Compare the
result with the closed-loop measurement.

16

X.3

Loop shaping game

Connect the setup for the load-feedback case (both in hardware and Simulink).
In this experiment youll need to show all your loopshaping tricks to design and implement a
high performance controller for the system.
a. Look back to exercise 3.1 and try to predict the new frequency response based on your
previous (motor feedback) measurements. Design a very simple controller based on
this prediction which should stabilize the load feedback case.
b. Perform an FRF measurement with this controller, using a sampling frequency of 4000
Hz. Interpret the result by explaining what you see.
c. Design a controller (offline) with an as high as possible bandwidth, given the constraints of stability and max(|S|) < 6dB. Show your designed transfer functions of
CH and S and determine the bandwidth.
d. Implement the designed controller in an experiment. If you run into problems (broken
axis, unstable system, etc), try to explain why, and solve it!
e. Measure the actual achieved open loop and sensitivity transfer functions (CH and S),
and show these in your report. Determine from these transfers the achieved bandwidth.
Mention the controller parameters youve used in your report!
f. Optional: Alternatively, you might try to design your controller online using pato03.mdl
and the available RTscope. Tuning must be done with care however! Small parameter
changes might lead to instability immediately!
Notice:
The system is very critical under load feedback, so start with a very safe Kp and Kd
and first do a frequency response measurement (part a.)
Then tune in a safe way and use ShapeIt to create filters.
Keep the cover in place for protection of your eyes. The axis can break and fly around!

X.4

Feedforward Tuning

Connect the setup for the motor-feedback case. You might want to use pato01.mdl (with a
real-time implementation of QadScope) instead of mini01.mdl for this exercise.
a. Define an appropriate (and challenging) setpoint trajectory and monitor the tracking error. Use a well-tuned PD controller, i.e. a controller which is suitable for a
feedforward tuning procedure.
b. Minimize the error by adjusting the feed forward gains Kf c , Kf v and Kf a .
c. Determine the level of improvement.

17