PID Control & MRAC for DC Motor Arduino
PID Control & MRAC for DC Motor Arduino
CALLAO
FACULTY OF ELECTRICAL ENGINEERING AND
ELECTRONICS
SCHOOL OF ENGINEERING
ELECTRONICS
MEMBERS Code
Arias Saavedra Jan Gunter Javier 1523220609
Trejo Jesús, Gustavo Renzo 1623225619
Branco Costa Ortega 1623206011
Luna Mitacc Carlos Jesus 1913240019
Carhuaricra Soto Arnold 1523220583
2022-B
PID CONTROL AND MRAC OF A DC MOTOR USING ARDUINO
I. OBJECTIVES.
Implement at the software level Matlab and Simulink, the speed control of the motor
DC.
Implement a sensor card used in laboratory No. 1, as well as use a model.
power (driver L298N) to drive the DC motor.
Use an Arduino Uno or another board for speed control programming.
Simulate using a sensor and actuator card for speed data collection
of a DC motor.
Apply PID and MRAC control techniques for DC motor speed control.
A PID controller or regulator is a device that allows for the control of a system in
closed loop so that it reaches the desired output state. The PID controller is
composed of three elements that provide a proportional, integral, and
Derivatives. These three actions are what name the PID controller.
The reason why PID controllers were invented: to simplify the tasks of the
operators and exercise better control over the operations. Some of the
the most common applications are:
PROPORTIONAL
The proportional part consists of the product between the error signal and the constant.
proportional to achieve that the steady-state error approaches zero, but
in most cases, these values will only be optimal in a specific
portion of the total control range, with different optimal values for each
portion of the range. However, there is also a limit value in the constant
proportional to from which, in some cases, the system reaches values greater than
the desired ones. This phenomenon is called overshoot and, for safety reasons, does not
it should exceed 30%, although it is advisable that the proportional part does not even
it produces overshoot. There is a continuous linear relationship between the value of the variable
controlled and the position of the final control element (the valve moves to the same
value per unit of deviation). The proportional part does not take into account the time, so
so, the best way to fix the permanent error and make the system
contains some component that takes into account the variation with respect to the tempo,
including and configuring the integral and derivative actions.
Where:
e (t )=SP−PV ( t ) it is the error (SP is the point of establishment, and PV(t) is the variable
of process).
INTEGRAL
I=K
salt ie∫ ( τ ) dτ
0
Where:
τ it is the integration variable (consider the value from the moment 0 to the
current moment t)
DERIVATIVE
The derivative action manifests when there is a change in the absolute value of the error;
(if the error is constant, only the proportional and integral modes act).
The error is the deviation between the measurement point and the set value, or 'Set
The function of the derivative action is to keep the error to a minimum by correcting it.
proportionally at the same speed as it occurs; in this way it avoids that
the error increases.
It is derived with respect to time and then multiplied by a constant Kd and then added.
to the previous signals (P+I). It is important to adapt the control response to the
changes in the system since a greater derivative corresponds to a larger change
fast and the controller can respond accordingly.
The formula of the derivative is given by:
of ( t )
D salt=K d
dt
Where:
The signal r(t) is called the reference and indicates the state that is desired to be achieved in the
output of the system y(t). In a temperature control system, the reference r(t) will be
the desired temperature and the output y(t) will be the actual temperature of the controlled system.
As can be seen in the previous diagram, the input to the PID controller is the signal.
deerror e(t). This signal indicates to the controller the difference that exists between the state
what is intended to be achieved or reference r(t) and the actual state of the system measured by the
sensor, signal h(t).
If the error signal is large, it means that the system state is far from
desired reference state. If, on the contrary, the error is small, it means that the
the system has reached the desired state.
The output of these three terms, the proportional, the integral, and the derivative are
summed to calculate the output of the PID controller. Defining y(t) as the output of the
controller, the final form of the PID algorithm is:
t
of ( t )
e (t )=Kp e ( t ) +K I∫ e ( τ ) dτ+Kd
0 dt
MODEL REFERENCE ADAPTIVE CONTROL
The primary loop must respond faster than the secondary loop, case
contrario el sistema tendera a saturarse porque se estaría obligando al sistema a
react quickly to what cannot be
Therefore, the secondary loop must vary more slowly than the primary loop.
MRAC METHOD
The adaptive control with Reference Model (MRAS) consists of using a model
(a pattern) that produces a desired output given a certain input and to which it must
follow the process (the process must behave the same as the reference model). The
model does not necessarily have to be made in a material form, it can be just a
mathematical model simulated on a computer.
In reference model control, the output of the model (ym) is compared with the
output of the process (yp) and the difference is used to generate the control signals
adequate.
1. A primary controller
2. The reference model
3. The adaptation mechanism that generates the laws of adaptation
The Adaptation mechanism looks at the output of the process (yp) and the output of the model of
reference (ym) and calculate the appropriate parameters so that the error (e = ym - yp)
zero tent. The adaptation mechanism can use, if available, additionally
from the output signals of the process (yp) and the reference model (ym), the signals of
input and the state variables of the process.
One of the most important parts of adaptive control is the obtaining of the law of
control, for which there are several approaches:
The chosen Reference Model must be sensitive to the dynamics of the process, since if
for example, if a model with a very fast dynamic is chosen, the control signal will be
very large causing saturations and the system unable to respond to such
dynamic.
δ=0.8y ts=2 s
2% error criterion
4
t s= ⟹ w n= 4 =2.5
δ.wn 2∗0.8
The transfer function of the reference model is:
2
wn 6.25
2
=
22
s + 2δ wns +w ns + 4 s +6.25
III. MATERIALS.
DC motor with encoder.
Fig. 1: DC motor with encoder.
ATmega328p (Arduino UNO)
L298
LM016L
LM2907
The programming of the ATmega328p was done in Microchip Studio, where the following definition is made
of variables, functions, and the development of the main programming block that will carry out the
PID control of a DC motor.
V. CIRCUIT SIMULATION.
VI. CONCLUSIONES.