Development of DC Motor Speed Control Using PID Ba
Development of DC Motor Speed Control Using PID Ba
1 (MARCH 2024)
Development of DC Motor Speed Control Using PID Based on Arduino and Matlab
For Laboratory Trainer
Heru Supriyono 1, Fedrik Fajar Alanro 1,Agus Supardi 1
1
Department of Electrical Engineering Universitas Muhammadiyah Surakarta, Surakarta, 57102, Indonesia
ARTICLE INFORMATION A B S T R A C T
DC motors are widely used as propulsions, including in electric bicycles. The problem faced by
Received: October 31, 2023 students in the DC motor control laboratory working using software simulation is that they do
Revised: March 23, 2024 not have practical learning experience using digital instruments. This article aims to develop a
Accepted: March 31, 2024 DC motor speed control that can be used to learn practical Proportional Integral Derivative
Available online: March 31, 2024 (PID) control in the laboratory. The DC motor speed control was developed using a combination
of Arduino UNO microcontroller and Matlab software. The PID method was used because it is
still broadly studied and applied in industries. The test results showed that the developed trainer
KEYWORDS can work well with PID variable values that can be entered via the keypad, and DC motor
transient responses can be displayed in Matlab. From the experimental results, it was found that
DC motor speed, DC motor control, PID, the optimal PID variable values were Kp=0.04, Ki=0.05, and Kd=0.004, where the controller
produced a low overshoot value, i.e., 0.73% of its set point and a settling time of 10.66 seconds.
microcontroller, Arduino
The test results of using the developed trainer in the Fundamental of Control Engineering
laboratory work showed that the developed trainer gave students practical learning experience
CORRESPONDENCE in designing PID control for DC motor speed by using digital equipment, i.e., microcontroller
and actual DC motor as well as analyzing its corresponding transient response in Matlab
Phone: +62(0271)717417 software environment.
E-mail: [email protected]
INTRODUCTION [13], and other plants. Because of its extensive use, PID control
was also frequently used as a basic comparison of developing new
A DC motor is a machine component that converts electrical control algorithms, such as reported by Velasco-Muñoz et al.
energy into kinetic energy. The use of DC motors is widespread [14]. A PID control has advantages such as minimizing or
in many applications, mainly as an actuator, for example, in a nullifying steady-state error and reaching reference set point [15].
mobile robot [1], an underwater vehicle [2], a fuel mixing process Choosing the proper three PID constant combinations is called
[3], a refrigerated cabinet [4], a solar tracker [5] and so on. Many the tuning process. One of the most widely used tuning methods
studies were conducted on many aspects, such as control relating was the Ziegler-Nichols method, which was used by Lemus et al.
to its energy consumption [6] and its angular position control [7]. [16]. Ziegler-Nichols method was also reported to provide PID
Relating to its speed, the two most controlled variables of a DC constants with fast rise time [17]. Ziegler-Nichols method offers
motor involve its speed and rotation direction, as reported by more straightforward computation than analytical tuning models,
Glowinski et al. [8]. Speed controlling is very important in the such as an auto-regression model [18] or a fuzzy-based tuning
application of DC motors, so that has attracted researchers to algorithm [19]. However, the transient response from PID control
work in it, for example, by Tapia-Olvera et al. [9], Alejandro- chosen using Ziegler-Nichols has the disadvantage that the
Sanjines et al. [10] and other published works. Several studies maximum overshoot is still considerably significant, more than
have been carried out in terms of controlling the DC motor, for 20%.
example, using fuzzy logic, Proportional Integral Derivative
(PID) and Internal Model Control (IMC) methods [11], and so on. Controlling a DC motor for practical learning or laboratory work
could be performed in a complete simulation environment using
Proportional Integral Derivative (PID) control has three control software such as Sulityawati et al. [20] and Munadi et al. [21].
variables, namely proportional constant (𝐾𝑝 ), integral constant However, studying DC motor control using simulation only has
(𝐾𝑖 ), and derivative constant (𝐾𝑑 ). In time-domain transient disadvantages, such as students will not have experience in
response, proportional control action affects the rise time, integral practical control by using digital instruments. Learning DC motor
control action affects steady-state error, and differential control control in the laboratory using hardware systems has the
action affects overshoot/undershoot. PID control was studied advantage that students would gain experience in control design
widely for controlling a ball beam plant [12], a brushed DC motor
https://doi.org/10.25077/jnte.v13n1.1155.2024 Attribution-NonCommercial 4.0 International. Some rights reserved
HERU SUPRIYONO / JURNAL NASIONAL TEKNIK ELEKTRO - VOL. 13 NO. 1 (MARCH 2024)
by using digital instruments compared to simulation software, as [28], controlling home appliances [29], and ultrasonic sensor-
also studied by Sozanski [22]. based parking assistant [30].
In Universitas Muhammadiyah Surakarta, DC motor speed As a practical trainer, the set point value and the three PID
control is learned in fundamental control engineering subjects, as parameters should be inputted and changeable all the time for trial
well as both theory and laboratory works. In the laboratory work, and error learning. The keypad inputs Kp, Ki, Kd, and set point
students used to learn to control the DC motor speed by using values. The Arduino UNO processes the inputs and then displays
Matlab simulation only. A low-cost, practical trainer based on them on the LCD. The Arduino UNO then gives control
microcontroller and Matlab software simulation is needed to commands based on these PID variable values to the DC motor
increase student learning experience. This article aims to develop via the driver, and the speed value is displayed on the LCD. In the
a low-cost DC motor speed control using a combination of a developed system, the L298N motor driver differs from the
microcontroller-based system and Matlab software environment, L293D driver used by Divakar et al. [31]. A closed-loop control
which can be used as a trainer for studying DC speed motor system managed the motor speed to remain stable as close as the
control in the laboratory and to give practical learning experience set point. In addition to the LCD, the speed of the DC motor was
by using digital instruments. The controlled DC motor speed also sent to the serial monitor, which will later be used to input
output can be displayed using Matlab software for further the data into Matlab software.
analysis. PID control is consistently implemented in the closed-
Hardware Configuration
loop control architecture in the DC motor control, as depicted in
Figure 1. The hardware configuration of the proposed system used an
Arduino UNO microcontroller, a DC motor, an L298N driver, an
LCD, and keypad instruments, as seen in Figure 3.
METHODS
General Architecture
The general architecture of the developed DC motor speed control
for a laboratory trainer with Arduino-based systems can be seen
in the block diagram presented in Figure 2.
https://doi.org/10.25077/jnte.v13n1.1155.2024 37
HERU SUPRIYONO / JURNAL NASIONAL TEKNIK ELEKTRO - VOL. 13 NO. 1 (MARCH 2024)
System Testing
The obtained system was tested by using the following procedure.
Firstly, the initial PID variables Kp, Ki, and Kd were manually
calculated by using the Ziegler-Nichols method. Secondly, the
Kp, Ki, and Kd found were inputted into the system using a
keypad, and the obtained DC motor speed was displayed to the
MATLAB software to analyze its transient response. After that,
the PID control must be fine-tuned to get the best transient output
Figure 4. Flowchart of the Program using trial and error. The display of the LCD when inputting PID
constants and the DC motor speed setpoint can be seen in Figure
RESULTS AND DISCUSSION 7.
Obtained System
The obtained DC motor speed control trainer can be seen in
Figure 5 and 6. All hardware circuits were placed in a plastic
container box to protect them from external environments such as
dirt, water spray, dent, or vibration, which could damage the
circuit. The controlled DC motor is placed outside the container
box.
After inputting the values of Kp, Ki, Kd, and set points and
running the program, the obtained DC motor speed in rpm value
Figure 5. Obtained Hardware Circuit Placed in The Box can be seen on the serial monitor in the Arduino application; the
DC motor speed data on the serial monitor needed to be copied to
the spreadsheet software MS Excel, which was used in the
38 https://doi.org/10.25077/jnte.v13n1.1155.2024
HERU SUPRIYONO / JURNAL NASIONAL TEKNIK ELEKTRO - VOL. 13 NO. 1 (MARCH 2024)
SPEED (RPM)
3 contains the actual DC motor speed value in rpm. The data taken 1500
is free, but it should not be too small. After that, the data was then
inputted into the Matlab software by copying and pasting the data 1000
from the spreadsheet software into Matlab’s workspace. The
500
Matlab software displayed the transient response graphic,
including its time-domain parameter overshoot, settling time, 0
rise, and time values. 1 5 9 13 17 21 25 29 33 37 41 45 49 53
1500
1000 2000
SPEED (RPM)
500 1500
0 1000
1 5 9 13 17 21 25 29 33 37 41 45 49 53
500
DATA POINTS
0
Figure 8. Transient Response of DC Motor Speed when Kp=1, 1 5 9 13 17 21 25 29 33 37 41 45 49 53
Ki=0, and Kd=0 DATA POINTS
In experiment 2, as seen in Figure 9, the PID variables were Figure 11. Transient Response of DC Motor Speed when
changed to Kp=1, Ki=0.5, and Kd=0. The DC motor speed Kp=0.05, Ki=0.06, and Kd=0.005
depicted in Figure 9 showed that the output reached the set point
at 1500 rpm but had a relatively high overshoot, i.e., around 13.33 In experiment 5, the PID constants of Kp = 0.03, Ki = 0.04, and
%, and there was still oscillation ±12% around the set point. Kd = 0.005 were used. The obtained graphic depicted in Figure
12 was excellent; there was no overshoot, and the resulting speed
2000 was stable with a steady-state error lower than ±0.2%. However,
the transient response became slower compared to the results of
1500 experiment 4, as can be seen in Figure 12 below.
SPEED (RPM)
1000
2000
500
SPEED (RPM)
1500
0 1000
1 5 9 13 17 21 25 29 33 37 41 45 49 53
500
DATA POINTS
0
Figure 9. Transient Response of DC Motor Speed when Kp=1, 1 5 9 13 17 21 25 29 33 37 41 45 49 53
Ki=0.5, and Kd=0 DATA POINTS
In experiment 3, the PID variables of Kp=0.1, Ki=0.5, and
Figure 12. Transient Response of DC Motor Speed when
Kd=0.7 were used. The transient response depicted in Figure 10
Kp=0.03, Ki=0.04, and Kd=0.005
showed that the overshoot is still around 13%, but the steady state
In experiment 6, PID variables were set to Kp=0.04, Ki=0.05, and
condition has a minimal error with oscillation of less than ±1%
Kd=0.004 were used. The obtained transient response depicted in
around the set point 1500 rpm. It is shown in Figure 10 below.
Figure 13 showed that the result was outstanding because the
https://doi.org/10.25077/jnte.v13n1.1155.2024 39
HERU SUPRIYONO / JURNAL NASIONAL TEKNIK ELEKTRO - VOL. 13 NO. 1 (MARCH 2024)
graph had no overshoot and was faster than the result of Testing of the Obtained System for Laboratory Works
experiment 5. The steady-state error was tiny, less than ±1%.
The obtained system was tested for Fundamental Control
2000 Engineering laboratory works. This system replaced the full
simulation laboratory works module used previously. The
SPEED (RPM)
40 https://doi.org/10.25077/jnte.v13n1.1155.2024
HERU SUPRIYONO / JURNAL NASIONAL TEKNIK ELEKTRO - VOL. 13 NO. 1 (MARCH 2024)
Advanced Trends in Computer Science and Engineering, [23] J. Syllignakis, P. Panagiotakopoulos, and E. Karapidakis,
vol. 8, no. 3, pp. 936-942, 2019. “Automatic speed controller of a DC motor using arduino
[8] S. Glowinski, S. Pecolt, A. Błazejewski, and B. Młynski, for laboratory applications,” Engineering and Industry
“Control of brushless direct-current motors using bioelectric Series Volume Power Systems, Energy Markets and
EMG signals,” Sensors 2022, vol. 22, pp. 1-13, 2022. Renewable Energy Sources in South-Eastern Europe 2016,
[9] R. Tapia-Olvera, F. Beltran-Carbajal, O. Aguilar-Mejia, and pp. 351-364, 2016.
A. Valderrabano-Gonzalez, “An adaptive speed control [24] A. Latif, A. Z. Arfianto, H. A. Widodo, R. Rahim, and E. T.
approach for DC shunt motors,” Energies 2016, vol. 9, pp. Helmy, “Motor DC PID system regulator for mini conveyor
1-16, 2016. drive based-on Matlab,” Journal of Robotics and Control
[10] U. Alejandro-Sanjines, A. Maisincho-Jivaja, V. Asanza, L. (JRC), vol. 1, no. 6, pp. 185-190, 2020
L. Lorente-Leyva, and D. H. Peluffo-Ordóñez, “Adaptive PI [25] S. R. Rex, and M. S. R. Praba, “Speed control of DC motor
controller based on a reinforcement learning algorithm for with PWM using microcontroller in hardware in loop,”
speed control of a DC motor,” Biomimetics 2023, vol. 8, pp. International Journal of Engineering & Technology,
1-26, 2023. International Journal of Engineering & Technology, vol. 7,
[11] Md. A. Ahmad, K. Kishor, and P. Rai, “Speed control of a no. 3, pp. 116-119, 2018.
DC motor using controllers,” Automation, Control and [26] M. Saad, A. H. Ahmed, and M. Al Sharqawi, “Real time DC
Intelligent Systems, vol. 2, no. 6, pp. 1-9, 2014. motor position control using PID controller in LabVIEW,”
[12] M. Aviles, J. Rodríguez-Reséndiz, J. Pérez-Ospina, and O. Journal of Robotics and Control (JRC), vol. 2, no. 5, pp. 342-
Lara-Mendoza, “A comprehensive methodology for the 348, 2021.
development of an open source experimental platform for [27] O. O. Adejumo, and W. A. Azeez, “Development of a
control courses,” Technologies 2023, vol. 11, pp. 1-25, microcontroller based DC motor Speed Control System,”
2023. World Journal of Engineering and Technology 2019, vol. 7,
[13] R. Bitriá, and J. Palacín, “Optimal PID control of a brushed pp. 634-639, 2019.
DC motor with an embedded low-cost magnetic quadrature [28] N. Shaharudin, M. Z. Hasan, and S. M. Noor, “Direct
encoder for improved step overshoot and undershoot Current (DC) motor speed and direction controller,” Journal
responses in a mobile robot application,” Sensors 2022, vol. of Physics: Conference Series, 2129 (2021) 012035, pp. 1-
22, 7817, 1-24, 2022. 6, 2021.
[14] H. Velasco-Muñoz, J. E. Candelo-Becerra, F. E. Hoyos, and [29] R. N. Rohmah, F. N. Alwi, and Jatmiko, “Equipment for
A. Rincón, “Speed regulation of a permanent magnet DC monitoring and controlling of household electricity
motor with sliding mode control based on washout filter,” consumption in a IoT-based smart house,” Emitor, vol. 22,
Symmetry 2022, vol. 14, pp. 1-25, 2022. no. 01, pp. 34-38, 2022.
[15] A. Ma’arif, N. R. Setiawan, and E. S. Rahayu, “Embedded [30] Supriyono and Marjuki, “Ultrasonic sensor parking assistant
control system of DC motor using microcontroller arduino with arduino uno,” International Journal of Advanced
and PID algorithm,” IT Journal Research and Development Research in Engineering and Technology (IJARET), vol. 11,
(ITJRD), vol. 6, no. 1, pp. 30-42, 2021. no. 5, pp. 26-33, 2020.
[16] J. P. T. Lemus, G. C. V´elez, and N. J. C. Rodr´ıguez, “PID [31] A. Divakar, J. Joseph, J. T. George, N. N. Prabhu, and A.
controller design for DC motor,” Contemporary Engineering Nabi, “A study on DC motor operations and speed control
Sciences, vol. 11, no. 9, pp. 4913 – 4920, 2018. using microcontroller,” International Journal of Advanced
[17] A. Abdulameer, M. Sulaiman, M. S. M. Aras, and D. Research in Electrical, Electronics and Instrumentation
Saleem, “Tuning methods of PID controller for DC motor Engineering, vol. 5, no. 4, pp. 2460-2464, 2016.
speed control,” Indonesian Journal of Electrical Engineering
and Computer Science, vol. 3, no. 2, pp. 343-349, 2016. AUTHORS BIOGRAPHY
[18] J. A. Niembro-Ceceña, R. A. Gómez-Loenzo, J. Rodríguez-
Reséndiz, O. Rodríguez-Abreo, and A. Odry, “Auto- Heru Supriyono
regression model-based off-line PID controller tuning: an He is a full time lecturer at the Department of Electrical
adaptive strategy for DC motor control,” Micromachines Engineering Universitas Muhammadiyah Surakarta. His main
2022, vol. 13, pp. 1-21, 2022. researches are in the areas of automation, robotics, control, and
[19] P. Kofinas, and A. I. Dounis, “Fuzzy Q-learning agent for computer system.
online tuning of PID controller for DC motor speed control,”
Algorithms 2018, vol. 11, 1pp. 1-13, 2018. Fedrik Fajar Alanro
[20] N. Sulistyawati, Fahmizal, and I. Nathasya, “DC motor He is full time student at the Department of Electrical
speed control with buck converter uses full state feedback- Engineering Universitas Muhammadiyah Surakarta. His main
pole placement,” ELKOMIIKA, vol. 9, no. 2, pp. 415-429, interest is in power system and industrial automation
2021.
[21] Munadi, M. A. Akbar, T. Naniwa, and Y. Taniai, “Model Agus Supardi
reference adaptive control for DC motor based on simulink,” He is a full time lecturer at the Department of Electrical
2016 6th International Annual Engineering Seminar Engineering Universitas Muhammadiyah Surakarta. His main
(InAES), Yogyakarta, Indonesia, pp. 1-6, 2016. expertise falls in the area of electrical power systems, electrical
[22] K. Soza´nski, “Low cost PID controller for student digital machines (both generator and motor), and insulation systems.
control laboratory based on arduino or STM32 modules,”
Electronics 2023, vol. 12, pp. 1-23, 2023.
https://doi.org/10.25077/jnte.v13n1.1155.2024 41