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/CH8/EX8.1/DEPENDENCIES/fig_settings.sci | 9 ++++ Working_Examples/3432/CH8/EX8.1/Ex8_1.sce | 56 +++++++++++++++++++++ Working_Examples/3432/CH8/EX8.1/Ex8_1_f0.pdf | Bin 0 -> 27021 bytes Working_Examples/3432/CH8/EX8.1/Ex8_1_f1.pdf | Bin 0 -> 28141 bytes Working_Examples/3432/CH8/EX8.1/Ex8_1_model.xcos | 1 + 5 files changed, 66 insertions(+) create mode 100755 Working_Examples/3432/CH8/EX8.1/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH8/EX8.1/Ex8_1.sce create mode 100755 Working_Examples/3432/CH8/EX8.1/Ex8_1_f0.pdf create mode 100755 Working_Examples/3432/CH8/EX8.1/Ex8_1_f1.pdf create mode 100755 Working_Examples/3432/CH8/EX8.1/Ex8_1_model.xcos (limited to 'Working_Examples/3432/CH8/EX8.1') diff --git a/Working_Examples/3432/CH8/EX8.1/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH8/EX8.1/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH8/EX8.1/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/CH8/EX8.1/Ex8_1.sce b/Working_Examples/3432/CH8/EX8.1/Ex8_1.sce new file mode 100755 index 0000000..015f648 --- /dev/null +++ b/Working_Examples/3432/CH8/EX8.1/Ex8_1.sce @@ -0,0 +1,56 @@ +///Example 8.1 +// Digital Controller using tustin approximation. + +xdel(winsid())//close all graphics Windows +clear; +clc; +//------------------------------------------------------------------ +//Cntroller +s=poly(0,'s'); +numD=s/2+1; +denD=s/10+1; +D=10*numD/denD; +Ds=syslin('c',D); +//sampling freq. = 25 times bandwidth +Wbw=10; +Ws=25*Wbw; +fs=Ws/2/%pi; +T=1/fs; //sampling time +a=1;b=-1; +c=1;d=1; +//Digital controller +z=poly(0,'z'); +Dz=horner(Ds,2/T*(a*z+b)/(c*z+d)); +disp(Dz,'Digital Controller : ') + +//------------------------------------------------------------------ +//step response and control efforts. +figure(0); +importXcosDiagram(".\Ex8_1_model.xcos") + //The diagram data structure +xcos_simulate(scs_m,4); +scs_m.props.context +plot(yt.time,yt.values(:,1),'r--') +plot(yt.time,yt.values(:,2),2) + +xlabel('Time (sec.)'); +ylabel('Position, y'); +title(["Comparison between digital and continuous controller step... + response";"with a sample rate 25 times bandwidth";"(a) Position "],... + 'fontsize',3); +exec .\fig_settings.sci; // custom script for setting figure properties + +//control effort + +figure(1); +plot(ut.time,ut.values(:,1),'r--') +plot2d2(ut.time,ut.values(:,2),2) + +xlabel('Time (sec.)'); +ylabel('Control, u'); +title(["Comparison between digital and continuous controller step... + response";"with a sample rate 25 times bandwidth";"(b) Control "],... + 'fontsize',3); +exec .\fig_settings.sci; // custom script for setting figure properties +//------------------------------------------------------------------ + diff --git a/Working_Examples/3432/CH8/EX8.1/Ex8_1_f0.pdf b/Working_Examples/3432/CH8/EX8.1/Ex8_1_f0.pdf new file mode 100755 index 0000000..18b8139 Binary files /dev/null and b/Working_Examples/3432/CH8/EX8.1/Ex8_1_f0.pdf differ diff --git a/Working_Examples/3432/CH8/EX8.1/Ex8_1_f1.pdf b/Working_Examples/3432/CH8/EX8.1/Ex8_1_f1.pdf new file mode 100755 index 0000000..ab9cb8c Binary files /dev/null and b/Working_Examples/3432/CH8/EX8.1/Ex8_1_f1.pdf differ diff --git a/Working_Examples/3432/CH8/EX8.1/Ex8_1_model.xcos b/Working_Examples/3432/CH8/EX8.1/Ex8_1_model.xcos new file mode 100755 index 0000000..ece7753 --- /dev/null +++ b/Working_Examples/3432/CH8/EX8.1/Ex8_1_model.xcos @@ -0,0 +1 @@ + \ No newline at end of file -- cgit