search for


Design of Fuzzy Logic Based Controller for Gyroscopic Inverted Pendulum System
Int. J. Fuzzy Log. Intell. Syst. 2018;18(1):58-64
Published online March 25, 2018
© 2018 Korean Institute of Intelligent Systems.

Ali Rohan1, Mohammed Rabah1, Kang-Hyun Nam2, and Sung Ho Kim3

1School of Electronics and Information Engineering, Kunsan National University, Gunsan, Korea, 2Faculty of Industrial & Academic Cooperation Division, Kunsan National University, Gunsan, Korea, 3Department of Control and Robotics Engineering, Kunsan National University, Gunsan, Korea
Correspondence to: Sung Ho Kim (
Received February 1, 2018; Revised March 17, 2018; Accepted March 20, 2018.
This is an Open Access article distributed under the terms of the Creative Commons Attribution Non-Commercial License ( which permits unrestricted non-commercial use, distribution, and reproduction in any medium, provided the original work is properly cited.

Anti-rolling gyro systems (ARG) were introduced long time ago for reducing the roll motion of ships caused by the ocean waves. These systems are composed of gyroscopic stabilizer, which typically controls the roll motion by generating some counteracting roll stabilizing torque. These systems are very sensitive to the outer disturbances and require robust control mechanism to maintain the stable state. In this work, gyroscopic inverted pendulum based on gyroscopic stabilizer is considered to develop control technique for reducing the roll motion effect of the system. The gyroscopic inverted system was modeled in MATLAB/Simulink and fuzzy logic based control technique was developed. The proposed control technique was implemented and tested with the practical system. Furthermore, the performance of the proposed system is compared with a typical PD type controller. Simulation and experimental results show that the proposed system performs well and maintains a stable state under various disturbances.

Keywords : Gyro stabilizer, Fuzzy logic, Inverted pendulum, Anti rolling gyro
1. Introduction

The inverted pendulum system is a nonlinear and unstable system and is an ideal experimental platform for the research and verification of many control theories [17]. There are a lot of inverted pendulum systems, such as single link inverted pendulum [8], double link inverted pendulum [9], triple link inverted pendulum [10], rotary inverted pendulum [11], and inertia wheel pendulum [12]. All of these were designed to validate the balance control algorithms. Most of these inverted pendulums except the inertia wheel pendulum are balanced using driving torque from a fixed foundation or moving cart and can be used for the stabilization of the other mechanical platforms. The inertial wheel pendulum, on the other hand, is used widely for the balance control of some objects, especially unicycle robot [13, 14]. Generally, the inertial wheel pendulum works by generating the torque by controlling the acceleration and deceleration of the spinning flywheel. This requires very high motor driving capabilities and is less efficient. On the other hand, gyroscopic stabilizing devices are more efficient and stable. Instead of controlling the acceleration and deceleration of the flywheel, the gyroscopic stabilizing device can be used to generate greater precession torque with small directional change. Gyroscopic stabilizers use conservation of angular momentum to stabilize unstable bodies by functioning as an actuator using the phenomenon of gyroscopic precession. Therefore, in this work gyroscopic inverted pendulum was chosen as a basic platform. In order to control the system, different control techniques have been implemented by different authors comprising of controllers like PID, fuzzy logic and artificial neural network (ANN). In [15], approximate linearization was used effectively to design a controller for an inverted pendulum. Some researchers used method of applying oscillatory vertical force to the pendulum pivot [16, 17]. In [18], nonlinear auto-regressive moving average (NARMA) was implemented on inverted pendulum system.

In this work, fuzzy logic controller is proposed and implemented for the stability and control of gyroscopic inverted pendulum and compared with a PD type controller, normally used to control such system. In comparison to the previously used control techniques, the proposed controller is simple and does not require complex calculations and logic development. Modeling of the gyroscopic inverted pendulum is done using MATLAB/Simulink. Simulations were carried out to check the response and robustness of the proposed controller. Based on simulation results and parameter calculations the practical test platform was developed. Fuzzy logic was implemented using a microcontroller under normal computational time. Simulation and practical results show that the proposed controller works well to maintain a stable state and can compensate the outer disturbances effectively and efficiently.

This paper is divided into following sections: Section 2 describes the dynamics of the inverted pendulum system. Section 3 consists of modeling and validation of the system comprising of simulation and experimental test system details. Section 4 contains the simulation and experimental test results and Section 5 outlines the conclusion.

2. Gyroscopic Inverted Pendulum Dynamics

To model a gyroscopic inverted pendulum, a coordinate system is assumed. Figure 1 shows the basic coordinate system for the inverted pendulum, where θ is the roll angle along x-axis, α is the gimbal angle along y-axis and φ is the flywheel spin direction along z-axis.

The gyroscopic inverted pendulum is composed of three parts:

  1. Pendulum body frame.

  2. Gyroscope.

  3. Flywheel connected to the gyroscope.

The dynamics of these parts is derived from conservation of


where T is the kinetic energy and U is the potential energy of the system. The kinetic and potential energy equations were derived for all the three parts.

T=TPendulum+TGyro+TFlywheel,U=(mghg+mphp+mfhf)gcos θ,

where the torque of pendulum, gyro, and flywheel are:


A disturbance force d(t) acting on the x-y plane was considered and final equation of motion from Euler-Lagrange equation can be derived as follows:

ddt(Lθ˙)-Lθ=d(t)hbsin θ.

From (7), the acceleration of the pendulum tilt angle is derived as follows:

θ¨=(C1gsin θ+2I1θ˙α˙sin αcos α-Ifyωcos αα˙-d(t)hbsin θ)(Ipx+C2+(Igx+Ifx)cos2α+(Igy+Ify)sin2α),



It can be observed from (8) that the precession motion, which generates the precession torque to compensate for the disturbances, plays an important role in the stabilization of the system and by controlling this precession motion the stabilization of the gyroscopic inverted pendulum can be performed effectively. The parameters of the system are given in Table 1.

3. Design of Fuzzy Logic Based ARG Controller

MATLAB/Simulink was used to model the system with defined parameters and simulations were carried out to check the validity.

Figure 2 shows the basic block diagram of the system, where the controller was designed by using the fuzzy logic.

Proposed fuzzy logic based controller comprises of two inputs, errore(k), change of error Δe(k) and one output i.e., pulse-width modulation (PWM) to derive a motor for generating stabilizing torque. The tilt angle θ was taken as the control parameter and controller was designed to maintain the defined reference tilt angle under varying disturbances. The membership functions of the proposed fuzzy logic based controller are shown in Figure 3.

The developed controller used the following rule base as shown in Table 2.

Figure 4 show the details of the controller block. The proposed fuzzy logic controller was compared with the typical PD type controller to observe the performance and response of the system.

The output of the controller was given as an input to the gyroscopic inverted pendulum system which consists of a DC motor to control the precession motion and generates the compensating torque to stabilize the system. Figure 5 shows block diagram of the gyroscopic inverted pendulum system and the dc motor. For developing this model, the equations derived in Section 2 were utilized.

Figure 6 shows the results obtained by simulation of the modeled gyroscopic inverted pendulum system. A disturbance of θ = 15° was applied at the start of the simulation, and simulation were carried out to observe the response of the proposed fuzzy logic controller and was compared with the typical PD controller. It can be observed clearly from the output results that the fuzzy logic controller provides better response and stabilize the system very effectively and efficiently and is very good in maintaining the reference angle θ = 0°. On the other hand PD controller tries to achieve the stabilization, but it shows a constant oscillations within the range of θ = 1.5° to θ = −1.5°.

4. Experiment Results

Experiments were performed for the stabilization of gyroscopic inverted pendulum using the experimental platform shown in Figure 7.

It can be seen in the Figure 7, the gyroscopic inverted pendulum consists of three different parts. Red one is the flywheel which is coupled to a gyro stabilizer, yellow one is the gyro stabilizer, blue one is a stepping motor used to control the precession motion of the gyro stabilizer, green part shows the pendulum body frame and orange one is an IMU (inertial measurement unit) used to get the angular acceleration and angle values.

Generally, the gyro stabilizer comprises of a flywheel with large inertia which rotates at high speed and generates the natural precession motion and the compensating torque, which acts as a counteracting force and mitigate the external disturbances.

This compensating torque produced by natural precession motion is not enough to stabilize the system. For this, the experimental platform was equipped with a stepper motor. By controlling the motor speed and direction, fast precession motion and bigger torque generation can be obtained.

Proposed fuzzy logic controller and PD controller were implemented using Arduino Uno. Normally, the fuzzy rule base is implemented using some linguistic variable but in case of practical implementation, it is required to convert the rule base into a feasible set of values which will allow the microcontroller to work under its normal computational time.

Hence for practical implementation, the fuzzy rule base was converted into a lookup table. A lookup table was generated using the MATLAB/Simulink and simulation was carried out to obtain the output values under different input scenarios. These output values in the form of a lookup table were used inside of microcontroller algorithm. Figure 8 shows the Simulink block diagram used for generating the lookup table.

The overall flowchart of the proposed control system is shown in Figure 9. The parameter values used for designing the Simulink model and experimental platform are given in Table 3.

Figure 10 shows the results obtained from the experimental platform. It can be observed from the practical results that the proposed fuzzy logic controller is able enough to compensate for the disturbances and perform better than typical PD controller.

Experimental platform was tested under varying disturbances and the response of the proposed fuzzy logic controller was recorded. Figure 11 show the results under varying disturbances applied externally to the system.

The performance of the proposed control system was analyzed using some parameters like sum of square error given as:


Performance index was calculated for both fuzzy logic and PD controller, values obtained are shown in Table 4. The values shows that the proposed system performance is much better than the other types of controller.

5. Conclusion

An effective and efficient control technique based on fuzzy logic has been proposed in this work. Simulation and practical implementation for stabilizing the gyroscopic inverted pendulum system was performed. Control technique was compared with the previously used control methods especially PD controller. The simulation and experimental results shows that the fuzzy logic based control technique works well to mitigate the disturbances caused by some external effects.

Conflict of Interest

No potential conflict of interest relevant to this article was reported.

Fig. 1.

Basic coordinate system: (a) flywheel and gimbal axis and angles, (b) pendulum axis and angle. energy using Lagrange’s method.

Fig. 2.

Basic block diagram of the system.

Fig. 3.

Membership functions: (a) input membership function e(k), (b) input membership function Δe(k), and (c) output membership function PWM.

Fig. 4.

Simulink block diagram for performance comparison.

Fig. 5.

Gyroscopic inverted pendulum system.

Fig. 6.

Simulation result of the proposed fuzzy logic controller in comparison to a PD controller.

Fig. 7.

Experimental platform: (a) normal position, (b) stabilized position.

Fig. 8.

Simulink block for lookup table generation.

Fig. 9.

Overall control system flow chart.

Fig. 10.

Experimental results.

Fig. 11.

Fuzzy logic controller response for varying disturbances.


Table 1

Parameters of the sysetem

mpMass of pendulum
mgMass of gyro
mfMass of flywheel
hpHeight of pendulum
hgHeight of gyro
hfHeight of flywheel
ωFlywheel speed
gGravitational constant
IpxPendulum inertia
IgxGyro inertia (x-axis)
IgyGyro inertia (y-axis)
IfxFlywheel inertia (x-axis)
IfyFlywheel inertia (y-axis)

Table 2

Fuzzy rule base


Table 3

Parameter values used for Simulink model and experimental platform


Table 4

Sum of square error

Fuzzy logic controller120.382
PD controller145.29

  1. Jaleel, JA, and Francis, RM 2013. Simulated annealing based control of an inverted pendulum system., Proceedings of the International Conference on International Conference on Control Communication and Computing, Thiruvananthapuram, India, Array, pp.204-209.
  2. Li, ZH, Yang, HG, Chen, GJ, and Liang, C 2011. Modeling and simulation optimization of the double inverted pendulum system in modelica., Proceedings of the International Conference on Electronics, Communications and Control, Ningbo, China, Array, pp.4382-4385.
  3. Wai, RJ, and Chang, LJ (2006). Stabilizing and tracking control of nonlinear dual-axis inverted-pendulum system using fuzzy neural network. IEEE Transactions on Fuzzy Systems. 14, 145-168.
  4. Lee, GH, and Jung, S 2008. Control of inverted pendulum system using a neuro-fuzzy controller for intelligent control education., Proceedings of the IEEE International Conference on Mechatronics and Automation, Takamatsu, Japan, Array, pp.965-970.
  5. Mahmud, K 2013. Design and analysis of the control of an inverted pendulum system by MATLAB., Proceedings of the IEEE Global High Tech Congress on Electronics, Shenzhen, China, Array, pp.207-211.
  6. Xu, JX, Al Mamun, A, and Daud, Y 2011. Pendulum-balanced autonomous unicycle: conceptual design and dynamics model., Proceedings of the IEEE Conference on Robotics, Automation and Mechatronics, Qingdao, China, Array, pp.51-56.
  7. Canete, L, and Takahashi, T 2014. Development of a single controller for the compensation of several types of disturbances during task execution of a wheeled inverted pendulum assistant robot., Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems, Chicago, IL, Array, pp.2414-2420.
  8. Skalak, R, and Yarymovych, MI (1960). Subharmonic oscillations of a pendulum. Journal of Applied Mechanics. 27, 159-164.
  9. Furuta, K, Okutani, T, and Sone, H (1978). Computer control of a double inverted pendulum. Computers & Electrical Engineering. 5, 67-84.
  10. Furuta, K, Ochiai, T, and Ono, N (1984). Attitude control of a triple inverted pendulum. International Journal of Control. 39, 1351-1365.
  11. Furuta, K, Yamakita, M, Kobayashi, S, and Nisbimura, M (1992). A new inverted pendulum apparatus for education. Advances in Control Education 1991. Burlington, NJ: Elsevier, pp. 133-138
  12. Spong, MW, Corke, P, and Lozano, R (2001). Nonlinear control of the reaction wheel pendulum. Automatica. 37, 1845-1851.
  13. Li, Y, Lee, JO, and Lee, J (2012). Attitude control of the unicycle robot using fuzzy-sliding mode control. Intelligent Robotics and Applications. Heidelberg: Springer, pp. 62-72
  14. Zhao, J, Xiong, M, and Jin, H 2010. Dynamics and a convenient control design approach for a unicycle robot., Proceedings of IEEE International Conference on Information and Automation, Harbin, China, Array, pp.706-711.
  15. 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.
  16. Kapitsa, PL (1951). Dynamical stability of a pendulum with an oscillating suspension point. Zurnal eksperimental’noj i teoreticeskoj fiziki. 24, 588-597.
  17. Maravall, D, Zhou, C, and Alonso, J (2005). Hybrid fuzzy control of the inverted pendulum via vertical forces. International Journal of Intelligent Systems. 20, 195-211.
  18. Chetouane, F, and Darenfed, S (2008). Neural network NARMA control of a gyroscopic inverted pendulum. Engineering Letters. 16, 274-279.

Ali Rohan received his B.S. degree in Electrical Engineering from The University of Faisalabad, Pakistan in 2012. Currently, pursuing his M.S. and 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

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, Kunsan, South Korea in 2017. Currently, pursuing his Ph.D. in Electrical, Electronics and Control Engineering from Kunsan National University, South Korea. His research Interests includes UAV’s, Fuzzy Logic Systems and Machine learning.


Kang-Hyun Nam received his B.S. degree in Management Information System from Yongin University in 2003. He completed his M.S. from Kyung Hee University in 2006, worked in Samsung Electronics at Development of Core Networking from 1986 to 2006, worked in Jeju Digital Contents Research Center from 2006 to 2013, and served as Assistant Professor at Gwangju University from 2013–2017. Currently, he is a professor at Kunsan National University working in collaboration with the Industry-University Cooperation. His research interests include sensor networks, IoT platform, big data, intelligent networking system, 5G slice service logic.


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