Post Reply 
Bode/Nyquist plot.....
05-13-2015, 11:03 AM
Post: #1
Bode/Nyquist plot.....
program is based on (Statistics 1Var)...the numerical values from this this code is valid but plots are temperamental. need help pls.
BODE(ƒ1,ƒ2,[num],[den])>>enter. example
BODE(-1,1,[1],[1 0.2 1])>>enter.
use VIEW key to select graphs.

Code:

Tf();
BODE();
VIEW "Start",START()
BEGIN
D1:={};
D2:={};
SetSample(H1,D1);
SetFreq(H1,D2);
H1Type:=4;
STARTVIEW(6,1);
WAIT();
STARTVIEW(-1,1);
END;

export BODE(Xmin,Xmax,num,den)
BEGIN
local num:=poly2symb(num,"*x");
local den:=poly2symb(den,"*x");
expand(num/den)▶F1;
Xtick:=0.01;
makelist(ALOG(X),X,Xmin,Xmax,Xtick)▶L1;
L2:=Tf(L1);
L7:=20*LOG(ABS(L2));
L3:=ARG(L2)*180/pi;
L4:=IM(L2);
L5:=RE(L2);
END;

EXPORT Tf(x)
BEGIN
L2:=(F1(X)|x=L1);
END;

VIEW "Nyquist",nyquist()
BEGIN
L5▶D2;
L4▶D1;
Xmin:= FLOOR(MIN(D1)+1);
Xmax:=CEILING(MAX(D1)+1);
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
STARTVIEW(1,1);
END;

VIEW "Magnitude",Magnitude()
BEGIN
D1:=L1;
D2:=L7;
Xmin:= -1;
Xmax:= 1;
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
STARTVIEW(1,1);
END;

VIEW "Phase",Phase()
BEGIN
D1:=L1;
D2:=L3;
Xmin:= -1;
Xmax:= 1;
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
STARTVIEW(1,1);
END;

PLOT()
BEGIN
Xmin:= -1;
Xmax:= 1;
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
STARTVIEW(1,1);
END;

Symb()
BEGIN
SetSample(H1,D1);
SetFreq(H1,D2);
H1Type:=4;
STARTVIEW(0,1);
END;
Find all posts by this user
Quote this message in a reply
05-13-2015, 11:13 AM (This post was last modified: 05-13-2015 11:24 AM by salvomic.)
Post: #2
RE: Bode/Nyquist plot.....
(05-13-2015 11:03 AM)toshk Wrote:  program is based on (Statistics 1Var)...
...

hi, thank you, but, please, check the code included...
I get this error (copy and pasting):
error in line 7 -> SetSample(H1,D1);
I don't think that the error is really there, perhaps elsewhere...

Thank you,
Salvo

EDIT:
no error in your program!
here there was previous data on Statistic 1var, so there there was an error with H1 and so on...
Also with some programs of mine this happens...

please, advice what data put in Statistic 1var for your example above, so I'll be able to test...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2015, 04:04 PM (This post was last modified: 05-13-2015 04:17 PM by toshk.)
Post: #3
RE: Bode/Nyquist plot.....
(05-13-2015 11:13 AM)salvomic Wrote:  
(05-13-2015 11:03 AM)toshk Wrote:  program is based on (Statistics 1Var)...
...

hi, thank you, but, please, check the code included...
I get this error (copy and pasting):
error in line 7 -> SetSample(H1,D1);
I don't think that the error is really there, perhaps elsewhere...

Thank you,
Salvo

EDIT:
no error in your program!
here there was previous data on Statistic 1var, so there there was an error with H1 and so on...
Also with some programs of mine this happens...

please, advice what data put in Statistic 1var for your example above, so I'll be able to test...
G(s) =

1
---------------
s^2 + 0.2 s + 1

Continuous-time transfer function. for frequencies(rad/s) between .01 and 10 shd be entered:

BODE(-1,1,[1],[1 0.2 1])>>enter.
use VIEW >>Start (if you think to empty D1 and D2)
use VIEW >>Magnitude. (to load freq. vs dB magnitude)
soft Menu>>Zoom>>Auotscale (to see how off the plot is)
Find all posts by this user
Quote this message in a reply
05-13-2015, 04:37 PM
Post: #4
RE: Bode/Nyquist plot.....
(05-13-2015 04:04 PM)toshk Wrote:  Continuous-time transfer function. for frequencies(rad/s) between .01 and 10 shd be entered:

