Subject: v05i023:  bode_rk - BodePlot V2.32 (a complete one), Part01/02
Date: 1 Jun 92 23:35:45 GMT
Organization: Univ. of North Carolina @ Wilmington

DISCLAIMER:
-----------

The programs are provided "as is" with no expressed or implied warrantys.
Any  damage  or  losses  caused by the use of these programs is soley the
resposibility of the user.


If there any questions or comments please don't hesitate to mail me.

Please excuse me my bad english, it isn't my native language !

**************************************************************************
*                     *                                                  *
* |)  /\  |/          * Organization: Fachhochschule Osnabrueck          *
* |\./--\.|\          *               Fachbereich Elektrotechnik         *
*                     *                                                  *
* Rainer A.  Kemme    ****************************************************
* Sedanstrass 16      * Internet    : kemme@jupiter.rz.uni-osnabrueck.de *
* W4500 Osnabrueck    * Ph.         : +49  541 61252                     *
* Germany             * FAX         : +49 2651 48845                     *
*                     *                                                  *
**************************************************************************
END_RDME

BEGIN_DOC bode.doc

BodePlotter V2.32  (a complete one)    24-May-1992
--------------------------------------------------

Introduction:
-------------
This  program  is  developed  for  use  in  control systems. It is (i.e.) a
useful  tool  to  utilize the frequency response of the open-loop system to
determine the stability of a closed-loop system and something more.

At this point I refer to all these interesting books about control systems.

The  following  sections  give  a  short explanation on the contents of the
Bode directory. 

Some further simple examples are located at the end of this DOC.

Changes made since V2.0: - a few 'semantic traps' removed
			 - back-up the last plot
			   (includes a softkey to switch between the actual
			    and the last plot [CTSW])
			 - ability to change size of PICT from CST-menu
			   (i.e 640x400 for prints, if there is enough RAM)
			 - now it's possible to leave SETUP by pressing the
			   [DEL]-key
			 - menu-sreen of 'SETUP' is GROB
			 - two different independent-variables: \Gw or f
			   f means: i*2*pi*f    \Gw means i*\Gw
			 - a new plot-type: y: |F| (dB) vs. \Gw or f

Bode directory:
---------------

Download the bode plot routines.  Enter the BODE directory.  Now you
should see

	       [DEL] [TF] [SETUP] [MGPH] [PARM] [CST] 
	       
		    press (NXT) and you will see
		    
	       [EQ] [EQ] [PPAR] [PPAR] [PICT] [omega]
	       
		    press (NXT) and you will see
		    
	       [F] [MENU] [   ] [   ] [   ] [   ]


DEL      a  little  program  that  put's  all  variables  left of it into a
	 list.  Now it is easy to remove the variables. 

TF       contains  the  transfer  function  (in terms of S)  to be plotted.
	 It is also included in the temporary menu. 

SETUP    is  meant  to  select  the  kind  of  plot  and toogle  the smooth
	 function.   A   more   precisely   explanation  follows   in   the
	 explanation on the CST-menu. 

MGPH     MaGnitude and PHase, computes a few numerical details (more than
	 magnitude and phaseshift) for a given (radian) frequency.

PARM     displays the contents of the PPAR variable in a  goodlooking form.

CST      It's  contents  automates  most  of  the  work  for  plotting bode
	 diagrams. 

EQ       This equation is drawn by the HP-48SX.  It is a result of SETUP. 

eq       The equation of the plot before.

PPAR     It  contains  a  list  of  plotting parameters used by the command
	 DRAW,  by  AUTO  for  autoscaling, and by the interactive graphics
	 operations. 

ppar     The parameters of the plot before.

PICT     It contains the image of the plot before.

omega    the independent variable.

f        the alternative independant variable.

menu     the menu GROB.



The CST-variable and -menu
--------------------------

TF       This  variable  contains  the  transfer function in terms of S (S,
	 not s) Just after downloading it contains 'INV(1+S)'

SETUP    ------------------------------------
	 |      BodePlot V2.32 by  RAK      |
	 |                                  |
	 |      y: |F|        x:     w      |   w   = omega
	 |      y: |F|        x: log w      |
	 |      y: |F|        x:     w      |
	 |    ->y: |F|(db)    x: log w      |
	 |      y:  <) (o)    x:     w      |   <)  = angle
	 |      y:  <) (o)    x: log w      |   (o) = degree
	 |      Smooth.....:  ( )           |
	 |      Indep. Var.:  w <--> f      |
	 |      EXIT                        |
	 ------------------------------------
	 
	 The display after pressing the SETUP-key.

	 The UP and DOWN keys are used to choose the kind of plot, to
	 toogle the Smooth function, select the independant variable and
	 leave 'SETUP' without changes.
	 Just press [ENTER] to select a kind of plot or press DEL to leave
	 SETUP-menu without changes. Don't press [ON/ATTN] to leave the
	 SETUP-menu. This will break the program, and leave you with the
	 flags set the way 'SETUP' likes them.
	 
XRNG     Specifies the x-axis display range. It takes two arguments from
	 stack, real numbers or cursor-position-coordinates (complex nums.).
	 If the arguments are cursor-position-coordinates, it will use only
	 the real-parts of them.
	 Note: If the x-scale is linear '1 10 XRNG' specifies a x-range from
	       1 rad/s up to 10 rad/s, but if the x-scale is logarithmic
	       '1 10 XRNG' specifies a x-range from 10^1 (10) rad/s up to
	       10^10 (1E10) rad/s.
	 (XRNG calls the PARM-program to display the contents of the PPAR
	 variable.)

