{'fraction_non_alphanumeric': 0.027388350917762684, 'fraction_numerical': 0.010044804162451222, 'mean_word_length': 4.630187144019528, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Adaptive Neuro-Fuzzy Control Approach for a Single Inverted Pendulum System

The inverted pendulum is an under-actuated and nonlinear system, which is also unstable. It is a single-input double-output system, where only one output is directly actuated. This paper investigates a single intelligent control system using an adaptive neuro-fuzzy inference system (ANFIS) to stabilize the inverted pendulum system while tracking the desired position. The nonlinear inverted pendulum system was modelled and built using MATLAB Simulink. An adaptive neuro-fuzzy logic controller was implemented and its performance was compared with a Sugeno-fuzzy inference system in both simulation and real experiment. The ANFIS controller could reach its desired new destination in 1.5 s and could stabilize the entire system in 2.2 s in the simulation, while in the experiment it took 1.7 s to reach stability. Results from the simulation and experiment showed that ANFIS had better performance compared to the Sugeno-fuzzy controller as it provided faster and smoother response and much less steady-state error.


INTRODUCTION
Being an under-actuated, non-linear and unstable system, the inverted pendulum (IP) has been examined by many researchers to study the behavior and performance of different and new types of control algorithms [1], [2]. The inverted pendulum has several forms and types where each type has its own characteristics and degree of freedom. The most common types are the single IP, double IP, single rotary IP, and double rotary IP [3]. Even though these types may have different shapes and sizes, their main objective is the same, namely, to balance the whole system. Since the inverted pendulum is a basic form of any advanced balancing systems [4]- [6], its applications widely vary from simple robots like scooters and robot arms, to more sophisticated systems such as satellites and rocket launch [2], [7]- [9].
In general, the inverted pendulum system has two equilibrium points [10], [11]: the stable downward position, which is undesirable as it requires no control input and thus has no value from a control perspective, and the unstable upright position. To stabilize the unstable upright position of the inverted pendulum, an on-going rectifying mechanism is needed to keep the cart moving continuously in a particular way. Therefore, various controlling techniques and algorithms have been applied on the inverted pendulum to achieve a desirable performance [12]. These techniques vary from classical control theories to advanced intelligent controllers. Intelligent control, which is a feasible approach, is achieved by combining an artificial intelligence control methodology, usually fuzzy controller, with another control technique such as

SYSTEM MODEL DESCRIPTION
The inverted pendulum system is considered as a pendulum that is fixed on a pivot placed on a cart, as shown in Figure 1. The cart can only move in a horizontal direction while the pendulum can move in an angular motion around the pivot. The cart mass and pendulum mass are represented by M and m, respectively. The length between the center of the pendulum and the pivot point is denoted as L, while I stands for the inertia of the pendulum. There are two forces acting on the inverted pendulum, which are the external force (F) in the horizontal direction and the gravity force (g) in the vertical direction. The friction coefficient of the cart (b) is also counted, while the friction of the pendulum when rotating can be neglected. Table 1 shows the values of the system's parameters where these specifications are taken from a real inverted pendulum in a laboratory. The inverted pendulum apparatus is the GLIP2001 model developed by Googol Technology Ltd. The apparatus required an external power supply and was connected to a computer. The controller was implemented in MATLAB and was connected to a real inverted pendulum via a DSP-based motion card (GT-400-SV-PCI).  The free body diagram of the inverted pendulum system, shown in Figure 2, was used to obtain the mathematical model. By applying Newton's Second Law of motion, the force applied to the cart and pendulum in the horizontal and vertical axes were found. Since the cart can only move left and right, it will be enough to analyze the force in the horizontal direction for the cart which is For the pendulum, the force will be analyzed in the horizontal and vertical directions, respectively. The force equation in the horizontal and the vertical direction will be Horizontal: The moment of inertia around the center of the bar is determined by the following equation By substituting (2) and (3) into (4) and manipulating the resulted equation, the first dynamic equation of the nonlinear system is The second dynamic equation of the non-linear system can be obtained by combining (1) and (2), which is Since the mathematical model should exactly represent the real system, the assumptions from the real inverted pendulum system are taken into consideration. In the real system, the input of the plant (u) is assumed to be the acceleration of the cart. Therefore, some modifications are needed in the general dynamic equations of the system, as follows: By substituting the values of parameters from Table 1  ISSN: 2088-8708

ADAPTIVE NEURO-FUZZY INFERENCE CONTROL (ANFIS)
ANFIS is a multi-layer feed forward network [20] with supervised learning capability, as shown in Figure 3. It has two optimization technique options for its learning method. It can either use a hybrid method, which consists of back-propagation and least square estimation, or a back-propagation method. The ANFIS model is based on the Takagi-Sugeno (T-S) fuzzy model. Therefore, its output membership functions will be either a constant or a linear. It will also follow the first order T-S model rule which is: If Input 1 = x and Input 2 = y, then Output is z = Ax + By + C (10) where A, B, and C are constant. When the output is constant, it means that the values of A and B are zero.
ANFIS also uses the same principle as Sugeno FIS to determine the number of rules. The number of rules depends on the number of inputs and membership functions used for each input. The number of rules follows the following equation The number of ANFIS rule = (11) where µ is the number of membership functions while u is the number of inputs.
Since there are four inputs (the error of angle, the error of displacement and their rates) in the controller, the number of membership functions will only be two states (Negative and Positive) to avoid rule explosion. Therefore, the number of rules is 4 2 = 16 rules. Generalized bell-shaped membership is chosen since it provides a smoother response for non-linear systems.
To tune the ANFIS controller, an input-output data is needed, where this data provides the required relationship between the acceleration of the cart and the inputs. The input-output data was collected from a closed loop system using an LQR controller. Collecting the data is considered as the first and the most crucial step in the adaptive neuro-fuzzy controller since incomplete or wrong data will lead to unacceptable performance or unstable system. Therefore, in this project, the input-output data were collected in different situations where the initial position of the cart and pendulum were different in each situation. Based on the collected data, the optimization learning method chosen was the hybrid algorithm, while the value of acceptable error and number of epochs was selected to be 0.0001 and 100, respectively. When the structure of the desired neuro-fuzzy was created, the controller started its train which stopped when the error reached the tolerance error or the maximum number of epochs.

RESULTS AND ANALYSIS
The ANFIS controller was implemented in MATLAB using ANFIS editor. In Simulink, the sampling time was set to be 0.01 s in the simulation while it was 0.005 s in the experiment.   Figure 4 shows the structure of the inverted pendulum system in Simulink. The cart was set to track the input when it changed from 0 to 0.2 m at t = 1 s. At the same time, the pendulum should remain near the upright position within the allowable range. The initial conditions of the pendulum and cart were set to be 0. Figure 5 presents the response of the cart and the pendulum in the simulation. Since no input was applied at the beginning and the initial condition of the plant was set to 0, the response of the inverted pendulum system started when the input changed from 0 to 0.2 m at t=1 s. If the cart were to move suddenly to the positive direction, the pendulum would fall to the negative direction since the cart and pendulum were coupled to each other [9]. Therefore, when the cart was set to the positive direction, it would first move to the opposite direction in order to prevent the pendulum from falling before tracking the desired position.  Figure 5(b), it can be seen that the cart needed 1.5 s to reach the desired location, while the angle needed 2.2 s to return back to its upright position, with no steady-state error in both responses. The response of the cart was very smooth with no overshoot. However, the overshoot of the angle was 0.095 rad when input was applied.

Experiment results
The inverted pendulum apparatus mentioned in section 2.1 was used. At the beginning, the pendulum was stable in the downward position. However, the upper angle was initially set to be 0 while the cart position was set to be 0 at the center of the guide rail. The pendulum was raised to the upright position by hand until it reached a suitable range for the controller to start working at ±0.34 rad. The cart was kept moving to stabilize the pendulum while staying in its initial position. It kept oscillating around its initial position while the pendulum oscillated around the upper vertical axis. The system became stable after 1.7 s as long as the oscillation was small and within the allowable range. Figure 6 shows the response of the cart and pendulum in the experiment.  Figure 6(a) shows that the cart was able to reach the desired position in 1.5 s. However, the pendulum needed more time to return to its initial position as it took 1.7 s after the input was applied, as shown in Figure 6(b). Similar to the simulation, there was no overshoot in the response of the cart, but a small steady-state error (S.S.E) occurred (around 1.5%). The S.S.E is still acceptable since it was less than 2%. On the other hand, the angle had a small level of S.S.E of 0.005 rad and an overshoot of 0.08 rad. The comparison of the simulation and the experiment results are shown in Table 2.   Nour et al. (2007) implemented a four-input Sugeno fuzzy inference system to control the inverted pendulum [4]. Similar to the ANFIS controller, they also used two membership functions and 16 rules. The output membership functions were selected to be linear outputs where their parameters were determined using the state feedback equation. The subsequent paragraphs compare the results of both the simulation and experiment

Simulation results
The ANFIS controller was compared with the Sugeno-Fuzzy controller in the simulation and experiment. Figure 7(a) and Figure 7(b) show the cart and angle responses of both controllers, respectively. Both controllers were implemented in MATLAB separately with the same initial conditions. The solid line represents the applied input while the dotted and dashed lines represent the ANFIS controller and the sugenofuzzy controller, respectively. It can be seen that the Sugeno FIS controller required more time to stabilize both the pendulum and the cart compared to the ANFIS controller, as it needed 5.8 s to stabilize the entire system. Moreover, it had an overshoot of 8% in the cart's response with a small steady-state error (0.5%), while the response from the ANFIS controller was smooth with no overshoot or steady-state error. On the other hand, the overshoot of the Sugeno controller's angle was much smaller than the one in the ANFIS controller. However, both overshoots were still acceptable. Table 3 shows the summary of the cart and angle response of the ANFIS and Sugeno FIS controllers in the simulation.

Experiment comparison
Even though the results of the controller in [4] were only the simulation results, the same controller was implemented in the same real inverted pendulum to make a fair comparison between Sugeno FIS and the ANFIS controller in the experiment. Its comparative performance is shown in Table 4. Like the simulation, the ANFIS controller gave better performance and smoother response compared to the Sugeno FIS controller. Even though the Sugeno FIS controller was able to stabilize the system, there was a huge steady-state error level for the cart's response during the experiment. This error may cause some problems and difficulties to the end user. The Sugeno Fuzzy controller also had a high settling time compared to the ANFIS controller as it needed approximately 4 s to reach stability. Overall, it was clear that using the ANFIS method was much better in terms of settling time and steady-state error.

CONCLUSION
The objective of this study was achieved by designing an adaptive neuro-fuzzy inference system (ANFIS) to control the inverted pendulum system within a brief time. The controller was implemented in the MATLAB environment using the ANFIS editor. The ANFIS controller provided an efficient and quick response with a small error in both simulation and experiment. It also showed better performance in terms of overshoot, stability and settling time compared to Sugeno FIS. However, the ANFIS controller performance depended heavily on the input-output data collected from a closed loop controlled system. Therefore, this step should be implemented only after in-depth and careful planning.