Você está na página 1de 49

Module 1: Transfer Functions and

Frequency Responses
Module 1: Transfer Functions and Frequency Responses
This article is contained in Scilab Control Engineering Basics study module, which is used as
course material for International Undergraduate Program in Electrical-Mechanical
Manufacturing Engineering, Department of Mechanical Engineering, Kasetsart University.

Module Key Study Points

How to create a transfer function in Scilab


Xcos CTR block usage
Frequency response concept
Scilab commands for plotting frequency responses

In general, the first step for control system analysis and design is to acquire a model that
represents the actual plant to be controlled. Then a feedback diagram is constructed with this
plant model and a controller described as transfer functions, either in continuous or discrete
time domain. For analysis and design in frequency domain such as the so-called classical
method, loopshaping, or Quantitative Feedback Theory (QFT), some form frequency response
data is needed. Hence, in this module we show how to formulate a transfer function in Scilab
and plot its frequency response.

Transfer Function Formulation

To be concrete, we consider in Figure 1 a simple diagram of robot joint driven by DC motor


through a gear transmission with ratio r:1 [1].

Figure 1 robot joint connected to DC motor via a gear transmission

Let be the sum of motor and gear inertia. By simple calculation, it is easy to
show that the rotational motion in terms of is described by

1/49
(1)

where represents torque constant. We want to describe a model in transfer function form so
that a block diagram can be drawn. To develop the electrical side of DC motor, consider the
model shown in Figure 2.

Figure 2 a model of permanent magnet DC motor

By Kirschoffs voltage law, we have

(2)

where is back emf constant. From now on we omit the subscript in the armature
inductance and resistance. It is left to the reader to verify that, in Laplace domain, the joint
dynamics in Figure 1 can be described by

(3)

(4)

This can be drawn as a block diagram in Figure 3.

Figure 3 block diagram of the robot joint dynamics in Figure 1

2/49
The transfer function from to can be derived by setting , which gives

(5)

Similarly, the transfer function from to is found by setting .

(6)

To simplify the equation further, we can assume that the electrical constant is much
smaller than the mechanical constant . So the transfer functions in (5) and (6) reduce
to

(7)

(8)

respectively. These two equations correspond to second order differential equation in time
domain

(9)

By omitting parameter subscripts, (9) can be rewritten as

(10)

with represents effective damping, control input, and


disturbance input. The reduced block diagram of (10) can be drawn as in Figure
4.

Figure 4 reduced block diagram of robot joint dynamics

So, the transfer function for a robot joint driven by DC motor we will be using in our study
modules is in the form

3/49
(11)

Lets put some values to the parameters, say, . Hence the resulting transfer
function becomes

(12)

Now we demonstrate how to construct a transfer function such as (12) in Scilab. One method
begins by creating the Laplace variable s

-->s=poly(0,'s')
s =
s

and then use it to form P as described by (12)

-->P = 1/(10*s^2+0.1*s)
P =
1
---------
2
0.1s + 10s

So far so good. It already looks like (12). However, this data format still lacks some inside
information necessary for further processing such as frequency response plot. So one more
step is needed to convert it to a continuous-time linear transfer function, by using the syslin()
command

-->P = syslin('c',P)
P =
1
---------
2
0.1s + 10s

The interactive response shown in Scilab console does not look any different than before. But
the first argument c passed to syslin tells Scilab that this is a continuous-time system. Now P
is ready to be used by other commands such as bode, freqresp etc.

Another method that eventually yields the same P is shown below.

-->num = 1;
-->den = poly([0 0.1 10],'s','c');
-->P = syslin('c',num,den)
P =
1
---------
2
0.1s + 10s

4/49
In this method, the numerator and denominator of P are created first, as a number 1 for the
former and a polynomial of s for the latter. Note that the row vector passed to poly(),
representing the polynomial coefficients, starts with the lowest order of s.

Transfer Function Block in an Xcos Model

Xcos is a simulation engine that comes with Scilab. Here we assume that the reader has some
familiarity with basic functionality of Xcos to the level that she could create some simple
diagram using blocks from standard palettes.

The standard block for transfer function can be located in Continuous time systems palette,
under the name CLR. When a user clicks on this block, a parameter dialog window emerges.
For this block, numerator and denominator in terms of polynomial of s can be put into the
input field directly. For our transfer function (12), the data is typed in as shown in Figure 5.

Figure 5 A dialog window for setting transfer function parameters

In the next section, we will connect some input to this plant and measure its output by an
oscilloscope.

Frequency Response

Figure 6 depicts frequency response concept in a nutshell. In words, for a Linear Time-
Invariant (LTI) system driven by a sinusoid input, the output is a sinusoid with same
frequency, only its magnitude and phase might change. When the input frequency varies,
this results in new values for and . This pair of data through out a range of frequency,
actually a vector of complex numbers, constitutes a frequency response for an LTI system.

Figure 6 An LTI system driven by sinusoid input

5/49
To experiment with this, build a model shown in Figure 7, or download sinio_compare.zcos,
and run the simulation. Note that the transfer function used is the DC motor model from the
voltage input to shaft velocity output; i.e., the integrator is removed.

Figure 7 sinusoid input and output comparison

See the input and output comparison from the scope. Change the input frequency by clicking
on and put in new value. Do you see the change in amplitude and phase of the output?

Relationship between transfer function and frequency response

You may remember from linear systems course that, for a continuous-time transfer function
described in terms of Laplace variable s, frequency response can be achieved by letting
.

(13)

By this relationship, a frequency response of a transfer function can be plotted the hard
way. Using (12) as an example, we solve for manually by substituting , which
gives

(14)

Now we can plot the magnitude and phase versus frequency by using the following set of
commands

f=linspace(0.01,1,1000); // frequency vector (Hz)


w=2*%pi*f; // convert to rad/s
Pmag=zeros(1,1000);Pph=zeros(1,1000);
for k=1:1000, // compute P(jw) at each frequency point
P=1/(-10*w(k)^2+0.1*%i*w(k));
[Pmag(k),Pph(k)]=polar(P);
end

6/49
Pph = (180/%pi)*Pph; // convert to degree
figure(1)
subplot(211),plot2d(f,Pmag); // magnitude plot
xlabel("Frequency (Hz)");
ylabel("Magnitude");
subplot(212),plot2d(f,Pph); // phase plot
xlabel("Frequency (Hz)");
ylabel("Phase (degree)")

that yields Figure 8. First a linear frequency vector is created in Hz and converted to
radian/sec. Vectors for keeping magnitude and phase information are initialized

