Вы находитесь на странице: 1из 14

PZGUI User's Manual

Pole/Zero Graphical User Interface


by Dr. Mark A. Hopkins, Assoc. Prof.
Electrical and Microelectronic Engineering, Rochester Institute of Technology

Page 1 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
PZGUI, the Pole/Zero Graphical User Interface, Ver. 7.4.xx
by Dr. Mark A. Hopkins, Assoc. Prof.
Electrical and Microelectronic Engineering, Rochester Institute of Technology

This program is a MATLAB add-on tool, in the form of m-files, that helps students and engineers
to understand the complicated relationships among the following:
pole/zero maps
open-loop and closed-loop Bode plots
Nichols and Nyquist plots
open-loop and closed-loop time responses
root locus
output sensitivity plots
the continuous-time s-plane and the discrete-time z-plane
This tool is useful over a range from one micro-hertz to above one terahertz.
The pzgui m-files are available in a "zip" file through the following link:
http://people.rit.edu/maheee/pzgui/Download%20PZGUI%20Matlab%20toolbox.htm
The pzgui toolbox has been tested on all recent versions of MATLAB, and on version 6.5.
To install on your machine:
Unzip the files into a new subdirectory, e.g., \My Documents\Matlab\pzgui.
Then, from the drop-down menu on the Matlab window, select File Set Path.
In the user-interface window that comes up, select that subdirectory and click Add Folder.
You might want to save the new path when you close this user-interface window.
To run the programs in MATLAB:
After you have added the pzgui subdirectory to the MATLAB path,
to start up the tool, type pzgui at the MATLAB command prompt

How to Enter a Model Into pzgui


These comments are written for the continuous-time half of pzgui, but they apply equally well,
with only minor changes, to the discrete-time half of the tool. The two halves are linked in many
ways, to help in the study of how discrete-time and continuous-time models are related.
The system model is always represented as a zero/pole/gain (zpk) model, corresponding to a Lap-
lace-domain open-loop transfer function in factored form:
K ( s 1 )( s 2 )( s m )
G ( s ) = e s , where m n
( s p1 )( s p 21 )( s p n )
s
The exponential factor, e , accounts for any pure delay. By default, the delay = 0.
In pzgui, the closed-loop model is always obtained by simple (negative) output feedback.
Page 2 of 14 PZGUI User's Manual
1996-2012, Mark A. Hopkins
The zpk transfer function is displayed in terms of its pole- and zero-locations in a "pole-zero map",
and the gain factor. When you first start up pzgui, youll see the pole/zero map and main GUI.
Initially, there is a second-order model defined, but it's easy to modify the model, as you'll see.
Whenever the model is changed, all plots are immediately updated to reflect the change.
Change the gain by typing a new numerical value in the Gain
data window, then pressing the Enter key on the keyboard.

Add a pole or a vector of poles


In the s-plane location window of the POLES frame
enter a new pole location as a real or complex number,
e.g., -2+3j, or enter more than one location
or enter a poles by typing in the name of a variable in the
MATLAB workspace. For example, on the MATLAB com-
mand line you could type
mypoles = roots([1 14 76 235 102]);
then type mypoles into s-plane location.
Click the Add pushbutton to add the specified pole or poles.
The dropdown menu labeled selected pole just beneath the word
POLES contains a list of all the poles currently in the model.
Delete a pole:
Select a pole to delete from the selected pole menu.
Click on the Delete pushbutton to delete the selected pole.
If the pole is non-real valued, the complex-conjugate pole will
automatically be deleted, also.
Move a pole to a specified location by selecting the pole in the
menu, entering the desired new location in the s-plane location Figure 1. ZPK-modification
window, and then clicking the Move pushbutton. controls.

Add a zero or a vector of zeros in the same way you add poles, except of course using controls
that are in the ZEROS frame.
Delete a zero in the same manner you delete a pole, except of course using controls that are in
the ZEROS frame.
Move a zero to a specified location in the same manner you move a pole, except of course us-
ing the GUI controls that are in the ZEROS frame.

Drag-and-drop poles and zeros to new locations using the mouse:


When you position the mouse-cursor near a pole (or zero) in the pole/zero map, the cursor will
change to a "hand" icon. Then you can drag-and-drop the pole (or zero) to a new location
If you drag a complex pole or zero to a new location, the complex-conjugate pole also moves.

Page 3 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
Introduce "pure delay" into the model using the text-window at the top-right corner.

Change the sample-period Ts of the discrete-time model using the text-window just below the
pure-delay text-window. When you start pzgui, the default value is Ts = 0.005 seconds, cor-
responding to a sample frequency of 200 Hz. The sample-period is needed, for example, if you
transform a continuous-time model into a discrete-time model.

