Optimal PID and fuzzy logic based position controller design of an overhead crane using the Bees Algorithm

Different industrial applications frequently use overhead cranes for moving and lifting huge loads. It applies to civil construction, metallurgical production, rivers, and seaports. The primary purpose of this paper is to control the motion/position of the overhead crane using a PID controller using Genetic Algorithms (GA) and Bee Algorithms (BA) as optimization tools. Moreover, Fuzzy Logic modified PID Controller is applied to obtain better controller parameters. The mathematical model uses an analytical method, and the PID model employs Simulink in MATLAB. The paper presents the PID parameters determination with a different approach. The development of membership functions, fuzzy rules employ the Fuzzy Logic toolbox. Both inputs and outputs use triangular membership functions. The result shows that the optimized value of the PID controller with the Ziegler-Nichols approach is time-consuming and will provide only the initial parameters. However, PID parameters obtained with the optimization method using GA and BA reached the target values. The results obtained with the fuzzy logic controller (0.227% overshoot) show improvement in overshoot than the conventional PID controller (0.271% overshoot). The mathematical model of the overhead crane was successfully developed using Lagrange’s Equation of motion. The Simulink model of the transfer function obtained from mathematical equations is done using MATLAB. The PID control parameters optimization uses well-known algorithms (GA and BA), and a Fuzzy Logic Controller is used to obtain a better control result. The mathematical model of the overhead crane was successfully developed using Lagrange’s Equation of motion. The Simulink model of the transfer function obtained from mathematical equations is done using MATLAB. The PID control parameters optimization uses well-known algorithms (GA and BA), and a Fuzzy Logic Controller is used to obtain a better control result.


Introduction
Overhead cranes are used repeatedly in different industrial applications to transport huge loads in horizontal (moving) and vertical (lifting) directions. It applies to civil construction, metallurgical production, rivers, and seaports. It provides ascent or descent of cargoes and their distance shifting using hoisting and traveling devices [1]. The parts of the overhead crane system consist of the following parts: 1. Trolley (the main part of the crane which contains the driving motor), 2. Girder (the guide for traversing motion), 3. Traveler (the guide for traveling motion), 4. Cable (used in lifting and lowering motion which contains a hook) and 5. Load to be lifted/payload/. Figure 1 presents the structure of a three-dimensional industrial overhead crane system and its schematic representation [2]. Overhead cranes attain three different motions: Traversing, Traveling, and Hoisting/Lowering. Transporting the loads quickly to the desired position without oscillation or swing is the primary goal of the controlling unit. In transporting loads, the rope length and lifted load mass often change accordingly due to transportation tasks. Due to this, the oscillation was quickly created in the system while lifting the load horizontally. The motion of the trolley, the length of the cable, the load to be lifted, and external interferences such as friction and wind force will affect the swinging motion and positioning performance of the control system for the crane. Therefore, it is necessary to design a controller that can reduce or suppress the uncertainty of the system.
Optimization tool applied by researchers to non-linear model predictive controller [3], new variable structure control using meta-heuristics algorithms for frequency regulation [4], Energy Management of Controllable Loads New Supervisor Fuzzy Nonlinear Sliding Mode Control [5] and Predictive Controller for LFC of Nonlinear Multi-area Power System with Energy Storage Devices [6].
Moreover, many researchers tried to overcome the problem by designing different effective and efficient controlling systems. The modeling and control of the swinging effect of the three-dimensional overhead crane using state feedback control in discrete time to obtain highperformance swinging motion at high speed have been studied [7]. A detailed review of the control strategies of cranes (2000)(2001)(2002)(2003)(2004)(2005)(2006)(2007)(2008)(2009)(2010)(2011)(2012)(2013)(2014)(2015)(2016) was conducted [8]. In their paper, they have presented the different methods used for controlling the crane. A new anti-swing control scheme has been designed [9], based on the Lyapunov stability theorem, consisting of a feed-forward control and a non-linear PID control with gravity compensation. Partial feedback linearization control, which uses a swing-suppressing element, has been developed and checked experimentally for anti-swing control of overhead cranes [10]. Anti-sway control using PID controller has been investigated [11], and the development and management of Gantry Crane System using the Robust and State feedback controllers [12]. In addition, the study of the feedback control system investigated by researchers [13,14], and real-time trajectory control of an overhead crane using servo-constraints [15], and the optimal performance control mechanisms by optimizing the control parameters [16].
Furthermore, the effects of external disturbances and time-varying parameters on a flexible system have been studied [17]. The control system was designed based on the adaptive feedback control and predictive unity magnitude shaper system using the NNUMZV-APIDLNN algorithm. Moreover, some researchers present the study of the Fuzzy and LQR-PID controllers for anti-swing control of overhead cranes [18], the Harmony Search radial basis function neural network algorithm for optimal anti-swing motion trajectory [19], the differential evolution (DE) algorithm based fuzzy logic for PID optimal parameters [20], the PSO algorithm for PID-PD parameters optimization [21], and the Riccati discrete-time transfer matrix method of a multibody system (MS-RDTTMM) for control design of overhead motion [22].
Despite the PID controller, some researchers apply the Fuzzy logic controller to overcome the motion of cranes. [23] studied the application of a Fuzzy logic controller (FLC) fewer rules for moving the overhead crane in the desired way by ensuring swing-free payload motion. A two-rule base FLC, one for displacement control, the other for swing control, was designed and implemented. The FLC result shows that the motion of the overhead crane is smooth, and the control result shows no overshoot. An alternative method for studying the dynamic model and anti-swing motion control of two-dimensional overhead cranes was proposed by [22]. The paper describes an efficient method called the Riccati discrete-time transfer matrix of a multibody system (MS-RDTTMM). Then, positioning and anti-swing control use three separate fuzzy logic controllers. In addition, tuning the initial control parameters uses a Genetic Algorithm. The result shows that the computational efficiency, numerical stability, and control performance are greatly improved.
Shao et al. [24] investigate the non-linear and uncertainty of the dynamic model of the overhead crane with Takagi-Sugeno (T-S) fuzzy modeling and PSO-based robust linear quadratic regulator (LQR). In addition to [25], the comparative analysis of Neural-Network and Fuzzy Auto-Tuning sliding mode controls overhead cranes under payload and cable variations. The proposed control methods are simple, feasible, and robust-finally, a series of numeral simulations for testifying the effectiveness of the methods.
This work aimed to develop a mathematical model using Lagrange's equation of motion. Then the motion of the overhead crane is controlled using a PID controller and a fuzzy logic controller. The PID controller parameters are optimized using the Bees Algorithm and GA. The paper has four sections: the introduction presets previous works in the area and the objectives of the current work, and then the mathematical modeling and the design of PID control in the method part. The results of optimization, PID controller, and fuzzy logic controller are in the result section, and finally, in the last section, the conclusion is presented.

