Overview
This tutorial shows how to use the root locus design method for digital DC motor position control. This tutorial uses LabVIEW 8.2 with LabVIEW Control Design Toolkit.
These tutorials are based on the Control Tutorials developed by Professor Dawn Tilbury of the Mechanical Engineering department at the University of Michigan and Professor Bill Messner of the Department of Mechanical Engineering at Carnegie Mellon University and were developed with their permission.
In this example, the controller will be designed by a Root Locus method. A digital DC motor model can obtain from conversion of analog DC motor model, as we will describe. According to the Modeling DC Motor Position page, the open-loop transfer function for DC motor's position is:

where:
- electric resistance (R) = 4 ohm
- electric inductance (L) = 2.75E-6 H
- electromotive force constant (K=Ke=Kt) = 0.0274 Nm/Amp
- moment of inertia of the rotor (J) = 3.2284E-6 kg*m^2/s^2
- damping ratio of the mechanical system (b) = 3.5077E-6 Nms
- input (V): Source Voltage
- output (sigma dot): Rotating speed
- The rotor and shaft are assumed to be rigid
The design requirements are:
- Settling time: Less than 0.04 seconds
- Overshoot: Less than 16%
- Steady-state error: 0 with a step disturbance input
Continuous to Discrete Conversion
The first step in the design of a discrete-time system is to convert a continuous transfer function to a discrete transfer function. LabVIEW MathScript can be used to convert the above transfer function to a discrete transfer function by using the c2d command. The c2d command requires three arguments: system, a sampling time (T) and a type of hold circuit. In this example we will use the zero-order hold (zoh).
From the design requirement, let the sampling time, T, equal 0.001 seconds, which is 1/100 of the required time constant or 1/40 of the required settling time.
In LabVIEW, click Tools >> MathScript Window. In the MathScript Window, select the Script tab, and add the following code in the Script Editor:
R = 4;
L = 2.75E-6;
K = 0.0274;
J = 3.2284E-6;
b = 3.5077E-6;
num = K;
den = [(J*L) (J*R)+(L*b) (R*b)+(K^2) 0];
motor = tf(num,den)
Ts = 0.001;
motor_d = c2d(motor, Ts, 'zoh')
[numd,dend] = tfdata(motor_d,'v')
When you run this script, you should see the following result:
Transfer Function
Input:1 Output:1
0.001z^2+0.001z+0
---------------------
z^3-1.942z^2+0.942z+0
Sampling time: 0.001000
numd =
0 0.0010389 0.0010214 9.4536e-010
dend =
1 -1.9425 0.94249 5.2319e-017
In this result, notice that both the numerator and the denominator of the discrete transfer function have one extra root at z = 0. Also, we can get rid of the leading zero coefficient in the numerator. To do this, we will cancel out the extra pole and zero to avoid numerical problems. Otherwise, LabVIEW will consider both the numerator and denominator to be fourth-order polynomials.
Add the following code to the end of your script:
numd = numd(2:3);
dend = dend(1:3);
motor_d = tf(numd,dend,Ts)
When you run the script, you will find that the discrete transfer function is:
θ(z) 0.001z+0.001
----- = ----------------
V(Z) z^2-1.942z+0.942
We would like to see what the closed-loop response of the system looks like when no controller is added. First, we have to close the loop of the transfer function by using the feedback command. After closing the loop, let's see how the closed-loop stairstep response performs by using the step and stairs commands. The step command will provide the vector of discrete step signals and the stairs command will connect these discrete signals.
Add the following MathScript code at the end of the existing script:
sys_cl = feedback(motor_d,1);
[x1,t] = step(sys_cl,.5);
stairs(t,x1)
xlabel('Time (seconds)')
ylabel('Position (rad)')
title('Stairstep Response: Original')
When you run the script, you should see the following plot:

Figure 1: Stairstep Response: Original
Root Locus Design
The main idea of root locus design is to obtain the closed-loop response from the open-loop root locus plot. By adding zeros and poles to the original system, the root locus can be modified, to get a new closed-loop response.
First, let's see the root-locus for the system itself. In your script, add the following commands:
rlocus(motor_d)
title('Root Locus of Original System')
zgrid(0,0)
axis([-2,2,-2,2])
When you run your script, you should see the following plot:

Figure 2: Root Locus of Original System
To get the zero steady-state error from the closed-loop response, we have to add an integral control. Recall that the integral control in continuous-time is 1/s. If we use the backward difference approximation for mapping from the s-plane to the z-plane as described by s = 1/(z-1), one pole will be added at 1 on the root locus plot.
After adding the extra pole at 1, the root locus will have three poles near 1. Therefore the root locus will move out to the right, and the closed-loop response will be more unstable. Thus, we must add one zero near 1, inside the unit circle, to cancel with one pole and pull the root locus in. We will add a zero at z = 0.95.
In general, we must at least add as many poles as zeros for the controller to be causal.
Add the following MathScript code to the end of your existing script:
numi = [1 -0.95];
deni = [1 -1];
icontr = tf(numi,deni,Ts);
Recall from the Digital Control Tutorial page that the zgrid on command can be used to find the desired region (satisfying the design requirements) on the discrete root locus plot. From the design requirement, the settling time is less than 0.04 seconds and the percent overshoot is less than 16%.
The formulas for finding the damping ratio and natural frequency are:


