From 8ac15bc5efafa2afc053c293152605b0e6ae60ff Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Tue, 3 Sep 2019 18:27:40 +0530 Subject: Xcos examples from textbooks and for blocks --- .../3432/CH6/EX6.10/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.10/Ex6_10.sce | 46 ++++++++++++ Working_Examples/3432/CH6/EX6.10/Ex6_10_f0.pdf | Bin 0 -> 19822 bytes Working_Examples/3432/CH6/EX6.10/Ex6_10_f1.pdf | Bin 0 -> 24942 bytes .../3432/CH6/EX6.11/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.11/Ex6_11.sce | 28 ++++++++ Working_Examples/3432/CH6/EX6.11/Ex6_11_f0.pdf | Bin 0 -> 36890 bytes Working_Examples/3432/CH6/EX6.11/Ex6_11_f1.pdf | Bin 0 -> 25699 bytes .../3432/CH6/EX6.12/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.12/Ex6_12.sce | 40 +++++++++++ Working_Examples/3432/CH6/EX6.12/Ex6_12_f0.pdf | Bin 0 -> 35633 bytes Working_Examples/3432/CH6/EX6.12/Ex6_12_f1.pdf | Bin 0 -> 32028 bytes .../3432/CH6/EX6.13/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.13/Ex6_13.sce | 77 ++++++++++++++++++++ Working_Examples/3432/CH6/EX6.13/Ex6_13_f0.pdf | Bin 0 -> 28637 bytes Working_Examples/3432/CH6/EX6.13/Ex6_13_f3.pdf | Bin 0 -> 18495 bytes .../3432/CH6/EX6.14/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.14/Ex6_14.sce | 8 +++ Working_Examples/3432/CH6/EX6.14/Ex6_14_f1.pdf | Bin 0 -> 24019 bytes Working_Examples/3432/CH6/EX6.14/Ex6_14_f2.pdf | Bin 0 -> 34449 bytes Working_Examples/3432/CH6/EX6.14/Ex6_14_model.xcos | 1 + .../3432/CH6/EX6.15/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.15/Ex6_15.sce | 78 +++++++++++++++++++++ Working_Examples/3432/CH6/EX6.15/Ex6_15_f0.pdf | Bin 0 -> 35202 bytes Working_Examples/3432/CH6/EX6.15/Ex6_15_f1.pdf | Bin 0 -> 24894 bytes .../3432/CH6/EX6.16/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.16/Ex6_16.sce | 55 +++++++++++++++ Working_Examples/3432/CH6/EX6.16/Ex6_16_f0.pdf | Bin 0 -> 33525 bytes .../3432/CH6/EX6.17/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.17/Ex6_17.sce | 57 +++++++++++++++ Working_Examples/3432/CH6/EX6.17/Ex6_17_f0.pdf | Bin 0 -> 32489 bytes Working_Examples/3432/CH6/EX6.17/Ex6_17_f1.pdf | Bin 0 -> 21521 bytes .../3432/CH6/EX6.18/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.18/Ex6_18.sce | 42 +++++++++++ Working_Examples/3432/CH6/EX6.18/Ex6_18_f0.pdf | Bin 0 -> 32830 bytes Working_Examples/3432/CH6/EX6.18/Ex6_18_f1.pdf | Bin 0 -> 29436 bytes .../3432/CH6/EX6.19/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.19/Ex6_19.sce | 74 +++++++++++++++++++ Working_Examples/3432/CH6/EX6.19/Ex6_19_f0.pdf | Bin 0 -> 33664 bytes Working_Examples/3432/CH6/EX6.19/Ex6_19_f1.pdf | Bin 0 -> 27888 bytes .../3432/CH6/EX6.2.b/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.2.b/Ex6_2.sce | 28 ++++++++ Working_Examples/3432/CH6/EX6.2.b/Ex6_2_f0.pdf | Bin 0 -> 29204 bytes .../3432/CH6/EX6.3/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.3/Ex6_3.sce | 65 +++++++++++++++++ Working_Examples/3432/CH6/EX6.3/Ex6_3_f0.pdf | Bin 0 -> 20461 bytes Working_Examples/3432/CH6/EX6.3/Ex6_3_f1.pdf | Bin 0 -> 24108 bytes .../3432/CH6/EX6.4/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.4/Ex6_4.sce | 28 ++++++++ Working_Examples/3432/CH6/EX6.4/Ex6_4_f0.pdf | Bin 0 -> 37569 bytes .../3432/CH6/EX6.6/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.6/Ex6_6.sce | 30 ++++++++ Working_Examples/3432/CH6/EX6.6/Ex6_6_f0.pdf | Bin 0 -> 38639 bytes Working_Examples/3432/CH6/EX6.7/EX6_7_f0.pdf | Bin 0 -> 34768 bytes Working_Examples/3432/CH6/EX6.7/Ex6_7.sce | 44 ++++++++++++ .../3432/CH6/EX6.8/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.8/Ex6_8.sce | 48 +++++++++++++ Working_Examples/3432/CH6/EX6.8/Ex6_8_f0.pdf | Bin 0 -> 15692 bytes Working_Examples/3432/CH6/EX6.8/Ex6_8_f1.pdf | Bin 0 -> 32774 bytes .../3432/CH6/EX6.9/DEPENDENCIES/fig_settings.sci | 9 +++ Working_Examples/3432/CH6/EX6.9/Ex6_9.sce | 53 ++++++++++++++ Working_Examples/3432/CH6/EX6.9/Ex6_9_f0.pdf | Bin 0 -> 26216 bytes Working_Examples/3432/CH6/EX6.9/Ex6_9_f1.pdf | Bin 0 -> 23106 bytes 63 files changed, 946 insertions(+) create mode 100755 Working_Examples/3432/CH6/EX6.10/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.10/Ex6_10.sce create mode 100755 Working_Examples/3432/CH6/EX6.10/Ex6_10_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.10/Ex6_10_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.11/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.11/Ex6_11.sce create mode 100755 Working_Examples/3432/CH6/EX6.11/Ex6_11_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.11/Ex6_11_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.12/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.12/Ex6_12.sce create mode 100755 Working_Examples/3432/CH6/EX6.12/Ex6_12_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.12/Ex6_12_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.13/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.13/Ex6_13.sce create mode 100755 Working_Examples/3432/CH6/EX6.13/Ex6_13_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.13/Ex6_13_f3.pdf create mode 100755 Working_Examples/3432/CH6/EX6.14/DEPENDENCIES/fig_settings.sci create mode 100644 Working_Examples/3432/CH6/EX6.14/Ex6_14.sce create mode 100755 Working_Examples/3432/CH6/EX6.14/Ex6_14_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.14/Ex6_14_f2.pdf create mode 100755 Working_Examples/3432/CH6/EX6.14/Ex6_14_model.xcos create mode 100755 Working_Examples/3432/CH6/EX6.15/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.15/Ex6_15.sce create mode 100755 Working_Examples/3432/CH6/EX6.15/Ex6_15_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.15/Ex6_15_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.16/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.16/Ex6_16.sce create mode 100755 Working_Examples/3432/CH6/EX6.16/Ex6_16_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.17/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.17/Ex6_17.sce create mode 100755 Working_Examples/3432/CH6/EX6.17/Ex6_17_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.17/Ex6_17_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.18/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.18/Ex6_18.sce create mode 100755 Working_Examples/3432/CH6/EX6.18/Ex6_18_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.18/Ex6_18_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.19/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.19/Ex6_19.sce create mode 100755 Working_Examples/3432/CH6/EX6.19/Ex6_19_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.19/Ex6_19_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.2.b/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.2.b/Ex6_2.sce create mode 100755 Working_Examples/3432/CH6/EX6.2.b/Ex6_2_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.3/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.3/Ex6_3.sce create mode 100755 Working_Examples/3432/CH6/EX6.3/Ex6_3_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.3/Ex6_3_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.4/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.4/Ex6_4.sce create mode 100755 Working_Examples/3432/CH6/EX6.4/Ex6_4_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.6/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.6/Ex6_6.sce create mode 100755 Working_Examples/3432/CH6/EX6.6/Ex6_6_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.7/EX6_7_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.7/Ex6_7.sce create mode 100755 Working_Examples/3432/CH6/EX6.8/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.8/Ex6_8.sce create mode 100755 Working_Examples/3432/CH6/EX6.8/Ex6_8_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.8/Ex6_8_f1.pdf create mode 100755 Working_Examples/3432/CH6/EX6.9/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH6/EX6.9/Ex6_9.sce create mode 100755 Working_Examples/3432/CH6/EX6.9/Ex6_9_f0.pdf create mode 100755 Working_Examples/3432/CH6/EX6.9/Ex6_9_f1.pdf (limited to 'Working_Examples/3432/CH6') diff --git a/Working_Examples/3432/CH6/EX6.10/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.10/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.10/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.10/Ex6_10.sce b/Working_Examples/3432/CH6/EX6.10/Ex6_10.sce new file mode 100755 index 0000000..f1f5c20 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.10/Ex6_10.sce @@ -0,0 +1,46 @@ +//Example 6.10 +// Nyquist plot for an Open-loop unstable system. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +sysG=(s+1)/(s*(s/10-1)); +evans(sysG,50) +exec .\fig_settings.sci; //custom script for setting figure properties +title(["Root Locus for","$G(s)=(s+1)/[s(s/10-1)]$"],'fontsize',3) +zoom_rect([-5 -4 5 4]) +f=gca(); +f.x_location = "origin" +f.y_location = "origin" +h=legend(''); +h.visible = "off" + +g1=syslin('c',(s+1)/(s*(s/10-1))); +//------------------------------------------------------------------ +//The bode plot of the system +figure; +bode(g1,0.1/2/%pi,100/2/%pi,"rad") +exec .\fig_settings.sci; //custom script for setting figure properties +title(["Bode plot for","$G(s)=(s+1)/[s(s/10-1)]$"],'fontsize',3) +//bode(g,2*%pi*0.1,2*%pi*100) +//------------------------------------------------------------------ +figure; +//The nyquist plot of the system +nyquist(g1,0.5/2/%pi,100/2/%pi,0.05) +exec .\fig_settings.sci; //custom script for setting figure properties +title(["Nyquist plot for","$G(s)=(s+1)/[s(s/10-1)]$"],'fontsize',3) +f=gca(); +f.x_location = "origin"; +f.y_location = "origin"; +zoom_rect([-2 -2 1 2]); +xset("color",2); +xset("font size", 3); +xstring(-1,1.5,"${\fgcolor{blue}{\omega>0}}$",0,0); +xstring(-1,-1.5,"${\fgcolor{blue}{\omega<0}}$",0,0); +xstring(-1.5,0,"${\fgcolor{blue}{\omega=\pm \sqrt{10}}}$",0,0); +xstring(-0.5,0.1,"${\fgcolor{blue}{\omega=\infty}}$",0,0); +xarrows([-0.2;0],[0.2;0],-1,2) +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.10/Ex6_10_f0.pdf b/Working_Examples/3432/CH6/EX6.10/Ex6_10_f0.pdf new file mode 100755 index 0000000..36c7a51 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.10/Ex6_10_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.10/Ex6_10_f1.pdf b/Working_Examples/3432/CH6/EX6.10/Ex6_10_f1.pdf new file mode 100755 index 0000000..b0d811d Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.10/Ex6_10_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.11/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.11/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.11/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.11/Ex6_11.sce b/Working_Examples/3432/CH6/EX6.11/Ex6_11.sce new file mode 100755 index 0000000..4a78234 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.11/Ex6_11.sce @@ -0,0 +1,28 @@ +//Example 6.11 +// Stability properties for a conditionally stable system. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +Gs=(s+10)^2/(s^3); +evans(Gs,100) +exec .\fig_settings.sci; //custom script for setting figure properties +zoom_rect([-40 -20 5 20]) +title(["Root locus for","$G(s)=(s+10)^2/s^3$"],'fontsize',3) +h=legend(''); +h.visible = "off" +Gs1=syslin('c',(s+10)^2/(s^3)); +//------------------------------------------------------------------ +//The nyquist plot of the system +figure; +nyquist(7*Gs1,8/2/%pi,100/2/%pi,0.005) +exec .\fig_settings.sci; //custom script for setting figure properties +title(["Nyquist plot for","$G(s)=(s+10)^2/s^3$"],'fontsize',3) +f=gca(); +f.x_location = "origin"; +f.y_location = "origin"; +xset("color",2); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.11/Ex6_11_f0.pdf b/Working_Examples/3432/CH6/EX6.11/Ex6_11_f0.pdf new file mode 100755 index 0000000..68c5877 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.11/Ex6_11_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.11/Ex6_11_f1.pdf b/Working_Examples/3432/CH6/EX6.11/Ex6_11_f1.pdf new file mode 100755 index 0000000..3b27650 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.11/Ex6_11_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.12/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.12/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.12/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.12/Ex6_12.sce b/Working_Examples/3432/CH6/EX6.12/Ex6_12.sce new file mode 100755 index 0000000..ae6ce2f --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.12/Ex6_12.sce @@ -0,0 +1,40 @@ +//Example 6.12 +// Nyquist plot for a system with Multiple Crossover frequencies + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +K=85; +g1=K*(s+1)/(s^2*(s^2+2*s+82)); +g2=(s^2+2*s+43.25)/(s^2+2*s+101); + +Gs=syslin('c',g2*g1); +//------------------------------------------------------------------ +figure; +//The nyquist plot of the system +nyquist(Gs,0.5/2/%pi,100/2/%pi,0.005) +title(["Nyquist plot for the complex system";... +"$G(s)=85(s+1)(s^2+2s+43.25)/[((s^2+2s+82)(s^2+2s+101)]$"],... +'fontsize',3) +exec .\fig_settings.sci; //custom script for setting figure properties +zoom_rect([-2 -1 0.6 1]) +f=gca(); +f.x_location = "origin"; +f.y_location = "origin"; +xset("color",2); +//------------------------------------------------------------------ +//The bode plot of the system +gm=g_margin(Gs); +pm=p_margin(Gs) +disp(pm,"Phase margin",gm,"Gain margin") +figure(1) +bode(Gs,0.01/2/%pi,100/2/%pi,0.01) +title(["Bode plot for";... +"$G(s)=85(s+1)(s^2+2s+43.25)/[((s^2+2s+82)(s^2+2s+101)]$"],... +'fontsize',3) +exec .\fig_settings.sci; //custom script for setting figure properties +//------------------------------------------------------------------ + diff --git a/Working_Examples/3432/CH6/EX6.12/Ex6_12_f0.pdf b/Working_Examples/3432/CH6/EX6.12/Ex6_12_f0.pdf new file mode 100755 index 0000000..2c70787 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.12/Ex6_12_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.12/Ex6_12_f1.pdf b/Working_Examples/3432/CH6/EX6.12/Ex6_12_f1.pdf new file mode 100755 index 0000000..6a37281 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.12/Ex6_12_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.13/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.13/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.13/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.13/Ex6_13.sce b/Working_Examples/3432/CH6/EX6.13/Ex6_13.sce new file mode 100755 index 0000000..3d22214 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.13/Ex6_13.sce @@ -0,0 +1,77 @@ +//Example 6.13 +// Use of simple design criterion for spacecraft attitude control. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +G=1/s^2; +g1=syslin('c',G); + +//The bode plot of the system +zoom_rect([0.01 -20 100 60]) +bode(g1,0.05/2/%pi,2/2/%pi,"rad") +exec .\fig_settings.sci; //custom script for setting figure properties +title('Magnitude of the spacecrafts frequency','fontsize',3) +//------------------------------------------------------------------ + +K=1; +Td=20; +Ds=(Td*s+1); +gd1=syslin('c',K*Ds*G); + +////The bode plot of compnenstaed open loop system +figure +bode(gd1,0.01/2/%pi,1/2/%pi,"rad") +exec .\fig_settings.sci; //custom script for setting figure properties +title('Bode plot for compensated open-loop transfer function'... +,'fontsize',3) +xstring(0.02,70,"-40db/decade",0,0); +xstring(0.2,40,"-20db/decade",0,0); + +//The bode plot of compnenstaed closed loop system +K=0.01; +gc1=K*gd1/(1+K*gd1); +gcl1=syslin('c',gc1); +figure +bode(gcl1,0.01/2/%pi,10/2/%pi,"rad") +title('Closesd loop frequency response','fontsize',3) +exec .\fig_settings.sci; //custom script for setting figure properties + +//Bandwidth +[frq, repf,splitf]=repfreq(gc1,[0.01/2/%pi:0.001:10/2/%pi]); +[db, phi]=dbphi(repf); +w=find(db<=db(1)-3); +wc=w(1); +frqc=frq(wc)*2*%pi; + +plot2d3(frqc,db(wc),5) + +[r c]=size(frq(1:w(1))); +magn=db(wc)*ones(r,c) +plot(frq(1:w(1))*2*%pi,magn,"b--") +temp_db=db(w); +[r c]=size(db(w)); +temp_w=frqc*ones(r,c); +plot(temp_w,temp_db,"b--") +xset("font size", 3); +xstring(0.04,-16,"$\omega_{BW}$"); +xstring(frqc,-4,"-3db"); +xset("line style",4) +xarrows([0.01;frqc],[-10;-10],-0.2,5) +xarrows([frqc;0.01],[-10;-10],-0.2,5) +//------------------------------------------------------------------ +//Step response of PD compnensation +figure +t=0:0.5:100; +v=csim('step',t,gcl1); +plot2d(t,v) + +//Title, labels and grid to the figure +exec .\fig_settings.sci; //custom script for setting figure properties +title('Step response for PD compensation','fontsize',3) +xlabel('Time t (sec.)','fontsize',2) +ylabel('$\theta$','fontsize',2) +//------------------------------------------------------------------- diff --git a/Working_Examples/3432/CH6/EX6.13/Ex6_13_f0.pdf b/Working_Examples/3432/CH6/EX6.13/Ex6_13_f0.pdf new file mode 100755 index 0000000..d57831e Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.13/Ex6_13_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.13/Ex6_13_f3.pdf b/Working_Examples/3432/CH6/EX6.13/Ex6_13_f3.pdf new file mode 100755 index 0000000..42cd3fa Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.13/Ex6_13_f3.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.14/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.14/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.14/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.14/Ex6_14.sce b/Working_Examples/3432/CH6/EX6.14/Ex6_14.sce new file mode 100644 index 0000000..c3b2f0a --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.14/Ex6_14.sce @@ -0,0 +1,8 @@ +//Example 6.14 +//Lead compensation for DC motor. + +// the required value +// for step response, set sw to 2 +// for ramp response, set sw to 0 + +sw = 2 diff --git a/Working_Examples/3432/CH6/EX6.14/Ex6_14_f1.pdf b/Working_Examples/3432/CH6/EX6.14/Ex6_14_f1.pdf new file mode 100755 index 0000000..107b25e Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.14/Ex6_14_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.14/Ex6_14_f2.pdf b/Working_Examples/3432/CH6/EX6.14/Ex6_14_f2.pdf new file mode 100755 index 0000000..69288db Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.14/Ex6_14_f2.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.14/Ex6_14_model.xcos b/Working_Examples/3432/CH6/EX6.14/Ex6_14_model.xcos new file mode 100755 index 0000000..3e29294 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.14/Ex6_14_model.xcos @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Working_Examples/3432/CH6/EX6.15/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.15/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.15/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.15/Ex6_15.sce b/Working_Examples/3432/CH6/EX6.15/Ex6_15.sce new file mode 100755 index 0000000..2a3b9a4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.15/Ex6_15.sce @@ -0,0 +1,78 @@ +//Example 6.15 +//Lead compensation for Temperature Control System. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +numG=1; +denG=(s/0.5+1)*(s+1)*(s/2+1); +sysG=numG/denG; +//Dc gain +K=9; + +KGs=syslin('c',K*sysG); + +//Lead compensator 1 +numD=s+1; +denD=s/3+1; +D1=numD/denD; +D1s=syslin('c',D1); + +KGD1s=D1s*KGs; //compensated system + +//Lead compensator 2 +numD=s/1.5+1; +denD=s/15+1; +D2=numD/denD; +D2s=syslin('c',D2); + +KGD2s=D2s*KGs; //compensated system + +//The bode plot of the system with K +bode([KGs;KGD1s;KGD2s],0.1/2/%pi,10/2/%pi,['KG';'KGD1';'KGD2'],"rad"); +exec .\fig_settings.sci; // custom script for setting figure properties +title('Bode plot for lead compensation design','fontsize',3) +//------------------------------------------------------------------ +//Margins of uncompensated and compensated systems +[gm1,wcg1]=g_margin(KGs); +[pm1,wcp1]=p_margin(KGs); +disp(wcp1*2*%pi,"Wcp",wcg1*2*%pi,"Wcg",pm1,... +"Phase margin",gm1,"Gain margin",... +"Uncompensated system :") + +[gm2,wcg2]=g_margin(KGD1s); +[pm2,wcp2]=p_margin(KGD1s); +disp(wcp2*2*%pi,"Wcp",wcg2*2*%pi,"Wcg",pm2,... +"Phase margin",gm2,"Gain margin",... +"System with D1 compensator :") + +[gm3,wcg3]=g_margin(KGD2s); +[pm3,wcp3]=p_margin(KGD2s); +disp(wcp3*2*%pi,"Wcp",wcg3*2*%pi,"Wcg",pm3,... +"Phase margin",gm3,"Gain margin",... +"System with D2 compensator :") +//------------------------------------------------------------------ +//step response comparison +//closed loop system +Gc1=KGD1s/(KGD1s+1); +Gc2=KGD2s/(KGD2s+1); +figure; +t=0:0.05:20; +v1=csim('step',t,Gc1); +v2=csim('step',t,Gc2); +plot2d([t',t'],[v1',v2']) + +//Title, labels and grid to the figure +exec .\fig_settings.sci; //custom script for setting figure properties +title('Step response for lead compensation design','fontsize',3) +xlabel('Time t (sec.)','fontsize',2) +ylabel('y','fontsize',2) + +xset("font size", 3); +xarrows([2.5;1.5],[1.3;1.2],-1,1) +xstring(2.5,1.3,"D2",0,0) +xstring(4,1.2,"D1",0,0) +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.15/Ex6_15_f0.pdf b/Working_Examples/3432/CH6/EX6.15/Ex6_15_f0.pdf new file mode 100755 index 0000000..1e7a2c4 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.15/Ex6_15_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.15/Ex6_15_f1.pdf b/Working_Examples/3432/CH6/EX6.15/Ex6_15_f1.pdf new file mode 100755 index 0000000..7726e01 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.15/Ex6_15_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.16/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.16/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.16/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.16/Ex6_16.sce b/Working_Examples/3432/CH6/EX6.16/Ex6_16.sce new file mode 100755 index 0000000..a21196a --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.16/Ex6_16.sce @@ -0,0 +1,55 @@ +//Example 6.16 +//Lead compensation for Servomechanism System. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +numG=10; +denG=s*(s/2.5+1)*(s/6+1); +G=numG/denG; +//Dc gain +K=1; + +KGs=syslin('c',K*G); + +//Lead compensator 1 +numD=s/2+1; +denD=s/20+1; +D1=numD/denD; +D1s=syslin('c',D1); + +KGD1s=D1s*KGs; //compensated system + +//Lead compensator 2 +numD=s/4+1; +denD=s/40+1; +D2=D1*numD/denD; //double compensator +D2s=syslin('c',D2); + + +KGD2s=D2s*KGs; //compensated system + +//The bode plot of the system with K +bode([KGs;KGD1s;KGD2s],0.1/2/%pi,100/2/%pi,['KG';'KGD1';'KGD2'],"rad"); +exec .\fig_settings.sci; //custom script for setting figure properties +title('Bode plot for lead compensation design','fontsize',3) +//------------------------------------------------------------------ +//Margins of uncompensated and compensated systems +[gm1,wcg1]=g_margin(KGs); +[pm1,wcp1]=p_margin(KGs); +disp(wcp1*2*%pi,"Wcp",wcg1*2*%pi,"Wcg",pm1,... +"Phase margin",gm1,"Gain margin","Uncompensated system :") + +[gm2,wcg2]=g_margin(KGD1s); +[pm2,wcp2]=p_margin(KGD1s); +disp(wcp2*2*%pi,"Wcp",wcg2*2*%pi,"Wcg",pm2,... +"Phase margin",gm2,"Gain margin","System with D1 compensator :") + +[gm3,wcg3]=g_margin(KGD2s); +[pm3,wcp3]=p_margin(KGD2s); +disp(wcp3*2*%pi,"Wcp",wcg3*2*%pi,"Wcg",pm3,... +"Phase margin",gm3,"Gain margin","System with D2 compensator :") +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.16/Ex6_16_f0.pdf b/Working_Examples/3432/CH6/EX6.16/Ex6_16_f0.pdf new file mode 100755 index 0000000..b236af6 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.16/Ex6_16_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.17/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.17/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.17/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.17/Ex6_17.sce b/Working_Examples/3432/CH6/EX6.17/Ex6_17.sce new file mode 100755 index 0000000..22af946 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.17/Ex6_17.sce @@ -0,0 +1,57 @@ +//Example 6.17 +//Lag compensation for Temperature Control System. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +numG=1; +denG=(s/0.5+1)*(s+1)*(s/2+1); +G=numG/denG; +//Dc gain +K=3; //to set phase requirement + +KGs=syslin('c',K*G); + +//Lag compensator +numD=5*s+1; +denD=15*s+1; +D=3*numD/denD; +Ds=syslin('c',D); + +KGDs=Ds*KGs; //compensated system + +//The bode plot of the system with K +bode([KGs;KGDs],0.01/2/%pi,10/2/%pi,['KG';'KGD'],"rad"); +exec .\fig_settings.sci; //custom script for setting figure properties +title('Frequency response of lag-compensation design','fontsize',3) + +//------------------------------------------------------------------ +//Margins of uncompensated and compensated systems +[gm1,wcg1]=g_margin(KGs); +[pm1,wcp1]=p_margin(KGs); +disp(wcp1*2*%pi,"Wcp",wcg1*2*%pi,"Wcg",pm1,"Phase margin",... +gm1,"Gain margin","Uncompensated system :") + +[gm2,wcg2]=g_margin(KGDs); +[pm2,wcp2]=p_margin(KGDs); +disp(wcp2*2*%pi,"Wcp",wcg2*2*%pi,"Wcg",pm2,"Phase margin",... +gm2,"Gain margin","Compensated system :") + +//------------------------------------------------------------------ +//step response +//closed loop system +Gc=KGDs/(KGDs+1); +figure; +t=0:0.05:20; +v=csim('step',t,Gc); +plot2d(t,v) + +//Title, labels and grid to the figure +exec .\fig_settings.sci; //custom script for setting figure properties +title('Step response for lag compensation design','fontsize',3) +xlabel('Time t (sec.)','fontsize',2) +ylabel('y','fontsize',2) +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.17/Ex6_17_f0.pdf b/Working_Examples/3432/CH6/EX6.17/Ex6_17_f0.pdf new file mode 100755 index 0000000..441cf5b Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.17/Ex6_17_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.17/Ex6_17_f1.pdf b/Working_Examples/3432/CH6/EX6.17/Ex6_17_f1.pdf new file mode 100755 index 0000000..607607c Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.17/Ex6_17_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.18/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.18/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.18/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.18/Ex6_18.sce b/Working_Examples/3432/CH6/EX6.18/Ex6_18.sce new file mode 100755 index 0000000..0ec43ba --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.18/Ex6_18.sce @@ -0,0 +1,42 @@ +//Example 6.18 +//Lag compensation for DC motor. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +g=1/s/(s+1); +K=10; //DC gain +KGs=syslin('c',K*g); + +//Lag compensator +numD=10*s+1; //0.1 +denD=100*s+1; //0.01 +D=numD/denD; +Ds=syslin('c',D); + +KGDs=Ds*KGs; //compensated system + +//The bode plot of the system +bode([KGs;KGDs],0.001/2/%pi,10/2/%pi,['KG(s)';'D(s)G(s)'],"rad"); +exec .\fig_settings.sci; // custom script for setting figure properties +title('Frequency response of lag-compensation design... + of DC motor','fontsize',3) +//------------------------------------------------------------------ +//step response +//closed loop system +Gc=KGDs/(KGDs+1); +figure; +t=0:0.05:50; +v=csim('step',t,Gc); +plot(t,v,2) + +//Title, labels and grid to the figure +exec .\fig_settings.sci; // custom script for setting figure properties +title('Step response for Lag-compensation design... + of DC motor','fontsize',3) +xlabel('Time t (sec.)','fontsize',2) +ylabel('y','fontsize',2) +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.18/Ex6_18_f0.pdf b/Working_Examples/3432/CH6/EX6.18/Ex6_18_f0.pdf new file mode 100755 index 0000000..5f85523 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.18/Ex6_18_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.18/Ex6_18_f1.pdf b/Working_Examples/3432/CH6/EX6.18/Ex6_18_f1.pdf new file mode 100755 index 0000000..e43c621 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.18/Ex6_18_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.19/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.19/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.19/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.19/Ex6_19.sce b/Working_Examples/3432/CH6/EX6.19/Ex6_19.sce new file mode 100755 index 0000000..126f637 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.19/Ex6_19.sce @@ -0,0 +1,74 @@ +//Example 6.19 +//PID compensation design for spacecraft attitude control. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +G1=(0.9/s^2); +G2=(2/(s+2)); +G=G1*G2; +Gs=syslin('c',G); + +// PID controller parameters +Td_inv=0.1; // Td_inv=1/Td=0.1 +Kd=1/Td_inv; //Kd=Td=Td_inv (derivative gain) + +Ti_inv=0.005; // Ti_inv=1/Ti=0.005 +Ki=Ti_inv; //Ki=Ti_inv (integral gain) + +Kp=0.05 //Kp (Proportional gain) + +D=Kp*(Kd*s+1)*(Ki/s+1); //PID Compensator + +Dsc=syslin('c',D); + +Ds=syslin('c',D/Kp); //PID Compensator with Kp=1 +// Compensated system with Kp=1 +GDs=Gs*Ds; +//PID compensated system Kp=0.05; +GDsc=Gs*Dsc; +//------------------------------------------------------------------ +//The bode plots +bode([Gs;GDs;GDsc],0.01/2/%pi,100/2/%pi,... +['G(s)';'D(s)G(s) with (Kp=1)';'D(s)G(s) with (Kp=0.05)'],"rad"); +exec .\fig_settings.sci; //custom script for setting figure properties +title('Compensation for PID design','fontsize',3) + +//Phase margin of pid compensated system with Kp=0.05; +[pm wcp]=p_margin(GDsc); + +//------------------------------------------------------------------ +//closed loop system +//step response +Gc=GDsc/(GDsc+1); +figure; +t=0:0.05:40; +y=csim('step',t,Gc); +plot(t,y,2) + +//Title, labels and grid to the figure +exec .\fig_settings.sci; //custom script for setting figure properties +title('Step response for PID compensation of spacecraft'... +,'fontsize',3) +xlabel('Time t (sec.)','fontsize',2) +ylabel('$theta$','fontsize',2) +//------------------------------------------------------------------ +//step disturbance response +Gc=G1/((G1*G2*D)+1); +Gcs=syslin('c',Gc); +figure; +t=0:0.5:1000; +u=0.1*ones(1,length(t)); +y=csim(u,t,Gcs) +plot(t,y,2) + +//Title, labels and grid to the figure +exec .\fig_settings.sci; // custom script for setting figure properties +title('Step disturbance response for PID compensation... + of spacecraft','fontsize',3) +xlabel('Time t (sec.)','fontsize',2) +ylabel('$theta$','fontsize',2) +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.19/Ex6_19_f0.pdf b/Working_Examples/3432/CH6/EX6.19/Ex6_19_f0.pdf new file mode 100755 index 0000000..f2687e0 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.19/Ex6_19_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.19/Ex6_19_f1.pdf b/Working_Examples/3432/CH6/EX6.19/Ex6_19_f1.pdf new file mode 100755 index 0000000..c4b8b97 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.19/Ex6_19_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.2.b/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.2.b/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.2.b/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.2.b/Ex6_2.sce b/Working_Examples/3432/CH6/EX6.2.b/Ex6_2.sce new file mode 100755 index 0000000..03eae0b --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.2.b/Ex6_2.sce @@ -0,0 +1,28 @@ +//Example 6.2 +//Frequency response characteristics of Lead compensator. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function and its bode plot +K=1, T=1, alpha=0.1 +s=poly(0,'s'); +sysD=syslin('c',K*(T*s+1)/(alpha*T*s+1)); + +//The bode plot of the system + +fmin=0.1/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec) +fmax=100/2/%pi; //maximum frq. in Hz for response (100 read/sec) +//------------------------------------------------------------------ +//Bode plot for frequency in Hz (scilab ver. 5.4.1) +//bode(g,fmin,fmax); +//OR +//Bode plot for frequency in rad/sec (scilab ver. 5.5.1) +bode(sysD,fmin,fmax,"rad") + +//------------------------------------------------------------------ +title('(a) Magnitude and (b) phase for the lead compensator',... +'fontsize',3) +exec .\fig_settings.sci; //custom script for setting figure properties +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.2.b/Ex6_2_f0.pdf b/Working_Examples/3432/CH6/EX6.2.b/Ex6_2_f0.pdf new file mode 100755 index 0000000..827a43a Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.2.b/Ex6_2_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.3/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.3/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.3/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.3/Ex6_3.sce b/Working_Examples/3432/CH6/EX6.3/Ex6_3.sce new file mode 100755 index 0000000..bb49eb0 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.3/Ex6_3.sce @@ -0,0 +1,65 @@ +//Example 6.3 +//Bode Plot for Real Poles and Zeros. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function and its bode plot +K=2000; +s=poly(0,'s'); +Gs=syslin('c',(K*(s+0.5))/(s*(s+10)*(s+50))); + +//The bode plot of the system +wmin=0.1; // mininmum frq. in rad/sec for response +wmax=100; // maximum frq. in red/sec for response +fmin=wmin/2/%pi // mininmum frq. in Hz for response +fmax=wmax/2/%pi // maximum frq. in Hz for response +//------------------------------------------------------------------ +//Bode plot for frequency in Hz (scilab ver. 5.4.1) +//bode(g,fmin,fmax) +//OR +//(Only for scilab ver. 5.5.1) +//Bode (frequency scale in rad/sec) +// or gainplot or phaseplot plot with asymptotes +figure(0) +gainplot(Gs,fmin,fmax); +bode_asymp(Gs,wmin,wmax); +xstring(0.03,22,"slope=-1(-20db/dec)",0,0); +xstring(0.2,9,"slope=0",0,0); +xstring(3,7,"slope=-1(-20db/dec)",0,0) +xstring(0.9,-8,"slope=-2(-40db/dec)",0,0) +title('Composit plots (a) magnitude plot','fontsize',3); +h=legend(''); +exec .\fig_settings.sci; //custom script for setting figure properties +h.visible = "off" +//------------------------------------------------------------------ + +//phase plot for poles and zeros +zr=((s/0.5)+1)/s //infact this is zero and pole at origin. +zr=syslin('c', zr); +pl1=1/((s/10)+1) +pl1=syslin('c', pl1); +pl2=1/((s/50)+1) +pl2=syslin('c', pl2); +figure(1) +phaseplot([Gs;zr;pl1;pl2],fmin,fmax); +xstring(5.5,-14,"$\frac {1}{s/0.5+1}$",0,0); +xstring(2.8,-22,"$\frac{1}{s/50+1}$",0,0); +xstring(2.5,-60,"$\frac{1}{s/10+1}$",0,0); +xstring(1.2,-100,["Composite";"(Actual)"],0,0); +title('Composit plots (b) Phase','fontsize',3); +exec .\fig_settings.sci; //custom script for setting figure properties + +//------------------------------------------------------------------ +figure(2) +bode(Gs,fmin,fmax,"rad"); //frequency scale n radians +bode_asymp(Gs,wmin,wmax); +exec .\fig_settings.sci; //custom script for setting figure properties +title('(c) magnitude plot and phase plot approximate and actual... +','fontsize',3) +xstring(2.8,-22,"$\frac{1}{s/50+1}$",0,0); +h=legend(''); +h.visible = "off" + +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.3/Ex6_3_f0.pdf b/Working_Examples/3432/CH6/EX6.3/Ex6_3_f0.pdf new file mode 100755 index 0000000..f344048 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.3/Ex6_3_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.3/Ex6_3_f1.pdf b/Working_Examples/3432/CH6/EX6.3/Ex6_3_f1.pdf new file mode 100755 index 0000000..fa0837d Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.3/Ex6_3_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.4/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.4/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.4/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.4/Ex6_4.sce b/Working_Examples/3432/CH6/EX6.4/Ex6_4.sce new file mode 100755 index 0000000..6e1124a --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.4/Ex6_4.sce @@ -0,0 +1,28 @@ +//Example 6.4 +//Bode Plot with Complex Poles. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function and its bode plot +K=10; +s=poly(0,'s'); +Gs=syslin('c',(K)/(s*(s^2+0.4*s+4))); +//The bode plot of the system + +fmin=0.1/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec) +fmax=10/2/%pi; //maximum frq. in Hz for response (100 read/sec) +//------------------------------------------------------------------ +//Bode plot for frequency in Hz (scilab ver. 5.4.1) +//bode(g,fmin,fmax); +//OR +//Bode plot for frequency in rad/sec (scilab ver. 5.5.1) +bode(Gs,fmin,fmax,0.01,"rad") + +//------------------------------------------------------------------ +title(['Bode plot for a transfer function with complex poles';... + '(a) magnitude... + (b) phase'],'fontsize',3) + +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.4/Ex6_4_f0.pdf b/Working_Examples/3432/CH6/EX6.4/Ex6_4_f0.pdf new file mode 100755 index 0000000..58d9414 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.4/Ex6_4_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.6/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.6/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.6/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.6/Ex6_6.sce b/Working_Examples/3432/CH6/EX6.6/Ex6_6.sce new file mode 100755 index 0000000..a70ab9c --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.6/Ex6_6.sce @@ -0,0 +1,30 @@ +//Example 6.6 +//Bode Plot for Complex Poles and Zeros: +//Satellite with Flexible appendages. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function and its bode plot +K=0.01; +s=poly(0,'s'); +NumG=K*(s^2+0.01*s+1); +DenG=s^2*((s^2/4)+0.02*(s/2)+1) +sysG=syslin('c',NumG/DenG); + +fmin=0.09/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec) +fmax=11/2/%pi; //maximum frq. in Hz for response (100 read/sec) +//------------------------------------------------------------------ +//Bode plot for frequency in Hz (scilab ver. 5.4.1) +//bode(g,fmin,fmax); +//OR +//Bode plot for frequency in rad/sec (scilab ver. 5.5.1) +bode(sysG,fmin,fmax,0.01,"rad") + +//------------------------------------------------------------------ +title(["Bode plot for a transfer function with complex... +poles and zeros"; "(a) magnitude (b) phase"],'fontsize',3) +//------------------------------------------------------------------ + +disp('NOTE : Result of the above example can be verified by checking the figures shown in example 6.5') diff --git a/Working_Examples/3432/CH6/EX6.6/Ex6_6_f0.pdf b/Working_Examples/3432/CH6/EX6.6/Ex6_6_f0.pdf new file mode 100755 index 0000000..9e2dc15 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.6/Ex6_6_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.7/EX6_7_f0.pdf b/Working_Examples/3432/CH6/EX6.7/EX6_7_f0.pdf new file mode 100755 index 0000000..9e46a12 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.7/EX6_7_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.7/Ex6_7.sce b/Working_Examples/3432/CH6/EX6.7/Ex6_7.sce new file mode 100755 index 0000000..0ea6d5b --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.7/Ex6_7.sce @@ -0,0 +1,44 @@ +//Example 6.7 +//Computation of velocity error constant Kv from Bode plot + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function and its bode plot +K=10; +s=poly(0,'s'); +Gs=syslin('c',(K)/(s*(s+1))); +//The bode plot of the system + +fmin=0.01/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec) +fmax=10/2/%pi; //maximum frq. in Hz for response (100 read/sec) +//------------------------------------------------------------------ +//Bode plot for frequency in Hz (scilab ver. 5.4.1) +//bode(g,fmin,fmax); +//OR +//Bode plot for frequency in rad/sec (scilab ver. 5.5.1) +bode(Gs,fmin,fmax,0.01,"rad") +title(['Determination of Kv from the Bode plot for the system',... +'$10/[s(s+1)]$'],'fontsize',3) +//choose frequency (rad) and magnitude from bode plot and calculate Kv +//Here at w=0.01, magngitude in db is M=60 +//i.e actual magnitude of the reponse is |A|=10^(M/20) +w=0.01; // in rad +M=60 // in db +A=10^(M/20) //actual gain + +//Velocity error constant Kv=w*|A(w)| +Kv=w*A; +disp(Kv,"The Velocity error Constant from bode plot is: ") +//------------------------------------------------------------------ +// Computation of the Kv +[frq repf]=repfreq(Gs,fmin,fmax); +//frq in Hz, repf is freq. response in rectangular form. +//From bode plot, Kv=w*|A(w)| +//i.e Kv=2*pi*f*|A(2*pi*f)| + +idx=1;//selecting the frequency and response at that frequency from arrays +Kv=2*%pi*frq(idx)*abs(repf(idx)) +disp(Kv,"The Velocity error Constant is computed at 0.0015915 Hz (0.01 rad/sec) : ") +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.8/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.8/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.8/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.8/Ex6_8.sce b/Working_Examples/3432/CH6/EX6.8/Ex6_8.sce new file mode 100755 index 0000000..6625052 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.8/Ex6_8.sce @@ -0,0 +1,48 @@ +//Example 6.8 +// Nyquist plot for a second order system. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function and its root locus +s=poly(0,'s'); +g=1/(s+1)^2; +sysG=syslin('c',g); + +evans(sysG); +exec .\fig_settings.sci; //custom script for setting figure properties +f=gca(); +f.x_location = "origin" +f.y_location = "origin" +title(['Root locus of','$G(s)=1/(s+1)^2$','with respect to K'],... +'fontsize',3) +zoom_rect([-3,-2,2,3]) +h=legend(''); +h.visible = "off" +//------------------------------------------------------------------ +figure(1) +//The bode plot of the system +fmin=0.01/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec) +fmax=100/2/%pi; //maximum frq. in Hz for response (100 read/sec) + +//Bode plot for frequency in Hz (scilab ver. 5.4.1) +//bode(g,fmin,fmax); +//OR +//Bode plot for frequency in rad/sec (scilab ver. 5.5.1) +bode(sysG,fmin,fmax,0.01,"rad") +title(['Open loop bode plot for', '$G(s)=1/(s+1)^2$'],'fontsize',3); +exec .\fig_settings.sci; //custom script for setting figure properties +//------------------------------------------------------------------ + +figure(2) +//The nyquist plot of the system +nyquist(sysG); +title('Nyquist plot of the evaluation of K G(s) for s=C1 and K=1'... +,'fontsize',3); +exec .\fig_settings.sci; //custom script for setting figure properties +f=gca(); +f.x_location = "origin" +f.y_location = "origin" +xset('color',2) +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.8/Ex6_8_f0.pdf b/Working_Examples/3432/CH6/EX6.8/Ex6_8_f0.pdf new file mode 100755 index 0000000..2bb5cdb Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.8/Ex6_8_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.8/Ex6_8_f1.pdf b/Working_Examples/3432/CH6/EX6.8/Ex6_8_f1.pdf new file mode 100755 index 0000000..690c6b5 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.8/Ex6_8_f1.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.9/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH6/EX6.9/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.9/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.9/Ex6_9.sce b/Working_Examples/3432/CH6/EX6.9/Ex6_9.sce new file mode 100755 index 0000000..a66b127 --- /dev/null +++ b/Working_Examples/3432/CH6/EX6.9/Ex6_9.sce @@ -0,0 +1,53 @@ +//Example 6.9 +// Nyquist plot for a third order system. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//System transfer function +s=poly(0,'s'); +g=syslin('c',1/(s*(s+1)^2)); + +//The bode plot of the system +fmin=0.01/2/%pi; +fmax=100/2/%pi; +//[frq,repf]=repfreq(g1,fmin,fmax,0.01); +bode(g,fmin,fmax,"rad"); +frq=[1,10]/2/%pi; +[frq, repf]=repfreq(g,frq); +[db, phi]=dbphi(repf); +plot(frq*2*%pi,db,'ro'); +exec .\fig_settings.sci; //custom script for setting figure properties +title(["Bode plot for","$G(s)=1/[s(s+1)^2]$"],'fontsize',3) +//zoom_rect([[0.1 0] -70 [12 -180] 20]) +xset("font size", 3); + +xstring(1,0,"$C\,\, (\omega=1)$",0,0); +xstring(2,-75,"$E\,\, (\omega=10)$",0,0); +f=gca(); + +//------------------------------------------------------------------ +//The nyquist plot of the system +figure; +nyquist(g,0.8/2/%pi,10/2/%pi,0.02) + +exec .\fig_settings.sci; //custom script for setting figure properties +title(["Nyquist plot for","$G(s)=1/[s(s+1)]^2$"],'fontsize',3) +f=gca(); +f.x_location = "origin"; +f.y_location = "origin"; +zoom_rect([-1 -0.2 0.5 0.2]); +xset("clipping", -1.2, 0.2, 1.4,0.4); +xset("font size", 3); +xset("color",2); +xstring(-0.6,0.1,"${\fgcolor{blue}{\omega<0}}$",0,0); +xstring(-0.6,-0.1,"${\fgcolor{blue}{\omega>0}}$",0,0); +xstring(-0.7,0.005,"${\fgcolor{blue}{\omega=\pm 1}}$",0,0); +xstring(-1,-0.2,... +"${\fgcolor{blue}{\text{From \infty at \omega=0^+}}$",0,0); + xstring(-0.7,0.15,"${\fgcolor{blue}... + {\text{Towards \infty at \omega=0^-}}$",0,0); +xstring(-0.525,-0.04,"C",0,0); +xstring(-0.075,0,"E",0,0); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH6/EX6.9/Ex6_9_f0.pdf b/Working_Examples/3432/CH6/EX6.9/Ex6_9_f0.pdf new file mode 100755 index 0000000..0717e6c Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.9/Ex6_9_f0.pdf differ diff --git a/Working_Examples/3432/CH6/EX6.9/Ex6_9_f1.pdf b/Working_Examples/3432/CH6/EX6.9/Ex6_9_f1.pdf new file mode 100755 index 0000000..482ef93 Binary files /dev/null and b/Working_Examples/3432/CH6/EX6.9/Ex6_9_f1.pdf differ -- cgit