The mathematical model of overhead crane
The schematic representation of a two-dimensional overhead crane system is shown in Fig. 2, assuming only twodimensional motions (i.e., vertical and horizontal motions). Here, F t − represents the actuating force acted on the trolley by the motor; x− is the horizontal position of the trolley; x l and y l − are the horizontal and vertical positions of the load to be lifted, respectively. m t and m l − are the mass of the trolley and the load, respectively;l− is the length of the cable; θ− is the swing angle of the load; and g − denote the gravitation acceleration.
Assumptions used in the development of mathematical equations: • The motion of the overhead crane is limited to only two-dimensional motion. The third motion is ignored from analysis because the crane can move either traversing or traveling motion at a time. • The deflection of the girder beam is not considered in this study and is assumed to be rigid. • The mass and deflection of the cable are also assumed to be very small and neglected. Thus, the length of the rope remains constant during the moving process of the trolley. • The external effects: friction, wind effects on both trolley and load were considered in this study, as shown in Fig. 2. • By assuming the swinging angle as minimal, the approximation of trigonometric functions sinθ ≈ θ, cosθ ≈ 1, θ̇θ 2 ≈ 0. , is applied.
• The load to be lifted and the trolley is assumed to be a point mass.
Thus, to drive the equation of motion of the given system, let us use the generalized Euler-Lagrange equation: Thus, the two kinetic energy equations of the 2D overhead crane system are the kinetic energy of the trolley in Eq. 5 and the kinetic energy of the lifted load in Eq. 6.
From the geometry of the given system, the position and the velocity are: Moreover, the potential energy of the system is: The determination of Lagrange's Parameter requires the substitution of Eqs. (9, 10) into Eq. (2): The partial derivatives of Lagrange's Parameters are: Moreover, let us assume the force applied to the system to be: Substituting the above parameters into Euler-Lagrange Eq. (1), gives two equations: The matrix form of the equation of motion is: where, B t − the damping coefficient due to friction between the trolley and the air.
B l − the damping coefficient due to friction between the lifted load and the air.
For small swing, let us assume the approximation of trigonometric functions sinθ ≈ θ, cosθ ≈ 1, θ̇θ 2 ≈ 0. Thus, the equation of motion of the system will be: To obtain the transfer function of the linearized system of equations analytically, we must first take the Laplace transform of the system equations.
Assume that all of the initial conditions are zeroes, so these equations represent the location of the crane/trolley is at the left end of the beam. Thus, the Laplace transform of the Eqs. (17) and (18) can be:

