Physical setup and system equations Photo courtesy: Pope Electric Motors Pty imited ! common actuator in control systems is the DC motor" It directly pro#ides rotary motion and$ coupled %ith %heels or drums and ca&les$ can pro#ide transitional motion" 'he electric circuit o( the armature and the (ree &ody diagram o( the rotor are sho%n in the (ollo%ing (igure: )or this example$ %e %ill assume the (ollo%ing #alues (or the physical parameters" 'hese #alues %ere deri#ed &y experiment (rom an actual motor in Carnegie Mellon*s undergraduate controls la&" + moment o( inertia o( the rotor ,-. / 0"01 kg"m234s23 + damping ratio o( the mechanical system ,&. / 0"1 5ms + electromoti#e (orce constant ,6/6e/6t. / 0"01 5m4!mp + electric resistance ,7. / 1 ohm + electric inductance ,. / 0"8 9 + input ,:.: Source :oltage + output ,theta.: position o( sha(t + 'he rotor and sha(t are assumed to &e rigid 'he motor torque$ T$ is related to the armature current$ i$ &y a constant (actor Kt" 'he &ack em($ e$ is related to the rotational #elocity &y the (ollo%ing equations: In SI units ,%hich %e %ill use.$ Kt ,armature constant. is equal to Ke ,motor constant." )rom the (igure a&o#e %e can %rite the (ollo%ing equations &ased on 5e%ton*s la% com&ined %ith 6irchho((*s la%: 1. Transfer Function ;sing aplace 'rans(orms$ the a&o#e modeling equations can &e expressed in terms o( s" By eliminating I,s. %e can get the (ollo%ing open<loop trans(er (unction$ %here the rotational speed is the output and the #oltage is the input" 2. State-Space In the state<space (orm$ the equations a&o#e can &e expressed &y choosing the rotational speed and electric current as the state #aria&les and the #oltage as an input" 'he output is chosen to &e the rotational speed" Design requirements )irst$ our uncompensated motor can only rotate at 0"1 rad4sec %ith an input #oltage o( 1 :olt ,this %ill &e demonstrated later %hen the open<loop response is simulated." Since the most &asic requirement o( a motor is that it should rotate at the desired speed$ the steady< state error o( the motor speed should &e less than 1=" 'he other per(ormance requirement is that the motor must accelerate to its steady<state speed as soon as it turns on" In this case$ %e %ant it to ha#e a settling time o( 3 seconds" Since a speed (aster than the re(erence may damage the equipment$ %e %ant to ha#e an o#ershoot o( less than 8=" I( %e simulate the re(erence input ,r. &y an unit step input$ then the motor speed output should ha#e: Settling time less than 3 seconds >#ershoot less than 8= Steady<state error less than 1= Matlab representation and open-loop response 1. Transfer Function We can represent the a&o#e trans(er (unction into Matla& &y de(ining the numerator and denominator matrices as (ollo%s: Create a ne% m<(ile and enter the (ollo%ing commands: J=0.01; b=0.1; K=0.01; R=1; L=0.5; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; 5o% let*s see ho% the original open<loop system per(orms" !dd the (ollo%ing commands onto the end o( the m<(ile and run it in the Matla& command %indo%: step(num,den,0:0.1:3) tt!e("#tep Resp$nse %$& t'e (pen L$$p #)stem") ?ou should get the (ollo%ing plot: )rom the plot %e see that %hen 1 #olt is applied to the system$ the motor can only achie#e a maximum speed o( 0"1 rad4sec$ ten times smaller than our desired speed" !lso$ it takes the motor @ seconds to reach its steady<state speedA this does not satis(y our 3 seconds settling time criterion" 2. State-Space We can also represent the system using the state<space equations" 'ry the (ollo%ing commands in a ne% m<(ile" J=0.01; b=0.1; K=0.01; R=1; L=0.5; *=[+b,J K,J +K,L +R,L]; -=[0 1,L]; .=[1 0]; /=0; step(*, -, ., /) Example: PID Design Method (or DC Motor Speed Control Proportional control PID control 'uning the gains )rom the main pro&lem$ the dynamic equations and the open<loop trans(er (unction o( the DC Motor are: and the system schematic looks like: t )or the original pro&lem setup and the deri#ation o( the a&o#e equations$ please re(er to the Modeling a DC Motor page" With a 1 rad4sec step input$ the design criteria are: Settling time less than 3 seconds >#ershoot less than 8= Steady<stage error less than 1= 5o% let*s design a PID controller and add it into the system" )irst create a ne% m<(ile and type in the (ollo%ing commands ,re(er to the Modeling page (or the details o( getting these commands." J=0.01; b=0.1; K=0.01; R=1; L=0.5; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; 7ecall that the trans(er (unction (or a PID controller is: Proportional control et*s (irst try using a proportional controller %ith a gain o( 100" !dd the (ollo%ing code to the end o( your m<(ile: Kp=100; num0=Kp*num; den0=den; 'o determine the closed<loop trans(er (unction$ %e use the cloop command" !dd the (ollo%ing line to your m<(ile: [num01,den01]=1!$$p(num0,den0); 5ote that num01 and den01 are the numerator and the denominator o( the o#erall closed< loop trans(er (unction" 5o% let*s see ho% the step response looks$ add the (ollo%ing to the end o( your m<(ile$ and run it in the command %indo%: t=0:0.01:5; step(num01,den01,t) tt!e("#tep &esp$nse 2t' 3&$p$&t$n .$nt&$!") ?ou should get the (ollo%ing plot: PID control )rom the plot a&o#e %e see that &oth the steady<state error and the o#ershoot are too large" 7ecall (rom the PID tutorial page that adding an integral term %ill eliminate the steady<state error and a deri#ati#e term %ill reduce the o#ershoot" et*s try a PID controller %ith small 6i and 6d" Change your m<(ile so it looks like the (ollo%ing" 7unning this ne% m<(ile gi#es you the (ollo%ing plot" J=0.01; b=0.1; K=0.01; R=1; L=0.5; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; Kp=100; K=1; Kd=1; num1=[Kd, Kp, K]; den1=[1 0]; num0=1$n4(num,num1); den0=1$n4(den,den1); [num01,den01]=1!$$p(num0,den0); step(num01,den01) tt!e("35/ .$nt&$! 2t' sm0!! K 0nd Kd") Tuning te gains 5o% the settling time is too long" et*s increase 6i to reduce the settling time" Bo &ack to your m<(ile and change 6i to 300" 7erun the (ile and you should get the plot like this: 5o% %e see that the response is much (aster than &e(ore$ &ut the large 6i has %orsened the transient response ,&ig o#ershoot." et*s increase 6d to reduce the o#ershoot" Bo &ack to the m<(ile and change 6d to 10" 7erun it and you should get this plot: So no% %e kno% that i( %e use a PID controller %ith 6p/100$ 6i/300$ 6d/10$ all o( our design requirements %ill &e satis(ied" Example: ! State<Space Controller (or DC Motor Speed Designing the (ull<state (eed&ack controller !dding a re(erence input )rom the main pro&lem$ the dynamic equations in state<space (orm are the (ollo%ing: )or the original pro&lem setup and the deri#ation o( the a&o#e equations$ please re(er to the Modeling a DC Motor page" With a 1 rad4sec re(erence added to the system$ the design criteria are: Settling time less than 3 seconds >#ershoot less than 8= Steady<state error less than 1= Create a ne% m<(ile and type in the (ollo%ing commands ,re(er to the main pro&lem (or the details o( getting these commands." J=0.01; b=0.1; K=0.01; R=1; L=0.5; *=[+b,J K,J +K,L +R,L]; -=[0 1,L]; .=[1 0]; /=0; Designing te full-state feedbac! controller Since &oth o( the state #aria&les in our pro&lem are #ery easy to measure ,simply add an ammeter (or current and a tachometer (or the speed.$ %e can design a (ull<state (eed&ack controller (or the system %ithout %orrying a&out ha#ing to add an o&ser#er" 'he schematic (or a (ull<state (eed&ack system is: 7ecall that the characteristic polynomial (or this closed<loop system is the determinant o( "sI-"#-$K%% %here s is the aplace #aria&le" Since the matrices # and $&K are &oth 3x3 matrices$ there should &e 3 poles (or the system" By designing a (ull<state (eed&ack controller$ %e can mo#e these t%o poles any%here %e %ant them" We shall (irst try to place them at <8 C i and <8<i ,note that this corresponds to a Deta / 0"EF %hich gi#es 0"1= o#ershoot and a sigma / 8 %hich leads to a 1 sec settling time." >nce %e come up %ith the poles %e %ant$ Matla& %ill (ind the controller matrix$K$ (or us" Simply add the (ollo%ing code to the end o( your m<(ile : p1 = +5 + ; p2 = +5 + ; K = p!01e(*,-,[p1 p2]); 5o% look at the schematic a&o#e again" We see that a(ter adding the 6 matrix into the system$ the state<space equations &ecome: We can see the closed<loop response &y simply adding the (ollo%ing line to the end o( your m<(ile: t=0:0.01:3; step(*+-*K,-,.,/,1,t) 7un your m<(ile in the command %indo%$ ?ou should see the (ollo%ing plot: #dding a reference input )rom this plot %e see that the steady<state error is too large" In contrast to the other design methods$ %here %e (eed &ack the output and compare it to the re(erence to compute an error$ here %e are (eeding &ack &oth states" We need to compute %hat the steady<state #alue o( the states should &e$ multiply that &y the chosen gain 6$ and use this ne% #alue as our re(erence (or computing the input" 'his can &e done in one step &y adding a constant gain 5&ar a(ter the re(erence: We can (ind this 5&ar (actor &y using the Matla& command &s10!e: 6b0&=&s10!e(*,-,.,/,K) 5ote that the (unction &s10!e is not a standard (unction in Matla&" ?ou %ill ha#e to copy it &e(ore you use it" Click here (or more in(ormation" 5o% %e can plot the step response &y adding the (ollo%ing line o( code to your m<(ile: t=0:0.01:10; step(*+-*K,-*6b0&,.,/,1,t) tt!e("#tep Resp$nse 2t' K .$nt&$!!e& 0nd 6b0&") 'his time$ the steady<state error is much less than 1=$ and all the other design criteria ha#e &een met as %ell