[comp.sys.handhelds] bode plots on the 48

hernes@ndsuhp.UUCP (05/08/90)

Hello Networkers,

First of all I would like to thank all who replied to my previous posting.
Also, I should apoligize to all who I may have offended, that was not my
purpose.

Secondly, I have been working on a few programs for the '48.  Here is a
bode/polar plotter (developed for use in control systems).

The hp48sx will plot bode diagrams almost directly from the transfer
Function.  The following automates most of the work for plotting bode
diagrams and polar plots.  Sometimes the Y-scale doesn't make the graph
very clear and then you have to set Y limits manually (or zoom).

The programs are as follows:  

KEY12.1: this is the program bound to my user "B" key, it sets up a
         temporary menu of:
             { Mag Phase Polar L<-->L TF X.AXIS S }
where

Mag:  This program plots the magnitude of F(jw) versus frequency.      
      It takes two numbers from the stack, which are the lower and upper
      'X' limits, then it autoscales the 'Y' axis and plots the bode 
      diagram for the function in 'TF'.

Phase: This program plots the phase of F(jw) versus frequency.
       It takes two numbers from the stack, which are the lower and upper
       'X' limits, then it autoscales the 'Y' axis and plots the phase
       vs. freq for 'TF'.

Polar: This uses the parametric plotting capabilities of the hp to 
       plot the imaginary part of F(S) versus the real part.
       It also takes two numbers from the stack, which, as expected are
       the lower and upper limits of 'X' which is the independent variable.

L<-->L: This toggles the scale of the frequency from log to linear, and
        changes the axis labels appropriately.  This does not affect the
        Polar plotter. L<-->L sets or clears user flag #1 so that it is
        obvious which scale will be plotted.

TF:     This variable contains the Transfer Function (in terms of S)
        to be plotted.  It is included in the temporary menu for
	convenience.


%%HP: T(3)A(D)F(.); 
DIR
  KEY12.1
    \<< { Mag Phase
Polar { "L\<-\->L"
LOG\<-\->LIN } TF
 } TMENU
    \>>
  LOG\<-\->LIN
    \<< xlabels
      IF 1 FS?
      THEN 1 CF 2 '
i*X'
      ELSE 1 SF 1 '
i*ALOG(X)'
      END 'S' STO
GET 'X.AXIS' STO
    \>>
  X.AXIS "j\Gw"
  xlabels {
"LOG(j\Gw)" "j\Gw" }
  Polar
    \<< 'PPAR' PURGE
TF 'EQ' STO S \->
OLDS
      \<< 'i*ALOG(X)'
'S' STO PARAMETRIC
DUP2 2 \->LIST 'X'
SWAP + INDEP {
(0,\<)0) "RE{G}" "IM{G}" }
AXES SWAP - 100 /
RES ERASE AUTO DRAX
DRAW OLDS 'S' STO
      \>>
    \>>
  Phase
    \<< 'PPAR' PURGE
TF EVAL ARG 'EQ'
STO XRNG (0,\<)0)
X.AXIS "\<)F" 3 \->LIST
AXES ERASE AUTO
DRAX LABEL DRAW
    \>>
  Mag
    \<< 'PPAR' PURGE
TF EVAL ABS 'EQ'
STO XRNG (0,\<)0)
X.AXIS "|F|" 3
\->LIST AXES ERASE
AUTO DRAX LABEL
DRAW
    \>>
  S 'i*X'
END