Sei sulla pagina 1di 10

DC Motor Speed Modeling Physical setup and system equations Design requirements Matlab representation and open-loop response

Physical setup and system equations Photo courtesy: Pope Electric Motors Pty Limited A common actuator in control systems is the DC motor. It directly provides rotary motion and, coupled with wheels or drums and cables, can provide transitional motion. The electric circuit of the armature and the free body diagram of the rotor are shown in the following figure: For this example, we will assume the following values for the physical parameters. These values were derived by experiment from an actual motor in Carnegie Mellon's undergraduate controls lab. * moment of inertia of the rotor (J) = 0.01 kg.m^2/s^2 * damping ratio of the mechanical system (b) = 0.1 Nms * electromotive force constant (K=Ke=Kt) = 0.01 Nm/Amp * electric resistance (R) = 1 ohm * electric inductance (L) = 0.5 H * input (V): Source Voltage * output (theta): position of shaft * The rotor and shaft are assumed to be rigid The motor torque, T, is related to the armature current, i, by a constant factor Kt. The back emf, e, is related to the rotational velocity by the following equations: In SI units (which we will use), Kt (armature constant) is equal to Ke (motor constant). From the figure above we can write the following equations based on Newton's law combined with Kirchhoff's law: 1. Transfer Function Using Laplace Transforms, the above modeling equations can be expressed in terms of s. By eliminating I(s) we can get the following open-loop transfer function, where the rotational speed is the output and the voltage is the input. 2. State-Space In the state-space form, the equations above can be expressed by choosing the rotational speed and electric current as the state variables and the voltage as an input. The output is chosen to be the rotational speed. Design requirements First, our uncompensated motor can only rotate at 0.1 rad/sec with an input voltage of 1 Volt (this will be demonstrated later when the open-loop response is simulated). Since the most basic requirement of a motor is that it should rotate at the desired speed, the steady-state error of the motor speed should be less than 1%. The other performance requirement is that the motor must accelerate to its steady-state speed as soon as it turns on. In this case, we want it to have a settling time of 2 seconds. Since a speed faster than the reference may damage the equipment, we want to have an overshoot of less than 5%.

If we simulate the reference input (r) by an unit step input, then the motor speed output should have: Settling time less than 2 seconds Overshoot less than 5% Steady-state error less than 1% Matlab representation and open-loop response 1. Transfer Function We can represent the above transfer function into Matlab by defining the numerator and denominator matrices as follows: Create a new m-file and enter the following 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)]; Now let's see how the original open-loop system performs. Add the following commands onto the end of the m-file and run it in the Matlab command window: step(num,den,0:0.1:3) title('Step Response for the Open Loop System') You should get the following plot: From the plot we see that when 1 volt is applied to the system, the motor can only achieve a maximum speed of 0.1 rad/sec, ten times smaller than our desired speed. Also, it takes the motor 3 seconds to reach its steady-state speed; this does not satisfy our 2 seconds settling time criterion. 2. State-Space We can also represent the system using the state-space equations. Try the following commands in a new m-file. J=0.01; b=0.1; K=0.01; R=1; L=0.5; A=[-b/J K/J -K/L -R/L]; B=[0 1/L]; C=[1 0]; D=0; step(A, B, C, D) Run this m-file in the Matlab command window, and you should get the same output as the one shown above.Root Locus Design Method for DC Motor Speed Control Drawing the open-loop root locus