The "PZGUI OPTIONS" Menu


Several very useful functions are available through the pzgui options menu item.

Figure 2. The PZGUI OPTIONS menu has some very useful functions.

Background Color
If you want to print one of the figures, you will most likely want to select a white background
(which usually gives a more attractive print), and you might also want to hide all the user-
interface controls. Both of those things can be done by selecting from the four items at the top
of the "PZGUI OPTIONS" menu, shown in Fig. 2.

Page 4 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
Load a Complete Model
Complete models can be loaded either from the Matlab workspace, or from data (.mat) files.
When you load a model, the model being loaded replaces whatever model is currently in
pzgui.
If you elect to load a model "from the workspace", pzgui will inspect both the base workspace
and the global workspace for existing variables that can provide the required information.
Fig. 3 shows an example when you select "Load model from workspace". In this case, several
models were previously defined, as shown in the list, and recognized by pzgui.
Notice that multi-input, multi-output (MIMO) models can, indeed, provide the necessary infor-
mation to load a model, but you will be prompted to pick just one of the possible input/output
paths, because pzgui is a single-input, single-output (SISO) tool.

Figure 3. Example of loading a complete model from the workspace.

Another possibility is to "Load random flexible-structure" type of model. This generates a


pseudo-random model of whatever order you specify, between 7 and 499 poles, with the lowest-
frequency first resonant mode that you specify. The model is not completely random, because it
is guaranteed to be stable, and have all its complex pole-pairs at very light damping factors, but
it can generate some interesting models to play around with (see more about this on page 14).

Save a Complete Model


Complete models can be saved either to the Matlab workspace, or to a data (.mat) file.
If you elect to "save model to workspace", you will be prompted for the "format" in which to
save the model. A model can be saved as any one of the standard Controls Toolbox 'lti' objects,
i,e., the 'ss', the 'zpk', or the 'tf' object formats. You will also be prompted for a variable
name to be used in creating the workplace variable that will contain the saved model.
If you elect to "save model to file", the model will be saved as a structure variable that pzgui
will be able to recognize and load. However, pzgui can also recognize several other Matlab
variable-types in .mat-files, such as the 'lti' objects ('ss', 'zpk', and 'tf'), and 'struct' ob-
jects that have a full set of recognizable field names, such as 'z', 'p' and 'k'.

Page 5 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
The PID and Phase-Lead (or Phase-Lag) Design Tools
These tools are very useful for studying various techniques to design these three types of con-
trollers. One of the most useful aspects of these tools is being able to "preview" the effects of a
particular controller design, before actually adding the controller to the pzgui model.

Figure 4. The Phase-Lead (or Phase-Lag) Design Tool

Fig. 4 shows the user-interface for the phase-lead design tool. If the sign of "Extreme Phase" is
negative, it becomes the "Phase-Lag" design tool. Any one of six parameters can be altered, and
the zpk design will be adjusted accordingly. Initially, all six of the parameters are blank.
Note that there is a checkbox labeled "DCgain = 1" that forces the gain to whatever value is re-
quired to achieve low-frequency gain of unity in the controller.
The "Apply" pushbutton causes the zero/pole/gain design to be "added in" to whatever the cur-
rent pzgui model may be. The "Preview" pushbutton shows a preview in all the plots.

Other Controls in the Main G.U.I.


There are several other user-interface controls in the main G.U.I., as described in this section.

Figure 5. More user-interface controls: the "Grid" and "Fix DC" checkboxes.
The Fix DC checkbox
When this checkbox is "on" (checked), the dc-gain will be held constant even as changes are
made to pole and zero locations. If there are poles or zeros at s = 0, then gain at extremely low
frequencies (but not zero) is held constant. Default checkbox value is "off".

The Grid checkbox


When this checkbox is "on" (checked), a grid of constant damping-factor and constant natural
frequencies is made visible in the zero/pole map. Default checkbox value is "on".

Page 6 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
Figure 6. More user-interface controls: the "Help" checkbox and "Center" pushbutton.

The Help checkbox


When this checkbox is "on" (checked), a separate figure is opened to display helpful text ex-
plaining what the various objects are in the main GUI. If you move the mouse-cursor over any
object in the main GUI, the text in the separate figure is updated to describe that object.

The Center pushbutton


Clicking on this pushbutton causes the zero/pole map axes to be rescaled to show all the poles
and zeros in (hopefully) the best scaling.

Figure 7. More user-interface controls: the "Undo" and "Redo" pushbuttons.


