A proportional-integral-derivative (PID) controller is a common feedback mechanism that can be used to regulate the speed of a direct current (DC) motor. In this article, we will show how to design and tune a PID controller for a DC motor using MATLAB and Simulink.
A DC motor is an electric device that converts electrical energy into mechanical energy. The speed of a DC motor depends on the applied voltage and the load torque. The transfer function of a DC motor can be written as:
where is the angular velocity,
is the applied voltage,
is the moment of inertia,
is the viscous friction coefficient,
is the motor constant,
is the armature resistance, and
is the armature inductance.
To control the speed of a DC motor, we can use a PID controller that compares the desired speed with the actual speed
and generates a control voltage
that drives the motor. The PID controller has three parameters: proportional gain
, integral gain
, and derivative gain
. The transfer function of a PID controller can be written as:
The PID controller can be implemented in Simulink using the PID Controller block. The block diagram of the closed-loop system is shown below:

To tune the PID controller parameters, we can use the PID Tuner app in Simulink Control Design. The app allows us to specify the desired performance criteria, such as rise time, settling time, overshoot, and steady-state error, and automatically computes the optimal PID gains. Alternatively, we can manually adjust the PID gains and observe the effect on the closed
51082c0ec5