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.
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.
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 Table 1.
The block diagram of the proposed system is shown in Figure 2.
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.
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:
where K_{p}, K_{i}, and K_{d} 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).
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.
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 (K_{pf}, K_{df}, β).
It is assumed that K_{p}, K_{d}, are in a prescribed ranges [K_{p min}, K_{p max}] and [K_{d min}, K_{d max}]. K_{p} and K_{d} are normalized into the range between zero and one by the following linear transformation:
The integral time constant is determined with reference to the derivative time constant,
And the integral gain is thus obtained by
For determining the range of K_{p} and K_{d} we are going to use Ziegler Nichols method for tuning PID where
where K_{u} is the ultimate gain at which the output is stable and T_{u} is the oscillation period [16].
The parameters K_{pf}, K_{df} and β are determined by a set of fuzzy rules.
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 K_{p} = 50.1, K_{i} = 1, K_{d} = 8.2.
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 Figure 11.
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 K_{pf} and K_{df} and for β it will be small (1), medium small (2), medium (3), big (4). The FLC rules for K_{pf}, K_{df} and β are shown in Tables 3, 4 and 5, respectively. The membership function for the inputs (e and δe) and outputs (K_{pf}, K_{df} and β) are shown in Figure 13. The Fuzzy PID controller implementation in MATLAB/Simulink is shown in Figure 14.
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
where n is the number of data, i = 1, …, n and e is the error. From
According to the SSE results, the Fuzzy PID has the best response under small disturbances.
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.
No potential conflict of interest relevant to this article was reported.
No potential conflict of Interest relevant to this article was reported.
GIP physical parameters.
Block diagram of position control of GIP.
PID block diagram.
FLC block diagram.
Fuzzy PID basic structure.
GIP control model in MATLAB/Simulink.
GIP plant in MATLAB/Simulink.
PID implementation in MATLAB/Simulink.
FLC parameters.
(a)
FLC implementation in MATLAB/Simulink.
FLC of Fuzzy PID parameters.
(a)
Fuzzy PID controller implementation in MATLAB/Simulink.
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.
Parameters of GIP
Parameter | Description |
---|---|
Mass of pendulum | |
Pendulum’s moment of inertia | |
Length of GIP (fulcrum to the center of gravity) | |
Moment of inertia of the flywheel | |
Motor’s resistance | |
Motor’s inductance | |
Motor’s torque constant | |
Motor’s friction factor | |
Pendulum’s angular position | |
Flywheel angular position | |
Motor’s current | |
Motor’s voltage | |
Flywheel’s torque | |
Gravitational torque | |
Acceleration due to gravity |
The FLC rule base of the GIP
NB | NM | NS | ZO | PS | PM | PB | |
---|---|---|---|---|---|---|---|
NB | NB | NB | NB | NB | NM | NS | ZO |
NM | NB | NB | NB | NM | NS | ZO | PM |
NS | NB | NB | NM | NS | ZO | PM | PB |
ZO | NB | NM | NS | ZO | PM | PB | PB |
PS | NM | NS | ZO | PM | PB | PB | PB |
PM | NS | ZO | PM | PB | PB | PB | PB |
PB | ZO | PM | PB | PB | PB | PB | PB |
The FLC rule base for
NB | NM | NS | ZO | PS | PM | PB | |
---|---|---|---|---|---|---|---|
NB | B | B | B | B | B | B | B |
NM | S | B | B | B | B | B | S |
NS | S | S | B | B | B | S | S |
ZO | S | S | S | B | S | S | S |
PS | S | S | B | B | B | S | S |
PM | S | B | B | B | B | B | S |
PB | B | B | B | B | B | B | B |
The FLC rule base for
NB | NM | NS | ZO | PS | PM | PB | |
---|---|---|---|---|---|---|---|
NB | S | S | S | S | S | S | S |
NM | B | B | S | S | S | B | B |
NS | B | B | B | S | B | B | B |
ZO | B | B | B | B | B | B | B |
PS | B | B | B | S | B | B | B |
PM | B | B | S | S | S | B | B |
PB | S | S | S | S | S | S | S |
The FLC rule base for
NB | NM | NS | ZO | PS | PM | PB | |
---|---|---|---|---|---|---|---|
NB | S | S | S | S | S | S | S |
NM | B | B | S | S | S | B | B |
NS | B | B | B | S | B | B | B |
ZO | B | B | B | B | B | B | B |
PS | B | B | B | S | B | B | B |
PM | B | B | S | S | S | B | B |
PB | S | S | S | S | S | S | S |
The SSE results of each controller
Controller | SSE (a) | SSE (b) | SSE (c) |
---|---|---|---|
PID | 4.1344 | 8.358 | 15.234 |
FLC | 4.5997 | 8.023 | 14.405 |
Fuzzy PID | 3.2667 | 7.843 | 14.101 |
E-mail: mohamedmostafamousa1991@gmail.com
E-mail: ali rohan2003@hotmail.com
E-mail: shkim@kunsan.ac.kr