The Undo and Redo pushbuttons
These pushbuttons are reasonably self-explanatory. If you make a change to the open-loop
model, you can undo the change, and later re-do the change, using these pushbuttons.

Figure 7. More user-interface controls: the discrete-time "link" controls.


The "D-T pzgui" pushbutton
This pushbutton will cause the pzgui zero/pole interface for
discrete-time to be created alongside the continuous-time pzgui.

The "D-T Link by:" checkbox, and "link-method" menu


When the discrete-time (D-T) link checkbox is "on", the model in
the continuous-time (C-T) GUI is transformed into a D-T model, Figure 8. Link-method menu.
which is then put into the D-T pzgui.

Page 7 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
While the D-T link checkbox is "on", any changes you make to the model in the C-T pzgui
will immediately be transformed into changes to the model in the D-T pzgui.

The method used for the C-T to D-T transformation is the one currently selected in the "link me-
thod" menu, shown in Fig. 8. There are three methods available: (1) z=esT simply maps the lo-
cations of poles and zeros directly from the s-plane to the z-plane; (2) ZOH equiv computes the
zero-order-hold equivalent model; and (3) bilinear computes the bilinear (or Tustin) transforma-
tion. The link-method selection can be changed at any time; whenever the selection is changed,
all figures are recomputed and updated.

Figure 9. More user-interface controls: The "Draw Box" checkbox.