Figure 8 a simple frequency response plot

Then, the frequency response of P is computed at each frequency point , converted to polar
form, and put into the magnitude and phase vectors. The phase vector is converted from
radian to degree. Last, the magnitude and phase are plotted in the same figure using subplot()
command.

Some drawback of this plot is obvious. The frequency range is quite limited and the plots are
concentrated only on narrow low frequency region. This is the reason that a frequency
response is plotted on a semi-logarithm scale and the magnitude is expressed in decibel,

7/49
where . Slightly adjust the above Scilab code to yield a much nicer plot
range as in Figure 9.

Figure 9 a frequency response plot that covers broader frequency range


f=logspace(-5,2,1000);
w=2*%pi*f; // convert to rad/s
Pmag=zeros(1,1000);Pph=zeros(1,1000);
for k=1:1000, // compute P(jw) at each frequency point
P=1/(-10*w(k)^2+0.1*%i*w(k));
[Pmag(k),Pph(k)]=polar(P);
end
Pmag = 20*log10(Pmag); // convert Pmag to dB
Pph = (180/%pi)*Pph; // convert Pph to degree
figure(2)
subplot(211),plot2d("ln",f,Pmag); // magnitude plot
xlabel("Frequency (Hz)");
ylabel("Magnitude");
subplot(212),plot2d("ln",f,Pph); // phase plot
xlabel("Frequency (Hz)");
ylabel("Phase (degree)");

This type of frequency response is known as Bode plot. An easier way to plot from a transfer
function created by syslin() is by the command bode().

-->s=poly(0,'s');

8/49
-->P = 1/(10*s^2+0.1*s);
-->P = syslin('c',P);
-->bode(P)

This yields the plot in Figure 10. Type help bode to see options such as how to adjust
frequency range.

Figure 10 frequency response using Scilab bode command

Keyword: the frequency range that a plant is responsive is called bandwidth. Strictly speaking,
bandwidth covers frequency region such that the gain is above or . When trying
to identify bandwidth from a Bode plot, we can roughly indicate the frequency point where
the magnitude curve touches line. For example, from Figure 10, the bandwidth is about
.

Another type of frequency response useful for control design is called a Nyquist plot.
Actually, it is the same data expressed in different format. Recall that each point of frequency
response is just a complex number. When it is described in polar form, we get a Bode plot. A
Nyquist plot, on the other hand, is the frequency response described in rectangular form
. So it constitutes a graph in complex plane. A Nyquist plot is easily produced with
command nyquist, say,

-->nyquist(P)

9/49
yields the plot in Figure 11. We will discuss this type of data more in later modules.

Figure 11 frequency response from Scilab nyquist command

For the last part of this study module, we discuss an application of using frequency response
that may be useful beyond control engineering field. A filter is an electronic circuit, either
analog or digital, that can be used to alter the frequency response of a system to suit some
particular needs. The most common one is a low pass filter (LPF) used to attenuate high
frequency noise.

Lets make our plant more realistic. Suppose in our DC motor robot joint with transfer
function described by (12), the joint angle is measured by a potentiometer and the resulting
voltage is fed to a 12-bit A/D input of a microcontroller. The interface circuit are properly
designed to use the full range of A/D; i.e., joint angle at 0 degree corresponds to A/D value 0,
and at 360 degree, it reads as 4095. Adding this conversion factor in series with output of (12)
in effect raises the gain by 4095/360 or 11.375. The new plant is

(15)

The bandwidth of (15) is about 0.2 Hz, which you can verify by yourself from a Bode plot, or
search it more accurately from data as follows

-->s=poly(0, 's');
-->P=syslin('c',11.375/(10*s^2+0.1*s));
-->f=linspace(0.01,1,1000);
-->fres=repfreq(P,f); // compute frequency respons
-->ibw=find(abs(fres)<0.707); // find index of bandwidth frequency
-->fbw=f(ibw(1)) // locate BW frequency with index
fbw =
0.2022523

10/49
In this chunk of code, we use another Scilab frequency response function repfreq() , which
returns a vector of frequency response without plotting anything. Then use function find() to
locate the vector index with gain less than 0.707, and use that index to find the bandwidth
frequency.

Now, suppose that during operation, the potentiometer circuit that measures plant output is
somehow contaminated by some noise with higher frequency spectrum than the plant
bandwidth. To make it simple, suppose the noise is a sin wave of magnitude , and its
frequency is . We want to get rid of this noise using a simple passive LPF circuit as
shown in Figure 12.

Figure 12 a passive LPF circuit

consisting of only a resistor and a capacitor. We want to design the LPF with cutoff frequency
at the plant bandwidth . Consult some analog filter design cookbook to get that the
cutoff frequency of this filter can be selected from

(16)

Simple calculation shows that practical values of and yields the


cutoff frequency rad/s or approximately .

A transfer function for this LPF can be derived easily. It is left to the reader to verify that it
equals

(17)

Substituting the chosen component values yields

(18)

Plot the frequency response to verify the cutoff frequency. Since we are now interested in
only the magnitude plot, it is convenient to use Scilab function gainplot(), which does as its
name says

-->H=syslin('c',1/(1+0.8*s));
-->gainplot(H)

11/49
The plot result in Figure 13 shows that our LPF has cutoff frequency about as desired.

Figure 13 gain plot of LPF (18)

Exercise: Construct an Xcos diagram and simulate to verify that this LPF filter works. Use
(15) as plant transfer function and connect some command input to it, say, a narrow pulse.
Then add a sinusoid noise signal with magnitude and frequency to the plant output.
Use CMSCOPE block that has two channels. On the first channel, measure the output
contaminated by the noise, and on the second channel, measure the plant output after passing
through the LPF. Do you see the noise attenuated? Try varying the noise magnitude and
frequency. What happens when the noise frequency lies within the plant (and LPF)
bandwidth?

Summary

In this study module, we discuss transfer function and frequency response basics,
concentrating on Scilab commands and Xcos block usages. This serves as a good foundation
for later development, such as feedback control analysis and design that relies on block
diagram manipulation and frequency domain. Bode plot is a powerful tool used in classical
control design since WWII. In the past, plotting manually on a sheet of paper could be
tedious. Nowadays, software such as MATLAB or Scilab can generate magnitude and phase
plots easily and accurately. Some basic knowledge taught in a undergrad control course is still
necessary for sanity check.