Numerical values
The numerical values of the overhead crane parameters should be specified to simulate the transfer function in MATLAB Simulink. Accordingly, the following values are assumed for numerical purposes only.

Design of PID controller
There are several methods for designing PID controller parameters: proportional gain K p , integral time K i , and derivative time K d . One of the simplest methods is known as the Ziegler-Nichols rule [26] for tuning PID controller parameters based on the transient-response characteristics of a given plant. Ziegler-Nichols tuning rules aim at obtaining a 25% maximum overshoot in the step response, as shown in Fig. 3. The PID controller tuned by the Ziegler-Nichols method gives: However, the Ziegler-Nichols rule for tuning PID controller parameters (Table 1), is time-consuming and will provide only the initial parameters (25% maximum overshoot in the step response). Nowadays, different algorithms will optimize the PID parameters with the help of programmable software like MATLAB. In this study, optimization of the PID parameters uses the Bees and GA algorithms. The objective function used to determine the PID parameters is to minimize the transfer function:

PID controller result
The position control of the overhead crane, both in a horizontal and angular direction, was done using different methods. First of all, the Ziegler-Nichols approach is applied to find the PID parameters. The MATLAB code produced for the objective function of the overhead crane's horizontal and angular motions was applied to optimize the PID parameters using the Genetic Algorithm and the Bees Algorithm. Table 2 summarizes the control results obtained with these different methods for controlling the horizontal motion of the overhead crane. Ziegler-Nichols's approach provides initial PID parameters, later modified with other methods. However, optimization techniques are used for the improvement of the result effectively. The rise time and overshoot decreased when GA and the Bees Algorithms. Finally, fine-tuning/manual techniques were applied to obtain a more realistic value, which gives a result nearest to the target value. For comparison purposes, Fig. 6 presents the control result of four methods. Ziegler-Nichols's approach provides initial PID parameters, the poor result among the tested methods. The results were modified when the PID parameters were optimized using the Bees Algorithm and the Genetic Algorithm. Applying fine-tuning to the GA and the Bees Algorithm parameters result in a better outcome. Therefore, optimizing the PID parameters using the earlier algorithms is advisable to obtain a better control system.

Controlling of the angular/swinging motion ( -motion) of overhead crane
Similarly, the horizontal motion of the crane, the angular or swinging motion, is controlled with a PID Controller, as shown in Fig. 7. Tuning of PID parameters is obtained with GA using the optimization toolbox in MATLAB. The results were Kp = 5.8757e-05, Ki = 3.2605e-04, Kd = 7.3272e-05. Figure 8 shows the result obtained from the PID controller in Simulink. Figure 8 shows the GA-PID swinging motion control of the overhead crane. The overshoot and the rise time are approximately 0% and 0 s, respectively.

Application of fuzzy logic controller
Fuzzy logic is an artificial intelligence method that fuzzy membership functions that define some or all input and output parameters. Here, a fuzzy model uses the errors taken from the PID controller used to control the position of the overhead crane.
Chao et al. [27] present the equivalence between fuzzy Proportional-Integral-Derivative (PID) Controllers and Conventional PID Controllers. The paper proposes the transformation of a well-designed conventional PID Controller to an equivalent fuzzy logic controller (FLC) by observing and designing the operating ranges of the input/output of the controller. The result shows that FLC yields more satisfactory system responses efficiently.
Chao et al. [27] states the PID parameters have no relation with the number of membership functions but are strongly correlated to the operating ranges of the control input/output. Accordingly, the linear PID controller parameters can be:

Input parameters and operating ranges for horizontal motion of crane
To establish the operating ranges of the Fuzzy Membership Functions for error, integral error, and derivative (30) K P = a u 3a e , K I = a u 3a i and K D = a u 3a d −a e , a e − the operating range for the error e(t) −a i , a i − the operating range for the integral error ∫ e(t)dt −a d , a d − the operating range for the derivative error de(t) dt −a u , a u − the operating range for the system output error, we will examine the error signal graph for horizontal motion given in Fig. 9

Input parameters and operating ranges for swinging/ angular motion of crane
The operating ranges of the fuzzy membership functions for error, integral error, and derivative error may be determined by carefully observing the error signal graph  Fig. 10. The graph indicates that the approximate value of a e is 5.8708 e-05%, insignificant. Accordingly, the operating ranges can be calculated by using the above equation and using the PID controller parameters as: Kp = 5.8757e-05, Ki = 3.2605e-04, Kd = 7.3272e-05

