0% found this document useful (0 votes)
9 views20 pages

PID Control & MRAC for DC Motor Arduino

This document describes the objective of implementing PID control and MRAC of a DC motor using Arduino. It details the theoretical framework of PID control, including its proportional, integral, and derivative components. It also briefly explains model reference adaptive control (MRAC) and how it can adapt control parameters to maintain proper operation in the face of changes in the process. The document was written for an advanced control course and is authored by students from the Faculty of Electrical and Electronic Engineering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views20 pages

PID Control & MRAC for DC Motor Arduino

This document describes the objective of implementing PID control and MRAC of a DC motor using Arduino. It details the theoretical framework of PID control, including its proportional, integral, and derivative components. It also briefly explains model reference adaptive control (MRAC) and how it can adapt control parameters to maintain proper operation in the face of changes in the process. The document was written for an advanced control course and is authored by students from the Faculty of Electrical and Electronic Engineering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NATIONAL UNIVERSITY OF

CALLAO
FACULTY OF ELECTRICAL ENGINEERING AND
ELECTRONICS
SCHOOL OF ENGINEERING
ELECTRONICS

LABORATORY N°2 - 90G


THEME:
PID CONTROL AND MRAC OF A DC MOTOR USING
ARDUINO
COURSE:
ADVANCED CONTROL
PROFESSOR:
Dr. Ing. NICANOR RAUL BENITES SARAVIA

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.

II. THEORETICAL FRAMEWORK.

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:

Temperature links (air conditioning, heaters, refrigerators, etc.).


Level ties (level in liquid tanks such as water, dairy, mixtures,
raw, etc.).
Pressure ties (to maintain a predetermined pressure in tanks,
tubes, containers, etc.)
Flow ties (keep the flow within a line or pipe).

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.

The formula of proportionality is given by: P=K


salt e p (t )

Where:

K pit is the proportional gain. Tuning value.

e (t )=SP−PV ( t ) it is the error (SP is the point of establishment, and PV(t) is the variable
of process).

t it is the instant time.

INTEGRAL

The Integraltene control mode aims to reduce and eliminate error in


steady state, caused by external disturbances and which cannot
to be corrected by proportional control. Integral control acts when there is a
deviation between the variable and the setpoint, integrating this deviation into the
time and adding it to the proportional action. The error is integrated, which has the
function to average it or sum it over a specified period; then it is multiplied
by a constant Ki. Subsequently, the integral response is added to the mode
Proportional to form the P + I control with the purpose of obtaining a response
system stable without steady-state error. The integral mode presents a phase shift in the
90º response that added to the 180º of the negative feedback brings closer to
process to have a delay of 270º, then it will only be necessary for the tempo
dead contribute with 90º of delay to provoke the oscillation of the process.
the total gain of the control loop must be less than 1, thus inducing an attenuation in
the controller output to drive the process to its stability.
characterized by the total action time in minutes per repetition. It is the time in
that in front of a step signal, the final control element repeats the same one
movement corresponding to the proportional action.

The integral control is used to bypass the offset issue (deviation)


permanent of the variable with respect to the setpoint of the band
proportional. The formula of the integral is given by:
t

I=K
salt ie∫ ( τ ) dτ
0

Where:

K iit is the overall gain, an adjustment parameter.

τ 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:

K d is the derivative gain, an adjustment parameter

t it is the time or instant time.

Señal de referencia y señal de error

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

It is a special control task that consists of adapting the variable parameters of


a process to maintain the proper functioning of a system

If a control system changes its behavior due to changes in the


process parameters, so someone must adjust them through control
adaptive, which adapts parameters, gains which can change, by
example, with environmental changes.

Because without adaptation, most control systems do not work.


adequately. Because despite the variations in the characteristics of the process, the
control, adapting to maintain stable operation, that is to say so good
as possible.

Adaptive control can be represented in the form of a block diagram of the


the following way:

The adaptive control acts as a secondary control (secondary loop) influencing


to the parameters of primary 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.

The Control with Reference Model is used to achieve acceptable performances.


in those difficult control situations that include cases of variable parameters
in time.

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.

As observed in the figure, the MRAS is made up of three parts:

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:

1. Using sensitivity models


This method was used in the early stages of MRAC development to implement the
first laws of adaptive control.
2. The Lyapunov stability theory
3. The theory of hyperstability by Popov
The last two methods were used later (In the early 1960s despite the fact that
Lyapunov's methods were presented by their author in 1890); these methods
guarantees the stability of the entire system (controller + plant), which them
make particularly interesting, which became design methods
standard.

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.

OBTAINING ADAPTIVE CONTROL LAWS THROUGH THE METHOD OF


LYANUNOV

EXAMPLE: Let the first-order process and the reference model.

Deduce the adaptive law if kl is the variable parameter.

Representing the adaptive control law in a block diagram :

Representing in block diagram the adaptive law setene:


System identification:
The system's response to a unit step
With the help of the PID Tuner, we performed the identification of the parameters of the
PID controller to achieve a satisfactory response from our system.

PID controller data:


Ts=0.02s
Kp=1.553
Ki=10.43
Kd=0.039
We conducted a simulation in Simulink to verify the PID control.
ADAPTIVE CONTROL:
Reference model

δ=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

Response to the system

III. MATERIALS.
DC motor with encoder.
Fig. 1: DC motor with encoder.
ATmega328p (Arduino UNO)

L298

LM016L
LM2907

IV. CIRCUIT PROCEDURE.


Speed sensor:

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.

It should be noted that a filter generates a delay. The filter causes a


slower response to abrupt steps. The purpose of the filter is precisely to eliminate
the peaks and steps of high frequency, which do not provide data, but noise and take a
media with them to show a more real value.
With the obtained data, it was possible to find the required transfer function.
The Matlab tools allow us to obtain the transfer functions of
the systems whose modeling we do not know, that is, a dynamic system. Which
it is useful for the development of controllers.
To design an MRAC controller, the reference model and the law must be defined.
control and the adaptation law. The reference model must be such that the set
plant-controller can reproduce said model.
We observe that the control via MRAC has a more acceptable response than the
PID control in response to constant changes in the reference signal.

You might also like