12/49
Module 2: Feedback Properties
This article is contained in Scilab Control Engineering Basics study module, which is used as
course material for International Undergraduate Program in Electrical-Mechanical
Manufacturing Engineering, Department of Mechanical Engineering, Kasetsart University.

Module Key Study Points

The benefiets of feedback


Step response and tracking performance
Stability judgment from transfer function pole locations
Root-locus plot
Disturbance attenuation performance

In this study module and later on, we use the robot joint driven by DC motor model developed
in module 1. When we add some command input to the transfer function, it is evident that
position control with no feedback, called open-loop control, for this plant is difficult and
inaccurate, unlike a step motor whose angle per step is predefined.

The simplest feedback loop can be formed by computing the error; i.e., difference between
command and output, and multiplying that value by a gain to construct a control input for the
plant. This scheme may be called proportional control, which is often used in applications
with no tracking requirement, such as temperature control, or regulation of liquid level in a
tank.

To experiment how this simple feedback scheme performs with our robot joint, we construct
an Xcos model like shown in Figure 1, or download
p_feedback.zcos.

Figure 1 a simple proportional feedback control

Notice in this diagram that we wrap the output as negative feedback to the summing junction.
This in effect feeds the difference between the step command and output to the gain block.
Another learning point from this model file is how to push some variables to Scilab

13/49
workspace using To workspace blocks. The reason for using these blocks is that we want to
compare responses from 3 different proportional gain settings. Instead of creating 3 copies of
the diagram in Xcos with different gain values, it is easier to change the output variable name
and run the simulation 3 times, then plot the results in Scilab.

Click on a To workspace block. There are 3 input fields. We need to adjust only the
uppermost 2 Size of buffer and Scilab variable name and leave the Inherit field to 0. Here
we run the simulation 3 times with 3 sets of small gains 0.001, 0.01, and 0.1. The output
variable names are set to y1, y2, and y3.

An output from To workspace block is a data structure with two fields, namely time and
values. So, to compare the responses, issue the following codes

-->plot(r.time,r.values,y1.time,y1.values,y2.time,y2.values, ...
y3.time,y3.values);
-->xlabel('time (sec)');
-->ylabel('angle');
-->legend('Command','Gain=0.001','Gain=0.01','Gain=0.1');

which gives the plot in Figure 2.

Figure 2 step responses from different proportional gain settings

Tracking Performance

From the comparison in Figure 2, we observe in the lowest gain case that the step response
gradually rises to the command level of 1. When the gain increases, the response is faster, but

14/49
exceeds 1 further before settling more in an oscillating fashion. The step responses from most
dynamical systems behave quite the same. So we can formulate time-domain parameters that
can be used as control specifications like shown in Figure 3. Consult an undergrad control text
for definition of these parameters, some of them may have slight variants among authors. For
example, some may define rise time tr as the period the response goes from 0.1 to 0.9 of the
command value, while the settling time could be specified as the time the response stays
within 0.05 or 0.02 of the command value.

Figure 3 step response specifications

The step response explained thus far is one of the feedback properties called tracking
performance. The responses in Figure 1, even though they all converges to the command
value, may not be satisfactory in practice, because it takes about 800 seconds (or 13 minutes!)
to settle.

We can improve this step response by adding some dynamics to the controller, instead of
using only a proportional gain. The next example exploits a type of simple control, known as
a (1st order) lead-lag compensator, that has the controller transfer function in the form

(1)

Our control design job is to select the control parameters , , , to achieve a good tracking
response. Note that z and p are called the zero and pole of . In general, zeros and poles

15/49
of a transfer function correspond to the roots of its numerator and denominator, respectively.
Certain feedback properties can be determined from their locations. We will get back to this
later.

At this point, let us do some trial and error design with the lead-lag compensator feedback
diagram in Figure 4. Download leadlag_feedback.zcos, adjust the parameters , , to
achieve the best step response possible. Actually, there exists some design procedure for a
lead-lag feedback system discussed in a standard undergrad control textbook. At this point,
consult one if you are hopeless. We will gradually learn about control design after a few
basics are made clear to the reader.

Figure 4 a lead-lag compensator feedback model

Using this ad-hoc design, we are satisfied with

(2)

that yields the step response in Figure 5. Obviously, tracking performance is vastly improved,
since now the step response settles within 0.2 second, compared to 800 seconds when using
only proportional gain.

16/49
Figure 5 response from lead-lag compensator (2)

Is there any drawback in replacing the static gain with this dynamic controller? Go back to the
proportional control gain simulation. You can verify by yourself that increasing the gain can
never destabilize the system. For the lead-lag compensator, lets see what happen when
someone adjusts the compensator zero and pole wildly, say, he might inadvertently switch the
zero and pole location to

(3)

Running the simulation with this compensator yields the response in Figure 6. This is an
example of unstable response, as the output oscillates out of bound. So, in the next section, we
study in more detail this important feedback property.

Figure 6 response from lead-lag compensator (3)

Closed-Loop Stability
17/49
We should have put this statement before anything else: a feedback system must be stable. An
unstable closed-loop system is not only useless, it can also cause harm to the operator and/or
environment. Imagine an output such as in Figure 6 would cause the robot arm to swing
wildly and hit anything in the area.

As already well-known, for an SISO system like our DC motor robot joint, feedback stability
can be checked from the poles of a closed-loop transfer function. For a stable system, all such
poles must lie in the left half of complex plane. A system with pole(s) on the axis, which
gives oscillatory response may be called marginally stable.

For example, in the diagram of Figure 4, the transfer function from to with unity feedback
can be computed as

(4)

To form in Scilab is straightforward

-->s=poly(0,'s');
-->P=syslin('c',1/(10*s^2+0.1*s));
-->C=syslin('c',20000*(s+0.01)/(s+100));
-->Tyr=C*P/(1+C*P)
Tyr =
2000
--------------
2
2000 + 100s + s

Its poles can then be observed graphically by issuing command

plzr(Tyr)

which gives the plot shown in Figure 7. The poles are indicated by x symbol. (The round
symbol marks the origin of complex plane, not a zero, since this transfer function has none.)
We conclude that the closed-loop system is stable since all poles lie within the left half plane.

18/49
Figure 7 pole zero display from plzr command

Unfortunately, I could not find a single Scilab command to compute the poles from a transfer
function directly (please email me if there is such a command that I missed). Two ways to get
around this 1) extract the denominator from the transfer function and compute the root with
roots command, or 2) extract state-space data with abcd command and compute the
eigenvalues of matrix A using spec command.

Stability versus Gain Adjustment

