summaryrefslogtreecommitdiff
path: root/Working_Examples/3432/CH4/EX4.8
diff options
context:
space:
mode:
Diffstat (limited to 'Working_Examples/3432/CH4/EX4.8')
-rwxr-xr-xWorking_Examples/3432/CH4/EX4.8/DEPENDENCIES/fig_settings.sci9
-rwxr-xr-xWorking_Examples/3432/CH4/EX4.8/Ex4_8.sce150
-rwxr-xr-xWorking_Examples/3432/CH4/EX4.8/Ex4_8_f0.pdfbin0 -> 44186 bytes
-rwxr-xr-xWorking_Examples/3432/CH4/EX4.8/Ex4_8_f1.pdfbin0 -> 38691 bytes
4 files changed, 159 insertions, 0 deletions
diff --git a/Working_Examples/3432/CH4/EX4.8/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH4/EX4.8/DEPENDENCIES/fig_settings.sci
new file mode 100755
index 0000000..5d5e7d4
--- /dev/null
+++ b/Working_Examples/3432/CH4/EX4.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/CH4/EX4.8/Ex4_8.sce b/Working_Examples/3432/CH4/EX4.8/Ex4_8.sce
new file mode 100755
index 0000000..5f5e371
--- /dev/null
+++ b/Working_Examples/3432/CH4/EX4.8/Ex4_8.sce
@@ -0,0 +1,150 @@
+//Example 4.8
+//Equivalent discrete controller for DC motor speed control.
+//------------------------------------------------------------------
+//NOTE THAT-- The system response (continuous) to sampled control
+//input depends on
+//the sampling time set for continuous signal in SIMULATION.
+//In this example we consider sampling period of 0.009 sec
+//to represent continuous time signal.
+//------------------------------------------------------------------
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+// Continuous time system and controller
+// System transfer function
+s=%s;
+num=[45 0];
+den=[45 14 1]
+Nms=poly(num,'s','coeff');
+Dns=poly(den,'s','coeff');
+Gp=syslin('c',Nms/Dns); //system transfer function
+
+// Controller
+
+numDa=[6 1];
+denDa=[0 1]
+Nms=poly(numDa,'s','coeff');
+Dns=poly(denDa,'s','coeff');
+sysD=syslin('c',1.4*Nms/Dns); //controller transfer function
+
+//Closed loop responses
+
+num=[1 0];
+den=[1 0];
+Nms=poly(num,'s','coeff');
+Dns=poly(den,'s','coeff');
+H=syslin('c',Nms/Dns)
+
+sysDa=Gp*sysD/.H;
+
+//step response and control input
+t=0:0.009:5;
+yt=csim('step',t,sysDa); //step response
+figure(0)
+plot2d(t,yt,1)
+Gu=sysD/(1+Gp*sysD);
+ut=csim('step',t,Gu); //control input
+figure(1)
+plot2d(t,ut,1)
+//------------------------------------------------------------------
+
+sys=tf2ss(Gp); //state space model of the system
+con=tf2ss(sysD); //controller state space model
+
+// discrete-time time system and controller
+
+//Discretize the system and control with sampling time Ts=0.07
+// using Bilinear Transform
+Ts=0.07;
+sysDd=cls2dls(sys,Ts); // discrete-time system state space model
+conDd=cls2dls(con,Ts); // discrete-time controller state space model
+
+//Pulse transfer function of system
+Gpz=ss2tf(sysDd);
+//Pulse transfer function of controller
+Gcz=ss2tf(conDd);
+//Closed loop response
+Gz=Gpz*Gcz/(1+Gpz*Gcz)
+//Control input pulse transfer function
+Guz=Gcz/(1+Gpz*Gcz)
+T=0:Ts:5;
+r=ones(1,length(T));
+yd=flts(r,Gz);............//Discrete respnse to discrete input
+ud=flts(r,Guz); //Discrete Control input
+//continuous response for digital input
+t=0:0.009:5;
+k=0;
+
+for i=1:length(yd)
+ for j=1:8
+ if (k+j)>length(t) then
+ break
+ else
+ YD(1,k+j)=yd(i);
+ end
+ end
+ k=k+j;
+end
+
+yt=csim(1-YD,t,Gp*sysD);
+scf(0)
+plot2d(t,yt,5);
+scf(1)
+plot2d2(T,ud,5);
+//------------------------------------------------------------------
+//Discretize the system and control with sampling time Ts=0.035
+// using Bilinear Transform
+Ts=0.035;
+sysDd=cls2dls(sys,Ts); // discrete-time system state space model
+conDd=cls2dls(con,Ts); // discrete-time controller state space model
+
+Gpz=ss2tf(sysDd); //Pulse transfer function of system
+Gcz=ss2tf(conDd); //Pulse transfer function of controller
+
+//Closed loop response
+Gz=Gpz*Gcz/(1+Gpz*Gcz)
+//Control input pulse transfer function
+Guz=Gcz/(1+Gpz*Gcz)
+T=0:Ts:5;
+r=ones(1,length(T));
+yd=flts(r,Gz);............//Discrete respnse to discrete input
+ud=flts(r,Guz); //Discrete Control input
+t=0:0.009:5;
+k=0;
+
+for i=1:length(yd)
+ for j=1:4
+ if (k+j)>length(t) then
+ break
+ else
+ YD(1,k+j)=yd(i);
+ end
+ end
+ k=k+j;
+end
+
+yt=csim(1-YD,t,Gp*sysD);
+scf(0)
+plot2d(t,yt,2);
+scf(1)
+plot2d2(T,ud,2);
+
+scf(0)
+//Title, labels and grid to the figure
+exec .\fig_settings.sci; //custom script to set the figure properties
+title('Comparision plots of Speed-control system with continuous...
+ and discrete controllers','fontsize',3)
+xlabel('Time t (sec.)','fontsize',2)
+hl=legend(['Continuous time','Discrete-time, Ts=0.07 s'...
+,'Discrete-time, Ts=0.035 s'],4);
+scf(1)
+//Title, labels and grid to the figure
+exec .\fig_settings.sci; //custom script to set the figure properties
+title('Comparision plots of Speed-control system with continuous...
+ and discrete controllers','fontsize',3)
+xlabel('Time t (sec.)','fontsize',2)
+hl=legend(['Continuous time','Discrete-time, Ts=0.07 s',...
+'Discrete-time, Ts=0.035 s']);
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH4/EX4.8/Ex4_8_f0.pdf b/Working_Examples/3432/CH4/EX4.8/Ex4_8_f0.pdf
new file mode 100755
index 0000000..dbe4cf6
--- /dev/null
+++ b/Working_Examples/3432/CH4/EX4.8/Ex4_8_f0.pdf
Binary files differ
diff --git a/Working_Examples/3432/CH4/EX4.8/Ex4_8_f1.pdf b/Working_Examples/3432/CH4/EX4.8/Ex4_8_f1.pdf
new file mode 100755
index 0000000..63a7f87
--- /dev/null
+++ b/Working_Examples/3432/CH4/EX4.8/Ex4_8_f1.pdf
Binary files differ