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 1 – Simulation Using Analog Computer

Day 2 of ECE 486 Lab. We will go through Lab 1 of lab manual and study basic step responses of a second order system.

Maths Behind the Scenes

A second order system can be modeled by a corresponding second transfer function \(\frac{Y(s)}{U(s)}\), where \(Y(s)\) is the Laplace transform of the output signal \(y(t)\) in time domain whereas \(U(s)\) the transform of input signal. A transfer function indicates “input-output” relationship.

\[ \frac{Y(s)}{U(s)} = \frac{\omega^2_n}{s^2 + 2 \zeta \omega_n s + \omega^2_n}. \]

  • \(\zeta \hspace{.65em}\) - damping ratio, dimensionless (You need to practical writing it down by hand. Over the years I have seen many interesting handwritten zeta’s.1)
  • \(\omega_n\) - natural frequency, [rad/s] (Why is it named such?)

Assuming zero initial conditions, \(s\) in frequency domain means taking derivative once back in time domain. For example, given output signal \(y(t)\), its Laplace transform denoted \(Y(s) \triangleq \mathcal{L} \{ y(t) \}\). Hitting \(Y(s)\) with an \(s\), i.e., \(Y(s) \mapsto s Y(s)\) is equivalent to operation in time domain \(y(t) \mapsto \frac{d}{d t} y(t)\). In a similar fashion, higher order derivatives in time domain can be regarded as inverse of product of its Laplace transform and power of \(s\),

\[ \frac{d^n}{d t^n} y(t) = \mathcal{L}^{-1} \{ s^n Y(s) \}. \]

A very important application of Laplace transform is solving differential equations (associated with LTI systems). Converting a differential equation to algebraic equation, solve the algebraic equations instead, then inverse transform the solution of the algebraic equation to get the solution of the original differential equation.

Hardware Part

Analog computer patch-up and data collecting. Use the patch-up wiring scheme you came up with in part (e) of prelab 1.

Matlab Part

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

% ... 

%% preamble 
% lab 1 - simulation using analog computer
% 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

% ...

Visualize data using plot(). The printer in lab does only black and white. In order to differentiate various data graphs, you might consider playing with line styles rather than colors. The following example may be helpful.

% loop over different line styles in the figure
% Yu Sun & Pei Ng posed this question

% 2015-09-08
% Y\"un Han
% ECE 486 Lab 1

%% 
clear     % clear values of 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

%% get 8 different graphs, which is not important
t = linspace(0,10,101);  % generate time array
y = zeros(8,length(t));  % init y array
for i = 1:8
    y(i,:) = sin(i/8*t); % each row of y is y(t)
end

%% loop over different line styles, which was the issue
% create a cell of strings
% lineStyles = ['r- ';'b: ';'g-.';'k--']; % method #1
% cellstr strips the space
% lineStyles = cellstr(lineStyles);
% in the code below, use 'char' to convert the cell string back to normal
% string

lineStyles = {'r-','b:','g-.','k--'}; % method #2
%% plot code
figure(1) % name a figure window
for i = 1:8

    % plot the graphs with looping line styles
    % mod(i,4)+1 ranges 1 through 4
    % the first applied line style is the 2nd in the lineStyles array
    % plot(t,y(i,:),char(lineStyles(mod(i,4)+1))) % method #1

    plot(t,y(i,:),lineStyles{mod(i,4)+1}) % method #2
    % only hold on once
    if (i == 1)
        hold on
    end

end

% decorate the figure
plt_opt = {'interpreter','latex'};
title('Loop over different linestyles')
xlabel('$t$ [s]', plt_opt{:})
ylabel('$y(t)$ [V]', plt_opt{:})
plt_lgnd = legend('$y_1 = \sin(1/8t)$', ...
                  'y2', ... % compare the difference btwn Roman font with the above in math mode, Computer Modern
                  'y3', ...
                  'y4', ...
                  '$y_5 = \sin(5/8t)$', ...
                  'y6', ...
                  'y7', ...
                  'y8','location','southwest');
set(plt_lgnd, plt_opt{:})
% if you need to legend 'selected' graphs, check out the following,
% http://www.mathworks.com/matlabcentral/answers/97684-how-can-i-choose-which-plots-of-data-to-label-in-a-legend-for
% -the-figure-with-plots-of-multiple-data

% see the resulting figure  

The reason why you want to explore different line styles is (again) that in case you don’t have a color printer and print out your lab report in lab, our lab printer only does black and white.

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

  • Maybe you have noticed that lab 1 is quite an easy one if you follow exactly the instructions of your lab manual. But it may not be the case for future labs (starting from lab 4). So you need to gear up for this class and keep up learning [hard]. Also, you should get started early on each prelab and lab report, don’t let yourself be fooled by the illusion that you can finish it within 2 hours on Monday afternoons during my office hours.
  • Now for lab 1 report calculation, you can call the function StepResponseMetrics.m you wrote (kind of2) for lab 0 report, to calculate the specs of step responses. And for theoretical specs you can always code up the formulae on page 13 of your lab manual (for 2nd order systems only). I don’t recommend any use of calculators! You have Matlab at your disposal.
  • You have to follow the official report template. It is a nonissue from now on since you can choose either the TeX version or the M$ version. They are available on the course website.

Due Date

Lab 1 Report is due at the beginning of Lab 2 (Sep 21). Prelab 2 is due on Monday by 5pm of the week of Lab 2 (Sep 18). 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
See the latest news about handwriting of college students.
2
There are two commands I want you to pay attention to, namely, sim() in LabReport0.m and find() in StepResponseMetrics.m.

Author: Yün Han

Last updated: 2017-09-14 Thu 20:29