In practice, a controller gain might be the easiest parameter to adjust, since it leaves the
dynamic part intact. Sometimes we are interested to visualize the closed-loop pole locations
as a function of gain value. This is known in the control literature as the root-locus method.

To richen the problem a little more, suppose another pole at is added to the lead-lag
compensator (2) to become

(5)

Then form a so-called loop transfer function

(6)

19/49
This transfer function is normally used in a few control design schemes such as classical
method and QFT. It is also used in the root-locus method. So we construct it in Scilab as
before

-->C=syslin('c',20000*(s+0.01)/(s+100)^2);
-->L = C*P
L =
2000
----------------
2 3
10000s + 200s + s

The Scilab command for root-locus method is evans

-->evans(L);
-->sgrid;

gives the plot in Figure 8. This is simply the plot of . We see that as the gain
increases, two of the poles travel towards the right half complex plane, resulting in closed-
loop instability.

Figure 8 root-locus plot from command evans

Suppose we want to know the maximum gain value before the system becomes unstable.
Issue this command

-->[kmax,s]=kpure(L)

20/49
s =
100.i
kmax =
1000.

The maximum value of moves the closed-loop poles to the location on the
axis. The reader should download leadlag2_feedback.zcos and verify that the output oscillates
at this gain value. Increasing the gain more should destabilize the system.

Disturbance Attenuation Performance

In the exercise at the end of last module, we simulate the situation that the plant output is
contaminated by some exogenous signal. For the open-loop case, using an LPF can improve
the signal measured by a sensor, but actually does not suppress the effect of that signal on the
plant output. Feedback control, on the other hand, can effectively attenuate a disturbance
signal, whether it is injected at the input or output of the plant, provided that the controller is
properly crafted for the type and spectrum of the disturbance.

To experiment with disturbance attenuation, construct an Xcos model like in Figure 9, or


download feedback_wdist.zcos.

Figure 9 feedback model with output disturbance

This is the same lead-lag compensator with some disturbance signal added to the plant output.
The disturbance can be selected as a step or sinusoid by means of a toggle switch. The step
disturbance is of magnitude 1. The sinusoid disturbance signal has magnitude 0.5 and
frequency 1 Hz . Both are set to active at t = 1.5 sec. The simulation results are shown in
Figure 10 and 11, for the step and sinusoid disturbance inputs, respectively.

21/49
Figure 10 response to step disturbance

Figure 11 response to sinusoid disturbance

For the case of step disturbance in Figure 10, we see the output is affected at the step time t =
1.5 sec, but is swiftly brought back to the command level of 1 in about 0.2 sec. An open-loop
system could not perform such compensation. When the disturbance is a sinusoid signal like
in Figure 11, the plant output oscillates with the same frequency as the disturbance, but with
magnitude of about 0.2, while the disturbance input magnitude is 0.5.

You may try altering the disturbance frequency to see how it affects the response. Is it
possible to compute the level of attenuation as a function of frequency? The answer is yes.
First we need to discuss another important closed-loop transfer function.

The Sensitivity Transfer Function

Generally speaking, the response at any measured point to an input injected at any point in
the feedback loop is dictated by , the closed-loop transfer function from to . Lets
denote the disturbance signal and plant output by d and y, respectively. So to compute
attenuation level for the feedback model in Figure 9, we need to derive the transfer function

22/49
from the output disturbance to the plant output. With simple block diagram manipulation, it
can be shown this transfer function equals

(7)

This closed-loop transfer function is well-studied in control literature. It bears a specific name
the sensitivity transfer function, and is often denoted by capital letter ; i.e.,

(8)

So, to compute in Figure 8, and display Bode magnitude plot, issue the following
commands

-->s=poly(0,'s');
-->P=syslin('c',1/(10*s^2+0.1*s));
-->C=syslin('c',20000*(s+0.01)/(s+100));
-->L = C*P
L =
2000
--------
2
100s + s
-->S=1/(1+L)
S =
2
100s + s
--------------
2
2000 + 100s + s
-->gainplot(S)

This yields Figure 12. The phase of sensitivity function has no useful information so no need
to plot it. Take a note on the shape of sensitivity frequency system, which always looks more
or less like this for a typical system that has nonzero DC gain. Attenuation is good in the low
frequency range, then the response goes to 0 dB as frequency increases. We will study how to
formulate this curve as control specifications in later module.

23/49
Figure 12 Bode magnitude plot of the sensitivity function

At this point we are just interested on the attenuation level of sinusoid input disturbance in
Figure 11. The disturbance frequency is 1 Hz. From the graph we have -10 dB attenuation.
Convert this to absolute gain yields the value 0.32. So when the sinusoidal disturbance has
magnitude 0.5, the output should swing at magnitude of about 0.16. This conforms to the
simulation result in Figure 11.

Summary

In this study module, we examine some important feedback properties, starting from step
response in time-domain, which can be used to tune a commercial controller such as PID, or
as specifications for custom control design. The most important property of a feedback system
is stability. We show how to determine whether a system is stable by checking the poles of
closed-loop transfer function. Root-locus is a technique to observe how pole locations change
as controller gain is adjusted. In the last section, we discuss disturbance attenuation
performance of a feedback system.

In the discussion, we explicitly give definitions for 2 important transfer functions, namely the
loop transfer function in (6), and the sensitivity transfer function in (8). To anticipate the
development in later module, we have to mention that (4), often denoted simply as , is
referred to as complementary sensitivity transfer function. This is due to the fact that

(9)

(9) is called an algebraic constraint. We will see in the next module how this relationship
could make feedback system design a challenge.

24/49
Module 4: PID Control
This article is contained in Scilab Control Engineering Basics study module, which is used as
course material for International Undergraduate Program in Electrical-Mechanical
Manufacturing Engineering, Department of Mechanical Engineering, Kasetsart University.

Module Key Study Points

understand the basics of PID control


learn the effects of 3 parameters to system response
learn how response is degraded by integrator windup
How to tune PID parameters by Ziegler-Nichols Frequency Domain method

PID stands for Proportional, Integral, and Derivative. It is a standard control structure used
successfully in many industrial applications. Commercial PID controllers can be bought off
the shelf and installed in the system. After some setup and tuning the three PID gains, and
perhaps some additional parameters, the system is up and running in no time. Of course, this
means the control engineer is certain the plant can be handled by the PID controller and
understand how to adjust the control parameters. Without such knowledge, it could be a
frustrating experience to her.

