CMU
UM


Example: PID Design Method for the DC Motor Position

Proportional control
PID control
Tuning the gains

From the main problem, the dynamic equations in transfer function form are the following:

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:

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 main problem for the details of getting those commands).

Recall that the transfer function for a PID controller is:

Proportional control

Let's first try using a proportional controller with a gain of 1.7. Add the following code to the end of your m-file:

To determine the closed-loop transfer function, we use the cloop command. Add the following line to your m-file: Note that numc and denc are the numerator and the denominator of the overall closed-loop 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:

You should get the following plot:

Now lets take a look at the step disturbance response. Add the following to the end of your m-file, and run it in the command window:

You should get the following plot:

PID control

From the plots above we see that although the steady-state error looks good the settling time is too large, as is the overshoot. We also see that the steady-state error to a disturbance is large. Recall from PID tutorial page that adding an integral term will eliminate the steady-state error and a derivative term will reduce the overshoot. Let's first try a PI controller to get rid of the disturbance steady state error. Change your m-file so it looks like:

You should get the following step response:

Lets see what happened to the step disturbance response, add the following to your m-file:

You should get the following plot:

Tuning the gains

The settling time is still too long. Let's increase the gains in order to speed up the response. Go back to your m-file and change Ki to 200 and Kp to 17. Rerun the file and you should get plots like these:

Now we see that the response is faster than before, but the large Ki has worsened the transient response (big overshoot). Let's now try a PID controller to reduce the overshoot. Go back to the m-file and make the following changes to look at the step response.

Rerun it and you should get this plot:

Your step disturbance plot should look like this:

We now see that our step response looks really good, it has less than 16% overshoot and the settling time is roughly 40ms, and there is no steady-state error. However the step disturbance response is now really slow. Lets increase Ki to speed up the disturbance response. Change Ki to 600 in your m-file and rerun the file. You should get the following plots:

We now can see that the step response has a settling time of roughly 40ms, it has less than 16% overshoot, and it has no steady state error. The step disturbance response also has no steady state error. So now we know that if we use a PID controller with

Kp=17,
Ki=600,
Kd=.15,

all of our design requirements will be satisfied.


User Feedback

We would like to hear about suggestions you have for improvement, difficulties you had with the tutorials, errors that you found, or any other comments that you have. This feedback is anonymous.


PID Examples
Cruise Control | Motor Speed | Motor Position | Bus Suspension | Inverted Pendulum | Pitch Controller | Ball and Beam

Motor Position Examples
Modeling | PID | Root Locus | Frequency Response | State Space | Digital Control:RL

Tutorials

Basics | PID | Modeling | Root Locus | Frequency Response | State Space | Digital Control | Examples

8/24/97 WM