Real-Time Implementation of Model Predictive Control in A Low-Cost Embedded Device
Real-Time Implementation of Model Predictive Control in A Low-Cost Embedded Device
Real-Time Implementation of Model Predictive Control in A Low-Cost Embedded Device
Jorge BUELE
Facultad de Ingeniería en Sistemas, Electrónica e Industrial, Universidad Técnica de Ambato
Ambato, 180103, Ecuador
Esteban X. CASTELLANOS
Departamento de Eléctrica y Electrónica, Universidad de las Fuerzas Armadas ESPE
Latacunga, 050104, Ecuador
Marco PILATÁSIG
Departamento de Eléctrica y Electrónica, Universidad de las Fuerzas Armadas ESPE
Latacunga, 050104, Ecuador
Paulina AYALA
Facultad de Ingeniería en Sistemas, Electrónica e Industrial, Universidad Técnica de Ambato
Ambato, 180103, Ecuador
Marcelo V. GARCÍA
Departamento de Ingeniería de Sistemas y Automática, University of the Basque Country
Bilbao, 48013, Spain
ABSTRACT cost. The MPC due to its predictive capacity is very useful for
modular systems, linear and non-linear systems, mono variables
This document presents a general description of the and multi variables with an excellent dynamic response [1-4], its
implementation of a low-cost system for flow control. A use is very varied, so much so that in [2] and [5] its use is
preconditioning of the signal coming from the process to be proposed in the implementation of level converters with load
controlled is carried out and, through Arduino UNO, data is control and three-phase inverters, in [6] an application is
acquired. Using this data in the embedded board Raspberry Pi 3, presented in smart networks with multiple electric vehicle
a predictive control by model (MPC) has been implemented in charging stations, in [7] its use in an altitude controller for an
real time. The plant model is obtained using the identification unmanned four-engined helicopter, in [8] it is used to control the
tool of the MATLAB software. The design of the controller temperature of a refrigeration station and in general in several
which are in the latest version of this software, has been applications of an industrial nature [9-13].
developed in Simulink using the new complements made for this
board. The experimental results show that despite the technical Due to an MPC can not exist without a computer, developers
limitations and the high computational cost that this controller created computers with embedded low-cost systems and its
represents, both devices can work together and present high application has been widely studied: in [14] the Beaglebone is
performance, robustness and good response in the presence of used to perform closed-loop control of the speed of a DC motor,
disturbances. in [15] Raspberry Pi is used for the control of household devices
(Internet of Things), in [16] BeagleBoard xM is used for latency
Keywords: Predictive control, Embedded device, Process reduction in transmissions of live music, in [17] the Beaglebone
control. Black is applied for the navigation control of a robot analyzing
the image information, in [18] the use of Arduino UNO with
Raspberry Pi for the control of flow using a controller with fuzzy
1. INTRODUCTION logic is presented, while in [19] it is used to control a wheelchair
by moving the iris for paralyzed people. In [20] it is used for
In the industry, controllers are highly necessary to manipulate monitoring the air quality, and in [21] the combination of
and monitor a large number of variables because they directly Arduino and Raspberry Pi is used for the control of appliances
influence in production, therefore, controllers have evolved with intelligent communication. All this works developed can
progressively, each time seeking better performance in demonstrate that embedded systems are currently a
development and time response. It means that they have traveled computational alternative for controllers and user’s applications
from basic controllers, to classic controllers and finally to so even for the implementation of an MPC.
advanced controllers.
This paper presents the flow control in a didactic station by
The Model Predictive Controller MPC, was implemented in developing an MPC controller using for data acquisition the
chemical plants and refineries in the 80s, nowadays it is very Arduino UNO board and for the system implementation the
applied at an industrial level, but it requires a high computational Raspberry Pi 3 board which contains the appropriate embedded
106
Proceedings of The 9th International Multi-Conference on Complexity, Informatics and Cybernetics (IMCIC 2018)
system for the aforementioned controller. The tests of Table 1 Model comparison table
performance, robustness and safety against disturbances are Validation model Model Percentage similarity (%)
demonstrated through dynamic graphs while conclusions about Order 2 94.63
their operation are detailed at the end of this document. Sample Order 3 94.65
Order 4 94.94
This work is presented as follows: first the Introduction, then the
System Identification, later the Controller Design. After that the
Hardware Setup is showed for the implementation, then the Real
Time Implementation and finally section 6 and 7 for Results and
Conclusions respectively.
2. SYSTEM IDENTIFICATION
Where:
FIT – Flow Indicator Transmitter
FZ – Flow Driver
I/E – Current/Voltage Converter
FI – Flow Indicator
SP – Set point
3. CONTROLLER DESIGN
107
Proceedings of The 9th International Multi-Conference on Complexity, Informatics and Cybernetics (IMCIC 2018)
associated with the evolution of the system through the prediction For the subsequent acquisition of this signal it is required to
horizon. convert it to a voltage range of 1 to 5V, through a simple
converter circuit (I/E), which consists of a resistance of 250Ω
𝑁𝑝 𝑁𝑝 (6) placed in series with the process. Additionally, a low pass filter
𝐽=∑ (𝑦̂ − 𝑟)𝑇 𝑄(𝑦̂ − 𝑟) + ∑ ∆𝑢𝑇 𝑅∆𝑢 is added to eliminate signals of high frequency and a capacitor in
𝑘=0 𝑘=0
the power supply.
Where, Np is the prediction horizon, k is every instant of time, 𝑦̂
is the future output, r is the reference, Q is the weight matrix of The platform used for data acquisition is Arduino Uno R3. An
the error in the output, ∆𝑢 is the predicted change in the control open source platform that is based on the ATmega328P
variable and R is the weight matrix of control. microcontroller, which has 32 KB of flash memory (with 0.5 KB
used for the boot manager) [23]. It has 14 digital I/O pins, 6 of
In Figure 3 it can be seen the block diagram of the general them are used as a PWM signal and 6 for analog input pins. Its
structure that has a predictive control based in the model. software consists of a standard programming language and a
firmware that runs on the board, it is programmed using a
simplified C++ language in a development environment called
IDE [24].
After the control stage and since Raspberry Pi in all its versions
does not have a digital/analog converter (DAC), the integrated
circuit (C.I.) PCF8591 is used, which receives data through I2C
communication and operates at 8 bits of resolution. It should be
taken into account that this C.I. provides a maximum voltage of
Figure 3. Block Diagram of the general structure of the 5V and the variable frequency drive of the process operates
predictive controllers between 0 - 10V. Therefore, an amplifier circuit with gain 2 and
an impedance matching stage is implemented by the C.I. LF353.
To perform all the conditioning discussed in this section, an
electronic board has been made with conventional elements and
4. HARDWARE SETUP all the C.I.s mentioned, the design is shown in Figure 4.
Table 2 Flow process station specifications Figure 4. Design of the electronic board
Part name Function details
Process tank 25 gal
(capacity)
Rotameter 10 – 40 lpm 5. REAL TIME IMPLEMENTATION
(range)
I/E converter 4 - 20 mA input, 0 - 5 V output The implementation of the MPC controller is done with the
Flow Indicator Type four wires, 0– 30 ft/s input, 4–20 mA DC predictive control toolbox of MATLAB, the toolbox empowers
Transmitter output, operating voltage 12 - 42 V DC the use of state matrices, specified restrictions by the plant and
Flow Driver 0 – 10 V input, 3-Phase output, operating even delays that allow the emulation of the performance of the
voltage 230 V 3-Phase. controller in a more real way.
108
Proceedings of The 9th International Multi-Conference on Complexity, Informatics and Cybernetics (IMCIC 2018)
a)
b)
Figure 7. a) Response curves of PV vs. SP. b) CV response
Figure 4. Complete setup of the flow control station. curves.
109
Proceedings of The 9th International Multi-Conference on Complexity, Informatics and Cybernetics (IMCIC 2018)
6.2. Controller performance with disturbance represents. The response of the controller to sudden changes in
SP were fast and with a minimum overshoot percentage. In
Figure 8 shows the response curves when there is a disturbance addition, this controller presents robustness and a well behavior
in the process (opening of V-3), where the selected disturbance in the presence of disturbance.
percentages are 69.3% and 77% with a SP = 25 LPM. If the
disturbance is greater than 77% despite the fact that the control For future work, these authors propose the implementation of
action is 100%, the process variable does not reach the expected multiple advanced controllers in this kind of boards for make a
value, which could cause damage to the station. Despite applying comparison between the behavior of each one of them inside an
the maximum possible percentage, the controller could eliminate industrial environment.
subsequent effects of this application and the flow was quickly
reestablished to the setpoint without presenting an error in steady
state. ACKNOWLEDGMENTS
8. REFERENCES
110
Proceedings of The 9th International Multi-Conference on Complexity, Informatics and Cybernetics (IMCIC 2018)
Predictive Control of industrial processes", European [18] M. Pilatásig et al., "Implementation of fuzzy controller in
Control Conference (ECC), Zurich, 2013, pp. 1571-1576. low cost embedded boards for a flow system", 2017
[11] D. Liang, F. Xu, H. Chen and S. Yu, "Support vector CHILEAN Conference on Electrical, Electronics
machine based model predictive control for engine idle speed Engineering, Information and Communication
control", 2017 Chinese Automation Congress (CAC), Technologies (CHILECON), Pucón, Chile, 2017, pp. 1-7.
Jinan, China, 2017, pp. 2772-2777. [19] S. Mathur, B. Subramanian, S. Jain, K. Choudhary and D.
[12] M. Aftab, Ch. Chen, Ch. Chau and T. Rahwan, "Automatic R. Prabha, "Human detector and counter using raspberry Pi
HVAC control with real-time occupancy recognition and microcontroller", 2017 Innovations in Power and
simulation-guided model predictive control in low-cost Advanced Computing Technologies (i-PACT), Vellore,
embedded system", Energy and Buildings, Vol. 154, 2017, India, 2017, pp. 1-7.
pp. 141-156. [20] S. Kumar and A. Jasuja, "Air quality monitoring system
[13] J. Ma, W. Song, S. Wang and X. Feng, "Model Predictive based on IoT using Raspberry Pi", 2017 International
Direct Power Control for Single Phase Three-Level Rectifier Conference on Computing, Communication and
at Low Switching Frequency", IEEE Transactions on Automation (ICCCA), Greater Noida, India, 2017, pp.
Power Electronics, Vol. 33, No. 2, 2018. pp. 1050-1062. 1341-1346.
[14] I. Jaziri, L. Charaabi and K. Jelassi, "A closed Loop DC [21] P. Kumar and Umesh Chandra Pati, "Arduino and Raspberry
Motor Control using low cost single-board microcontroller Pi based smart communication and control of home appliance
based on embedded Linux", 2016 International Conference system," 2016 Online International Conference on Green
on Electrical Sciences and Technologies in Maghreb Engineering and Technologies (IC-GET), Coimbatore,
(CISTEM), Marrakech, Morocco, 2016, pp. 1-5. India, 2016, pp. 1-6.
[15] S. J. Johnston, M. Apetroaie-Cristea, M. Scott and S. J. Cox, [22] V. Bagyaveereswaran, T. D. Mathur, S. Gupta and P.
"Applicability of commodity, low cost, single board Arulmozhivarman, "Performance comparison of next
computers for Internet of Things devices", 2016 IEEE 3rd generation controller and MPC in real time for a SISO
World Forum on Internet of Things (WF-IoT), Reston, process with low cost DAQ unit", Alexandria Engineering
USA, 2016, pp. 141-146. Journal, Vol. 55(3), 2016, pp. 2515-2524.
[16] L. Gabrielli, M. aBussolotto and S. Squartini, "Reducing the [23] Y. A. Badamasi, "The working principle of an Arduino",
latency in live music transmission with the BeagleBoard xM 2014 11th International Conference on Electronics,
through resampling", 2014 6th European Embedded Computer and Computation (ICECCO), Abuja, Nigeria,
Design in Education and Research Conference (EDERC), 2014, pp. 1-4.
Milano, Italy, 2014, pp. 302-306. [24] T. Kaur, S. Mahajan, S. Verma, Priyanka and J. Gambhir,
[17] I. Siradjuddin, S. P. Tundung, A. S. Indah and S. "Arduino based low cost active dual axis solar tracker",2016
Adhisuwignjo, "A real-time Model Based Visual Servoing IEEE 1st International Conference on Power Electronics,
application for a differential drive mobile robot using Intelligent Control and Energy Systems (ICPEICES),
Beaglebone Black embedded system", 2015 IEEE Delhi, India 2016, pp. 1-5.
International Symposium on Robotics and Intelligent
Sensors (IRIS), Langkawi, Malaysia, 2015, pp. 186-192.
111