BODE(-1,1,[1],[1 0.2 1])>>enter.
use VIEW >>Start (if you think to empty D1 and D2)
use VIEW >>Magnitude. (to load freq. vs dB magnitude)
soft Menu>>Zoom>>Auotscale (to see how off the plot is)

ok, I mean: I have already D1 and D2 empty...
In View I can see only 1. "Split screen Plot Detail" 2. Autoscale...
Am I wrong?

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2015, 05:01 PM
Post: #5
RE: Bode/Nyquist plot.....
recompile under the copy of (Statistics 1Var)..then you shd see mine VIEW


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
05-13-2015, 05:13 PM
Post: #6
RE: Bode/Nyquist plot.....
(05-13-2015 05:01 PM)toshk Wrote:  recompile under the copy of (Statistics 1Var)..then you shd see mine VIEW

ok, but... I don't remember how, please, help Smile

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2015, 05:14 PM
Post: #7
RE: Bode/Nyquist plot.....
(05-13-2015 05:13 PM)salvomic Wrote:  ok, but... I don't remember how, please, help Smile

Open the app program in your program catalog (very top item), then exit and go the the app screen.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
05-13-2015, 05:20 PM
Post: #8
RE: Bode/Nyquist plot.....
select the copy of (Statistics 1Var) with the code.
Apps>>Statistics 1Var copy>>Enter
Shift>>Program>>Statistics 1Var copy>>Enter>>Check (for bugs).
Find all posts by this user
Quote this message in a reply
05-13-2015, 05:29 PM (This post was last modified: 05-13-2015 05:47 PM by salvomic.)
Post: #9
RE: Bode/Nyquist plot.....
(05-13-2015 05:14 PM)Tim Wessman Wrote:  
(05-13-2015 05:13 PM)salvomic Wrote:  ok, but... I don't remember how, please, help Smile

Open the app program in your program catalog (very top item), then exit and go the the app screen.

(05-13-2015 05:20 PM)toshk Wrote:  select the copy of (Statistics 1Var) with the code.
Apps>>Statistics 1Var copy>>Enter
Shift>>Program>>Statistics 1Var copy>>Enter>>Check (for bugs).

thanks to both of you

I created a Statistic 1var copy, followed both tips, but in View I can see always the standard items. I'm trying again

EDIT:
I put your code in a program (here called bode-nyquist). Must I put it in Statistic 1var copy also? Sorry, but for now I'm a bit confused...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2015, 06:00 PM (This post was last modified: 05-13-2015 06:09 PM by toshk.)
Post: #10
RE: Bode/Nyquist plot.....
the code must be in Statistics 1Var copy.
yes...
the code is based on Statistics 1Var, putting the code in mere program would not help.
Find all posts by this user
Quote this message in a reply
05-13-2015, 07:30 PM
Post: #11
RE: Bode/Nyquist plot.....
Can you please define what you mean by "tempermental"? I got it running here and it seems to be working fine - however I am not certain what I should be looking for.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
05-13-2015, 08:43 PM
Post: #12
RE: Bode/Nyquist plot.....
BODE(-1,1,[1],[1 0.2 1])
shd look like attached pix. are you getting the same? without having to hit VIEW or Plot and Zoom multiplies of times? the numerical values in D1 and D2 changes with each VIEW pressed but not the graph (Plot).
thanks


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
05-13-2015, 09:35 PM
Post: #13
RE: Bode/Nyquist plot.....
I'm trying with the new firmware, and I get this (apparent) error in the line

H1Type=4;

...

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2015, 10:25 PM
Post: #14
RE: Bode/Nyquist plot.....
with the new firmware, edit them out.
H1Type=4;
H1Type=4; and compile without error.
use Symb to set it up.
choose Dot under Plot1:
Find all posts by this user
Quote this message in a reply
05-13-2015, 10:34 PM
Post: #15
RE: Bode/Nyquist plot.....
(05-13-2015 10:25 PM)toshk Wrote:  with the new firmware, edit them out.
H1Type=4;
H1Type=4; and compile without error.
use Symb to set it up.
choose Dot under Plot1:

ok, I set Dot, but I don't understand:
H1Type=4;
H1Type=4;
?
The error cursor is set first than the "H" of "H1Type", still...

