Showing posts with label bode plot. Show all posts
Showing posts with label bode plot. Show all posts

Sunday, June 20, 2021

TI-84 Plus CE: Bode Plots of Transfer Functions

 TI-84 Plus CE: Bode Plots of Transfer Functions


Introduction


The problem BODEPLOT (2021) plots the Bode plot of a transfer function in the form:


f(s) = ( (s - z1) (s - z2) (s - z3) * ... ) / ( (s - p1) (s - p2) (s - p3) * ... )


where:

z_i = zeros of the transfer function

p_i = pole of the transfer function

s = jw

j = i = √-1

w = frequency


The plot uses a linlog plotting where each x is replaced with 10^x.  The y axis represents the conversion y = 20 log_10 ( abs f( 10^x * j) ).


Lists used:

L1:  list of zeros

L2:  list of poles

L3:  x

L4:  20 log_10 ( abs f( 10^x * j) )


You can review the zeros and poles after each entry.  Erasing zeros and poles will erase the latest entry. 


TI-84 Plus CE Program:  BODEPLOT

Version 5.3 and above


"EWS 2021-05-02"

ClrHome

Disp "TRANSFER FUNCTION","F(S)=(S-ZERO).../(S-POLE)","S=JW 10^(W),20log(abs())"

Pause 

a+bi

0→A

0→B

0→Z

Lbl 0

toString(A)+" ZEROS, "+toString(B)+" POLES"

Menu(Ans,"ADD ZERO",1,"ADD POLE",2,"ERASE LAST ZERO",3,"ERASE LAST POLE",4,"REVIEW",5,"PLOT",6)

Lbl 1

Input "ZERO? ",S

If A=0

{S}→L1

If A>0

augment(L1,{S})→L1

A+1→A

Goto 0

Lbl 2

Input "POLE? ",S

If B=0

{S}→L2

If B>0

augment(L2,{S})→L2

B+1→B

Goto 0

Lbl 3

If A>1

Then

A-1→A

A→dim(L1)

Else

0→A

DelVar L1

End

Goto 0

Lbl 4

If B>0

Then

B-1→B

B→dim(L2)

Else

0→B

DelVar L2

End

Goto 0

Lbl 5

ClrHome

If A>0

Then

Disp "ZEROS:"

Pause L1

End

If B>0

Then

Disp "POLES:"

Pause L2

End

Goto 0

Lbl 6

For(I,-­6,6)

1→N

If A>0

prod(i*10^(I)-L1)→N

1→D

If B>0

prod(i*10^(I)-L2)→D

If Z=0

Then

{I}→L3

{20log(abs(N/D))}→L4

1→Z

Else

augment(L3,{I})→L3

augment(L4,{20log(abs(N/D))})→L4

End

End

FnOff 

PlotsOff 

-­7→Xmin

7→Xmax

1→Xscl

min(L4)-.5→Ymin

max(L4)+.5→Ymax

10→Yscl

Plot1(xyLine,L3,L4)

PlotsOn 1

DispGraph


You can download the zip file here.


Examples


f(s) = 1/(s-3)

Poles:  { 3 }










f(s) = s-0.5

Zeros: { 0.5 }










f(s) = ((s+2)(s-2))/((s-1)(s-3))

Zeros: { -2, 2 }

Poles: { 1, 3}










f(s) = (s-4)/((s+1)(s-3))

Zeros: { 4 }

Poles: { -1, 3 }










Eddie


All original content copyright, © 2011-2021.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 



Wednesday, April 5, 2017

HP Prime: Magnitude Bode Plot



HP Prime:  Magnitude Bode Plot

How BODEPLOT Works

The program BODEPLOT for the HP Prime plots a handmade Bode Plot for any of the following forms:

(I) H(s) = K * (s/A + 1)/(s/B + 1)
(II) H(s) = K * (s/A + 1)
(III) H(s) = K * 1/(s/B + 1)

with K = constant, -A = real root, -B = real pole

The input screen:



For type (II), enter 0 for B.  For type (III), enter 0 for A.  K must be nonzero, and it is assumed that K is positive.  The plot is made of a composition of two or three basic plots.

One thing to know:  the program simulates semi-log plot.  The X axis represents values of 10^x.  Hence, X = 0 represents 1, X = 1 represents 10, X = 2 represents 100, and so on.  Hence, each X represents a decade (instead of the customary unit). 

HP Prime Program BODEPLOT

EXPORT BODEPLOT()
BEGIN
// Bode Magnitude Plot
// K*(s/A+1)/(s/B+1)
// 2017-04-05 EWS

INPUT({K,A,B},
"Mag.: K*(s/A+1)/(s/B+1)",
{"Const (K): ","Zero (−A): ",
"Pole (−B): "},
{"Constant","Zero","Plot"});


F1:="20*LOG(K)";
F2:="PIECEWISE(X≤LOG(A),0,
X>LOG(A),20X-20LOG(A))";
F3:="PIECEWISE(X≤LOG(B),0,
X>LOG(B),−20X+20LOG(B))";
F4:="F1(X)+F2(X)+F3(X)";

// dark red color
F4(COLOR):=#800000h;

IF A==0 THEN
F2:="0";
END;

IF B==0 THEN
F3:="0";
END;

STARTAPP("Function");
CHECK(4);
UNCHECK(1);
UNCHECK(2);
UNCHECK(3);
// Autoscale
STARTVIEW(10,1);

END;

Examples

Example 1:  K = 1.02, A = 100, B = 250   (root = -100, pole = -250)


Example 2:  K = 1.02, A = 100  (no pole, B = 0)


Example 3:  K = 1.02, B = 250  (no root, A = 0)


Since the plots are first generated in Autoscale, I executed a Zoom Out (2 x 2) after program execution.

Sources:

“Bode Plot”  Wikipedia.  Last edited February 7, 2017.  https://en.wikipedia.org/wiki/Bode_plot   Retrieved March 6, 2017

Cheever, Eric.  “Bode Plot: Examples”  Swarthmore College.  2015.  Link:  http://lpsa.swarthmore.edu/Bode/BodeExamples.html   Retrieved March 6, 2017


This blog is property of Edward Shore, 2017.


Earth's Radius by Latitude

Earth's Radius by Latitude Introduction: Calculating the Earth’s Radius In quick, general calculations, we assume that the...