where OS = the percent overshoot, and Ts = the settling time. The required damping ratio is 0.5 and the natural frequency is 200 rad/sec = 0.2 rad/sample.
Add the following code to the end of your script:
rlocus(icontr*motor_d);
zgrid on
title('Root Locus of System with Integral Control')
axis([-2,2,-2,2])
When you run the script, you should get the following plot:

Figure 3: Root Locus of System with Integrated Control
From the above root locus plot, we can see that system is unstable at all gains because the root locus is outside the unit circle. Moreover, the root locus should be in the region where the damping ratio line at 0.5 and the natural frequency line at 0.2 cross each other, to satisfy the design requirements.
Thus we have to pull the root locus in further by first canceling the zero at approximately -0.98, since this zero will add overshoot to the step response. Then we have to add one more pole and two zeros near the desired poles. After going through some trial and error, one more pole is added at 0.61 and two zeros are added at 0.76.
Add the following code to your script:
numc = conv([1 -0.76],[1 -0.76]);
denc = conv([1 0.9831],[1 -0.61]);
contr = tf(numc,denc,Ts);
rlocus(icontr*contr*motor_d);
zgrid on
title('Root Locus of Compensated System')
axis([-2,2,-2,2])
The system will have a pole at 0.61 instead of -0.98. When you run the script, you should get the following root locus plot:

Figure 4: Root Locus of Compensated System
From the above root locus plot, we see that the root locus is now in the desired region. Let's find a gain, K, on the root locus plot by using the rlocfind command. Then, we can obtain the stairstep response with the selected gain.
Add the following commands to the end of your script:
K = rlocfind(icontr*contr*motor_d)
sys_cl = feedback(K*icontr*contr*motor_d,1);
[x2,t] = step(sys_cl,.05);
stairs(t,x2)
xlabel('Time (seconds)')
ylabel('Position (rad)')
axis([0,0.05,0,1.4])
title('Stairstep Response of Compensated System')
When you run the script, you should see an Interactive Root Locus window pop up. On the plot, click on the x-axis (Real Axis) values to change the viewing window. Change the left-most x-axis value to 0.2 and the right-most value to 1.1. Next, drag one of the poles to make your plot look like this:

Figure 5: Interactive Root Locus to Select Gain
The selected gain should be around 330. Click OK.
You should now see a plot of the closed-loop compensated response:

Figure 6: Stairstep Response of Compensated System
From the above closed-loop response, the settling time is about 0.05 seconds, which satisfies the requirement, but the percent overshoot is 22%, which is too large, due to the zeros.
If we select the gain to be larger, the requirements will be satisfied. On the other hand, the problem will be unrealistic, and a huge actuator will be needed. You can try this yourself by picking a larger gain on the previous root locus plot, which will yield an unrealistically sudden step response.
So we have to move one pole and two zeros a little further to the right, to pull the root locus in a little bit more. The new pole will be put at 0.7, and two zeros will be at 0.85.
Go back to your script, and change only numc and denc, as shown below:
numc = conv([1 -0.85],[1 -0.85]);
denc = conv([1 0.9831],[1 -0.7]);
Again, change the Real Axis limits to 0.2 and 1.1 in the Interactive Root Locus window. Adjust the poles to make your plot look like this:

Figure 7: Interactive Root Locus to Select Gain
The selected gain should be around 450. Click OK.
You should now see a new plot of the closed-loop compensated response:

Figure 8: Stairstep Response of Compensated System
Now we see that the settling time and percent overshoot meet the design requirements of the system. The settling time is 0.04 seconds and the percent overshoot is about 10%.
Let's take a look at a disturbance response of the closed-loop system. We need to cancel the selected gain, the integral transfer function, and the controller's transfer function from the closed-loop transfer function. So add the following code to your script:
dist_cl=feedback(motor_d,K*icontr*contr);
[x4,t] = step(dist_cl,.25);
stairs(t,x4)
xlabel('Time (seconds)')
ylabel('Position (rad)')
title('Stairstep Response of Compensated System')
You will have to select the gain again. After that, you should see the following root locus plot:

Figure 9: Disturbance Response of Closed-Loop System
We can see that a response to the disturbance is small (3.3% of the disturbance) and settles within 2% of the disturbance after 0.04 seconds and eventually reaches zero.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