Finding the gain using the rlocfind command Adding a lag controller Plotting the closed-loop response From the main problem, the dynamic equations and the open-loop transfer function of DC Motor Speed are: and the system schematic looks like: For the original problem setup and the derivation of the above equations, please refer to the Modeling a DC Motor page. With a 1 rad/sec step reference, the design criteria are: Settling time less than 2 seconds Overshoot less than 5% Steady-state error less than 1% Now let's design a controller using the root locus method. Create a new m-file and type in the following commands (refer to main problem for the details of getting those 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)]; Drawing the open-loop root locus The main idea of root locus design is to find the closed-loop response from the openloop root locus plot. Then by adding zeros and/or poles to the original plant, the closedloop response can be modified. Let's first view the root locus for the plant. Add the following commands at the end of your m-file. rlocus(num,den) sgrid(.8,0) sigrid(2.3) title('Root Locus without a controller') The command sigrid is the user-defined function. You need to copy the sigrid.m file to your directly before using it. For more information on how to use functions, refer to functions. Two arguments in the sgrid command are the damping ratio (zeta) term (0.8 corresponds to a overshoot of 5%), and the natural frequency (Wn) term (= 0 corresponds to no rise time criterion) respectively. The single argument in the sigrid command is the sigma term (4.6/2 seconds = 2.3). After you have saved sigma.m file to your directly, run the above m-file in the command window. You should get the root locus plot shown below: Finding the gain using the rlocfind command If you recall, we need the settling time and the overshoot to be as small as possible. Large damping corresponds to points on the root locus near the real axis. A fast response corresponds to points on the root locus far to the left of the imaginary axis. To find the gain corresponding to a point on the root locus, we can use the rlocfind command. We can find the gain and plot the step response using this gain all at once. To do this, enter the following commands at the end of your m-file and rerun it.

[k,poles] = rlocfind(num,den) [numc,denc]=cloop(k*num,den,-1); t=0:0.01:3; step(numc,denc,t) title('Step response with gain') Go to the plot and select a point on the root locus half-way between the real axis and the damping requirement, say at -6+2.5i. Matlab should return the output similar to the following. selected_point = -5.9596 + 2.0513i k= 10.0934 poles = -6.0000 + 2.0511i -6.0000 - 2.0511i Note that the values returned in your Matlab command window may not be exactly the same, but should at least have the same order of magnitude. You should also get the following plot: As you can see, the system is overdamped and the settling time is about one second, so the overshoot and settling time requirements are satisfied. The only problem we can see from this plot is the steady- state error of about 50%. If we increase the gain to reduce the steady-state error, the overshoot becomes too large (Try this yourself). We need to add a lag controller to reduce the steady-state error. Adding a lag controllerFrom the plot we see that this is a very simple root locus. The damping and settling time criteria were met with the proportional controller. The steady-state error is the only criterion not met with the proportional controller. A lag compensator can reduce the steady-state error. By doing this, we might however increase our settling time. Try the following lag controller first: This can be done by changing your m-file to look like the following: 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)]; z1=1; p1=0.01; numa = [1 z1]; dena = [1 p1]; numb=conv(num,numa); denb=conv(den,dena); rlocus(numb,denb) sgrid(.8,0) sigrid(2.3)