So, in this module we discuss some basics of PID control and focus on how to analyze a
feedback sysem, with Scilab, build an Xcos diagram and simulate. For a detailed study, we
recommend [1]. For those interested in digital PID implementation, document [3] on this site
might be helpful. The e-book [4] provides more information on independent robot joint
control using PID.

Different forms of PID

The so-called textbook form of PID controller is described as follows

(1)

This algorithm computes the control variable as output, given the input , the error between
the command and plant output. We see that the control variable is a function of 3 terms: P
(proportional to error), I (time integral of error), and D (derivative of error), with
corresponding control parameters (proportional gain), (integral time), and (derivative
time), respectively. Taking Laplace transform of (1), we have

(2)

with the transfer function of PID controller

(3)

Another common structure of PID algorithm is represented by

25/49
(4)

In this form, the controller gains are distributed to each of the PID terms separately, with its
transfer function

(5)

For our discussion of PID controller, we focus on the form (4) and (5). Nevertheless, it is easy
to convert between parameters of (1) and (4) by the relations

(6)

Ex. 1: To get started with Xcos simulation of a PID feedback system, download file
pid_feedback.zcos . This launches an Xcos diagram in Figure 1. This diagram can easily be
constructed using Xcos standard palettes. It requires only a step_function, clock_c (from
Sources palette), PID and CLR blocks (from Continuous time systems palette),
SUMMATION (from Mathematical operations palette), MUX (from Signal Routing palette),
and CSCOPE (from Sinks palette). The plant transfer function is a robot joint driven by DC
motor model from module 1, with and .

Figure 1 pid_feedback.zcos basic PID simulation diagram

Click on the Simulation Start button to see the step response. Try adjusting the PID gains and
plant parameters to see their effects on the closed-loop system.

26/49
PID parameter tuning is well studied in control engineering. Here we give a brief guideline.
The proportional gain is a dominant quantity that normally has some nonzero value. The
integral gain helps eliminate steady state error but too high value could introduce
overshoot and oscillation. The derivative gain could help the response to reach steady state
faster but could amplify high frequency noise, and could affect stability if set too high.

When the plant model is not known, adjusting these 3 gains to achieve good response could
be problematic for an inexperienced user. Later we discuss a tuning procedure. Commercial
PID controller products usually have auto-tuning functions for user convenience.

Ex. 2: To experiment with the tracking and disturbance attenuation performance of PID
control, we setup a feedback diagram in Figure 2.

Figure 2 PID feedback diagram

which can be constructed as an Xcos model pid_dist.zcos in Figure 3. The joint inertia and
friction are set to and , respectively. The step disturbance at the plant input
is active at t = 2 sec, with step value of 80.

Figure 3 pid_dist.zcos Xcos model for PID feedback with disturbance

Note that in this example, we have the luxury of knowing the exact plant model. So it is
possible to solve for a good set of PID gains. An approach used in [2] turns off the gain
first and solve for and that yields a critical-damped system at chosen natural frequency.
Then is adjusted to eliminate steady-state error.

To elaborate, it is shown in [2] that when is set to 0, the resulting second order closed-loop
characteristic polynomial is described by

(7)

27/49
which gives

(8)

For example, suppose we select a critical-damped closed loop system , with natural
frequency . From (8), this yields and . Table 1 below gives
calculated P and D gain values for 3 selected natural frequencies.

4 160 80
8 640 160
12 1440 240

Table 1 and gains for 3 different natural frequencies

Using these 3 sets of gain values, we simulate the step responses. The results are shown in
Figure 4. As expected, the higher the natural frequency, the faster the response. We also see
that the steady-state error from step disturbance cannot be eliminated with the PD controller.

Figure 4 step responses of PD control with disturbance d = 80

To fix this problem, we need to turn on the gain of PID controller. With the controller
transfer function described by (5), the closed-loop system is now of third order

(9)

28/49
with the characteristic polynomial

(10)

Applying Routh-Hurwitz criteria to (10), it can be concluded that, given all positive PID
gains, the feedback system is stable if

(11)

The same Xcos diagram in Figure 3 can be used by putting some positive integral gain in the
PID block. Let us fix and , corresponding to natural frequency
rad/s. Figure 5 shows the responses from setting some values of . We see that the steady-
state error to command and disturbance is eliminated by increasing , though higher value
could introduce more overshoot.

Figure 5 step responses of PID control

Applying the bound (11) to this example yields

This can be verified by setting . The oscillating response in Figure 6 shows that
the closed-loop system is at the brink of stability.

29/49
Figure 6 closed-loop response at controller gains

Effect from Saturation

Analysis of PID feedback control is often performed under the assumption that the system is
purely linear. In real devices, nonlinear elements emerge at certain points in the feedback
loop. Saturation is one of them that could cause undesirable system response. This nonlinear
effect normally results from physical limits of signals and system parameters, say, maximum
motor torque and current. Another common saturation is the input limit of servo amplifier. An
industrial servo amp might allow input voltage command in the range volts, for example.

Effect from saturation is more pronounced when integral term is used in PID. The response
could have excessive overshoot due to error accumulation in the integral term. This is known
as integrator windup. See [1] for more detail.

Ex. 3: To see an effect from input saturation, construct an Xcos model as in Figure 7, or
download pid_ilim.zcos. It represents a comparison of two closed-loop systems, which are
basically the same except that the lower one has its input bounded between units.

30/49
Figure 7 pid_ilim.zcos Xcos diagram for Example 3

The controller gains are set at . Running the simulation


yields the step responses in Figure 8, and the control variables (controller output) in Figure 9.
We see that input saturation causes significantly larger overshoot and also worsens
disturbance response.

Figure 8 effect of integrator windup on output response

Figure 9 controller output with plant input limit

Tuning the PID Parameters

As stated before, adjusting the PID gains from scratch to achieve a good response may not be
trivial. As a result, most commercial PID controllers have functions to tune the 3 parameters
automatically. This is normally called autotuning feature. One of autotuning methods
suggested in the literature makes use of some relay feedback mechanisms, which is closely
related to a manual tuning scheme known as Ziegler-Nichols Frequency Domain (ZNFD)
method. Hence we discuss this ZNFD scheme in the last part of this module.

31/49
Note: The original ZNFD method applies the textbook PID equation (1). But since (1) and
(4) are closely-related by (6), here we make a conversion so that standard PID block in Xcos,
which assumes the form (4), can be conveniently used.

To tune a PID controller manually by ZNFD method, follow this procedure

