ECE 486 Control Systems Lab (Fall 2017)

[Back to Home]

Day 1 Day 2 Day 3 Day 4 Short labs, weekly
Day 5 Day 6 Day 8   Long labs, biweekly
Day 7 Day 9 Day 10 Day 11 Final project, weekly

Lab 6 – Lead Controller Design

Day 81 of ECE 486 Lab. The last lab in the lab book.

Maths Behind the Scenes

Bode Plot of Rational Transfer Functions

General higher order transfer functions can be boiled down to product of “simple” transfer functions.

  • Rational transfer functions such as \(G(s) = \frac{N(s)}{D(s)}\) can be thought of as the product of first order transfer functions and second order transfer functions.

    \begin{align*} G(s) &= \frac{N(s)}{D(s)} \\ &= \frac{b_m s^m + b_{m-1} s^{m-1} + \cdots + b_1 s + b_0}{a_n s^n + a_{n-1} s^{n-1} + \cdots + a_1 s + a_0} \\ &= \frac{b_m}{a_n} \frac{\prod_j^m s + z_j}{\prod_i^n s + p_i} . \end{align*}

    For physical systems, \(m < n\) and \(m, n \in \ZZ_{>0}\).

    Also for complex roots of \(D(s)\), for each complex \(p_i\) there must be a conjugate \(p_k = \bar{p}_i\) for some \(1 \leq k \leq n\) so that \(s^2 + (p_i+p_k)s + p_i p_k\) is a second order polynomial with real coefficients, hence

    \begin{align*} \frac{1}{s + p_i}\cdot \frac{1}{s + p_k} &= \frac{1}{s^2 + (p_i+p_k)s + p_i p_k} \\ &= \frac{1}{s^2 + (p_i+\bar{p}_i)s + p_i \bar{p}_i} \\ &= \frac{1}{s^2 + 2\Re(p_i) s + |p_i|^2} \end{align*}

    is a second order transfer function. Similar argument applies to the numerator \(N(s)\).

  • Rational transfer function with time delay \(e^{-\tau s}\), can also be reduced to product of first order and second order transfer functions, since by Padé, we have

    \[ e^z \approx \frac{1 + \frac{1}2 z}{1 - \frac{1}2 z} \]

    for \(z \in \CC\). Substitute \(z = -\tau s\), the claim holds.

  • By the aforementioned two arguments, it suffices to know how to sketch Bode plots for \(\frac{1}{\tau s + 1}\), \(\tau s + 1\), \(\frac{\omega_n^2}{s^2 + 2\zeta \omega_n s + \omega_n^2}\) and \(s^2 + 2\zeta \omega_n s + \omega_n^2\). Then for higher order system transfer functions, it is a matter of superimposing of all plots of first order and second order factors.