title('Root Locus with a lag controller') numa and dena are the numerator and denominator of the controller, and numb and denb are the numerator and denominator of the overall open-loop transfer function. You should get the following root locus, which looks very similar to the original one: Plotting the closed-loop response Now let's close the loop and see the closed-loop step response Enter the following code at the end of your m-file: [k,poles]=rlocfind(numb,denb) [numc,denc]=cloop(k*numb,denb,-1); t=0:0.01:3; step(numc,denc,t) title('Step response with a lag controller') Rerun this m-file in the Matlab command window. When prompted to select a point, pick one that is near the damping requirement (diagonal dotted line). You should get the a plot similar to the following: Your gain should be about 20. As you can see the response is not quite satisfactory. You may also note that even though the gain was selected to correlate with a position close to the damping criterion, the overshoot is not even close to five percent. This is due to the effect of the lag controller kicking in at a later time than the plant. (its pole is slower). What this means is that we can go beyond the dotted lines that represent the limit, and get the higher gains without worrying about the overshoot . Rerun your mfile, place the gain just above the white, dotted line. Keep trying until you get a satisfactory response. It should look similar to the following (we used a gain of around 50): The steady-state error is smaller than 1%, and the settling time and overshoot requirements have been met. As you can see, the design process for root locus is very much a trial and error process. That is why it is nice to plot the root locus, pick the gain, and plot the response all in one step. If we had not been able to get a satisfactory response by choosing the gains, we could have tried a different lag controller, or even added a lead controller. Frequency Design Method for DC Motor Speed Control Drawing the original Bode plot Adding proportional gain Plotting the closed-loop response Adding a lag controller From the main problem, the dynamic equations and the open-loop transfer function of DC Motor Speed are: and the system schematic looks like: For the original problem setup and the derivation of the above equations, please refer to the Modeling a DC Motor page. With the 1 rad/sec step input, the design criteria are: Settling time less than 2 seconds Overshoot less than 5% Steady-state error less than 1% Create a new m-file and type in the following commands (refer to the main problem for the details of getting those 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)];Drawing the original Bode plot The main idea of frequency-based design is to use the Bode plot of the open-loop transfer function to estimate the closed-loop response. Adding a controller to the system changes the open-loop Bode plot, therefore changing the closed-loop response. Let's first draw the Bode plot for the original open-loop transfer function. Add the following code to the end of your m-file, and then run it in the Matlab command window. bode(num,den) You should get the following Bode plot: Adding proportional gain From the bode plot above, we see that the phase margin can be greater than about 60 degrees if w is less than 10 rad/sec. Let's add gain to the system so the bandwidth frequency is 10 rad/sec, which will give us a phase margin of about 60 degrees. To find the gain at 10 rad/sec, you can try to read it off the Bode plot (it looks to be slightly more than -40 dB, or 0.01 in magnitude). The bode command, invoked with left-hand arguments, can also be used to give you the exact magnitude: [mag,phase,w] = bode(num,den,10) mag = 0.0139 To have a gain of 1 at 10 rad/sec, multiply the numerator by 1/0.0139 or approximately 72. num = 70*num and rerun your m-file. You should have the following Bode plot: Plotting the closed-loop response From the plot above we see that the phase margin is now quite large. Let's see what the closed-loop response look like. Add a % in front of the bode commands and add the following code to the end of your m-file: [numc,denc]=cloop(num, den, -1); t=0:0.01:10; step(numc,denc,t) You will see the following plot: The settling time is fast enough, but the overshoot and the steady-state error are too high. The overshoot can be reduced by reducing the gain a bit to get a higher phase margin, but this would cause the steady-state error to increase. A lag controller is probably needed. Adding a lag controller We can add a lag controller to reduce the steady-state error. At the same time, we should try to reduce the overshoot by reducing the gain. Let's reduce the gain to 50, and try a lag controller of which should reduce the steady-state error by a factor of 1/0.01 = 100 (but could increase the settling time). Go back and change your m-file so it looks like the

following: num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; num=50*K; z=1; p=0.1; numa=[1 z]; dena=[1 p]; numb=conv(num,numa); denb=conv(den,dena); bode(numb,denb) Rerun the file and you will get this plot: The phase margin looks good. The steady-state error is predicted to be about 1/40dB or 1%, as desired. Close the loop and look at the step response. Add the following lines of code to the end of you m-file and rerun. [numc,denc]=cloop(numb, denb, -1); t=0:0.01:10; step(numc,denc,t) Now you have a step response that meets the design requirements. The steady-state error is less than 1%, the overshoot is about 5%, and the settling time is about 2 seconds. PID Design Method for DC Motor Speed Control Proportional control PID control Tuning the gains From the main problem, the dynamic equations and the open-loop transfer function of the DC Motor are: and the system schematic looks like: For the original problem setup and the derivation of the above equations, please refer to the Modeling a DC Motor page. With a 1 rad/sec step input, the design criteria are: Settling time less than 2 seconds Overshoot less than 5% Steady-stage error less than 1% Now let's design a PID controller and add it into the system. First create a new m-file and type in the following commands (refer to the Modeling page for the details of 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)];Recall that the transfer function for a PID controller is:

