M-file:
% File Name: example5.m % Description: Matlab m-file supporting design of DC motor % position control. % % clear matlab memory and close all figures clear all; close all; % define motor transfer function, G L = 1e-3; R = 1; J = 5e-5; B = 1e-4; Ke = 0.1; Kt = 0.1; numG = [Kt/(L*J)]; denG = [1 (R/L + B/J) (R*B + Ke*Kt)/(L*J) 0]; G = tf(numG, denG); % P-control numD = [1]; denD = [1]; D = tf(numD, denD); subplot(2,2,1); rlocus(series(D,G)); title('P-Control'); sgrid(0.69, [180, 500, 1000]); [kp, p] = rlocfind(series(D,G)); cltf = feedback(series(kp*D,G), [1], -1); subplot(2,2,2); step(cltf); title(['P-Control w/k_P = ', num2str(kp)]); % PD-control numD = [1 502]; denD = [1]; D = tf(numD, denD); subplot(2,2,3); rlocus(series(D,G)); title('P-Control'); sgrid(0.69, [180, 500, 1000]); [kd, p] = rlocfind(series(D,G)); cltf = feedback(series(kd*D,G), [1], -1); subplot(2,2,4); step(cltf); title(['P-Control w/k_D = ', num2str(kd), 'k_P = ', num2str(502*kd)]);
Root-Locus, Selected Poles, and Resulting Step Responses Generated: