About PDServo
Author: John Bratcher This is a FREE user program for the Matrix Calculator MtrxCal. Search Handango for MtrxCal for more information about MtrxCal. PD Servo PD Servo is a linear math model of a proportional/psuedo derivative control system. This means that the feed forward compensation is proportional and the feedback compensation is both proportional and differential. This is most common in electric motor servos with tachometer as well as potentiometer feedback. This model, being linear, applies mostly to small signal stability analysis. Large command inputs will usually saturate current limits, which would greatly affect overall performance. Also, non linearity's such as coulombic and static friction as well as backlash are not included, which can also significantly influence performance. This program is useful as a first cut design/analysis of a servo system, which will later be enhanced with nonlinear simulation/analysis. To use PD Servo first initialize all the physical parameters taking care to use consistent units. I edit the file using the edit option of the main keys of MtrxCal. Then define the period and frequency ranges and their increments. This will most likely take several iterations to get the best combination. Then switch to matrix keys and execute the program. If all parameters are properly defined, a graph of the gain will appear. Tap the screen and the phase plot will appear. Tap again and the step response will be plotted. Finally, after another tap, a list of computed performance parameters will appear such as the natural frequency, resonance frequency, damping ratio, time constant and settling time. Note: the parameter definitions are not present in the executed program.They are only included here for definition. I've used metric units for consistency, but English units could also be used provided appropriate conversion factors are included.The script below was used to generate the screenshot.We encourage you to copy and past the script into matlab to check compatibility. kin=1; %input gain (outside closed loop)
kp=500; %feed forward proportional gain
kt=.01; %motor torque constant [NM/Amp]
kbemf=.01; %motor back emf constant [V-sec]
rm=1; %motor winding resistance [Ohms]
kfb=1; %proportional feedback gain
kd=.1; %feeback rate (derivative) gain
jm=10^-6; %motor rotor moments of inertia [NM-sec^2]
jf=.01; %load moments of inertia [NM-sec^2]
kdm=10^-6; %motor rate damping coefficient [NM-sec]
kdf=.1; %load rate damping coefficient [NM-sec]
n=150; %motor to load gear ratio
t0=0; %plot start time [sec]
tf=2; %plot stop time [sec]
ti=.02; %plot time increment [sec]
f0=-1; %plot start frequency exponent, 10^f0 [Hz]
ff=2; %plot stop frequency exponent, 10^ff [Hz]
fn=100; %number of logarithmically spaced points from f0 to ff
f=logspace(f0,ff,fn);
w=1j*2*pi.*f;
t=[t0:ti:tf];
kdfe=kdf+n^2*kdm;
jfe=jf+n^2*jm;
k1=kin*kp*kt/(jfe*rm);
k2=kdfe/jfe+n*kbemf*kt/(jfe*rm)+kd/jfe;
k3=kfb*kp*kt/(jfe*rm);
wn=sqrt(k3);
damp=k2/(2*wn)
fn=wn/(2*pi)
del=sqrt(1-damp^2);
fr=fn*del
tau=1/(damp*wn)
ts=4*tau
g=k1./(w.^2+k2*w+k3);
semilogx(f,20*log10(abs(g)));
title('Freq Resp: Magnitude')
xlabel('Frequency Hz')
ylabel('Mag dB')
pause;
clf
semilogx(f,angle(g)*57.3);
title('Freq Resp: Phase')
xlabel('Frequency Hz')
ylabel('Phase degs')
pause;
clf
pos=1-exp(-damp*wn.*t)./del.*sin(wn*del.*t+atan(del/damp));
plot(t,pos);
title('Step Response')
xlabel('time sec')
ylabel('position degs')


