diff options
Diffstat (limited to '3432/CH4/EX4.8')
-rw-r--r-- | 3432/CH4/EX4.8/Ex4_8.sce | 150 | ||||
-rw-r--r-- | 3432/CH4/EX4.8/Ex4_8_f0.pdf | bin | 0 -> 44186 bytes | |||
-rw-r--r-- | 3432/CH4/EX4.8/Ex4_8_f1.pdf | bin | 0 -> 38691 bytes |
3 files changed, 150 insertions, 0 deletions
diff --git a/3432/CH4/EX4.8/Ex4_8.sce b/3432/CH4/EX4.8/Ex4_8.sce new file mode 100644 index 000000000..5f5e37109 --- /dev/null +++ b/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/3432/CH4/EX4.8/Ex4_8_f0.pdf b/3432/CH4/EX4.8/Ex4_8_f0.pdf Binary files differnew file mode 100644 index 000000000..dbe4cf6bd --- /dev/null +++ b/3432/CH4/EX4.8/Ex4_8_f0.pdf diff --git a/3432/CH4/EX4.8/Ex4_8_f1.pdf b/3432/CH4/EX4.8/Ex4_8_f1.pdf Binary files differnew file mode 100644 index 000000000..63a7f87d4 --- /dev/null +++ b/3432/CH4/EX4.8/Ex4_8_f1.pdf |