turn off both the integral and derivative terms; i.e., setting . So now the
PID is left only with the proportional gain . We crank up to the point that the
closed-loop system starts to oscillate. At this point, the plant output will swing in a
constant sinusoid motion, not growing and not dying out. Write this value down on a
paper as .
Measure the period of oscillation. Write it down as .
Use Table 2 to tune the controller parameters

Controller Form
P
PI
PID
Table 2: suggested PID parameters from ZNFD method

From the above procedure, we could observe a drawback of the basic ZNFD method: the
system must oscillate at some point of gain setting before it becomes unstable. This implies
the Nyquist plot must cross the negative real axis at some point. For the DC motor model we
are using, the gain margin is infinity. Hence it is difficult to find the oscillating point and the
value.

There is some trick to get around such limitation, but this is beyond the scope of this module.
For our basic study, we simply modify the DC motor robot joint by adding some dynamics to
it, so that the Nyquis plot of crosses the negative real axis.

Ex. 4: Let us assume that the PID output is passed through a LPF with cutoff frequency 500
Hz before feeding the plant input. Using the filter design guide from module 1, we have the
LPF transfer function as

(12)

To simulate, construct an Xcos model in Figure 10, or download pid_znfd.zcos. With this
model, we are ready to perform the ZNFD tuning procedure described above. Click on the
PID block to set the I and D gains to zero. Then start increasing the P gain until the output
oscillates. This is what you must do in a real application when the plant model is not known.

32/49
Figure 10 pid_znfd.zcos Xcos diagram for ZNFD tuning method

Well, in this example we do know the plant model, dont we? So, to save us some time, the
value that causes output oscillation can be found, for example, using the method from
Module 2. First from the loop transfer function containing the plant, LPF, and PID controller
with .

-->kp = 1;
-->ki = 0;
-->kd = 0;

-->s=poly(0,'s');
-->P=syslin('c',1/(10*s^2+0.1*s)); // plant
-->H = syslin('c',1/(1+0.0003*s)); // filter
-->C=syslin('c',kp + ki/s + kd*s); // controller
-->L = C*H*P; // loop t.f

Then find the gain where the closed-loop pole touches the axis.

->[kmax,s]=kpure(L)
s =
5.7735027i
kmax =
333.33433

resulting in .

Verify this by setting the P gain to 333 in PID block. This yields the desired oscillatory
response as shown in Figure 11. The oscillation period can be roughly measured from the plot
to yield sec.

33/49
Figure 11 oscillatory response with

So from the last row of Table 2, ZNFD method suggests the three PID parameters as

Setting these gains gives the response in Figure 12.

Figure 12 response from PID gains suggested by ZNFD method

Note that the overshoot is quite excessive (70%). In a sense, ZNFD just gives us some good
values to start with. We may want to fine-tune the PID gains to improve the response further.
For example, decreasing the Ki gain would bring the overshoot down. Figure 13 shows the
response from original PID gains (green), compared with the case when Ki is reduced to 300
(blue), and 200 (magenta).

34/49
Figure 13 reduce overshoot in the response by decreasing

The ZNFD method could be explained using a Nyquist diagram in Figure 14. The diagram
shows how a point on the curve is moved related to the P, I , and D terms. Using the P term
alone, x could be moved in radial direction only. The I and D terms help provide more
freedom to move perpendicular to the radius. It can be shown that by using ZNFD method,
the critical point is moved to the point . The distance of this point
to the critical point is 0.5. So the sensitivity peak is at least 2. This explains the high overshoot
in the step response.

Figure 14 How a point on Nyquist curve is moved with PID control

35/49
Summary

PID is a simple control structure that is still used widely in various industrial applications. It
is a close relative to the lead-lag compensator explained in module 2, except that its
functionality may be more user-friendly. With some knowledge and practice, an engineer or
technician would be able to tune and operate a plant equipped with PID control.

In this module we discuss the basics of PID feedback systems, with emphasis on Xcos
simulations to show how the responses are related to three control parameters, as well as
effect from input saturation that could worsen the response. Without some good starting
values, tuning the PID gains can be cumbersome for a novice. So at the end, we mention a
manual tuning procedure known as the Ziegler-Nichols frequency domain method. Some
auto-tuning scheme of a commercial PID controller, such as the relay feedback method, is
based on the ZNFD manual tuning.

Module 5: State Feedback


inShare
<="" h2="">

This article is contained in Scilab Control Engineering Basics study module, which is used as
course material for International Undergraduate Program in Electrical-Mechanical
Manufacturing Engineering, Department of Mechanical Engineering, Kasetsart University.

Module Key Study Points

Understand state-space representation of a system


How to convert data between state-space and transfer function form
Design state feedback using simple pole-placement procedure
Append an integrator to state feedback to eliminate steady-state error

State feedback control, the topic of this study module, can be thought of as a foundation for
the so-called modern control* originated since 60. In contrast to the frequency domain
analysis of the classical control theory, modern control theory formulates the time-domain
data as a system of first-order differential equations in matrix form called state-space
representation, which is a mathematical model of the given system as a set of input, output,
and state variable.

* This terminology is commonly used in the control literature, regardless of calling a 50-year-
old approach modern could sometimes create confusion to a beginner. Indeed, the modern
control approach is so eternal that later developments have to be called post-modern.

First, we give some review on state-space representation, which is essential for the state
feedback design discussed later on. Let us take our simple DC motor joint model as an
example. A dynamic equation that governs the motion can be written as

36/49
(1)

To simplify the notation, the time dependent is omitted. Define the system states as the joint
position and velocity

(2)

By using these state variables, (1) can be rewritten as a system of first order differential
equations

(3)

or in matrix form as

(4)

and the output equation, with

(5)

In general, a linear time-invariant (LTI) system can be described as

(6)

(7)

where represent the state, input, and output vectors, respectively. (6) is called a state
equation, and (7) an output equation. Note that this representation is not unique, but depends
on how the states are defined. Moreover, though in our robot joint example the states are
conveniently joint position and velocity, for the general case the states might not have any
physical meaning, and hence could not be measured.

For a system represented by (6) and (7), it is easy to show that the corresponding transfer
function equals

(8)

To convert between state space and transfer function in Scilab, use commands ss2tf and tf2ss.
For example, for a plant transfer function

-->s=poly(0,'s');
-->P = 1/(s^2+s)

37/49
P =
1
-----
2
s + s

This can be converted to state-space form by

-->Pss = tf2ss(P);

Verify that the matrices conform to (4) with

-->Pss.A
ans =
0. 1.
0. - 1.

-->Pss.B
ans =
0.
1.
-->Pss.C
ans =
1. 0.