ok, I'll try tomorrow Smile

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2015, 10:37 PM (This post was last modified: 05-13-2015 11:55 PM by Tim Wessman.)
Post: #16
RE: Bode/Nyquist plot.....
You can now directly access the symb parameters in a consistent way. H1 will recall a list of parameters. H1(num):= will let you set any parameter.

So for example, you can just use this H1:={'D1','D2', 4}; to replace 3 commands.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
05-13-2015, 11:51 PM (This post was last modified: 05-13-2015 11:52 PM by alexzkter.)
Post: #17
RE: Bode/Nyquist plot.....
I created the Bode program with the long code, see capture:
   

Also created copy of Statistics 1Var named Bode:
   

Went into the app, shift-Program-enter on Bode program, debug (no errors) went back into the Statistics 1Var copy app then entered the code BODE(-1,1,[1],[1 0.2 1]) on the first cell but error message shows up:

   

What am I doing wrong?
Find all posts by this user
Quote this message in a reply
05-14-2015, 12:16 AM
Post: #18
RE: Bode/Nyquist plot.....
I believe the intent is for that command BODE(-1,1,[1],[1 0.2 1]) to be executed from the home screen or similar.


This is what I've done:
  1. execute START from VIEW. Q: I assume this will be to show the Info screen on completion?
  2. BODE(-1,1,[1],[1 0.2 1]) on the home screen. I now see 0 in D1 and 5 in D2. Is that what I should get?
  3. I execute nyquest and the xmin/max and ymin/max are identical. I assume that should not be the case?

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
05-14-2015, 12:21 AM (This post was last modified: 05-14-2015 12:48 AM by toshk.)
Post: #19
RE: Bode/Nyquist plot.....
the code is based on Statistics_1Var_Copy (newer firmware)
it works but buggy using Symb>>Dot....this is my code.
execute START from VIEW. Q: I assume this will be to show the Info screen on completion? Yes and also reset App.
BODE(-1,1,[1],[1 0.2 1]) on the home screen. Yes
Home screen >>VIEW>>Magnitude>>Plot (to see bode) use Zoom from soft menu
Code:

Tf();
BODE();
Xmin=0,Xmax=0;
VIEW "Start/Info",START()
BEGIN
D1:={};
D2:={};
SetSample(H1,D1);
SetFreq(H1,D2);
H1(3):=8;
STARTVIEW(6,1);
WAIT();
STARTVIEW(-1,1);
END;

export BODE(Xmin,Xmax,num,den)
BEGIN
Statistics_1Var_Copy.Xmin:=Xmin;
Statistics_1Var_Copy.Xmax:=Xmax;
local num:=poly2symb(num,"*x");
local den:=poly2symb(den,"*x");
expand(num/den)▶F1;
Xtick:=0.01;
makelist(ALOG(X),X,Xmin,Xmax,Xtick)▶L1;
L2:=Tf(L1);
L7:=20*LOG(ABS(L2));
L3:=ARG(L2)*180/pi;
L4:=IM(L2);
L5:=RE(L2);
END;

EXPORT Tf(x)
BEGIN
L2:=(F1(X)|x=L1);
END;

VIEW "Nyquist",nyquist()
BEGIN
L5▶D2;
L4▶D1;
Xmin:= FLOOR(MIN(D1)+1);
Xmax:= CEILING(MAX(D1)+1);
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
END;

VIEW "Magnitude",Magnitude()
BEGIN
D1:=L1;
D2:=L7;
Xmin:= Statistics_1Var_Copy.Xmin;
Xmax:= Statistics_1Var_Copy.Xmax;
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
END;

VIEW "Phase",Phase()
BEGIN
D1:=L1;
D2:=L3;
Xmin:= Statistics_1Var_Copy.Xmin;
Xmax:= Statistics_1Var_Copy.Xmax;
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
END;

PLOT()
BEGIN
Xmin:= Statistics_1Var_Copy.Xmin;
Xmax:= Statistics_1Var_Copy.Xmax;
Ymin:= FLOOR(MIN(D2)+1);
Ymax:= CEILING(MAX(D2)+1);
STARTVIEW(1,1);
END;


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
05-14-2015, 08:58 AM
Post: #20
RE: Bode/Nyquist plot.....
(05-13-2015 10:37 PM)Tim Wessman Wrote:  You can now directly access the symb parameters in a consistent way. H1 will recall a list of parameters. H1(num):= will let you set any parameter.

So for example, you can just use this H1:={'D1','D2', 4}; to replace 3 commands.

thanks Tim, very interesting now!

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)