A PID-Type Fuzzy Logic Controller-Based Approach For Motion Control Applications
A PID-Type Fuzzy Logic Controller-Based Approach For Motion Control Applications
Article
A PID-Type Fuzzy Logic Controller-Based Approach
for Motion Control Applications
José R. García-Martínez 1,† , Edson E. Cruz-Miguel 1,† , Roberto V. Carrillo-Serrano 1,† ,
Fortino Mendoza-Mondragón 2,† and Manuel Toledano-Ayala1,†
and Juvenal Rodríguez-Reséndiz 1, *
1 Facultad de Ingeniería, Universidad Autónoma de Querétaro, Querétaro 76010, Mexico;
[email protected] (J.R.G.-M.); [email protected] (E.E.C.-M.); [email protected] (R.V.C.-S.);
[email protected] (M.T.-A.)
2 Laboratorio de Investigación en Control Reconfigurable, Querétaro 76120, Mexico; [email protected]
* Correspondence: [email protected]; Tel.: +52-442-192-1200
† These authors contributed equally to this work.
Received: 14 August 2020; Accepted: 14 September 2020; Published: 17 September 2020
Abstract: Motion control is widely used in industrial applications since machinery, robots,
conveyor bands use smooth movements in order to reach a desired position decreasing the steady
error and energy consumption. In this paper, a new Proportional-Integral-Derivative (PID) -type
fuzzy logic controller (FLC) tuning strategy that is based on direct fuzzy relations is proposed in
order to compute the PID constants. The motion control algorithm is composed by PID-type FLC
and S-curve velocity profile, which is developed in C/C++ programming language; therefore, a
license is not required to reproduce the code among embedded systems. The self-tuning controller is
carried out online, it depends on error and change in error to adapt according to the system variations.
The experimental results were obtained in a linear platform integrated by a direct current (DC) motor
connected to an encoder to measure the position. The shaft of the motor is connected to an endless
screw; a cart is placed on the screw to control its position. The rise time, overshoot, and settling time
values measured in the experimentation are 0.124 s, 8.985% and 0.248 s, respectively. These results
presented in part 6 demonstrate the performance of the controller, since the rise time and settling
time are improved according to the state of the art. Besides, these parameters are compared with
different control architectures reported in the literature. This comparison is made after applying a
step input signal to the DC motor.
Keywords: fuzzy control; robot; PID controller; S-curve motion profile; applied artificial intelligence
1. Introduction
Linear motor motion controllers are presented in many industrial applications, including sliding
door closers, assambly, conveyor systems, electronic manufacturing, material handling, industrial
test, and robotic applications [1]. Motion control is a sub-field of automation that involves controlling
mechanical movements of load and it is applied directly to the actuator to manage physical variables,
such as torque, acceleration, velocity and position of an axis or axes, depending of the degree of
freedom (DoF) of the system [2]. Motion control is applied to avoid the stress that is produced by a
fast movement and to reduce the vibrations that are caused by the high rate of change in acceleration;
also, trajectories are created to reach a desired position that the actuators must achieve [3,4]. Most
commercial motion controllers that are available for industrial processes are based on classic controllers,
such as Proportional-Integral-Derivative (PID) controller, and they are of closed architecture [5].
The radical advances in technology have changed human life perception and intensified the
problem of man-machine interaction with the use of intelligent control algorithms that are capable of
translating human behavior into numerical representation applied to industrial applications. In 1965,
Zadeh proposed a theory of creating and processing models that are similar to those used by a human
brain, called fuzzy logic (FL) [6]. This theory was never intended for use in control systems. FL tries to
emulate the imprecise human reasoning of physical processes into information that is capable of being
handled by an embedded system or computer [7]. The FL has been judged over the years, because of its
ability to face the complex problems with no models needed. Furthermore, FL has been implemented
in problems where it was believed to be impossible to find a solution [8]. The logic applied to fuzzy
systems consists of sets; a fuzzy set is a class of objects with a continuum of grades of membership,
whereas a classic set is composed by true or false values [9].
FL-based controllers are more flexible and complex than PID controllers, since they cover a broader
range of operating conditions and they can work with inner and external disturbances of different
natures. The design of fuzzy controllers is easier than developing a model-based controller, and it is
customizable, due to one being able modify the structure, rule base, and display them as a human
being would do to control a system. There are a vast number of applications of FL, such as simplified
control of robots [10], control of car engines [11], cruise-control for automobiles [12], prediction systems
for early recognition of earthquakes [13], anti-lock braking systems [14], renewable energy systems [15],
aircraft engines [16], energy allocation [17,18], demand forecasting [19], predictive maintenance [20],
and material handling [21], just to mention a few.
PID, state-space controllers, artificial neural networks, and FL based controllers are the techniques
applied for motion control. Huang et al. [22] proposed a nonlinear adaptive controller for a linear
position tracking. The end effect of the linear induction motor is used in the design, and the impact
of friction dynamics is considered to design an observer-based compensation to face the friction
force. The results of this work are satisfactory, but the control algorithm was implemented in
MatLab/Simulink, which is a payment program and it is necessary for a license to work with it.
Kung et al. [23] proposed a controller for a two DoF platform based on Field Programmable Gate
Array (FPGA). The proposed motion control has two modules. The first module generates the motion
profiles and a fuzzy controller with 49 rules. The second module performs the functions of two current
vector controllers of permanent-magnet synchronous motor drives. The experimental results reported
good performance in the response of the controller, even with a step signal, but the number of rules
increase the performance capacity.
Boualleégue et al. [24] proposed a strategy to tune a PID-type fuzzy logic controller (FLC) using
the particle swarm optimization (PSO) algorithm. The scaling factors are used as constraints of the
optimization algorithm. The PID-type FLC presents a suitable response using nine rules for the
inference system. The convergence of the cost function satisfies the design parameters established,
it converges with only 30 iterations. The paper present two disadvantages, a Matlab/Simulink license
is required to implement the algorithm and the controller tuning is offline.
Bassi et al. [25] developed a self tuning PID controller while using the PSO algorithm. The reported
results show its performance as compared to a PID controller tuning by the Ziegler-Nichols method,
which is an empirical approach. The PSO algorithm is used to compute the controller gains minimizing
a cost function compund by the integral absolute error (IAE), integral square error (ISE), and integral
of time multiplied by absolute error (ITAE). The results that are presented in this paper are simulations
without experimental results displayed. Khan et al. [26] designed a 49-rules FLC using the genetic
algorithm (GA) to optimize the membership functions, FL rules, and scaling gains. The GA is
implemented offline to obtain the design parameters, Matlab/Simulink is used for simulation. When
the controller parameters are well defined the M-files, generated by Matlab, are translated into C/C++
language to be programmed in a microcontroller to control a DC motor.
A PID-type FLC is proposed by Fereidouni et al. [27]. The configuration developed is this
paper is called adaptive, because the scaling factors at output are dynamically tuned while the
Sensors 2020, 20, 5323 3 of 19
controller is functioning. To update the denormalization factors, a stochastic hybrid bacterial foraging
particle swarm optimization algorithm is used. Furthermore, several control architectures are reported.
Simulation results are only proposed using a database of 49 rules. In [28], Bejarbaneh et al. submitted
an adjusting technique for a PID-type FLC based on an hybrid PSO search algorithm called PSOSCALF.
The controller is applied to an inverted pendulum. The design of the PID-type FLC is based on 25
rules to compute the control signal. The simulation results demonstrate that this algorithm can be well
used in non-linear plants, since the control law is obtained considering the problem as an optimization
one. A possible disadvantage of these kinds of combinations, optimization algorithms, and FLC is
that the control signal can be trapped in a local minimum due to this being a inner characteristic
of the evolutionary algorithms or optimization algorithms [29,30]. On the other hand, the design
and simulation of a self-tuning PID-type FLC for an expert heating, ventilating, and air-conditioning
(HVAC) system is reported by Soyguder et al. in [31].The models of the variable flow-rate HVAC
system are generated using Matlab/Simulink. In this paper, three rule bases are proposed for the
variables K p , Kd and Ki . Each rule base is composed by 25 rules, in terms of processing this is a
disadvantage, since three deffuzification stages are evaluated.
In this paper a PID-type FLC is developed and implemented in a linear platform. The control
algorithm has the ability to adapt itself according to the system variations. On the other hand, the fuzzy
controller can be implemented in a low-cost embedded system, since the code it is easy to modify
and adapt. The control algorithm is programmed in C/C++, it means that a license is not required
to reproduce it. Furthermore, a profile generator is developed to design smooth trajectories that the
chart must follow. The article is divided into the following sections: Sections 2 and 3 present a FL
and S-curve motion profile background, respectively. In Section 4, the PID-type FLC is designed.
Section 5 presents a design methodology to implement the control algorithm based on user experience.
The results and discussion are written in Section 6. Finally, the conclusion is presented in Section 7.
Given two fuzzy sets à and B̃, Ã, B̃ ⊆ X, with the membership functions µ à ( x ) and µ B̃ ( x ),
the intersection à ∩ B̃ is expressed in Equation (3).
For fuzzy union, the fuzzy sets à and B̃, Ã, B̃ ⊇ X, with the membership functions µ à ( x ) and
µ B̃ ( x ), the union à ∪ B̃ is expressed in Equation (4).
A generalization of n-ary fuzzy intersection, Ã ∩ B̃, where R̃ and S̃ are fuzzy relations,
R̃, S̃ ⊆ X1 × X2 × ... × Xn is given by Equation (5). Similarly, the union of two fuzzy sets, R̃ ∪ S̃,
for n-ary fuzzy relations is given by the relation of R̃ and S̃, R̃, S̃ ⊆ X1 × X2 × ... × Xn . Equation (6)
represents the union of several fuzzy sets.
From a to b, the triangular function is drawn. When µ( x ) = m the unit is reached. In symmetric
functions m represent the middle point. The trapezoidal membership function has an interval where
µ( x ) is constant and its membership degree is one. It is considered as a generalization of the triangular
membership function and it is applied in systems where there is a range of optimal values, around
which the conditions are not suitable. Equation (9) describes the trapezoidal function.
x−a
b− a x ∈ [ a, b]
1 x ∈ (b, c]
µ( x ) = x −d (9)
x ∈ (c, d]
d−c
0 other values
In this case, a and d are the values on which the function is depicted. On the other hand, b and c
are the limits where µ( x ) is the unit. For x values out the range [a, d], the membership function is equal
to zero. The Gaussian membership function transforms the crisp values into a normal distribution
Sensors 2020, 20, 5323 5 of 19
and its middle point determines an ideal set, which is assigned a one. The degree of membership of
the rest of the input values decreases as they move away from the midpoint, both in the positive and
negative directions. This function is useful whether the membership degree is close to a specific value.
The Gaussian function has similar behaviour than the triangular function, the difference is that the first
one is used when it is required that the membership degrees have slow variations [35]. Equation (10)
is used to compute the membership degrees of the Gaussian function.
2
µ ( x ) = e−k( x −m) (10)
where m is the middle point, k must be greater than 0 (k > 0), and negative values are not allowed.
• The fuzzifier transforms a crisp value into a fuzzy value. The information can be presented in a
discrete form while using the fuzzy sets. The discretization process performs a scale mapping to
transform values measured in the variables to values of the discrete universe, either uniformly or
non-uniformly, or a combination of both.
• When the system states are available for measurement and control, the rule base are written
in terms of the state variables instead of error and its derivatives [36]. In general terms, this
stage contains all of the information of the application to be controlled, as well as the goals of
the controller.
• The inference engine combines the fuzzy if-then rules for mapping the set à from the controller
input space A to a fuzzy set B̃ in the controller output space B using the production rules and the
knowledge base of membership functions. All of the fuzzy rules are combined in a single fuzzy
relation using Equation (7).
• The defuzzification module changes from one domain to another the sets. It means that the fuzzy
numbers are transformed into crisp values according to the method to use. In the literature, there
exists several ways to map from one domain to another. Once the crisp number is obtained, it is
sent to the electronic interface to send it to the actuator.
Defuzzifier
Inference + 𝑢(𝑡)
Engine
𝑒(𝑡) +
𝑑
𝑑𝑡
3. S-Curve Profile
This section presents the background of the S-curve velocity profile. In Figure 2, the position,
S-curve velocity profile, trapezoidal acceleration, and square jerk are displayed. As is well known,
the S-curve is a seven-segment profile, where the total time displacement can be symmetric or
Sensors 2020, 20, 5323 6 of 19
asymmetric distributed. The acceleration and deceleration phases have the same length of time,
Tacc = Tdec and they are represented by three stages. The design of a trajectory is based on the desired
position Θd and the time displacement T. The maximum velocity reached by the profile is computed
in Equation (11).
Θd
Ωmax = (11)
(1 − Ψ ) T
Magnitude
Magnitude
Jerk
Aceleretion
Velocity
Position
Time [s]
The constant factor Ψ is proposed in order to vary the duration of acceleration phase Tacc = ΨT,
which is limited by 0 ≤ Ψ ≤ 21 . The maximum magnitude of the acceleration is obtained from
Equation (12). In Figure 2, one can notice that the jerk shape is modeled by a square signal placed
upon the acceleration variations.
Θd
Amax = (12)
Ψ(1 − Ψ)(1 − η ) T 2
where η is a constant factor used to calculate the length of the jerk pulse, Tjerk = ηTacc . The duration of
Tjerk must be less than Tacc to ensure continuity. The constant jerk value is calculated in Equation (13).
Θd
Jmax = (13)
Tjerk Ψ(1 − Ψ)(1 − η ) T
Once the jerk constant value is computed, the acceleration can be calculated for any instant of
time while using the Euler integral method of the Equation (14).
Z T
A ( t ) = A ( t − 1) + Jmax (t)dt (14)
t
The desired position is reached integrating the velocity. The Equation (16) is used to compute
the position.
Z T
Θ ( t ) = Θ ( t − 1) + Ω(t)dt. (16)
t
Sensors 2020, 20, 5323 7 of 19
Rule Base
Fuzzifier Defuzzifier
Inference 𝐾
*
Engine
+
Rule Base + 𝑢(𝑡)
Plant
𝑦(𝑡)
𝑟(𝑡) 𝑒(𝑡) Fuzzifier Defuzzifier
+
- 𝑑 𝐾
Inference *
𝑑𝑡 Engine
The labels of the linguistic-values are presented in Table 1 with their respective ranges.
Seven-linguistic-values are selected to compute the K p and Kd gains.
Table 1. Linguistic values for range of error and the derived of error.
Label Linguistic Value Range for Error (m) Range for d-Error (m/s)
NB Big Negative [−1, −0.5] [−10, −3.50]
NM Medium Negative [−0.75, −0.25] [−10, −0.50]
NS Small Negative [−0.50, 0] [−5, 0]
ZE Zero [−0.50, 0.50] [−2.50, 2.50]
PS Small Positive [0, 0.50] [0, 5]
PM Medium Positive [0.25, 0.75] [0.5, 10]
PB Big Positive [0.50, 1] [3.50, 10]
Figure 4 presents the linguistic variable of the error and change of rate in error; they are composed
by seven-linguistic-values.
Figure 4a presents an interval that goes to [−1, 1] m for error, this range is sufficient, since a
trajectory is applied and the variation tends to small values upon the set point, also a step input can
be applied among this interval. The linguistic variable, that represent the change of rate of error is
depicted in Figure 4b and its domain goes to [−10, 10] m/s, this range of values are selected since the
change of rate in error can present a high magnitude if a step input is applied. Both of the variables are
composed by triangular and gaussian membership functions.
Sensors 2020, 20, 5323 8 of 19
(a)
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
(b)
Figure 4. Linguistic variables (a) error and (b) derived of the error.
Figure 5a shows the range of values that the K p variable can take. Notice that these parameters
cannot present negative values. K p can be computed in a range of [0.5, 10], according to the measured
error. On the other hand, Kd has values from a small range [0.0, 0.5]. This consideration is proposed,
since the Kd gain in a PID controller can increase the error variation and make unstable the system.
0.8
u(Kd)
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6
Kd
(a) (b)
Table 2 presents the location of the singletons used to calculate the controller gains and their
respective linguistic values.
Table 3 displays the rule base used for the computation of the controller gains. The total number
of rules used for computing K p and Kd gains is seven. Besides, one can see in Table 3 the relationship
Sensors 2020, 20, 5323 9 of 19
between the measured input signal, with its respective linguistic variables, and the output relationship.
The inference process corresponds to a one-to-one relationship. Furthermore, it can be seen that
four-input linguistic variables NM, NS, PS, and PM point to a single output variable S. These fuzzy
relationships are used in order to ensure that the earnings values work on a range of adequate values.
Kp Kd
if e(t) is NB, then K p is B if de(t) is dNB, then Kd is dB
if e(t) is NM, then K p is S if de(t) is dNM, then Kd is dM
if e(t) is NS, then K p is S if de(t) is dNS, then Kd is dS
if e(t) is ZE, then K p is AZ if de(t) is dZE, then Kd is dAZ
if e(t) is PS, then K p is S if de(t) is dPS, then Kd is dS
if e(t) is PM, then K p is S if de(t) is dPM, then Kd is dM
if e(t) is PB, then K p is B if de(t) is dNB, then Kd is dB
The singleton is used as a membership function in the defuzzification stage to reduce the
computational cost at the moment to compute K p and Kd . This is important, since, in the conventional
fuzzy controller, just one defuzzification stage is required, whereas, in this proposal, two defuzzification
stages are implemented to simultaneously compute both controller gains.
Once the values of the relations are founded, Equation (18) is used to transform the fuzzy
set into the crisp value of the control gains. One can see in Figure 3 that K p and Kd values are
independently obtained.
∑ n µ c ( zi ) · zi
K p,d [n] = i=n1 (18)
∑ i =1 µ c ( z i )
where K p,d [n] represents the controller gains, µc (zi ) is the membership degree of the singleton, and zi
is the position of the singleton in the output variables K p and Kd . All of the possible values computed
from K p,d [n] are depicted in Figure 6. The use of gaussian and triangular functions in the fuzzification
stage are considered for approximating the response into a linear representation of all possible values
that the gains must take. Additionally, it can be observed that the gains never present negative values,
even if error is negative.
10 0.5
9 0.45
8 0.4
7 0.35
6 0.3
5 0.25
4 0.2
3 0.15
2 0.1
1 0.05
0 0
-1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1 -10 -7.5 -5 -2.5 0 2.5 5 7.5 10
(a) (b)
5. Design Methodology
The Figure 7 shows the steps to implement the control algorithm based on user experience.
The first step consist of recognizing the parameters of the motor as the maximum voltage, current,
torque, and velocity. In some cases, these parameters are not available; when this happens,
experimentation is required to detect the values to start the system design [5]. When the variables
needed to system design are known, the next step is to select the embedded system to interface the
computer, where is the control algorithm be implemented, and the electronic platform.
Sensors 2020, 20, 5323 10 of 19
Verify that
the control No
signal is
satisfied.
yes
The controller response carry out
the specifications required for the
linear platform.
The next three steps correspond to a loop, which is used to adjust the operation range for the
fuzzification method and select the appropriate membership functions, generally the trapezoidal and
triangular membership functions are used in microcontrollers due to their ease of processing. This is
important, since the controller inputs must be well defined to be capable to perform the signals that
will be mapped to fuzzy values.
The control algorithm is implemented when the ranges of operation are proposed. The algorithm
computes the error and the derivative of error to be used as input to the control system. These signals
are related to generate the system response by the defuzzifier and send it to the embedded system.
The embedded system process the control signal and generates a Pulse-Width-Modulation (PWM)
signal to move the shaft of the motor. The voltage applied to the motor does not have to exceed the
maximum value permitted and proposed in first step. On the other hand, if there is not a control
signal generated, then it is possible that the ranges of operation cannot detect the input signals and
it is necessary to adjust the ranges until the control signal is generated. Finally, if the control signal
presents a response that meets the proposed requirements, those working ranges are maintained and
the control algorithm will find the gain values of the controller.
an encoder with a resolution of 1024 Pulse Per Revolution (PPR). Figure 8 displays the linear platform
used for test the control performance.
A step input signal of magnitude 0.064 m, this value is proposed, since the maximum voltage of
the motor does not be exceed when the algorithm is running, is applied to the system to prove the
controller performance when it is applied to the plant. Furthermore, an integral constant Ki = 3 is
used for the step input signal. Regularly, this type of test signals are the most used to test the response
of the controllers to sudden changes in the reference signal, giving a general overview of what would
happen whether a load is added to the plant. If the controller, which is faced with an aggressive test
input, is not well tuned, the control response would fall into a zone of instability, which could cause
permanent damage to the mechanical and electrical structure. In Figure 9a, it can be observed that
the controller presents a fast response, since the system reaches the steady state in 0.248 s and the
overshoot is 8.985%. Figure 9b shows the error signal and it tends to zero.
0.08 0.07
0.07 0.06
0.06 0.05
0.05 0.04
0.04 0.03
0.03 0.02
0.02 0.01
0.01 0
0 -0.01
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) (b)
Figure 9. PID-like FLC response using a step signal (a) position and (b) error.
The control signal, Figure 10, is the voltage applied to the system. The maximum voltage value
obtained is beneath 24 V. When a controller is applied in a real application, the most important
parameter to limit is the control signal, since, if the system demands a greater quantity of the variable
that is being controlled than allowed, the control algorithm must be capable of protecting itself to
avoid generating values not allowed by the plant.
Figure 11a shows the behaviour of K p gains for a step input signal. The maximum value obtained
is K p = 8.43 and is decreasing until it reaches a constant value K p = 5.06. On the other hand, Kd reaches
a maximum magnitude of 0.225, after that, it tends to converge to zero, since there is not variations in
the shaft of the DC motor.
Sensors 2020, 20, 5323 12 of 19
25
20
15
10
-5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
8.5 0.25
8
0.2
7.5
0.15
7
0.1
6.5
0.05
6
0
5.5
5 -0.05
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) (b)
Figure 11. Controller gains response for the step signal (a) K p and (b) Kd .
Table 4 shows the performance of different control architectures comparing the rise time,
overshoot, and settling time. The response of the PID-type FLC presented in this paper has a fast
response, since the first time the position signal crosses the reference for the first time is in 0.124 s and
the time that it takes for the system to stabilize is 0.248 s.
Work Rise Time (s) Overshoot (%) Settling Time (s) Controller and Tuning
Proposed 0.124 8.985 0.248 PID-like FLC and FL
[26] 0.155 4.84 0.2526 FL and GA
[24] 0.21 15 0.64 PID-type FLC and PSO algorithm
[39] 0.40 1.21 0.61 PID and GA
[40] 0.1790 1 0.2585 Neural network
[25] 0.418 17.4 3.17 PID and PSO algorithm
constant used is Ki = 8. In Algorithm 1, the psudocode is presented to illustrate how the algorithm in
C/C++ language is programmed.
Figures 12a,b present the position and error signals, respectively. For Figure 12a, the position
follows a reference to compare the desired trajectory against the system position. The amplitude error
oscillates between 1.8 × 10−5 and −1.78 × 10−5 m. Note in Figure 12b that the error is zero at 2.65 s.
10-5
0.6 2
1.5
0.5
0.4
0.5
0.3 0
-0.5
0.2
-1
0.1
-1.5
0 -2
0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3
(a) (b)
Figure 12. Motion controller based on PID-like FLC, and S-curve velocity profile implementation,
(a) position and (b) error.
In Figure 13b, the control signal shows a maximum voltage peak of 16 V to achieve the desired
position. The control signal is computed by the PID-like FLC relation of the controller gains. On the
Sensors 2020, 20, 5323 14 of 19
other hand, according to Figure 13a, one can observe that the velocity follows the reference properly,
the maximum velocity computed by the trajectory algorithm is 0.94 m/s.
1 16
Real-vel[m/s]
Sprofile[m/s] 14
0.8
12
0.6 10
8
0.4
6
0.2 4
2
0
0
-0.2 -2
0 0.5 1 1.5 2 2.5 0 0.5 1 1.5 2 2.5
(a) (b)
Figure 13. S-curve velocity profile implementation (a) velocity and (b) control signal.
The controller gains tend to vary according to the error measure and rate of change of error.
The variation when the controller follows as the trajectory oscillates from 3 to 6.5 in magnitude for K p
and from 0 to 0.052 for Kd . Notice in Figure 14 that the controller gains do not have units.
6.5 0.06
6 0.05
5.5 0.04
5 0.03
4.5 0.02
4 0.01
3.5 0
3 -0.01
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
(a) (b)
Figure 14. Real time response of the controller gains (a) Kp and (b) Kd .
In real conditions, the servo systems are in contact with loads that must move smoothly in order
to prevent what they are transporting from falling; for this reason, a cylindrical load of 1.9 kg is added
on the carriage and, thus, prove that the control algorithm complies with the proposed specifications.
In addition, the responses obtained when the load is transported are compared, again the S-curve
movement profile and the parameters that were used in the previous test are implemented, in relation
to when there is no load on the cart. As one can see, the trajectory presented a similar behaviour
in error whether it is compared with the signal from Figure 13b; this means that the controller is
robust and it can adapt itself to variations of the system. The position follows properly the trajectory
proposed, as one can see in Figure 15.
The velocity follows the trajectory properly, as one can see in Figure 16a, in stages when the
acceleration and deceleration are computed, but when it must be constant, the velocity present a
transient response that is induced by the load applied to the shaft of the motor. The control signal
increased up to 23 V and oscillated under this value, as presented in Figure 16b.
Sensors 2020, 20, 5323 15 of 19
10-5
0.6 2
1.5
0.5
0.4
0.5
0.3 0
-0.5
0.2
-1
0.1
-1.5
0 -2
0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3
(a) (b)
Figure 15. Motion controller based on PID-like FLC and S-curve velocity profile implementation
adding a cylindrical load of 1.9 kg, (a) position and (b) error.
1 25
Real-vel[m/s]
Sprofile[m/s]
0.8 20
0.6 15
0.4 10
0.2 5
0 0
-0.2 -5
0 0.5 1 1.5 2 2.5 0 0.5 1 1.5 2 2.5
(a) (b)
Figure 16. S-curve velocity profile implementation adding a cylindrical load of 1.9 kg (a) velocity
and (b) control signal.
One can see in Figure 17 that the controller gains contain aggressive oscillations after the load is
applied as compared with the behaviour when no load is added, as in Figure 14, it can be justified
according to the voltage response from Figure 16b.
6.4 0.12
6.2
0.1
0.08
5.8
5.6 0.06
5.4
0.04
5.2
0.02
5
4.8 0
0 0.5 1 1.5 2 2.5 3 0 0.5 1 1.5 2 2.5 3
(a) (b)
Figure 17. Real-time response of the controller gains adding the cylindrical load of 1.9 kg (a) Kp and
(b) Kd .
Sensors 2020, 20, 5323 16 of 19
Table 5 displays a brief comparison of motion controllers presented in the literature. As can be
seen, some authors choose to use Matlab/Simulink and LabVIEW NI for the design of their algorithms,
the problem with using this type of tools is that you must have a license to be able to use the software
in a complete way, increasing the cost, in monetary terms, of the control system and, therefore, the
algorithm is restricted to the use of embedded systems compatible with these programs. The idea of
using a free programming language, which does not need licenses, for the design of motion control
systems makes the system affordable and easy to apply in other programming languages and even
different embedded systems. In this paper, three C/C++ functions were created in order to compute
the motion profile, the membership functions, and PID-type FLC, respectively. Algorithm 1 depicts
the real structure of the motion control algorithm.
7. Conclusions
This paper presented a new low computational cost control algorithm to tune a PID controller to
motion control applications in machinery. The auto-tune algorithm is based on fuzzy logic and it is
straightforward and easy to implement and translate to other computing languages. A linear platform
compounded by a DC motor connected to an endless screw and an incremental encoder is used to
carry out the corresponding tests. The design of the control algorithm is based on user experience, so
one can propose different membership functions for the fuzzyfication stage following the steps that
are presented in Figure 7. The presented results show that the PID-type FLC can modify its gains to
reduce the steady error under the 0.09%, even when a load is applied to the system. When a load of
1.9 kg is added on the cart of the linear platform, the controller presented a similar response in the
velocity and position. The control signal increases its magnitude from 16 to 23 V, but it is still under the
maximum value permitted. On the other hand, the controller gains considerably vary its magnitude,
but, when the system reaches the desired position, both gains tend to the same value obtained when
the system did not present load, K p = 5.2 and Kd = 0.
Author Contributions: Conceptualization, J.R.G.-M. and J.R.-R.; Methodology, J.R.G.-M. and R.V.C.-S.; Software,
J.R.G.-M.; Validation, J.R.G.-M., E.E.C.-M. and J.R.-R.; Formal analysis, J.R.G.-M.; Investigation and Visualization,
J.R.G.-M., E.E.C.-M. and J.R.-R.; Data curation, J.R.G.-M., M.T.-A. and F.M.-M.; Writing—original draft preparation;
Writing—original draft, review & editing, all the authors. All authors have read and agreed to the published
version of the manuscript.
Funding: This research was funded by the “Consejo Nacional de Ciencia y Tecnología (CONACYT)” under the
scholarship 778619. Also, we are grateful to the PRODEP for the partial funding of this paper.
Acknowledgments: We would like to thank the Graduate Studies Division from the Faculty of Engineering at
Universidad Autónoma de Querétaro by allowing me to make Ph.D. studies.
Conflicts of Interest: The authors declare no conflict of interest.
Sensors 2020, 20, 5323 17 of 19
Abbreviations
The following abbreviations are used in this manuscript:
FL Fuzzy Logic
FLC Fuzzy Logic Controller
PID Proportional-Integral-Derivative
PWM Pulse Width Modulation
GA Genetic Algorithm
PSO Particle Swarm Optimization
DC Direct Current
RPM Revolutions Per Minute
PPR Pulse Per Revolution
FPGA Field Programmable Gate Array
ISE Integral Square Error
ITAE Integral of Time Multiplied by Absolute Error
IAE Integral Absolute Error
NB Big Negative
NM Medium Negative
NS Small Negative
ZE Zero
PS Small Positive
PM Medium Positive
PB Big Positive
AZ Almost Zero
S Small
M Medium
B Big
References
1. Gurocak, H. Industrial Motion Control: Motor Selection, Drives, Controller Tuning, Applications; John Wiley & Sons:
Hoboken, NJ, USA, 2015.
2. García-Martínez, J.R.; Rodríguez-Reséndiz, J.; Cruz-Miguel, E.E. A New Seven-Segment Profile Algorithm
for an Open Source Architecture in a Hybrid Electronic Platform. Electronics 2019, 8, 652. [CrossRef]
3. Sabanovic, A.; Ohnishi, K. Motion Control Systems; John Wiley & Sons: Hoboken, NJ, USA, 2011.
4. Heo, H.J.; Son, Y.; Kim, J.M. A trapezoidal velocity profile generator for position control using a feedback
strategy. Energies 2019, 12, 1222. [CrossRef]
5. Martínez, J.R.G.; Reséndiz, J.R.; Prado, M.Á.M.; Miguel, E.E.C. Assessment of jerk performance s-curve and
trapezoidal velocity profiles. In Proceedings of the 2017 XIII International Engineering Congress (CONIIN),
Santiago de Queretaro, Mexico, 15–19 May 2017; pp. 1–7.
6. Chien, C. Fuzzy logic in control systems: Fuzzy logic controller. IEEE Trans. Syst. Man Cybern. Part II 1990,
20, 429–434.
7. Zadeh, L.A. Fuzzy sets. Inf. Control 1965, 8, 338–353. [CrossRef]
8. Roose, A.I.; Yahya, S.; Al-Rizzo, H. Fuzzy-logic control of an inverted pendulum on a cart. Comput. Electr. Eng.
2017, 61, 31–47. [CrossRef]
9. Verbruggen, H.B.; Bruijn, P. Fuzzy control and conventional control: What is (and can be) the real contribution
of fuzzy systems? Fuzzy Sets Syst. 1997, 90, 151–160. [CrossRef]
10. Sharma, R.; Bhasin, S.; Gaur, P.; Joshi, D. A switching-based collaborative fractional order fuzzy logic
controllers for robotic manipulators. Appl. Math. Model. 2019, 73, 228–246. [CrossRef]
11. Chiu, S. Using fuzzy logic in control applications: Beyond fuzzy PID control. IEEE Control Syst. Mag. 1998,
18, 100–104.
12. Boverie, S.; Demaya, B.; Le Quellec, J.; Titli, A. Contribution of fuzzy logic control to the improvement of
modern car performances. Control Eng. Pract. 1993, 1, 291–297. [CrossRef]
13. Preethi, G.; Santhi, B. Study on techniques of earthquake prediction. Int. J. Comput. Appl. 2011, 29, 55–58.
Sensors 2020, 20, 5323 18 of 19
14. Von Altrock, C. Fuzzy logic technologies in automotive engineering. In Proceedings of the WESCON’94,
Anaheim, CA, USA, 27–29 September 1994; pp. 110–117
15. Suganthi, L.; Iniyan, S.; Samuel, A.A. Applications of fuzzy logic in renewable energy systems—A review.
Renew. Sustain. Energy Rev. 2015, 48, 585–607. [CrossRef]
16. Larkin, L.I. A fuzzy logic controller for aircraft flight control. In Proceedings of the 23rd IEEE Conference on
Decision and Control, Las Vegas, NV, USA, 12–14 December 1984; pp. 894–897.
17. Xu, L.; Wang, Z.; Liu, Y.; Xing, L. Energy allocation strategy based on fuzzy control considering optimal
decision boundaries of standalone hybrid energy systems. J. Clean. Prod. 2020, 279, 123810. [CrossRef]
18. Essoufi, M.; Hajji, B.; Rabhi, A. Energy Management Strategy Based on a Combination of Frequency
Separation and Fuzzy Logic for Fuel Cell Hybrid Electric Vehicles. In Proceedings of the International
Conference on Electronic Engineering and Renewable Energy, Saidia, Morocco, 13–15 April 2020; pp. 593–606.
19. Oglu, A.R.B.; Kizi, I.I.T. A Method for Forecasting the Demand for Pharmaceutical Products in a
Distributed Pharmacy Network Based on an Integrated Approach Using Fuzzy Logic and Neural Networks.
In Proceedings of the International Conference on Intelligent and Fuzzy Systems, Istanbul, Turkey,
21–23 July 2020; pp. 998–1007.
20. Frigura-Iliasa, M.; Simo, A.; Dzitac, S.; Frigura-Iliasa, F.M.; Baloi, F.I. Fuzzy-Logic Based Diagnosis for High
Voltage Equipment Predictive Maintenance. In Proceedings of the International Conference on Computers
Communications and Control, Oradea, Romania, 11–15 May 2020; pp. 245–253.
21. Gola, A.; Kłosowski, G. Development of computer-controlled material handling model by means of fuzzy
logic and genetic algorithms. Neurocomputing 2019, 338, 381–392. [CrossRef]
22. Huang, C.I.; Fu, L.C. Adaptive approach to motion controller of linear induction motor with friction
compensation. IEEE/ASME Trans. Mechatron. 2007, 12, 480–490. [CrossRef]
23. Kung, Y.S.; Fung, R.F.; Tai, T.Y. Realization of a motion control IC for X{−}Y table based on novel fpga
technology. IEEE Trans. Ind. Electron. 2008, 56, 43–53. [CrossRef]
24. Bouallègue, S.; Haggège, J.; Ayadi, M.; Benrejeb, M. PID-type fuzzy logic controller tuning based on particle
swarm optimization. Eng. Appl. Artif. Intell. 2012, 25, 484–493. [CrossRef]
25. Bassi, S.; Mishra, M.; Omizegba, E. Automatic tuning of proportional-integral-derivative (PID) controller
using particle swarm optimization (PSO) algorithm. Int. J. Artif. Intell. Appl. 2011, 2, 25. [CrossRef]
26. Khan, S.; Abdulazeez, S.F.; Adetunji, L.W.; Alam, A.Z.; Salami, M.J.E.; Hameed, S.A.; Abdalla, A.H.;
Islam, M.R. Design and Implementation of an Optimal Fuzzy Logic Controller Using Genetic Algorithm; 2008.
Available online: https://thescipub.com/abstract/jcssp.2008.799.806 (accessed on 16 September 2020).
27. Fereidouni, A.; Masoum, M.A.; Moghbel, M. A new adaptive configuration of PID type fuzzy logic controller.
ISA Trans. 2015, 56, 222–240. [CrossRef]
28. Bejarbaneh, E.Y.; Bagheri, A.; Bejarbaneh, B.Y.; Buyamin, S.; Chegini, S.N. A new adjusting technique for PID
type fuzzy logic controller using PSOSCALF optimization algorithm. Appl. Soft Comput. 2019, 85, 105822.
[CrossRef]
29. Baldick, R. Applied Optimization: Formulation and Algorithms for Engineering Systems; Cambridge University
Press: Cambridge, UK, 2006.
30. Foulds, L.R. Optimization Techniques: An introduction; Springer Science & Business Media: Berlin/Heidelberg,
Germany, 2012.
31. Soyguder, S.; Karakose, M.; Alli, H. Design and simulation of self-tuning PID-type fuzzy adaptive control
for an expert HVAC system. Expert Syst. Appl. 2009, 36, 4566–4573. [CrossRef]
32. Silva, I.; Eugenio Naranjo, J. A Systematic Methodology to Evaluate Prediction Models for Driving Style
Classification. Sensors 2020, 20, 1692. [CrossRef] [PubMed]
33. Mu, S.; Goto, S.; Shibata, S.; Yamamoto, T. Intelligent position control for pneumatic servo system based on
predictive fuzzy control. Comput. Electr. Eng. 2019, 75, 112–122. [CrossRef]
34. Mendel, J.M. Uncertain rule-based fuzzy systems. In Introduction and New Directions; Springer:
Berlin/Heidelberg, Germany, 2017; p. 684.
35. Nguyen, A.T.; Taniguchi, T.; Eciolaza, L.; Campos, V.; Palhares, R.; Sugeno, M. Fuzzy control systems:
Past, present and future. IEEE Comput. Intell. Mag. 2019, 14, 56–68. [CrossRef]
36. Mendel, J.M. Explaining the Performance Potential of Rule-Based Fuzzy Systems as aGreater Sculpting of
the State Space. IEEE Trans. Fuzzy Syst. 2017, 26, 2362–2373. [CrossRef]
Sensors 2020, 20, 5323 19 of 19
37. Song, L.; Huang, J.; Liang, X.; Yang, S.X.; Hu, W.; Tang, D. An Intelligent Multi-Sensor Variable Spray System
with Chaotic Optimization and Adaptive Fuzzy Control. Sensors 2020, 20, 2954. [CrossRef]
38. Cruz-Miguel, E.E.; Rodríguez-Reséndiz, J.; García-Martínez, J.R.; Camarillo-Gómez, K.A.; Pérez-Soto, G.I.
Field-programmable gate array-based laboratory oriented to control theory courses. Comput. Appl. Eng. Educ.
2019, 27, 1253–1266. [CrossRef]
39. Neath, M.J.; Swain, A.K.; Madawala, U.K.; Thrimawithana, D.J. An optimal PID controller for a bidirectional
inductive power transfer system using multiobjective genetic algorithm. IEEE Trans. Power Electron. 2013,
29, 1523–1531. [CrossRef]
40. Peng, J.; Dubay, R. Identification and adaptive neural network control of a DC motor system with dead-zone
characteristics. ISA Trans. 2011, 50, 588–598. [CrossRef]
41. Osornio-Rios, R.A.; de Jesús Romero-Troncoso, R.; Herrera-Ruiz, G.; Castañeda-Miranda, R.
FPGA implementation of higher degree polynomial acceleration profiles for peak jerk reduction in
servomotors. Robot. Comput. Integr. Manuf. 2009, 25, 379–392. [CrossRef]
42. Jokić, D.; Lubura, S.; Rajs, V.; Bodić, M.; Šiljak, H. Two Open Solutions for Industrial Robot Control: The Case
of PUMA 560. Electronics 2020, 9, 972. [CrossRef]
43. Ponce, P.; Molina, A.; Tello, G.; Ibarra, L.; MacCleery, B.; Ramirez, M. Experimental study for FPGA PID
position controller in CNC micro-machines. IFAC-PapersOnLine 2015, 48, 2203–2207. [CrossRef]
44. Concha Sánchez, A.; Figueroa-Rodríguez, J.F.; Fuentes-Covarrubias, A.G.; Fuentes-Covarrubias, R.; Gadi, S.K.
Recycling and Updating an Educational Robot Manipulator with Open-Hardware-Architecture. Sensors 2020,
20, 1694. [CrossRef]
c 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access
article distributed under the terms and conditions of the Creative Commons Attribution
(CC BY) license (http://creativecommons.org/licenses/by/4.0/).