Convert back to transfer function by ss2tf

-->P1=ss2tf(Pss)
P1 =
1
-----
2
s + s

Note that a transfer function for a physical system must be strictly proper; i.e., its frequency
response must go to zero as the frequency approaches infinity. (No system could have
unlimited bandwidth in reality.) This implies its state-space representation must have zero
matrix.

State Feedback Control

Obviously, a state feedback control is feasible in practice when all states are measurable, such
as the robot joint dynamics in (4) with joint position and velocity as state variables. State
feedback design can be performed with a scheme known as pole placement, or more
systematic way using Ackermans formula.

The idea of pole placement is simple. Specify pole locations of the closed-loop system that
yields desired stability and performance criteria. Then choose the state feedback control gains
to move the closed-loop poles to such locations. A necessary condition is that the plant must
be stabilizable. The details can be studied from most undergraduate control textbooks.

The state feedback controller is simply a vector of gains connecting


the states to the plant input. So, for a set of specifed closed-loop poles, the design goal is to
38/49
compute . To see this more clearly, assume the command input is zero. We
have at the plant input

(9)

and the closed-loop state equation

(10)

The closed-loop poles can be computed from

(11)

Meanwhile, specifying the closed-loop poles yields the characteristic


polynomial

(12)

Hence, we can compare (11) and (12) to solve for manually, which could be tedious for
higher order equations. Scilab provides a convenient command ppol to solve for , given the
matrices and a vector of desired poles as arguments.

Ex. 1: Let us design a state feedback control for the simple robot joint described by (4), (5)
with . Specify the desired properties of closed-loop system as follows:

1. overshoot less than 5%


2. rise time less than 0.1 sec

By standard analysis of 2nd order system, we have that the specification (1) translates to
damping ratio , and using the relation , we have for (2) that
rad/s.. Substituting these two values to the closed-loop characteristic polynomials yields

(13)

with poles at . The above procedure can be carried out by the following
Scilab commands

-->z=0.7; wn=18;
-->lamda = s^2+2*z*wn*s+wn^2;
-->clpoles = roots(lamda)
clpoles =
- 12.6 + 12.854571i
- 12.6 - 12.854571i

and with the plant data from Pss calculated earlier, the state feedback gains can be computed
by this command

-->K=ppol(Pss.A,Pss.B,clpoles)
K =
324. 24.2

39/49
Construct Xcos model in Figure 1, or download ppol.zcos, to simulate the system. Notice in
the diagram that the plant is conveniently represented in transfer function form since the joint
velocity and angle can be accessed. Also, in computing the state feedback gains, we do not
take into consideration the command input. Hence the step response will have nonzero steady-
state error that needs to be compensated with a feedforward gain. An easy way to compute
this gain is by checking the DC gain of feedback system

Figure 1 ppol.zcos Xcos diagram for state feedback control


-->cltf=ss2tf(syslin('c',Pss.A-Pss.B*K,Pss.B,Pss.C))
cltf =
1
---------------
2
324 + 25.2s + s

which can be found by letting ,and at the result is . So, to compensate


this DC offset, we apply a feedforward gain of 324 to both the step and disturbance inputs.
With the disturbance of magnitude 0.1 enters the system at time t = 1 sec, the simulation
yields the step response in Figure 2. We see that the transient period conforms to the desired
spec; i.e., (1) overshoot less than 5% (2) rise time less than 0.1 sec. However, the closed-loop
system cannot get rid of the constant disturbance of 0.1 after t = 1 sec. This result is
predictable, because the state feedback is just a pair of static gains with no dynamics to
compensate the disturbance entering at the plant input. In the next example, we suggest a way
to circumvent this drawback.

40/49
Figure 2 step response from Xcos model in Figure 1

Ex. 2: From the PID example discussed earlier, we show the advantage of integral term in
eliminating the steady-state error. This principle can be applied to the state feedback scheme
by augmenting an integrator as shown in Figure 3. There exist some systematic procedure to
augment an integrator and design all gains simultaneously, but that means the second-order
relationship in the previous example is no longer applicable. So in this example we still use
the pole-placement for second-order system as before, and then adjust the integral gain
afterwards to achieve the desired response.

Figure 3 ppol_int.zcos Xcos model of state feedback with integrator

Notice that the integrator replaces the DC gain compensation in Figure 1 to correct the
response to the target steady-state value. Using the same state feedback gains results in slower

41/49
transient response than Figure 2, so we redesign the pole-placement step by increasing to
40 rad/s.

-->z=0.7; wn = 40;
-->lamda = s^2+2*z*wn*s+wn^2;
-->clpoles = roots(lamda)
clpoles =
- 28. + 28.565714i
- 28. 28.565714i

This yields a new pair of state feedback gains.

-->K = ppol(Pss.A,Pss.B,clpoles)
K =
1600. 55.

The DC gain of closed-loop system

-->cltf=clean(ss2tf(syslin(c,Pss.A-Pss.B*K,Pss.B,Pss.C)))
cltf =
1
-------------
2
1600 + 56s + s

equals . So a gain of is applied as compensation to the disturbance input to yield


the same level as in previous example; i.e., . By experimenting with the integral gain,
we select , which gives the response as in Figure 4. The rise time and overshoot
satisfy the specification given in Ex. 2, while the system recovers to the desired value after the
disturbance is applied at t = 1 sec.

42/49
Figure 4 step response from the Xcos model in Figure 3

Summary

In this module, we discuss state-space representation, using the robot joint driven by DC
motor model as an example. The two state variables are the joint position and velocity, which
are measurable in a real application. Hence the state feedback design scheme is suitable for
this system. Joint position is normally obtained from an encoder using hardware or software
readouts. Joint velocity may be measured via a tachometer, or obtained indirectly by counting
encoder pulses per known time period. Finally, we show how to append an integrator to a
state feedback design to eliminate steady-state error.

Module 6: Discrete-time Control Systems


Sampling Analog Signal

While a real world signal is continuous, a computer works with values stored in a bank of
memory. At one moment in time, a value to be processed is addressed by a data pointer. So,
as shown in Figure 2, the continuous signal has to be sampled into a sequence ,
where integer is the index, or the relative address of data to be selected by the pointer. The
signal is sampled at fixed time interval , called the sampling period. (In some areas of
engineering such as communication systems, multi-rate sampling may exist, but for digital
control applications there is no use for such complicated schemes.)

43/49
Figure 2 Sampling a continuous signal