The "Draw Box" checkbox
When turned "on", this opens up the discrete-time pzgui (if it's not already open). It also turns
off normal zooming in the continuous-time pzgui. Instead, when you hold down the left
mouse-button and move the mouse around the s-plane zero/pole map, a rectangular box is
drawn. Simultaneously, that box is "mapped" into the (z-plane) discrete-time pzgui, according
to the transformation method that is selected in the "link menu". The purpose of this feature is
to help study the relationships between the z-plane and the s-plane, and the various transforma-
tion methods between them. For example, this is a result with "bilinear" selected:

Page 8 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
Figure 10. More user-interface controls: The "Erase" pushbutton.

The "Erase" pushbutton


This pushbutton erases two different types of annotations that appear in the various plots.
First, it erases all boxes that might have been drawn in the D-T and C-T pzgui.
The second type of annotation it erases is related to the "selected frequency ", if a frequency is
currently selected. Frequency-selection is discussed in the next section (see page 12).

Figure 11. More user-interface controls: Checkboxes that create other plots.

Checkboxes that create other plots


You can create various frequency-domain and time-domain plots by clicking on the checkboxes
along the bottom of the main GUI, shown in Fig. 11.
Each of these checkboxes will create one or more plots based on the zero/pole/gain model that is
currently in the main GUI.
These plots are all highly interactive, and mouse-activity in any one of them often results in useful
information appearing in many of the others, particularly in the frequency-domain plots.
The various plots, from left to right, are:
O.L.Bode (two plots)
Standard Bode plots (i.e., frequency-response magnitude vs. frequency, and phase vs. fre-
quency) of the open-loop model currently in the main pzgui.
Once this plot is created, several options are available in the plot to change the scaling of x-
axis and y-axis. When you zoom in any of the Bode plots, the resulting frequency range is
automatically propagated to all the other Bode plots that are open.

Page 9 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
C.L. Bode (two plots)
Standard Bode plots (i.e., frequency-response magnitude vs. frequency, and phase vs. fre-
quency) of the closed-loop system obtained by simple negative feedback of the open-loop
model currently in the main pzgui.
Once this plot is created, several options are available in the plot to change the scaling of x-
axis and y-axis. When you zoom in any of the Bode plots, the resulting frequency range is
automatically propagated to all the other Bode plots that are open.
Nichols
Standard Nichols chart (i.e., frequency-response magnitude in dB vs. frequency-response
phase in degrees) of the open-loop model currently in the main pzgui. Once the plot is
created, there is an option to also include all of the Nyquist (negative-frequency) data.
Nyquist (two plots)
Standard Nyquist plot (i.e., polar plot of the frequency-response data) and contour plot (the
Nyquist contour in the s-plane) of the open-loop model currently in the main pzgui.
The Nyquist contour that is created and plotted automatically includes "detours" into the
right-half plane around any poles or zeros that fall exactly on the j-axis, in accordance with
Nyquist contour principles.
The Nyquist plot has optional "hybrid scaling" (a checkbox) that makes it easy to view simul-
taneously the large-scale and the small-scale features of the Nyquist plot. The hybrid scaling
option becomes the default whenever the Nyquist plot has any large-scale features.
There is an option to view a "Nyquist movie", which shows how the Nyquist plot is generated
by mapping the points encountered along the Nyquist contour. The start-frequency and end-
frequency of the movie can be specified, if you want to investigate a smaller part of the map-
ping.
O.L.Resp
The time-domain response of the open-loop model currently in the main pzgui.
Once this plot is created, there is a choice of input-type for the time-domain simulation. By
default, the input is a unit-step, but the other choices are an impulse function, a ramp func-
tion, a parabola, and a sinusoid.
The time-response plots have the option to display, in addition to the system output, the natu-
ral part of the response, the forced part of the response, and the difference between the input
and output. There is also an option to change the total simulation time (see page 12, below).
When sinusoidal input is selected, the frequency of the sinusoid can be specified in the figure,
and also changes if you make a frequency selection in one of the other figures (see the next
section for a discussion of frequency-selection). Also for sinusoidal input, if the system is
stable an option will appear to plot only the part of the response around the time that steady-
state is reached.
C.L.Resp
The time-domain response of the closed-loop system obtained by simple negative feedback of
the open-loop model currently in the main pzgui.

Page 10 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
Once this plot is created, there is a choice of input-type for the time-domain simulation. By
default, the input is a unit-step, but the other choices are an impulse function, a ramp func-
tion, a parabola, and a sinusoid.
The time-response plots have the option to display, in addition to the system output, the natu-
ral part of the response, the forced part of the response, and the difference between the input
and output. There is also an option to change the total simulation time (see page 12, below).
When sinusoidal input is selected, the frequency of the sinusoid can be specified in the figure,
and also changes if you make a frequency selection in one of the other figures (see the next
section for a discussion of frequency-selection). Also for sinusoidal input, if the system is
stable an option will appear to plot only the part of the response around the time that steady-
state is reached.
Rt Loc
Standard root-locus plot (i.e., loci of the closed-loop poles as a function of increasing gain in
the open-loop system) of the open-loop model currently in the main pzgui.
This plot is highly interactive, showing useful information as the mouse is moved around the
plot, and allowing a specific gain to be entered (or selected by mouse-click) to view the re-
sulting closed-loop pole locations.
When you move the mouse-cursor to any point in the s-plane of the root-locus plot, at the
lower left is displayed the numerical value of the open-loop transfer function H(s) evaluated
at that point in the s-plane.
When you move the mouse-cursor close to one of the root locus lines, at the lower left will
also be displayed the factor by which the open-loop transfer-function gain would have to be
multiplied, in order to place a closed-loop pole at that s-plane location. If you left-click the
mouse at that point, the required gain factor will appear at the lower-left of the figure, and the
resulting closed-loop poles will be highlighted in yellow.
In continuous-time pzgui, the s-plane frequency-domain effects of nonzero pure delay are
approximated by a fourth-order Pade approximation. The four poles and four zeros that are
introduced by the Pade approximation are colored gray in the root-locus plot, to distinguish
them from the poles and zeros that are the roots of the numerator and denominator polyno-
mials.
In discrete-time, effects of pure delay are shown in the root-locus as additional poles at z = 0,
again distinguished by being colored gray.

Sensitivity
Standard output sensitivity magnitude plot (i.e., frequency-response magnitude of the output-
disturbance transmission path vs. frequency) of the closed-loop system obtained by simple
negative feedback of the open-loop model currently in the main pzgui.

Page 11 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
Frequency Selection in pzgui
To help study the frequency-response of a system, pzgui includes the ability to select a specific
frequency. A specific frequency can be selected in any of the frequency-domain plots, which com-
prise the main GUI (s-plane), the root-locus plot, the various Bode plots, the Nichols chart, the Ny-
quist contour, the Nyquist plot, and the sensitivity plot. Essentially, that list is all of the plots
except the two time-domain response plots.
There is one other effect of selecting a frequency in one of those plots. If a time-response plot is
open, and the sinusoid input is selected in the plot's input-type menu, then the frequency you select
will be used to re-compute and re-plot the sinusoidal response.
In the main GUI or the root-locus, when you hover the mouse close to the j-axis, the nearest fre-
quency will be highlighted and annotated. Then if you click the left mouse-button, that point will
become the selected frequency (in radians./second), and the selection will be highlighted by a
small cyan circle appearing in all the various frequency-domain plots.
In the Bode, Nichols, Nyquist, and sensitivity plots, when you hover the mouse near the data plot
line, the frequency at the nearest point will be highlighted and annotated. Then if you click the left
mouse-button, that point will become the selected frequency (in radians./second), and the selection
will be highlighted by a small cyan circle appearing in all the various frequency-domain plots. Al-
so, a text description of the selected frequency will appear in the x-axis label of each plot.
To un-select any frequency selection, use the "Erase" button, described above. All the selected-
frequency highlights will disappear, and removed from the x-axis labels.

Additional Notes on the Various Plots


Whenever you make a change in pole locations, zero locations, gain, sample time, or delay,
all of the plots will be recomputed and updated.

Every plot has the "zoom" feature enabled:


If you click the left-side mouse button, the plot zooms in.
If you click the right-side mouse button, the plot zooms out.
If you double click the right-side mouse button, the plot should returns to full-scale,
showing all the plotted data.
By holding down the left-side mouse button, you can drag a rectangle around the area you
want to zoom on. The rectangle you draw is allowed to extend out beyond the edges of the
figure, to zoom out to areas that arent currently contained in the figure.
Zoom in or out in any Bode plot and all the other Bode plots, as well as the sensitivity plot,
will automatically display the new frequency range.

Page 12 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
The time-response plots:
These plots have several interactive choices you can make.
You can choose to plot either the impulse, step, ramp, parabola, or sinusoid response.
There is a "Show (Input-Output)" checkbox at the lower right that allows you to show the
difference between input and output, often called the output error, as an overlay on the plot.
The output always consists of the natural response plus the forced response.
The checkbox labeled "natural" at the lower left allows you to show (or not)
the "natural response" component of the output as an overlay on the plot.
The checkbox labeled "forced" at the lower left allows you to show (or not)
the "forced response" component of the output as an overlay on the plot.
For a sinusoid input, you can specify the frequency directly in the data window, or you can
specify it by making a frequency selection in one of the frequency-domain graphs (see pre-
vious section). If a frequency selection is greater than zero, it is automatically used to re-
compute and re-plot the sinusoidal response plots.
For a sinusoid input, the steady-state magnitude/phase of the system response are displayed
just below the Input drop-down menu.
For a sinusoid input, a checkbox appears that lets you restrict the simulation to start at
roughly the time steady-state is reached, and continue for only four cycles of the input sinu-
soid. This option helps make the steady-state response easy to view even when the frequen-
cy of the input changes by a lot.
For a step input, rise time, percent overshoot, percent undershoot, settling time, and steady-
state output are all calculated and displayed, if the plot goes beyond settling time.
For a step input, system "performance" is automatically calculated. You can select one of
four performance measures to compute (IAE, integrated absolute error; ITAE, integrated
time absolute error; ISE, integrated square error; or ITSE, integrated time square error),
and you can specify the range of time over which the measure is to be computed
(Perf Range Low and Perf Range High times).

Page 13 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins
Additional Notes on the PZGUI OPTIONS Menu
There are two additional capabilities accessed through the pzgui options menu, that have not been
discussed above. These will be discussed here. Refer back to Fig. 2, on page 4.

Show FRF computation


If you select this option, then whenever you select a frequency (see above), there will be addition-
al annotations in the main GUI.
Recall that the selected frequency will be highlighted by a small cyan circle on the j-axis in the
main GUI. If you have elected to show FRF computations, then additional lines will appear, and
text associated with each line.
These additional lines are drawn from each pole, and from each zero, to the selected point on the
j-axis. The text that appears gives the angle and length of each line.
Furthermore, for the continuous-time GUI only, if the number of poles does not exceed three, then
a figure is opened that details the actual FRF computation for the selected frequency.
These annotations are intended to help students understand the relationship between the Fourier
transform H(j), the Bode plots, and steady-state frequency response.

Load Random Flexible Structure


This feature is useful for more advanced control studies. It allows you to easily create high-order
stereotypical flexible-structure models, that have a component of randomness to them, but have
mostly very lightly damped poles and zeros.
These models can be used to study how to design controllers for flexible-structure-type systems.
During the creation of the random flexible-structure model, you will be automatically prompted for
the model-order, and for the frequency of the first (i.e., lowest-frequency) resonant mode. Model
order can be anywhere from seven to 499 poles.
The resulting model will exhibit features of a collocated sensor/actuator pair, out to about 50 times
the frequency of the lowest resonant mode. Above that frequency, non-minimum-phase zeros will
begin to appear, indicative of a non-collocated sensor/actuator pair.
The details of the model can be altered by the usual pzgui tools, if so desired. For example, the
model is always created with ac-coupling (i.e., dc gain equal to zero), but it is an easy matter to
move that zero somewhere else, for example, by drag-and-drop to a new location.

Page 14 of 14 PZGUI User's Manual


1996-2012, Mark A. Hopkins

Вам также может понравиться