Title Author Keyword ::: Volume ::: Vol. 19Vol. 18Vol. 17Vol. 16Vol. 15Vol. 14Vol. 13Vol. 12Vol. 11Vol. 10Vol. 9Vol. 8Vol. 7Vol. 6Vol. 5Vol. 4Vol. 3Vol. 2Vol. 1 ::: Issue ::: No. 4No. 3No. 2No. 1

Comparison of Position Control of a Gyroscopic Inverted Pendulum Using PID, Fuzzy Logic and Fuzzy PID controllers

Mohammed Rabah, Ali Rohan, and Sung-Ho Kim

1School of Electronics and Information Engineering, Kunsan National Univ., Gunsan, Korea, 2School of IT, Information and Control Engineering, Kunsan National Univ., Gunsan, Korea
Correspondence to: Sung-Ho Kim (shkim@kunsan.ac.kr)
Received April 9, 2018; Revised June 1, 2018; Accepted June 14, 2018.
This is an Open Access article distributed under the terms of the Creative Commons Attribution Non-Commercial License (http://creativecommons.org/licenses/by-nc/3.0) which permits unrestricted non-commercial use, distribution, and reproduction in any medium, provided the original work is properly cited.
Abstract

This paper presents the modeling and control of a gyroscopic inverted pendulum. Inverted pendulum is used to realize many classical control problems. Its dynamics are similar to many real-world systems like missile launchers, human walking and many more. The control of this system is challenging as it’s highly unstable which will tend to fall on either side due to the gravitational force. In this paper, we are going to stabilize the gyroscopic inverted pendulum using PID controller, fuzzy logic controller and fuzzy PID controller. These controllers will be compared to determine the performance and to distinguish which one has the better response. Experiments and simulations are conducted to examine the different controllers and results are presented under different disturbance scenarios.

Keywords : Gyroscopic inverted pendulum, Fuzzy logic, PID, Fuzzy PID, MATLAB/Simulink
1. Introduction

The inverted pendulum (IP) is a nonlinear and open-loop unstable system. Therefore, it has always been an interesting topic to control engineers. The control goal aims at keeping the IP at an upright position, despite the natural tendency of IP to fall on either side. There are a lot of IP’s system, such as single link IP, double link IP, and a triple link IP.

Most of the pendulums developed so far, still face some problems during stabilizing when there is a big disturbance affecting the system. Previously, control of a gyroscopic inverted pendulum (GIP) using neural network NARMA-L2 control has been studied in [1]. A GIP comparison between fuzzy logic controller (FLC) and PID has been studied in [2]. Authors in [3, 4] designed a GIP based on FLC and Fuzzy PID. A hybrid LQG-neural controller has been studied in [5]. In [6], approximate linearization was used to design a controller for an IP. Other researchers used a method of applying an oscillatory vertical force to the pendulum pivot [7]. [8, 9] proposed a FLC to control the rotary of an IP.

In this paper, a Fuzzy PID algorithm is proposed for the stability and control of the GIP while being affected by a big disturbance. The proposed algorithm is compared with a PID controller and a FLC. In comparison to the previously used controllers, the proposed controller is simple and doesn’t require complex calculations and logic development. Also, it doesn’t take much time to control the system in comparison to the neural network where it needs to train the data first. The modeling of the GIP system is done using MATLAB/Simulink. Simulations were carried out to check the response of the proposed controller in comparison with PID and FLC, while different disturbances are applied to the system. The comparison shows that the proposed controller is able to maintain the stability of the system under big disturbances.

In the next section, the dynamic model of GIP system is explained. In Section 3, the controllers used in this system are explained. In Section 4, the implementation of the GIP system is discussed and the simulation studies are carried out for all three controllers. Furthermore, the comparison between these controllers is discussed, followed by the conclusion.

2. System Description

The GIP is a free-standing pendulum. The fulcrum is a V-shaped groove at the base allowing one degree of freedom. The GIP system has a motor and a flywheel mounted at top of the body as shown in Figure 1. If the flywheel is made to rotate in any direction, the beam will rotate in the opposite direction so that the angular momentum about the center of gravity is conserved [10]. The GIP physical parameters are shown in

$Ldidt+Ri=V-K (dαdt-dθdt),$$Tf=Jf ·d2αdt2,$$Jf ·d2αdt2=Ki-bdαdt,$$Tg=mp·g·lp·sin(θ),$$Tg-Tf=Jp·d2αdt2.$

Eqs. (1) to (3) describe the motor-flywheel part of the system. Eq. (4) describes the non-linear gravitational torque that effects the stabilization of the system. Eq. (5) describes the net torque that controls the pendulum movement around the base [11, 12].

3. Controllers Description

The block diagram of the proposed system is shown in

As shown in Figure 2, three controllers are compared with each other to test the stability of the system. The input signal e is fed by the current position of GIP in degrees, and the output signal is the control signal in volts to the motor-flywheel assembly which stabilize the GIP.

### 3.1 PID Controller

Proportional-Integral-Derivative (PID) controller is a control loop feedback mechanism commonly used in industrial control systems [13]. A PID controller continuously calculates an error value as the difference between the desired reference r(t) and the output of the system y(t), then applies a correction based on proportional, integral, and derivative terms according to the following equation:

$y(t)=Kpe(t)+Ki∫0te(τ)dτ+Kdde(t)dt,$

where Kp, Ki, and Kd are the proportional, interval, and derivative gains are, e (t) is the error value, and y (t) is the output of the controller (Figure 3).

### 3.2 Fuzzy Logic Controller

FLC is an approach to computing based on “degrees of truth” rather than the usual “true or false” (1 or 0) Boolean logic on which the modern computer is based. The idea of fuzzy logic was first advanced by Dr. Lotfi Zadeh of the University of California at Berkeley in the 1960s. FLC has some advantages compared to other classical controllers such as simplicity of control, low cost and the possibility to design without knowing the exact mathematical model of the process. Fuzzy inference systems for all FLC has two inputs: error (e) which controls the GIP angular displacement, its derivative (δe), which controls the DC motor rotation speed and direction, and only one output. There are different fuzzy inference methods such as Mamdani and Sugeno [14]. Same as the PID, the input signal is the difference between the reference and the position of the pendulum. As shown in Figure 4, the FLC has three main stages, fuzzification, rule base and defuzzification. Fuzzification describes the input and output of the FLC to specify set of rules that is used to control our system. The collection of rules is called a rule base. The rules are in “If Then” format and formally the If side is called the conditions and the Then side is called the conclusion. The computer is able to execute the rules and compute a control signal depending on the measured inputs error (e) and its derivative (δe). Defuzzification is when all the actions that have been activated are combined and converted into a single non-fuzzy output signal which is the control signal of the system.

### 3.3 Fuzzy PID Controller

A Fuzzy PID controller utilizes fuzzy rules and reasoning to determine the gains for the PID controller. Figure 5 shows the basic structure of the Fuzzy PID [15]. As we can see the FLC takes two inputs (e and δe) and gives three outputs (Kpf, Kdf, β).

It is assumed that Kp, Kd, are in a prescribed ranges [Kp min, Kp max] and [Kd min, Kd max]. Kp and Kd are normalized into the range between zero and one by the following linear transformation:

$Kpf=Kp-Kp minKp max-Kp min,$$Kdf=Kd-Kd minKd max-kd min.$

The integral time constant is determined with reference to the derivative time constant,

$Ti=βTd.$

And the integral gain is thus obtained by

$Ki=Kp2βKd.$

For determining the range of Kp and Kd we are going to use Ziegler Nichols method for tuning PID where

$Kp min=0.32Ku, Kp max=0.6Ku,Kd min=0.08KuTu, Kd max=0.15KuTu,$

where Ku is the ultimate gain at which the output is stable and Tu is the oscillation period [16].

The parameters Kpf, Kdf and β are determined by a set of fuzzy rules.

4. Simulation Studies

### 4.1 GIP System

Figure 6 shows the control model for GIP. The saturation block is used to limit the output to +/− 10 V and the switch block is used to switch between the controllers. Figure 7 shows the implementation of GIP plant in MATLAB/Simulink. The pulse generator is used as a disturbance for the system every 10 seconds, with an amplitude of 0.2, 0.4, and 0.65, 0.9 rad. Figure 8 shows the implementation of a discrete PID controller where Kp = 50.1, Ki = 1, Kd = 8.2.

### 4.2 Fuzzy Logic Controller

FLC is used to generate gains instead of PID to avoid high fluctuations in the start. In FLC 7 linguistic variables are used for each input, which means there are 49 possible rules with all combination of the inputs. The set of linguistic values for two inputs and one output with 49 rules are negative big (NB), negative medium (NM), negative small (NS), zero (ZO), positive small (PS), positive medium (PM) and positive big (PB). A Mamdani type with triangular membership functions is used for the inputs and output as shown in Figure 9. The FLC uses MIN for t-norm operation, Max for s-norm operation, MAX for aggregation, MIN for implication, and Centroid for defuzzification. FLC rule base of the GIP system is shown in Table 2. FLC takes two inputs (e and δe) and one output (voltage). Membership functions of the inputs and output variable are shown in Figure 10. The FLC implementation in MATLAB/Simulink is shown in

### 4.3 Fuzzy PID Controller

In Fuzzy PID, the same parameters as FLC are used as shown in Figure 12. The set of linguistic values for the two inputs (e and δe) are same as the FLC model, but the output will be small (S) and big (B) for both Kpf and Kdf and for β it will be small (1), medium small (2), medium (3), big (4). The FLC rules for Kpf, Kdf and β are shown in Tables 3, 4 and 5, respectively. The membership function for the inputs (e and δe) and outputs (Kpf, Kdf and β) are shown in Figure 13. The Fuzzy PID controller implementation in MATLAB/Simulink is shown in

5. Simulation Results

Figure 15 shows the different disturbances applied to the system every 10 seconds and the output of each controller while compared to each other.

According to the comparison results, the FLC has the slowest response in Fig 15(a), while PID and Fuzzy PID are close to each other. In Figure 15(b) and 15(c), FLC and Fuzzy PID responses are close. In Figure 15(d), FLC and PID fail to stabilize the GIP while fuzzy PID was able to maintain the stability of GIP. Although the PID controller is easy to implement and fast to control the system, its gains are fixed, so in case of any disturbance or noise affecting the system, it will fail to control the system. On the other hand, FLC can control the system based on the error signal and its derivative. Thus FLC is stronger towards disturbance minimization compared to the PID. However, FLC takes longer time to control the system. Therefore, a Fuzzy PID controller is proposed, where it is used to control the system by determining the PID gains based on the error and its derivative. As it can be observed in Figure 15(a), PID controller has the fastest response, while the FLC has the slowest response. When the applied disturbance on the system is increased, PID performance becomes worse, and it takes more time to settle as shown in Figure 15(b) and 15(c), while FLC was able to maintain the stability of the system based on the error and its derivative. However, in Figure 15(d) when a higher disturbance is applied on the system, both PID controller and FLC failed to maintain it. On the other hand, Fuzzy PID controller shows that by determining the gain of PID controller based on the error signal and its derivative, it can maintain the stability of the GIP under any disturbances.

In order to determine which of these controllers has better performance under small disturbance, we calculated the sum of square errors (SSE) of each controller where

$SSE=∑i=1nei2,$

where n is the number of data, i = 1, …, n and e is the error. From Eq. (11), the SSE results of the controllers is shown in

According to the SSE results, the Fuzzy PID has the best response under small disturbances.

6. Conclusion

Most of the pendulums developed so far have restoring force applied at the fulcrum, that’s why a GIP is a challenging system for the design and testing of several control techniques. In this work, we compared the output of three different controllers. All three controllers have close results under small disturbances. So in order to distinguish between them, the SSE of each controller has been calculated to determine which controller has the best performance. Finally, Fuzzy PID has proved that it has the best performance under small disturbances. Also, it has proved that it is able to maintain the stability of GIP under big disturbances, while the other two controllers failed to stabilize it.

Conflict of Interest

Conflict of Interest

Figures
Fig. 1.

GIP physical parameters.

Fig. 2.

Block diagram of position control of GIP.

Fig. 3.

PID block diagram.

Fig. 4.

FLC block diagram.

Fig. 5.

Fuzzy PID basic structure.

Fig. 6.

Fig. 7.

Fig. 8.

Fig. 9.

FLC parameters.

Fig. 10.

(a) e and δe membership functions, (b) output membership function.

Fig. 11.

Fig. 12.

FLC of Fuzzy PID parameters.

Fig. 13.

(a) e and δe membership functions, (b)Kpf, Kdf membership functions, (c) β membership functions.

Fig. 14.

Fuzzy PID controller implementation in MATLAB/Simulink.

Fig. 15.

Simulation results of the three controllers while disturbance applied on the system is equal to (a) 0.2 rad, (b) 0.4 rad, (c) 0.65 rad, (d) 0.9 rad.

TABLES

### Table 1

Parameters of GIP

ParameterDescription
mpMass of pendulum
JpPendulum’s moment of inertia
lpLength of GIP (fulcrum to the center of gravity)
JfMoment of inertia of the flywheel
RMotor’s resistance
LMotor’s inductance
KMotor’s torque constant
bMotor’s friction factor
θPendulum’s angular position
αFlywheel angular position
IMotor’s current
VMotor’s voltage
TfFlywheel’s torque
TgGravitational torque
gAcceleration due to gravity

### Table 2

The FLC rule base of the GIP

e/δeNBNMNSZOPSPMPB
NBNBNBNBNBNMNSZO
NMNBNBNBNMNSZOPM
NSNBNBNMNSZOPMPB
ZONBNMNSZOPMPBPB
PSNMNSZOPMPBPBPB
PMNSZOPMPBPBPBPB
PBZOPMPBPBPBPBPB

### Table 3

The FLC rule base for Kpf

e/δeNBNMNSZOPSPMPB
NBBBBBBBB
NMSBBBBBS
NSSSBBBSS
ZOSSSBSSS
PSSSBBBSS
PMSBBBBBS
PBBBBBBBB

### Table 4

The FLC rule base for Kdf

e/δeNBNMNSZOPSPMPB
NBSSSSSSS
NMBBSSSBB
NSBBBSBBB
ZOBBBBBBB
PSBBBSBBB
PMBBSSSBB
PBSSSSSSS

### Table 5

The FLC rule base for α

e/δeNBNMNSZOPSPMPB
NBSSSSSSS
NMBBSSSBB
NSBBBSBBB
ZOBBBBBBB
PSBBBSBBB
PMBBSSSBB
PBSSSSSSS

### Table 6

The SSE results of each controller

PID4.13448.35815.234
FLC4.59978.02314.405
Fuzzy PID3.26677.84314.101

References
1. Chetouane, F, and Darenfed, S (2008). Neural network NARMA control of a gyroscopic inverted pendulum. Engineering Letters. 16, 274-279.
2. Chetouane, F, Darenfed, S, and Singh, PK (2010). Fuzzy control of a gyroscopic inverted pendulum. Engineering Letters. 18, 1-8.
3. Rohan, A, Rabah, M, Nam, KH, and Kim, SH (2018). Design of fuzzy logic based controller for gyroscopic inverted pendulum system. International Journal of Fuzzy Logic and Intelligent Systems. 18, 58-64.
4. Talha, M, Asghar, F, and Kim, SH (2017). Design of fuzzy tuned PID controller for anti rolling gyro (ARG) stabilizer in ships. International Journal of Fuzzy Logic and Intelligent Systems. 17, 210-220.
5. Sazonov, ES, Klinkhachorn, P, and Klein, RL 2003. Hybrid LQG-neural controller for inverted pendulum system., Proceedings of the 35th Southeastern Symposium on System Theory, Morgantown, WV, Array, pp.206-210.
6. Sugie, T, and Fujimoto, K (1998). Controller design for an inverted pendulum based on approximate linearization. International Journal of Robust and Nonlinear Control. 8, 585-597.
7. Kapitsa, PL (1951). Dynamical stability of a pendulum with an oscillating suspension point. Zhurnal Eksperimental’noii Teoreticheskoi Fiziki. 24, 588-597.
8. Srikanth, K, and Kumar, GVN (2017). Novel fuzzy preview controller for rotary inverted pendulum under time delays. International Journal of Fuzzy Logic and Intelligent Systems. 17, 257-263.
9. Tiep, DK, and Ryoo, YJ (2017). An autonomous control of fuzzy-PD controller for quadcopter. International Journal of Fuzzy Logic and Intelligent Systems. 17, 107-113.
10. Shiriaev, A, Pogoromsky, A, Ludvigsen, H, and Egeland, O (2000). On global properties of passivity-based control of an inverted pendulum. International Journal of Robust and Nonlinear Control. 10, 283-300.
11. Gottlieb, IM (1994). Electric Motors & Control Techniques. New York, NY: TAB Books
12. Lander, CW (1993). D.C. machine control. Power Electronics. London: McGraw-Hill International
13. Wang, LX, and Mendel, JM (1992). Fuzzy basis functions, universal approximation, and orthogonal least-squares learning. IEEE Transaction on Neural Networks. 3, 807-814.
14. Zhao, ZY, Tomizuka, M, and Isaka, S (1993). Fuzzy gain scheduling of PID controllers. IEEE Transactions on Systems, Man, and Cybernetics. 23, 1392-1398.
15. Ziegler, JG, and Nichols, NB (1942). Optimum settings for automatic controllers. Transactions of the ASME. 64, 759-768.
Biographies

Mohammed Rabah received his B.S. degree in Electronics and Telecommunication Engineering from the AL-SAFWA High Institute of Engineering, Cairo, Egypt in 2015. He completed his M.S. in Electrical, Electronics and Control Engineering from Kunsan National University, Gunsan, Korea in 2017. Currently, pursuing his Ph.D. in Electrical, Electronics and Control Engineering from Kunsan National University, Korea. His research interests includes UAV’s, fuzzy logic systems and machine learning.

Ali Rohan received his B.S. degree in Electrical Engineering from The University of Faisalabad, Pakistan in 2012. Currently, pursuing his M.S. & Ph.D. in Electrical, Electronics and Control Engineering from Kunsan National University, Korea. His research interests includes renewable energy system, power electronics, fuzzy logic, neural network, EV system, flywheel energy storage system.

E-mail: ali rohan2003@hotmail.com

Sung-Ho Kim received his B.S. degree in Electrical Engineering from Korea University in 1984. He completed his M.S. & Ph.D. in electrical engineering from Korea University in 1986 & 1991, respectively. In 1996, he completed his POST-DOC from Japan Hiroshima University. Currently, he is a professor at Kunsan National University. His research Interests includes fuzzy logic, sensor networks, neural networks, intelligent control system, renewable energy system, fault diagnosis system.

E-mail: shkim@kunsan.ac.kr

December 2019, 19 (4)