A question follows naturally. How often should we sample the signal ? Common sense
tells us the more frequent, the better, since it is obvious from Figure 6 if the samples are
close together, they should represent very well. That is valid. But, well, we tend to forget
one thing. The more frequent the sampling, the more data we have to keep. In a modern
desktop PC this does not sound like a problem. But for embedded control applications,
resources are expensive. The memory allocated for data process may be limited.

Let us investigate what happens if the sampling rate is too low. Figure 3 shows such a
scenario. The original signal we want to sample is . Undersampling causes the
reconstructed signal much different from the original. This problem is called aliasing.
Another good example of aliasing is when we watch a movie, sometimes we notice a moving
car with its wheels turn in the opposite direction. The film is an image sampling system. That
happens when the frame rate is too slow relative to the angular velocity of the wheel.

Figure 3 Aliasing problem

44/49
So, how could we select a proper sampling frequency? Intuitively, we can guess from Figure
3 that if we sample at least twice the frequency of the red sine wave, things should work fine.
That is in fact an established result, known as the Nyquist-Shannon Sampling Theorem. One
could find the details elsewhere. Here we state only the essence, in plain English: the
sampling rate must be at least twice the system bandwidth.

This sampling theorem only gives us a lower bound. Practically we would want a higher
sampling rate, say, 10 times the system bandwidth. Of course, tradeoffs between sampling
rate and amount of data memory need to be considered. Also, if a controller is working in
real-time, it has to fetch a data point, do some processing, and output something. We have to
make sure the whole algorithm could finish within the sampling time interval.

Figure 4 shows a basic structure for a real-time control algorithm. Notice that it has to be
implemented as a timer interrupt service routine to achieve a fixed, precise sampling period.

Figure 4 A real-time control algorithm

Discrete System Representation

A continuous-time dynamical system can be represented in the time domain by a differential


equation. We can use Laplace transform to find a representation in the frequency domain,
called a transfer function. Similar mechanisms exist for discrete-time. A discrete-time
dynamical system can be represented in time domain by a difference equation. The math tool
to convert it to a transfer function is called Z-transform.

Figure 5 shows 3 basic elements of a discrete system: summer, multiplier, and delay. The first
two operators behave the same as in continuous time. The third one is unique to discrete
world, but nothing is complicated about it. Output from the D block is simply the input
delayed by one sample. In Figure 5, lets say the input to D is , then the output of D
equals . When we convert the system using Z-tranform, what comes out is a rational
function of a complex variable . Without going into the theory, the point to remember is the
unit delay D transforms to in the Z-domain.

45/49
Figure 5 Discrete system representation in time and frequency domain

As often the case, the control design is done in continuous-time domain. After the design
process finishes, the S-domain transfer function (or continuous-time state space description) is
converted to a discrete transfer function in Z-domain. Of course, you can discretize the
continuous-time plant model as well, which may be particularly useful in case you want to
simulate the plant in an embedded processor. In either case, Scilab command for this purpose
is dscr.
Ex 1: From module 2 we have the plant transfer function for robot joint driven by DC motor

(1)

and the lead-lag controller

(2)

Construct these transfer functions in Scilab

46/49
-->s=poly(0,'s');
-->P=syslin('c',1/(10*s^2+0.1*s)); // plant
-->C=syslin('c',20000*(s+0.01)/(s+100)); // controller

Since dscr accepts data in state-space format, the transfer functions must be converted to
state-space descriptions first

-->Pss = tf2ss(P);
-->Css = tf2ss(C);

Then discretize with sampling period T = 0.01 second

-->Pdss = dscr(Pss,0.01);
-->Cdss = dscr(Css, 0.01);

and convert back to transfer functions

-->Pd = ss2tf(Pdss)
Pd =
0.0000050 + 0.0000050z
----------------------
2
0.9999 - 1.9999z + z
-->Cd = ss2tf(Cdss)
Cd =
- 19998.736 + 20000z
------------------
- 0.3678794 + z

Note to MATLAB user: Obviously, the dscr command in Scilab is not quite convenient to use
compared to c2d in MATLAB. First, it does not accept data directly in transfer function form.
Second, c2d allows you to select discretization method such as ZOH, FOH, TUSTIN, etc.
dscr, on the other hand, simply uses ZOH method. In case you want the TUSTIN method,
there is another Scilab command cls2dls, which uses the same syntax as dscr. See Scilab help
for more detail.

Closed-loop Stability

It is explained in a standard textbook in digital control systems that, generally speaking, the
stability region of a discrete transfer function is inside a unit circle. So we can use this fact to
determine whether closed-loop transfer function in Z-domain is stable or not. From the above
plant and controller data already in Scilab workspace, we form the discrete-time
complementary sensitivity transfer function

-->Ld = Cd*Pd;
-->Td = Ld/(1+Ld)
Td =
0.0999933 + 0.0999967z
------------------------
2
0.4678592 - 1.267846z + z

and plot poles and zeros of Td

47/49
--> Td = syslin('d',Td)
-->plzr(Td)

that yields the plot in Figure 6. The poles and zeros are indicated by x and o, respectively.

Figure 6 discrete pole-zero map from plzr command

From Figure 6, since all poles are in unit circle, we conclude that the closed-loop system is
stable.

If you want numerical values of the poles and zeros of a transfer function, Scilab has a
command trzeros to compute zeros

-->trzeros(Td)
ans =
- 0.9999667

I still cannot find a specific command to compute poles from a transfer function. Anyway,
with data already in transfer function form, all we need to do is to compute the roots of
denominator polynomial of Td

-->roots(Td.den)
ans =
0.633923 + 0.2569064i
0.633923 - 0.2569064i

48/49
Discrete-time or Hybrid Simulation

Discrete-time simulation, or an interconnection of discrete and continuous-time systems, can


be performed in Xcos by using palettes in Discrete Time Systems group. For example,
suppose we want to keep the robot joint DC motor plant as a continuous-time transfer
function, and use a discrete-time controller Cd.

The Xcos model in Figure 7 shows how easy to create such a model. The only new player in
this diagram is the DLR block from Discrete time system palette. The usage of this block is
quite like its continuous-time counterpart, only that it requires a red-arrow signal from the
system clock. The period of the clock must match the sampling time used for descritizing the
controller, in this case, 0.01 second. Simply put the numerator and denominator data of Cd as
block parameter.

Figure 7 hybridsim.zcos Xcos model for hybrid simulation

Running simulation yields the step reponse in Figure 8.

Figure 8 step response from hybrid simulation

49/49

Você também pode gostar