Nyquist Criterion Derived from Argument Principle in Complex Analysis

  • The theorem of Argument Principle.

    Theorem (Argument Principle): Let \(\gamma\) be a simple closed curve in \(\CC\). For a function \(f(z)\) that is meromorphic (i.e., with no singularities worse than poles) on \(\gamma\) and its interior, and \(f(z)\) does not vanish for any \(z \in \gamma\), then

    \begin{align*} \frac{1}{2\pi i} \int_\gamma\frac{f'}f &= \chi(f\circ \gamma; 0) \\ &= \text{#zeros of $f$ } - \text{ #poles of $f$ inside $\gamma$}, \end{align*}

    where \(\chi(f\circ\gamma; 0) = \chi\big(f(\gamma); 0\big)\) is the encirclement of \(0\) by the image curve of \(\gamma\) under \(f\).

  • Nyquist Stability Criterion derived from Argument Principle.

    In the context of control, whether or not a system is stable is determined by whether there are Right Half Plane closed-loop poles of a transfer function. Therefore the \(\gamma\) closed contour is chosen as \(\gamma = \Im(z) \cup C_R\) where \(C_R\) is a semi-circle on the right half plane with radius \(R = \infty\), \(\Im(z)\) is the imaginary axis so that the entire Open Right Half Plane is the interior of \(\gamma\) contour.

    The choice of \(f\) is the closed-loop transfer function \(1+KG(s)\) however the encirclement of \(0\) by \(1 + KG(s)\) is equivalent to encirclement of \(-\frac{1}K\) by the open-loop transfer function \(G(s)\) or encirclement of \(-1\) by \(KG(s)\).

    Since the Nyquist plot of \(G(s)\) is the image curve of \(\gamma\) under \(G\) in the complex plane, the sketch needs both modulus and argument of a complex number, or magnitude and phase in the parlance of Bode plots. This is when Bode plots kick in; we can sweep \(\omega: 0 \to \infty\) by using Bode plot as a guide to get the Nyquist plot \(G(j\omega)\).

Matlab Part

Keep the header/preamble of your script from Lab 0. (Include those lines as part of your matlab script template.)

You may find the “manual” Bode plot helpful since you can have full control of axis, label’s, legend etc. You need to use semilogx() 2 in the post lab report.

% ... 

%% preamble 
% lab 6 - lead controller design
% by me and partner 
% today's date 

%% 
clear     % clear values of (all) variables in workspace
clc       % clear messages in the command window
clf       % clear existing figures 
close all % close all existing windows; w/o 'all', only close the latest

% ...

% define the open/closed loop transfer function based on fitting data
num = ;   % use fitting results Kdsa, z, p1 and p2
den = ;
sysG = tf(num, den);
% use bode to calculate magnitude and phase
[mag_fit, phase_fit] = bode(sysG, omega_data); 
% note: [~, phase] = bode() uses ~ to suppress one output argument

% sysG_mag and sysG_phase will not be 1-d arrays, google the trick or see example 
% 3.5 in your text
% quote from the documentation
% """
% mag and phase are three-dimensional arrays, in which the first two dimensions 
% correspond to the output and input dimensions, and the third dimension is the
% number of frequencies. 
% """

% ... computing continues

%% plots code begins
figure(1)                                % name a figure window
subplot(211) % 2x1 subplots array; 1st   % work on 1st subplot, magnitude plot
semilogx(omega_data, 20*log10(mag_data)) % convert to dB if necessary?
                                         % start overlaying fitting and data plots
hold on                                  % try placing it before semilogx also?
semilogx(omega_data, 20*log10(mag_fit))  % convert to db if necessary?
% labels, title, legend ...

subplot(212) % 2nd subplot               % work on 2nd subplot, phase plot
semilogx(omega_data, phase_data*180/pi)  % convert to degrees if necessary?
hold on
semilogx(omega_data, phase_fit)          % convert to degrees if necessary?
% ...

Visualize data using plot().

Hardware Part

  • Since we are going to use Simulink™ Windows Target®, it is not a good idea to run your files from a network path. For example, you may need to create a folder named after your NetID in local C:\ drive and save your Matlab WinTarget files there. Move the folder to your thumb drive once you are finished.

    Always keep C:\ drive clean and organized.

  • Always clean up before exiting. Specifically,
    • Clean up bench table, restore pot, motor lock etc, reinstall screws;
    • Sort out wires color by color, type by type and put them back to racks;
    • Turn off oscilloscope, meters etc;
    • Restore chairs.

Follow-up

Comments

On Lab 6 Part (I)

The recommended way to run simulations in Part (I) was using script plus a saved simulink file. You don’t want to

  • go back and forth between simulink window and workspace;
  • hard code input signals Vi as \(0.5, 5, 50\) in step block or change the output variable name V in simulink;
  • hard code saturation limit and enable/disable it using manual switch

when you run different cases. Instead, keep the input signals as variables and initialize them in the script; use assignment to save a copy of the default output. See the example below.

% ...

% lab 6 part (i)

%% run unsaturated case and saturated cases separately

% unsaturated cases

sat_limit = inf;      % disable saturation block
% no need to use sat_up_limit and sat_low_limit separately since in our case 
% sat_low_limit = - sat_up_limit

% first case: Vi = .5

% initialize input voltage
Vi = .5; 
% run simulation once
sim('lab6_part_i')    % matlab searches for *.slx itself, no need to add extension
% save data immediately after the run before data is overwritten during next run
V05    =    V;        % V is the signal var name of 'to workspace' block
time05 = tout;        % tout is the default time array for data export

% second case: Vi = 5

% ...

% saturated cases

sat_limit = 10;       % enable saturation block

% ...

On Post Lab and onwards

We have completed all lab sessions of this semester (lab manual), that means from now on we will focus on the Final Project. There are only three lab meetings remaining.

  • The suggested schedule for Week 2 of FP is to complete Chapter 3 and half of Chapter 4 or complete both since you can go as fast as you want.
  • The week after Week 2 will be dedicated to the remaining half of Chapter 4 and Chapter 5.
  • The last meeting will be for catch-up or extra credit Chapters 6 and 7.
  • Lab 6 Report is due three weeks from now in lab during Week 2 of Final Project (Nov 30).
  • Prelab for FP is due on Monday, Nov 27.

Please make sure you can demo Chapter 2, frictionless motor before you go to Chapter 3 next time we meet on Nov 30, or at least you should demo within the first hour of lab time on Nov 30; or whenever you are ready, send me an email and by appointment I will check you out in lab; you are welcome to stop by my office hours to do the demo as well.

Everything about demos should be finalized by 5pm on Dec 15 and Final Project Report is due 5pm on Dec 18. You can start writing the FP report now. Just write as much as you can to the point where you are now. For example, if you have already shown me the demo of Chapter 2, you should be able to answer all the questions in the guidelines of FP. (You can ignore the note for Spring 2016 about Chapters 6 and 7.)

https://courses.engr.illinois.edu/ece486/Labs/Final_Project/fp_report.htm

Due Date

Lab 6 Report is due at the beginning of Week 2 Final Project (Nov 30). Prelab for the Final Project is due on Monday by 5pm of the week of Week 2 Final Project (Nov 27). Handwritten prelab is acceptable; typesetting is recommended.

Questions

You are always very welcome to stop by office hours on Mondays. Emailing questions is another way. You can always include [ECE486]blah in the title of your question emails.

Spot any typos? Email me at once. You will earn up to +5 points for each typo/technical error reported.

Footnotes:

1
Lab class meets weekly for the rest of the semester.
2
Some of you will probably notice placing hold on before or after actually makes a difference.

Author: Yün Han

Last updated: 2017-11-16 Thu 20:59