Implementation of A PID Control System On Microcontroller (DC Motor Case Study)
Implementation of A PID Control System On Microcontroller (DC Motor Case Study)
Mohamed Nasreldin M.A., Abdalaziz Abdalgfar A.A., Ahmed Alfatih A., Ahmed Abdelrahman A.A.
Karary University
Omdurman, Sudan
[email protected]
AbstractThis paper concerns with the design and known technique pulse width modulation (PWM) with help of
implementation of a microcontroller based PID controller for the fast switching power electronics circuits mostly chopper
purpose of controlling PMDC motor speed. The design had been circuits which is used to switch dc voltage on and off at very
done using MATLAB and Simulink and the system then
high rate and hence changes the power supplied to the
simulated using Proteus, in addition to a practical physical
machine [3]. These traditional methods of controlling the DC
system. The controller was implemented on an Arduino Uno
board to control the speed of the motor at a desired value with machine lacks the efficiency and fast response, therefore to
the possibility of changing it and its direction of rotation. The compensate this we have to use controllers to achieve stability
proposed system use an optical encoder as feedback sensor of and better performance which generally is represented as
motor speed which is compared with reference speed to produce transient and steady state response.
error signal for the controller input, the control signal then sets This paper aims toward implementing a PID controller
the PWM duty cycle to change the motor speed which controlled on a microcontroller board with focusing on control design
via H-bridge. The controller was able to track the input and analysis of the controller when used to control PMDC
regardless of friction, disturbance and medium changes of load
motor speed.
on motor shaft. Both implementation and simulation results had
The design procedure has taken in account several
been obtained and compared.
researches related to the subject along with studying system
Keywordscontrol; microcontroller; computing; machine dynamics before designing the control algorithm.
control. This paper organized as follows: Section II contains
theoretical information and related work. Section III describes
I. INTRODUCTION system design, implementation, software and hardware
Nowadays control systems are essential part of our life, components. Section IV presents experiments and simulation
they are found in home, office, transports, communication results. Section V contains conclusion, recommendation and
systems and computer systems. future work.
In general control systems are classified as classical
control systems and modern control, classical control systems II. THEORETICAL BACKGROUND
depends on feedback and transfer function on its operation, In order to do a control design or analysis we need system
while modern controller uses state-space representation, model, in this case our model is the transfer function of
digital computers, fuzzy logic and neural networks [1]. permanent magnet DC motor. Generally controlling dc motor
PID controller is classified as a classical controller but also uses armature circuit or excitation circuit, the paper deals with
it becomes modern controller when implemented as a code in armature circuit variables. Fig. 1 represents an armature
a control loop. Modern high speed microcomputers and controlled permanent magnet dc motors equivalent circuit,
microcontrollers are widely used in digital control systems and Fig. 2 shows the mechanical component.
because of its efficiency, speed, compactness and reasonable It is clear that electrical variables control the mechanical
cost [2]. ones so we can relate these two sets of variable by applying
DC motors are the most commonly used machines in circuit laws and motion laws to get the following equations
industry because it is simple, rigid and easy to control, the (1), (2) and (3).
most common control among this type of machine is varying
the supply voltage which is easy to manipulate using the will
Where:
Kp, Ti, Td: represents PID constants.
Fig.1: DC motor equivalent circuit. T: represents sampling time.
Equation (10) is known as velocity form of PID controller
which is suitable for implementation on a control loop
because it provides smooth control and avoids common
controllers problems like integral wind-up and derivative
Fig. 2. Mechanical variables in DC motor. kick [5].
di a Several researches have been made to provide a
e a (t ) = R a * i a (t ) + La * +v b (1) convenient speed control however we took three papers as
dt
reference and guide.
z *p
vb = * w(t) = kb w (t ) (2) Panduranga Talavaru, Nagaraj Naik R et al. provided a
2 * A
closed loop speed and position control using PID controller
s 2 J m * (s ) + sD m * (s ) = T m (s ) (3) implemented on ATmega32 microcontroller, the system used
T m = k t * I a (s) (4) rotary encoder as speed sensor and PMW technique to set the
motor speed at the desired set point entered via GUI on
Using Laplace transform on above equations we can get computer [6]. The design is simple and compact, however it
the transfer function that relates the shaft speed to the supply ignores the system performance analysis on transient and
voltage as follows: steady state.
w (s) 1 Sukumar Kamalasadan and Abhiman Hande Designed a
= (5)
Ea (s) 2 La R L R precise control of speed and direction, the system uses two
[(s Je +s( a Je + a De ) +( a De +Kb )]
microcontrollers, the first microcontroller reads the motor
Kt Kt Kt Kt
speed and drives it while the second one calculate the control
Where: signal, communication between the two microcontrollers was
2 done using controller area network (CAN) protocol [7]. The
N (6)
Je = J m + J L m proposed system was precise but suffers complexity in
NL choosing a sampling time due to the use of two
2
N microcontrollers.
De = D m + D L m (7) Another paper by Petr Dostalek, Libor Pekar et al. show
NL
that a self tuning controller can be implemented on
The sub letter L denotes load while m denotes motor [4]. 68HC908GB60 an 8-bits microcontroller manufactured by
PID controller uses three terms: proportional, integral and Freescale which is a part of the development board
derivative to drive an error signal (e) to zero, equation (8) M68EVB908GB60 by Axiom Manufacturing, The process is
shows continuous time PID controller transfer function. identified using modified recursive least squares method with
U (s ) K (8) a digital PID controller whose parameters are designed by
= K P + I + K DS
E (s ) S pole placement, the paper focused on decreasing the sampling
To implement a PID controller as a code we need to time that result in better system stability, the controller then
transfer it to a discrete controller and so we used backward used on two heat plants [8]. The last paper proofs that low
integration on equation (8) to get the following form: cost 8-bit microcontroller has sufficient arithmetic power to
handle adaptive control tasks.
U (z ) = K 1 + T +T d
(1 z )
1
(9)
E (z ) T i (1 z 1 )
p
T
III. SYSTEM DESIGN from transfer function that were discussed earlier, control
General PID speed control system is shown in Fig. 3 system toolbox used to plot system response as well as tuning
below, the controller compares desired speed that represent the PID controller, Fig. 5 shows block diagram of the system
the reference with actual speed that represent feedback signal in Simulink program.
to calculate error signal which is the input signal of the
controller, then a control signal is calculated based on
controller gain and structure, the control design aims to force
the system output to settle on its reference.