Proportional control Let's first try using a proportional controller with a gain of 100. Add the following code to the end of your m-file: Kp=100; numa=Kp*num; dena=den; To determine the closed-loop transfer function, we use the cloop command. Add the following line to your m-file: [numac,denac]=cloop(numa,dena); Note that numac and denac are the numerator and the denominator of the overall closedloop transfer function. Now let's see how the step response looks, add the following to the end of your m-file, and run it in the command window: t=0:0.01:5; step(numac,denac,t) title('Step response with Proportion Control') You should get the following plot: PID control From the plot above we see that both the steady-state error and the overshoot are too large. Recall from the PID tutorial page that adding an integral term will eliminate the steady-state error and a derivative term will reduce the overshoot. Let's try a PID controller with small Ki and Kd. Change your m-file so it looks like the following. Running this new m-file gives you the following 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; Ki=1; Kd=1; numc=[Kd, Kp, Ki]; denc=[1 0]; numa=conv(num,numc); dena=conv(den,denc); [numac,denac]=cloop(numa,dena); step(numac,denac) title('PID Control with small Ki and Kd') Tuning the gains Now the settling time is too long. Let's increase Ki to reduce the settling time. Go back to your m-file and change Ki to 200. Rerun the file and you should get the plot like this: Now we see that the response is much faster than before, but the large Ki has worsened the transient response (big overshoot). Let's increase Kd to reduce the overshoot. Go back to the m-file and change Kd to 10. Rerun it and you should get this plot:

So now we know that if we use a PID controller with Kp=100, Ki=200, Kd=10, all of our design requirements will be satisfied. A State-Space Controller for DC Motor Speed Designing the full-state feedback controller Adding a reference input From the main problem, the dynamic equations in state-space form are the following: For the original problem setup and the derivation of the above equations, please refer to the Modeling a DC Motor page. With a 1 rad/sec reference added to the system, the design criteria are: Settling time less than 2 seconds Overshoot less than 5% Steady-state error less than 1% Create a new m-file and type in the following commands (refer to the main problem for the details of getting these commands). J=0.01; b=0.1; K=0.01; R=1; L=0.5; A=[-b/J K/J -K/L -R/L]; B=[0 1/L]; C=[1 0]; D=0; Designing the full-state feedback controller Since both of the state variables in our problem are very easy to measure (simply add an ammeter for current and a tachometer for the speed), we can design a full-state feedback controller for the system without worrying about having to add an observer. The schematic for a full-state feedback system is: Recall that the characteristic polynomial for this closed-loop system is the determinant of (sI-(A-BK)) where s is the Laplace variable. Since the matrices A and B*K are both 2x2 matrices, there should be 2 poles for the system. By designing a full-state feedback controller, we can move these two poles anywhere we want them. We shall first try to place them at -5 + i and -5-i (note that this corresponds to a zeta = 0.98 which gives 0.1% overshoot and a sigma = 5 which leads to a 1 sec settling time). Once we come up with the poles we want, Matlab will find the controller matrix,K, for us. Simply add the following code to the end of your m-file : p1 = -5 + i; p2 = -5 - i; K = place(A,B,[p1 p2]); Now look at the schematic above again. We see that after adding the K matrix into the system, the state-space equations become:

We can see the closed-loop response by simply adding the following line to the end of your m-file: t=0:0.01:3; step(A-B*K,B,C,D,1,t) Run your m-file in the command window, You should see the following plot: Adding a reference input From this plot we see that the steady-state error is too large. In contrast to the other design methods, where we feed back the output and compare it to the reference to compute an error, here we are feeding back both states. We need to compute what the steady-state value of the states should be, multiply that by the chosen gain K, and use this new value as our reference for computing the input. This can be done in one step by adding a constant gain Nbar after the reference: We can find this Nbar factor by using the Matlab command rscale: Nbar=rscale(A,B,C,D,K) Note that the function rscale is not a standard function in Matlab. You will have to copy it before you use it. Click here for more information. Now we can plot the step response by adding the following line of code to your m-file: t=0:0.01:10; step(A-B*K,B*Nbar,C,D,1,t) title('Step Response with K Controller and Nbar')This time, the steady-state error is much less than 1%, and all the other design criteria have been met as well.

Potrebbero piacerti anche