Fuzzification
Low, Medium, and High are the three fuzzy sets of the input parameters of the horizontal motion and the output variable fuzzified into seven fuzzy sets. In angular motion, the five fuzzy sets of input parameters are Very Low, Low, Medium, High, and Very High, and the output variable is fuzzified into 13 fuzzy sets, as shown in Fig. 11. Therefore, the horizontal motion input parameters have three triangular membership functions and seven triangular-shaped

Fuzzy rules
The organization of the fuzzy rule base is a group of IF-THEN statements for both horizontal and angular motion. Three input variables (error, integral error, and derivative error) divided into a three-membership function (Low, Medium, and High) make 27 fuzzy rules for horizontal motion. Three input variables (error, integral error, and derivative error) divided into a five-membership function (V. Low, Low, Medium, High, and V. High) make 125 fuzzy rules for angular motion. The AND (min) operator combines the antecedent parts of the rules. For the implication method, to correlate the rule consequent with its antecedent, min was used.
The first rule of the FIS of the horizontal motion is Rule 1: IF input1 is Low and input2 is Low, input3 is Low, THEN output1 is mf1. In terms of actual variables, Rule 1 can be: "IF error is Low and integral error is Low and derivative   Similarly, the first rule of the FIS for angular motion is "Rule 1: IF input1 is Very Low and input2 is Very Low, and input3 is Very Low, THEN output1 is mf1. " In terms of actual variables, Rule 1 is: "IF error is V. Low and integral error is V. Low and derivative error is V. Low THEN the total error is V. Low. " Similarly, the output membership function generates 125 fuzzy rules.
This study uses the centroid defuzzification method for both motions, which considers the center of an area of the possibility distribution of the inference output. Figure 12 shows the result of the fuzzy logic design for horizontal and angular motions. Results show that the fuzzy logic design of both horizontal and angular motions is highly affected by the operating range of the input and output variables. However, the number of membership functions does not affect the design of the Fuzzy Logic system.

Fuzzy PID control system for horizontal motion
After designing Fuzzy Logic, the.fis file constructs the Simulink model of the horizontal motion as shown in Fig. 13  The results obtained from the Fuzzy modified PID controller are better than conventional PID controller in overshoot, settling time, and raising time. In the FLC modified PID controller of the horizontal motion, the overshoot equals 0.227%, smaller than the conventional PID controller.

Fuzzy PID control system for angular motion
The fuzzy.fis file constructs the Simulink model of the angular motion as shown in Fig. 15 and the results in Fig. 16. The results obtained from the Fuzzy modified PID controller are better than the conventional PID controller in overshoot, settling time, and raising time for the angular motion. In the Fuzzy Logic modified PID Controller, the overshoot is equal to zero for angular motion. Table 3 shows the fuzzy logic and the conventional PID controller results for horizontal and swinging motion of overhead cranes. In conclusion, the Fuzzy Logic Controller shows a better performance than the conventional PID controller.

Conclusion
This paper discusses overhead cranes' mathematical modeling and position control using GA and the Bees Algorithm-optimized PID controller. Moreover, the Fuzzy Logic Controller was applied to control the horizontal and swinging motion of the overhead crane. The mathematical modeling of the overhead cranes uses Lagrange's Approach. The mathematical equations developed were converted into a Transfer Function to apply the control methods. The PID controller parameters were first determined using the recommendation of Ziegler-Nichols Tuning Rules. Ziegler-Nichols Tuning provides initial values that provide poor control results. The use of GA and the Bees Algorithms provides the best PID control parameters. GA performs a 23.26% overshoot, and the Bees Algorithm achieves a 36.5% overshoot, a better result than Ziegler-Nichol's methods (69.36% overshoot). As a result, the controlled position of the horizontal motion has lower overshoot, slower rising time, and settling time. However, the finetuning method/trial and error method (0.271% overshoot) gives a better result because it uses the results obtained from optimization techniques. However, the fuzzy logic  controller provides a better result (0.227% overshoot for horizontal motion and 0.176% overshoot for angular motion) than the conventional PID methods. Therefore, the Fuzzy Logic Controller shows better performance than the conventional PID controller. The operating range of the input and output variables highly affects the fuzzy logic control system design. However, the number of membership functions does not affect the design of the FLC. The paper was limited to only single values of overhead crane parameters and recommended using different parameters of overhead cranes to obtain a better controller result. Finally, different mechanical systems problems need the application of these algorithms as an optimization.

Conflict of interest
The authors declare that they have no conflict of interest.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright