"So
much we think to know that our own arrogance blinds us impeding
us to see the most evident:
we are nothing"
¡¡ THANKS !! ...
... to all people who send me any comment about this library or any other one, about some aspects to improve, ideas ...
... AND ... ¡¡ I'M SORRY !! ...
... because due to the little time I have available I can't test the libraries as much as I'd like and surely there are a lot of bugs.
Throughout this document you'll find diverse notes like this one. Please, read them, they are very important.
INDEX
INTRODUCTION
(Note
for the G model users)
INTRODUCTION
Bode-Routh is a library for the HP48 (
GX model ) calculator which working along with the
polynomial library NEOPOLYS allows you to
accomplish multiple calculations related with engineering mainly
in analysis and system control applications. And although this
library solves a lot of different problem types I recommend you
to know well what you are doing before using this library because
there is always some bugs wich couldn't be detected in any other
way. Furthermore I would desire this library to serve more than a
tool to avoid the issue in one or another exam or a
"dangerous situation", as a utility to spend less time
calculating some things but always knowing well what you are
doing because that way is the only way to make a 100% use of all
the Bode-Routh features.
Its main advantages as opposed to any other library of this kind are:
And above all...
I've received a lot of commentaries from G model users who fell a bit discriminated because they aren't able to execute Bode-Routh in their calculators because after install also Neopolys there is no enough available free memory. Well then, originally I thought about to separate the commands as independent libraries with a common kernel library. At the end I desisted mainly for two reasons: first, actually I am finishing my engineering studies and I have no much free time available to dedicate to extract the commands; second, lately the memory upgrades for the calculator are cheap enough and this last option is the best solution for a lot of problems, not only the memory problem with Bode-Routh.
So, I'm sorry a lot but surely there will be never exist a Bode-Routh version for the G model.
¡¡¡ WARNING !!!
THIS LIBRARY WILL ONLY WORK IF THE POLYNOMIAL LIBRARY NEOPOLYS (VERSION 5.3 OR LATER -the last one is at this moment the 6.5- WITH THE LAPLACE AND Z TRANSFORMS) IS INSTALLED
As to the rest the instalation has no secrets. Simply transfer the .lib file of the Bode-Routh library that you prefer (with texts in spanish or english) by means of the kermit program you've got and the .trn file of the Neopolys pack that you prefer depending on if you use the Alg48 library or not (see the Neopolys manuals). Once transfered a variable with the same name that the file you have just downloaded will appear in the current calculator's directory. Press the white key associated with that variable to put its content on the stack and do 0 STO (if you want to install the library at port 0 or N STO if you want to install it at port number N). Now turn off and on the calculator or press simultaneously ON-C.
The polynomials are represented in the same way as Neopolys does, that is, by means of lists that contain the polynomial coefficients sorted from upper to lower exponent order, or a double list containing the polynomial roots. For example:
can be represented as
{ 1 -2 -5 6 }
or
{ { 1 3 -2 } }
The command Routh considers the user flags 2 and 3 when returning the results, that is
I suggest you to read the Neopolys manual to learn more about that library.
I think that is obvious enough what each command does. Furthermore the great majority of them are easy to use because they were made with input forms with several fields to refill and whose default values are almost always enough to obtain a nice result.
With this command you'll can obtain the magnitude or the phase Bode plot of the transfer function you want. The vertical axis in the magnitude plot represents the transfer function modulus in decibels (dB); in the phase plot the vertical axis is the transfer function argument. And in both cases the horizontal axis is the frequecy value IN LOGARITHMIC SCALE (Log (w)).
The fields:
NUM: Transfer function numerator.
DEN: Transfer function denominator.
D : Enter here the transfer function delay (if any). I remember you that the delay only affects to the phase diagram.
T : Choose the graph type to plot pressing "CHOOS" or "+/-".
RES : Plot resolution. Normally a number between 0 and 1. For you to have an idea about what field means this field represents more or less the distance between two consecutive points of the plot. Decrease its value if you want a better resolution although the plotting process will be a bit slow.
Due to a correction used to surpass the ±180° limit imposed by the calculator to avoid the typical "jumps" that appears in angle plots sometimes entering a high value in this field can give rise to an incorrect plot. If you have any doubt don't change this value because the default value is almost always good enough.
AUTO: When activated the vertical axis is automaticly scaled.
HR VR : Horizontal and vertical ranges. Normally the left value might be less than the right one but don't worry if you exchange the order because it will be automaticly corrected.
The menu:
EDIT, CHK, CHOOS: These are the typical options that appear in any calculator's input form.
PICT : Allows you to go to the PICTURE environment where the diagrams are plotted.
ERASE: Erase the plot at PICTURE.
DRAW: To draw the plot.
After pressing [ NXT ] ...
LABL : To put labels in the plot indicating the maximum and minimum horizontal and vertical values. It is activated by default.
AXES: When activated (by default) the axes are drawn.
Before get into the Bode command you put on the stack the transfer function numerator at level 2 and the transfer function denominator at level 1 the fields NUM and DEN will be automaticly loaded with those values. Likewise when leaving the Bode command you'll obtain the contents of the NUM and DEN fields at levels 2 and 1 as explained before.
At any field you are you can press DEL to restore the default values for the current field or the whole fields. The default value for the NUM and DEN fields are those one you got the first time you entered Bode.
In the phase diagram you'll see dotted the ±180° lines.
After the diagram is plotted once into the PICTURE environment if you press (X,Y) to see the cursor coordinates, remember that THE HORIZONTAL AXIS WAS DRAWN USING A LOGARITHMIC SCALE, and the value at that point IS NOT THE FREQUENCY VALUE AT THAT POINT BUT THE FREQUENCY LOGARITHM.That is, if after pressing (X,Y) you see something likeX: 2.1234567 ; Y: 123E3
or if you press TRACE and you see
X: 2.1234567 ; Y: 123E3
really THE FREQUENCY VALUE AT THAT POINT IS:
![]()
and NOT 2.1234567.
With this command you'll be able to draw the Nyquist plot for the transfer function you wish.
The fields:
All the fields have the same meanning that that in Bode except w. This value show the frequency values range to be drawn. Thus a default value of 6.5 means that the range is from -6.5 to 6.5. Increase this value when you see that some points "are absent" around the (0,0) or when you want a better resolution at that zone.
Due to the significance of the point -1+0·j when visible you'll see that point surrounded by a circle.
The menú:
Is the same that the one in "Bode".
A bigger value in the w field will make the plot to end later. If you see that the plot spends a lot of time ust press the ON (CANCEL) key. Furthermore for greater values of that field the automatic scaling of the vertical axis can be incorrect and to see correctly the Nyquist plot it will be necessary to adjust a bit the visualization ranges.
With this command you'll be able to plot the Nichols diagram, that is, the plot ABS(G(jw)) as opposed to ARG(G(jw)) for the transfer function G(s).
The fields:
They are exactly the same and they have the same meaning that those one in Nyquist and Bode.
The menu:
The same about the same.
To plot correctly this diagram a phase correction routine might have been implemented here as in the Bode phase diagram to surpass the ±180° limit, but I preferred to let it "as is" because that way just with a look you can know if the system is stable and even calculate aproximately the gain and phase margins (but not the crossover frequencies). See the example 4 . In spite of that you can change the plot width if you want.
The same note explained in the Nyquist help about the w field could be applied here.
By means of this command you'll be able to plot the Root Locus for the OPEN LOOP TRANSFER FUNCTION contained in the fields NUM and DEN. That is this command will plot the solutions of the equation
for different values of the gain K.
The fields:
NUM, DEN : Transfer function numerator and denominator.
RES : Graph resolution. Decrease this value if you want to get a greater resolution, bearing in mind that the plotting process will be slower.
HRNG, VRNG: Horizontal and vertical plot ranges
AU : When activated (by default it does) an automatic scaling will be made such vertically as horizontally, and the resolution will be also automaticly scaled, trying to find the best one.
LIN : By default the root locus will be plotted with points. Check this field to use lines instead, although it can be a bit slower.
The menú:
Is the same that in previous commands.
To stop the plot process press any key. If the calculator doesn't respond hold the key pressed.
You'll see some 'x' and some 'o' at the open loop poles and zeros locations respectively.
Some times it can seem that there is nothing plotted. Possible causes and their solution are:1) The resolution is very high and the points are out of range.
SOLUTION: decrease the RES field value.
2) The resolution is very low and the plot spends a lot of time to draw each point.
SOLUTION: increase the RES field value.
With this command you'll can draw the system response for the system represented by the CLOSED LOOP transfer function you wish for a continuous or a discrete time system when the input is one of
- Step
- Pulse
- Ramp
- Sine
The fields:
NUM, DEN : These fields contain the CLOSED LOOP transfer function numerator and denominator for a continuous or discrete time system.
T : Input type.
A : For a continuous time system enter here the signal amplitude. The meaning of this field for each input time is the next:
- Step: Step magnitude.
- Ramp : Ramp slope.
- Pulse: For this input this value is not considered.
- Sine: Sine signal amplitude.
For a discrete time system enter at this field the sample period.
w: This value is only considered when the input is a sine, and it represents the wave frequency.
AUTO: When activated the vertical axis will be automaticly scaled.
HR, VR : Horizontal and vertical plot ranges.
The menu:
Only the next options have to be commented:
INPU: When activated the input will be also drawn (with points). The pulse function will not be drawn anyway.
LINS: Deactivate this option if you want to draw the response with points instead of with lines.
DISC: Activate this option when working with a discrete time system. Each time you change this value you'll see how the maximum horizontal range value is also modified to adjust itself because usually the ranges for continuous and discrete systems are not the same.
Delayed transfer functions have not been considered because the difference between the response of a delayed system and the same system not delayed is a only a horizontal displacement of the plot.
After the graph is plotted, in the EQ variable you'll obtain the response equation that was drawn, that is , you'll get stored in that variable the inverse transform of the system with the corresponding input.
Don't forget to activate DISC when working with a discrete time system and to enter the sample period at field A.
Remember also that this command only works with CLOSED LOOP transfer functions.
With this command you'll be abel to obtain a lot of useful data when analyzing a system by means of its transfer function.
The options:
The results you can obtain are:
- Gain and phase margins.
- Bandwidth.
- Unitarian step response data (settling time, peak time, maximum overshoot, final value and steady state error).
- Closed loop poles.
- Statiliby limits, that is , the points where the root locus cross the vertical axis and the gain values at those points.
- Open loop poles.
- Open loop zeros.
Some options must be commented:
1) After selecting the gain and phase margins you'll be asked to enter the transfer function delay. If the system has no delay simply enter 0.
2) You can obtain the step response data for a continuous or a discrete time system. The choice is made just after choose the 'step response' data option.
For those of you who like programming and who would wish to obtain the data directly without the necessity of going through the dialogs this command can do that for you giving it the necessary data on the stack. Depending on the results you want to obtain you must put on the stack the data as shown hereafter:
4: transfer function numerador
3: transfer function denominador
2: transfer function delay ( 0 if no delay).
1: 0 (real number zero)And you'll obtain:
4: gain margin (GM)
3: the frequency where that margin was calculated, that is, the phase crossover frequency (wcf)
2: phase margin (PM)
1: the frequency where that margin was calculated, that is, the gain crossover frequency (wcg)
The
infinite values or impossible one are returned as -1.
3: transfer function numerator
2: transfer function denominator
1: 1With all that, after execute Datos you'll obtain:
1: Bandwidth (BW)
4: open loop transfer function numerator
3: open loop transfer function denominator
2: For a continuous time system put 0; for a discrete time system put 1.
1: 2Then you'll obtain the response data in the ordered as shown hereafter:
5: settling time (for the 2% border) (ts(2%))
4: per cent maximum overshoot (Mp(%))
3: peak time (tp)
2: output steady state value (when time tends to infinite) (r(inf))
1: steady state error (e)
3: open loop transfer function numerator
2: open loop transfer function denominator
1: 3Wherewith you'll obtain:
1: double list with the closed loop poles
3: open loop transfer function numerator
2: open loop transfer function denominator
1: 4
And if the root locus cross at any point the imaginary axis you'll obtain:
1: a list containing fields as
{ K { v1 v2 v3 ... } }
where the vi values are the points where the root locus cross the vertical axis and where K is the gain value at this points.
Open loop poles: In this case you have to put on the stack:
3: open loop transfer function numerator
2: open loop transfer function denominator
1: 5Obtaining
1: a double list with the open loop poles
Open loop zeros: Finally giving on the stack
3: open loop transfer function numerator
2: open loop transfer function denominator
1: 6You'll obtain
1: a double list with the open loop zeros
With this
command you'll be able to calculate simple continuous and
discrete controllers ( proportional (P),
proportional -derivative (PD),
proportional-integral (PI) and
proportional-integral-derivative (PID), so that
a given system achieve some specifications.
Unitarian negative feedback is supposed and the controller
transfer function serial with the plant transfer runction as
shown hereafter:
This command simply tries to find the solution that best fit the specifications imposed according to the controller type chosen. You must be chouse the controller type to use with the system or to try with all the controllers until you find the good one.
The fields:
NUM, DEN : Open loop transfer function numerator and denominator.
TYPE : Chose the controller type to calculate. The different types are P, PD, PI o PID.
ESPC: Chose the form you are going to give the specifications whereby calculate the controller. There are two posibilities:
- Sd(Zd): Chosen this option, in the next step you'll be asked to enter a dominant closed loop pole location be it in the s plane (Sd) or the z one (Zd) depending on if you work with a continuous or a discrete time system. That is, you can impose the root locus to go by the point you want (more or less).
At imposing a specific location for the closed loop dominant poles indirectly you are acting over the settling time and the maximum overshoot. Let's see a bit theory:
As you knoe, a second order system has two roots. Well then if we suppose the more general case in which that two roots are conjugated complexes, these one will be the dominant poles (because they are the unique poles); let's take the one with positive imaginary part and let's locate it in the complex plane:
According to that figure the dominant pole would be located at
Sd = (-x,y) = - x + i·y.
The damping factor is equal to the cosine of the betha angle shown in the picture, and the maximum overshot is related to the damping factor by the expression:
Furthermore the settling time (2% border) is also related with the damping factor and with the dominant pole modulus (wn in the figure) through the expression:
Hence we can see that varying the closed loop dominant pole we can act over the settling time and the maximum overshoot.
For systems with order grater tan 2 the presence of a couple of conjugated dominant poles conditionates the system's response, wherewith it can be assimilated to a second order system under certain conditions.The relation between the system response parameters and the dominant pole locations in a discrete time case can be obtained starting from the correspondence between the s plane and the z plane given by:
z = exp(T·s)
being T the sample period.
- Error, Mp, ts: Chosing this another option you'll can enter lately the steady state error , maximum overshoot and settling time you want for the system to have after it is controlled.
The values of Mp and ts are used to calculate the closed loop poles location by means of the previous expressions and starting from there calculate the poles and zeros controller locations; the error value is used to calculate the controller gain (along with the poles and zeros calculated previously)
In next versions I hope to add other controllers to the list of available one, as well as the possibility to give the specifications in terms of the gain and phase margins.
The menu:
Just the next options must be commented:
DISC: Activate this option if you are going to calculate a discrete controller.
DATA: When activated (by default) after calculating the controller in addition to the controller parameters you'll obtain the controlled system response data to an unitarian step (settling time, maximum overshoot, etc...).
CNTR: Press here to calculate the controller. Depending on the way you select to give the specifications you'll find with any of the next windows:
DISC |
DISC |
|
Sd(Zd) |
||
Error, Mp, ts |
After entering in the corresoponding window and pressing OK the controller is calculated and the results are shown in a window like this:
where the first thing that
appears is the controller transfer function followed by its
parameters. If you activated the option DATA in
the main window, following the controller parameters you'll find
the controlled system unitarian step response.
The option called GRAF that appears in the menu
will allow you to jump directly to the command Resp
with the controlled system closed loop transfer function
at fields NUM and DEN for you to plot the controlled response.
The table below relates the proportional, derivative and integral constans of each controller type in their usual form and the one calculated by Bode-Routh.
controller type |
Bode-Routh expression |
usual expression |
Parameters relations |
|
P | continuous | ![]() |
![]() |
![]() |
discrete | ![]() |
![]() |
![]() |
|
PD | continuous | ![]() |
![]() |
![]() |
discrete | ![]() |
![]() |
![]() |
|
PI | continuous | ![]() |
![]() |
![]() |
discrete | ![]() |
![]() |
![]() |
|
PID | continuous | ![]() |
![]() |
![]() |
discrete | ![]() |
![]() |
![]() |
This command applies the Routh-Hurwitz criterion to the polynomial given on the stack at level 1., obtaining at the same level a list with the coefficients of the first column in the Routh matrix and the whole matrix at level 2. Special cases as whole rows with zeros or first coefficient in the previous row equal to zero (in which it is substituted by 1.E-50) are considered. Symbolic constans and symbolic expressions can be also entered. See the example 12 where an application of this criterion is shown.
The final result depends on the state of user flags 2 and 3. The meaning of these flags is the same that in Neopolys, that is, with flag 2 activated the resuls are automaticly simplificated, and with flag 3 activated decimal results are converted to fractionals.
This command transforms a continuous system to its discrete equivalent by means of two of the most commonly methods used for this purpose. Before using this command you must put on the stack the next things:
3: continuous system's numerator
2: continuous system's denominator
1: sample period
to obtain
2: discrete system numerator
1: discrete system denominator
The command itself will ask you what method you wish to make the conversion by means of a dialog box wich will allow you to chose between:
This command also offers the possibility of make the conversion directly without going through the dialog box. To do that you must give on the stack the next things:
4: numerator
3: denominator
2: sample period
1: 0 to use the Zho method or 1 to use the bilineal one
Given the direct transfer function the feedback one and the feedback sign this command returns the closed loop transfer function. On the stack you must put
5: direct transfer function numerator
4: direct transfer function denominator
3: feedback transfer function numerator
2: feedback transfer function denominator
1: positive or negative real number indicating positive or negative feedback respectively.
You'll then obtain the closed loop transfer function as shown hereafter:
2: closed transfer function numerator
1: closed transfer function denominator
Let's explain it with an example:
Given the next system
the closed loop transfer function is
with the sign correspondence shown in the figure, that is, a positive feedback implies a negative sign in the F(s) and vice versa.
Although the sign in F(s) is the opposite to the one in the feedback, the sign of the real number at level 1 must be the same that the feedback's sign, NOT the one that must have F(s)
If the system has a unitarian feedback you should put at levels 2 and 3 the polynomial "{ 1 }".
My life's story is very very boring so I'm not gonna tire you narrating it. Nevertheless when you find any bug in this library, got any doubt or got any idea you think that could be interestgin to improve Bode-Routh, please contact me at:
apolo1@usuarios.retecal.es
CAMBIOS DESDE LA VERSIÓN 6.5
A new command called Cntr has been created allowing the
calculation of simple P, PD, PI
and PID controllers.
The commands Datos and C2DM now allow the results to be
obtainned directly wihtout the necessity of entering int the
inputforms and the dialog boxes. See their help for more
information.
Although in this occasion there were not very significant bugs (
¡¡ HALLELUJAH !! ) the code was revised and some small
modifications were made.
The manuals have been rewriten in HTML for a better
comprenhension and visualization.
There have been added 12 examples about solving some common
analysis and controller design problems with Bode-Routh.
CHANGES FROM VERSION 6.3
The main change has been
the extraction of the data command which were included in
previous commands inside the Bode-Routh commands shuch as Bode,
Resp, etc... and that have been put together in a command called
'DATA'.
The bandwidth calculation was not correct.
There have been modified some 'Rloc' command aspects such as:
CHANGES FROM VERSION 6.1
Added the command 'C2DM'.
The 'Resp''s menu option 'CNCT' has been substituted by 'DATS',
allowing you to calculate some data for a step response.
It has been added the posibility to calculate the bandwidth
inside the 'Bode' command.
There were corrected some minor bugs and optimized the code.
The default values for the fields 'AUTO' and 'RES' in the 'RLoc'
command have been changed.
The command 'RLoc' has been completely rewritten to gain for some
speed.
CHANGES FROM VERSION 6.0
The commands were updated
to take advantage of the last version (5.3) of Neopolys.
There were corrected some mistakes in the manuals.
CHANGES FROM VERSION 5.9
I made a mistake in
version 5.8 for which the graphs were always plotted without
connecting the points.
The graphics display was not correctly reset by the menu option
'ERASE', which made that plot dimensions were the previous
graphic dimensions.
There was corrected the error checking of the horizontal and
verti-cal plot ranges and now you can introduce the lower and
greatervalues in any of the two fields representing the
horizontal and vertical ranges, and they will be placed in the
correct position after drawing the plot and returning to the
input form.
CHANGES FROM VERSION 5.8
There was corrected a bug
which made the command 'GFM' return incorrect values for some
transfer functions.
An option was added to the command 'Resp' in order to be able to
draw the response plots either with lines or with points (
especially for discrete responses ).
CHANGES FROM VERSION 5.6
In previous versions the
transfer function delay was not considered when calculating the
gain and phase margins. Now it does.
Due to the incorporation of the Z transform calculation commands
in Neopolys, the command "Step" can now graph the
response of a continuous system or a discrete one.
The whole commands were updated in order to make use of the new
advantages of Neopolys version 4.4.
CHANGES FROM VERSION 5.5
The notation used in
version 5.5 for Wcg and Wcf (in the GFM command in
"BODE" one ) were not correct. Really, Wcg was Wcf and
Wcf was Wcg. That was corrected.
In the "->CL" command, the feedback sign considered
to close the loop was not the correct one. That was corrected.
Another few changes were made in order to work properly with
Neopolys (v4.1).
CHANGES FROM VERSION 5.1
Almost the whole set of
commands have been revised to make use of the new Neopolys v4.0
advantages , and an extensive code optimization have been made
leading in a great speed increase.
There were corrected some terms of the manuals which were not
correct as for example when talked about closed loop poles in
v5.1 really I was talking about the open loop poles, etc...
The Routh command considers the state of user flags 2 and 3 when
calculating and showing the results.
CHANGES FROM VERSION 5.0
There was corrected an
error in the "Bode" command for which the results in
the calculations of the gain and phase margins were not correct
when working in "RAD" mode.
When drawing the response to an input of type "Pulse"
the graph spent some time trying to draw the input function. That
was corrected and now the "Pulse" input function is not
drawn even when the option "INPU" is activated.
CHANGES FROM VERSION 2.3
There are so many many many many .....