AUTO     Calculates a y-axis display range.
	 (AUTO calls the PARM-program ...)
	 
ERASE    Erases PICT, leaving a blank PICT of the same dimensions.

DRAW     Draws transfer function of selected plottype.

YRNG     Specifies the y-axis display range. It takes two arguments from
	 stack, real numbers or cursor-position-coordinates (complex nums.).
	 If the arguments are cursor-position-coordinates, it will use only
	 the real-parts of them.
	 (YRNG calls the PARM-program ...)
	 
PPDI     Specifies how many points per display shall be plotted. It takes
	 one argument from stack.
	 No argument or a zero (0) will set high resolution.
	 (See the later example for details)
	 
PARM     Calling PARM, the display should look like this:
    
	 ------------------------------------
	 |       Type: FUNCTION f(w)        |
	 |       Axes: LOG w  <)  Sm( )     |
	 |       Xmin: -3                   |
	 |       Xmax: 3                    |
	 |       Ymin: -69.00000434         |
	 |       Ymax: -0.00000434          |
	 |       PpDi: High Resolution      |
	 [YRNG][PPDI][PARM][CTSW][SCRS][MGPH]


CTSW     ConText SWitch. A tool to switch between the actual image
	 and the image (PPAR inclusive) of the plot before (if saved). 
	 If you move around with the cursor you will always get the
	 right cursor-position-coordinates.
	 
SCRS     SCReen Size. The normal screen size is 131x64. If you want to
	 print a bodeplot on your dot-matrix-printer, laser-printer or
	 whatever, it may be useful to change the screen size of PICT
	 to any (any?) size you want. 
	 
	 ------------------------------------
	 |^                                 |
	 ||  y: 64 Pixel                    |
	 ||                                 |
	 ||           x: 131 Pixel          |
	 |+-------------------------------->|
	 |        Press: x y SCRS to        |
	 |        change screen-size        |
	 [YRNG][PPDI][PARM][CTSW][SCRS][MGPH]
	 
	 The display after pressing SCRS without arguments.
	 For a resolution of 320x200 (i.e.) just press: 320 200 [SCRS]
	 
MGPH     calculates a few important numerical details for the given TF.
	 It takes one argument ((radian) frequency) from stack.
	 The display should look like the this, if the argumnet is 100:
	 
	 -----------------------------------
	 |        w      : 100.000000       | <- (radian) frequency
	 |        Re     : 0.000099         | <- Real part
	 |        Im     : -0.009999        | <- Imaginary part
	 |        |F|    : 0.009999         | <- Magnitude
	 |        |F|(db): -40.0004347      | <- Magnitude in deziBel
	 |        Ph.(Sm): -89.427061       | <- Ph.-shift in deg. (smoothed)
	 |        Phase  : -89.427061       | <- Ph.-shift in degree
	 [YRNG][PPDI][PARM][CTSW][SCRS][MGPH]

	 MGPH, for example, is very useful if you want to draw a TF into
	 a Nichols chart.
	 Pressing ENTER in the graphics enviroment, it puts cursor-position
	 coordinates on stack (complex number). MGPH takes a complex as an
	 argumnet but checks PPAR for an appropriate x-scale.
	 (i.e.: (2,-40.00043)  => w = 100, if x-scale is logarithmic)

A word about smooth:
--------------------

The  phase  shift returned by the ARG function lies between -180 degree and
+180  degree.  Very  often it is useful to get phase shift between 0 degree
and  -360  degree.  Especially if there is a step in the plot. In this case
select Smooth in the Setup-menu. Smooth does not affect magnitude plots.
(Smooth ( ) = Smooth off, Smooth (X) = Smooth on)


I believe my BodePlotter is easy to use. But before you get in trouble try
the following examples. If there are more problems, mail me.


Examples:
---------

I assume the function in TF is the original ('INV(1+S)'). Now let's try to
plot the magnitude in db (F(db) against log omega:

- press (CST) key to enter the custom menu,
- press [SETUP]   (the arrow is just at the right position),
- press [NO]      (don't save PICT)
- press (ENTER) to select the desired plottype, now you see all parameters,
- put -2 (as beginning decade) and 2 (as ending decade) onto stack,
  press [XRNG], now you see an updated parameter-list,
- press [AUTO], after a few seconds the finally updated parm.-list appears,
- press [ERASE]
- press [DRAW]

Now let's try to plot the phase shift against log omega:

- press (ON/ATTN), you are back in the CST-menu,
- press [SETUP], press down-arrow-key twice,
- press (ENTER)
- press [YES]    (to save the magnitude plot from the example before)
- press [AUTO], (Phase plots are always in DEG-mode)
- press [ERASE] [DRAW]
- press (ON) (NXT)
- put a 3 onto stack and press [PPDI]
- press (NXT) [ERASE] [DRAW]       (look what happens, it explains PPDI)
- press (ON) (NXT)
- press [CTSW] (ON/ATTN) [CTSW] (ON/ATTN) ...        (look what 'll happen)

Now an example that explains Smooth:

- store 'INV((1+S*90)^3)' in TF
- press [SETUP], press down-arrow-key twice,
- press (ENTER)
- press [YES] / [NO]
- put -4 and 3 onto stack, press [XRNG],
- press (NXT) [PPDI] (NXT) [AUTO] [ERASE] [DRAW] (you see a terrible split)
- press (ON) [SETUP] and select >Smooth<
- press [AUTO] [ERASE] [DRAW] (it explains 'smooth')

END_DOC

