CT v1.16
Control's Toolbox v1.16 for TI-89
12/7/2002
By Francesco Orabona
DISCLAIMER
- Copyright (C) 2001-2002 Francesco Orabona
-
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your option) any later
version.
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
-
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
INTRODUCTION
- The Bode plot is the frequency plot of the transfer function W(s) of a linear system.
I have written this program because I haven't found a REAL program for the bode diagram. This program in fact doesn't use the 'angle' function for
the phase plot. For example angle(1/(s+10)^5)|s=100*i returns -61.4 degree, instead the right phase for a bode diagram is -421.4
degree!!! CT uses a special routine to write the right function of the phase, faster
than angle(), and it uses a custom routine for a faster calculation of the
amplitude. CT is the fastest program for the Bode diagram!!!
- The programs integrates syntactic help in the status bar and a complete help
accessible via HELP from the catalog and via CONTENTS from VAR-LINK.
INSTALLATION
- Use your link software to transfer the program, 'ct.89g' to your calculator. All files are automatically placed in the 'CT' folder.
Note that if you use the TI-Connect software the functions will be copied to
the 'main' directory: move it by hand.
- Once installation has occurred, do not move, delete, or rename any of the functions or the directory. Doing so may cause the programs to operate in
strange ways.
- Don't forget to run the programs before archiving, to gain speed.
- Operating System: TI-89 with AMS v2.05 (surely enough these programs will run
on AMS 2.0x, maybe even on earlier AMS versions, but I have not tested them).
- IMPORTANT: You must set 'English' as language in MODE.
USAGE
- CT(sys), where sys is a LTI SISO system transfer function. Transfer functions are expressed in the form they are commonly written in the
Laplace domain that is as function of s, for example (s^2+s+1)/((s+3)(s+5)). CT supports DELAYS!!! For SISO systems multiply the system for e^(-delay*s).
For example e^(-0.03s)*(s+1)/(s^2*(s^2+s+100)).
- Menu explanation:
- BODE TABLE memorizes the amplitude (in db) and the phase (in degree) functions in y1(x) and y2(x), then display a table of logarithmically or
linear equally spaced points within the selected frequencies; by default is selected 10 points for each decade of the calculated range of the plot.
- BODE DIAGRAM displays the bode plot of the amplitude or of the phase. 'Grid' is the logarithmic grid,
'Res' is the resolution of the plot.
A proper range for the plot is automatically calculated.
- NICHOLS DIAGRAM displays the Nichols plot of the system. 'Res' is the resolution of the plot. The x-axis is the amplitude in db, the y-axis is the phase in degree.
You can also diagram the constant amplitude closed loop line writing the number in db in the 'closed loop' dialog. For example write '-3' to
diagram the line at -3db.
- NYQUIST DIAGRAM displays the Nyquist plot of the system. Check 'Symmetric
plot' if you want to display also the symmetric curve. 'Res' is the resolution of the plot. The x-axis is the real part of the transfer function
valuated in s=i*omega, the y-axis is the imaginary part.
- MARGIN returns the gain margin, the phase margin, and associated frequencies Wcg and
Wcp, given the LTI SISO open-loop model SYS.
The gain margin is defined as 1/G where G is the gain at the -180 phase frequency. The gain margin is in dB, the phase margin is in degree.
Note: if there is more than one crossover point, margin will return the worst case gain and phase margins.
- ABOUT displays an about dialog!
- SAVE&EXIT exits without deleting all the variable used: y1, y2, xt1, yt1,
xt2, yt2, xt3, yt3, tblInput and restoring the previous settings.
- After the selected diagram it's plotted by the toolbar at the top you can:
- - return to the main menu pressing ESC;
- - save the plot as a PIC file (press <F1>+<1>);
-
- change the zoom (press <F2>);
-
- get a point info (press <F3>);
- To exit from the program restoring the previous settings and functions press ESC.
- CT need the private functions MAG1 and PHASE1, LOGSPACE and ZOOMFIT2 .
- CPOLES(EXPR,VAR), where EXPR is an expression in the variable VAR. Returns
a list with the complex poles of the expression.
- Note: The Matlab function is 'pole', but I have chosen to rename to 'cpoles' accordingly with the TI standards (see
'czeros').
- Usage example
- cpoles((x+10)/((x+1)(x+5)),5) returns
- {-1,-5}
-
DCGAIN(SYS), where SYS is a LTI SISO system transfer function. Returns the DC gain of LTI systems.
- Usage example
- dcgain((s+10)/(s+1)) returns
- 10
-
DLYAP(A,Q), it returns the matrix X, the solution of the special form of the
discrete Lyapunov matrix equation:
- A*X*At -X+Q=0
- DLYAP finds the solution using eigenvalue decomposition (I don't know other methods).
- Note: even if the results are real you must set 'rectangular' as Complex Format in MODE.
- DLYAP need the function LYAP.
- Usage example
- dlyap([1,1;1,-1],[1,0;0,1]) returns
- [[-1.,2.e-13][2.e-13,-1.]]
- GETTD(SYS), where SYS is a SISO system transfer function. Returns the time delay of the system.
- Usage example
- gettd(e^(-0.1)s*(s+10)/(s+1)) returns
- 0.1
- LOGSPACE(F,L,N), it returns a list of N logarithmically equally spaced points
between F and L.
- Note: I know that there is a faster algorithm, but this is more accurate.
- Usage example
- logspace(0.1,1,5) returns
- {.1, .177828, .316228, .562341, 1.}
-
LYAP(A,B), it returns the matrix X, the solution of the special form of the Lyapunov matrix equation:
- A*X + X*At = -B
- LYAP finds the solution using eigenvalue decomposition (I don't know other methods).
- Note: even if the results are real you must set 'rectangular' as Complex Format in MODE.
- Usage example
- lyap([0,-5;1,-2],[1,0;0,1]) returns
- [[1.7,.1][.1,.3]]
- MAG(SYS), where SYS is a LTI SISO system transfer function. Returns
abs(SYS)|s=i*omega, but it is faster than the simple command!
- MAG need the private function MAG1.
- Usage example
- mag(1/(s+1)^2) returns
-
1/(omega^2+1)
- MENU(), simply creates a custom menu with all the functions and programs.
- Usage example
- menu()
- PHASE(SYS), where SYS is a LTI SISO system transfer function. Returns
angle(SYS)|s=i*omega, but it is faster than the simple command and it
doesn't return a result between PI and -PI, like the function angle.
- Note: it will return an expression in radian or degree depends on the mode
setting.
- PHASE need the private function PHASE1.
- Usage example
- phase(1/(s+1)^2) returns
-
-2*tan^-1(w)
- POLY2COF(POLY,VAR), where POLY is a polynomial in the variable VAR. Returns the list of the coefficients of the polynomial.
- Usage example
- poly2cof(x^2+2x+3,x) returns
- {1,2,3}
- PZMAP(SYS), where SYS is a LTI SISO system transfer function. It plots the poles and zeros of SYS in the complex plane, the poles are
plotted as 'x' and the zeros are plotted as 'o'.
-
PZMAP need the program RLOCUS, ZPKDATA, GETTD,
ROOTS, CPOLES, POLY2COF.
- Usage example
- pzmap((s+1)/(s+10))
-
RLOCUS(SYS,kLIST), where SYS is a LTI SISO system transfer function, kLIST the list of gains. It plots the locus of the roots of:
- H(s) = D(s) + k * N(s) = 0,
- where N(s) and D(s) are the numerator and denominator of SYS, for the list of gains.
It also displays the PZMAP (see).
-
TIP: you can use the built-in function seq( instead of writing manually the
list kLIST.
- RLOCUS need ZPKDATA, GETTD, ROOTS,
CPOLES and POLY2COF
- Usage example
- rlocus((s+1)/(s+10),{1,2,3,4,5})
- ROOTS(coeffLIST), where coeffLIST is a list of polynomial coefficients.
Returns the complex roots of the polynomial via the method of the companion matrix. It is 2 times faster than cZeros and it returns the multiplicities of
each roots. Some approximation in the result is due to the approximation of the command
eigVl. This function is practically the same of the free Flash application 'Polynomial Root Finder' of the Texas Instruments, but it is slightly faster
even if it is written in basic! Moreover it doesn't returns an error with lists with only one element like {3}, but returns correctly an empty list {}.
- Usage example
- roots({1,2,1}) returns
- {-1,-1}
- ROUTH(POLY,VAR), where POLY is a polynomial in the variable VAR. Returns the
Routh-Hurwitz matrix. During the compilation of the rows of the matrix if there is a zero only in the first column it is replaced with the constant
epsilon. Instead if there is a row of zeroes first it forms an expression based on the row immediately above the row of zeroes, applying the
coefficients to their matching powers of s, then it takes the derivative of this expression and it uses the coefficients of the new expression in the row
of zeroes.
- ROUTH need the function POLY2COF.
- Usage example
- routh(s^4+s^3+s^2+s+1,s) returns
- [[1,1,1][1,1,0][eps,1,0][(eps-1)/eps,0,0][1,0,0]]
-
SS(A,B,C,D), where A,B,C,D are the matrices of the system:
- x' = Ax + Bu
- y = Cx + Du
- Returns the LTI SISO transfer function:
- W(s) = NUM(s) / DEN(s) = C * (sI - A)-1 * B + D
-
You can also enter an expression instead of a matrix if it contains only one element and you can enter '0' instead of the matrix D if it is empty.
- Usage example
- ss([1,2;3,4],[1;2],[0,1],0) returns
- (2*s+1)/(s^2-5*s-2)
-
TF(nLIST,dLIST), where nLIST and dLIST are the lists of the numerator and denominator coefficients in descending powers of s. You can also enter an
expression instead of a list if it contains only one element. Returns a LTI SISO transfer function, as functions of 's'.
- Usage example
- tf({1, -5, 6},{1, 1, 0}) returns
-
(s^2-5s+6)/(s^2+s)
- TF2SS(SYS), where SYS is a LTI SISO system transfer function. Displays the matrixes A,B,C,D of the system:
- W(s) = NUM(s) / DEN(s) = C * (s*I - A)-1 * B + D
- It also prompts to save the matrices in the variables a,b,c,d in the current directory; note that tf2ss isn't a function, it's a program!
- TF2SS need the functions TF2SS2, POLY2COF.
- Usage example
- tf2ss((2*s+1)/(s^2-5*s-2)) displays and creates the matrices
- a=[[0,1][2,5]]
- b=[[0][1]]
- c=[[1,2]]
-
d=0
- TF2SS2(SYS), where SYS is a LTI SISO system transfer function. Returns a list of 4 elements with the strings of the A,B,C,D matrices of the
system. TF2SS2 need the function POLY2COF.
- Usage example
- tf2ss2((2*s+1)/(s^2-5*s-2)) returns
- {"[[0,1][2,5]]","[[0][1]]","[[1,2]]","0"}
- ZOOMFIT2(), acts like the built-in program zoomfit but never reports an error
in case of plotting of constants.
- Usage example
- zoomfit2()
-
ZPK(zLIST,pLIST,gEXPR), where zLIST and pLIST are the list of zeros and poles
(set to {} if none) and gEXPR is the scalar gain. You can also enter an expression instead of a list if it contains only one element.
Returns a LTI SISO transfer function, as functions of 's'.
- Usage example
- zpk({2, 3},{0, -1},1) returns
- (s-2)*(s-3)/(s*(s+1))
-
ZPKDATA(SYS), where SYS is a LTI SISO system transfer function. Returns a list of 4 elements, the first 2 elements are the strings of the
lists of the zeros and poles of the system, the third is the DC gain, the forth is the delay time.
- ZPKDATA need the functions DCGAIN, GETTD,
ROOTS, POLY2COF.
- Usage example
- zpkdata(e^(-0.2s)*(2*s+1)/(s^2+6*s+10)) returns
- {"{-1/2}","{-3-i,-3+i}",1/10,1/5}
TO DO
- to add almost all the commands of the automatic control toolbox of MATLAB!
- Mag and Phase plot in split screen
- the commands bode, nichols, margin, nyquist in separate files
- an Italian version (someone wants to help me?)
- I have written c2d, expm, step, impulse, simul, but they need a powerful program to do the Laplace Transform, what?
- some other ideas?
CREDITS
Thanks to
HOW TO CONTACT ME
- If you use CT, please let me know: send me an email at bremen79@infinito.it
and tell me what you think of it, any suggestion, any ideas. Please also report any bugs you find while using the program, and please
don't forget to give me a description of what you did and what happened.
-
- Francesco Orabona
- bremen79@infinito.it
- Visit my site: www.infinito.it/utenti/bremen79/
- You can also found my programs at www.ticalc.org
Matlab is (c) MathWorks, Inc.