Control Theory Application for Swing Up and Stabilisation of Rotating Inverted Pendulum

: This paper introduces a new scheme for sliding mode control using symmetry principles for a rotating inverted pendulum, with the possibility of extension of this control scheme to other dynamic systems. This was proven for swing up and stabilisation control problems via the new sliding mode control scheme using both simulations and experiments of rotary inverted pendulum (RIP) underactuated systems. According to the Lyapunov theory, a section of the pendulum was compensated with a scale error in the upright position, as the desired trajectory was followed by the pendulum arm section. As the RIP’s dynamic equations were nonlinearly complex and coupled, the complex internal dynamics made the task of controller design difficult. The system control for the pathway of the reference model of the rotational actuator with the application of the sliding mode technique for moving back and forth up the inverted pendulum’s structure, till the arm to reach the linear range round the vertical upright position, was created and tested in an existent device. The stabilisation scheme was switched on in the sliding mode as soon as the arm reached the linear range. A comparison of the stabilisation performance for the same rotating inverted pendulum as discussed by other authors revealed that the proposed controller was more flexible and reliable in terms of the swing up and stabilisation time.


Introduction
There are three main components of a rotary inverted pendulum (RIP), namely, link 1 and link 2 of the pendulum, and a motor ( Figure 1). The working mechanism of the RIP framework is that link 1 is driven by the motor with the appropriate control order to such an extent that the descending link 2 can be adjusted in the vertical position [1]. It is well known in the domain of a control hypothesis that RIP is one of the most complex control problems [2]. Wiener, Johnson, et al. based their work on humans and other animals to study their movements because some types of machines behave similarly [3]. Humans and animals control their mechanisms based on environmental variables when they are in a reliable terrain while moving or performing certain tasks [3].
The authors in [4] regarding the design of general feedback theory of human behaviour, started with theoretical model before outlining the application of the physical model. There is another idea that its components map onto the adverse feedback system within the existing models of behaviour for artificial control systems [5]. The movement control of a two-legged robot is based on the inverse pendulum theory [6]. Its good example is an RIP system for nonlinear underactuated mechanical systems to practice the control theory and with special emphasis on robotics for applications [7]. Saleem et al. and Jadlovska et al. provided the mathematical equations and numerous calculations, to find the appropriate way for the nominal trajectory to control the RIP [8]. Wen et al. based their work [9] on the Lyapunov theory control for nonlinear dynamics associated with the RIP in an optimal control effort. In our case, for RIP, we solved this problem by using Kour and an LQR controller; we compared our results with the other authors' [10][11][12][13][14] because these authors examined the same problem with LQR [5,15]. Some authors [16][17][18][19][20] have tested and implemented the theory of fractional calculus with a PID controller [21]. Irrespective of their prominence, traditional PID controllers come up short on the global asymptotic steadiness verification [21,22]. The contribution of this article is the amalgamation of an upgraded and adjustment control scheme for the RIP system. On a very basic level, the proposed scheme serves simultaneously as the adjuster and the controller. These controllers utilise the state input of the link 1 angle (β), the link 2 angle (α), and their time subordinates to produce the ideal force (or voltage) control orders to upright balance link 2, while continuously turning link 1 as close as is conceivable to its unique position, separately [23][24][25][26]. In this study, we realised the occasion-based procedures to control a rotary pendulum, for both swinging up and balancing out its arm [27]. Swinging up a rotary pendulum is an old and testing issue in the field of nonlinear control research [28][29][30]. The rest of this paper is organised as follows: The RIP dynamics and its state space models are discussed in Sections 4-6. The stabilisation and swing up controllers principle is shown in Section 6. Sections 7-8 show the theoretical and experimental results, and finally, in the end, a conclusion is presented.

Rotary Inverted Pendulum
The model of rotational link 2 is shown in Figure 2. The rotating joint is appended to the servo engine shaft. The pivoting arm [rotating link] has a length , a moment of inertia , and an angle α; α increments decidedly when turning the counterclockwise. The pendulum interface is associated with the finish of the pivoting joint. It has an all-out connection and a focal point of mass . The moment of inertia for its center of mass is . The angle of inverted link 2, β, is zero when the inverted arm is in an upright position; by dividing the symmetry space along the z axis, and it increases in the positive direction when it moves in the clockwise direction [18,21]. There are six main components of the RIP, as shown in Figure 1: link 2, link 1, a motor with a gearbox ratio of 20:1, a base, and two encoders [1]. The RIP system is depicted in Figure 1, along with the geometric parameters and system variables. The RIP has two planes of symmetry through the z0 axis with a normal direction of x0 and y0; it can rotate in the plane perpendicular to la = y1. This is attributed to its symmetrical configuration. Therefore, the distance from the centre of mass (CoM) can be calculated as follows: : distance from some reference point to the (CoM), and : distance to the CoM for each individual object.
The movement of the mechanism can be described in a graph-analytical or analytical manner.
From Figure 2 is derived the kinematics equation of link 2.
The Kalman filter is moderately less numerically confounded and simpler to use than the other filters, for example, the applied filter. Therefore, the limit of the Kalman filter to situate nonlinear coordinated frameworks precisely is restricted [19,[23][24][25]. The allinclusive Kalman filter is expressed in Algorithm 1. In the accompanying Figures 3 and 4, we applied the Kalman filter on the grounds that the clamours from the encoder were enormous.
Algorithm 1 Description of the filtered angular velocity/acceleration Input: angular position, angular velocity, angular acceleration Output: for

DC Motor Modelling
The electric equal circuit of the armature and the free-body chart of the rotor are shown in Figure 5. The input of the system is the feeding voltage (v) applied to the motor's armature. The system output is the angular velocity of the shaft, marked as [20]. Therefore, we measured two parameters: armature resistance R and torque constant . From the measured samples for the R, we took 30 measurements, and their average was R 9.59 Ω.
Upon applying the Laplace transform to Equations (6)-(9), we obtained the following expressions in the frequency domain: Where: Ω , s • Ω , and =I .
The differential conditions from above can likewise be communicated in the statespace structure by selecting the engine position, engine speed, and armature current as the state variables [7]. Let the variables be • • and ; it is not difficult to get the accompanying state-space structure to depict in a linear form for the input and the output. Figure 6 presents a scheme of the DC motor with feedback control, and Figure 7 shows the DC motor simulation with the real parameters by using MATLAB/Simscape. The block diagram of Figure 6 has been included within the Simscape/Simulink in the DC motor block of Figure 7, in particular.  It has been proven for the RIP's equation of motion that the symmetry leads to the possibility of obtaining the solutions by using a real-time variable.
The steady-state velocities with different voltages obtained from the Simulink modes are shown in Figure 8. The steady-state velocities with different voltages obtained from the real DC motor are shown in Figure 9.

Rotary Inverted Pendulum Dynamics
Mathematical modelling should be possible by utilizing the Euler-Lagrange strategy. In order to write the differential equations of the motion of the pendulum [31], taking into consideration the symmetry between two links, we started from the general form of the Lagrange equations of the second type.
, 0 From Equations (11) and (12) we derived the followings: , => , -controllable variables-equal to the degrees of freedom. As we had two controllable variables, the two degrees of freedom, respectively, in the matrix form will be as follows: where: -kinetic energy matrix, ,centrifugal and Coriolis forces, G q -gravitational forces, and -torque.
The required partial derivatives for substitution in Equations (13)-(15) are as follows: , where:

Swing-Up and Stabilisation of RIP
The descending position to the vertical upright position and to hold it there. We used two control strategies: one for swinging up, and the other for balancing the pendulum parts with a small error to reach the dead position as soon as possible. The control using sliding models [32] was developed for both the methods of swinging up and stabilising ℯ . A subsequent order system for position control with a swaying joint movement that went about as the disturbance was mulled over for the pendulum of the swing up control. The following controller was structured with the goal that it followed a reference input in our case with a reference trajectory. Because of the symmetrical configuration of the RIP, this provided energy to the swing joint and placed it at the focal point, where it was utilised in another pendulum balancing control to balance out the unsteady points. For the trajectory, the quadrilateral wave of amplitude ±π/6 was used. The state-space equation for the stance control system [33] used was • ℬ • , where the variables and are the system matrix and is a concentrated disturbance that contains a disturbance due to an oscillating connection of the pendulum. Thus, ∈ ℯ , ℯ represented the error state vector, the desired state vector was , and the actual state vector was . The equation • | | • used differentiating sliding models ℯ , and then, we substitute the actual state vector . Thus, we obtained the sliding model . If ∈ , 0 was the desired vector, the derivative vector was ∈ 0,0 . The conditions given above were to integrate the control ; it was swing-up control, and the exchanging gain was more noteworthy than the greatest furthest reaches of the guarantee sliding [32]. The RIP system was a fourth-order system, and the state space was obtained with Equations (6) and (15), where ∈ ℛ , ∈ ℛ , and ℬ ∈ ℛ . On the basis of the above equation, the incorporated control was ℬ • • Π • | | • and the swing up control is presented.

Simulation Results
The simulation is shown in Figure 10  The reactions of the link 2 angle obtained by, respectively, utilising our strategy and the LQR method are presented in Figure 11, from which, one can infer that our swing-up technique was quicker than that utilising the LQR control scheme. The explanation was that, in the LQR control technique, link 2 needed to follow a to-and-fro movement until it arrived at a little neighbourhood of the vertical position [1]. Such a strategy would cost a considerable amount of time. Moreover, in our method, link 2 could be swung up with less movement because of the high-efficiency utilisation of the inertia [1]. Note that the multi-switching of the LQR controller might cause harm to the motor. In any case, the switching recurrence of our controller was considerably less than that of the LQR controller. A detailed performance comparison of our method and the LQR scheme is presented in Table 1, along with the swing up time, steady-state error, controller switched times, and controller saturation time [1] of our method; all of them were less than those of the LQR scheme. This detailed performance comparison revealed that our method was more efficient in terms of the swing up time and stabilisation for the same RIP.

Experimental Results
This section shows the experimental results of the combined sensitivity of our controller in comparison with LQR [28]. The platform of the RIP system is shown in Figure  12. The main controller chip was STM32F10 and Arduino Uno, the engine was MG513IPH, and the driver IC was TB 6612FNG [1]. The parameters for our controller were as follows: 2, 4, 6, 10 . The linear feedback parameter for was as follows: 381.5, 26.7, 3.08, 12.25 . The parameter of LQR was set as follows: 5200, 0 90 , 0, and 5200, 90 0 , 0, and 90, 10, 40, 50 . In the following text, we present the pseudo-code Algorithm 2-4 for our swing up method and the LQR for a low-cost RIP platform. The experimental results are shown in Figures 12-18. Figure 12 shows the responses of the pendulum angle, Figure 13 shows the responses of the pendulum angle velocity , Figure 14 shows the responses of the pendulum acceleration swing unfiltered , and Figure 15 shows the response of the arm velocity ; these data are presented in the sample steps. The response of the controller is given in Figure 16. Figure 17 shows that link 2 swung up in approximately 1.45 s for , and then was stabilised by the control. It is clearer from Figure 18 that the nonlinear part of the stabilisation controller worked from less than 1000 sample steps to 5000 sample steps under our controller for , roughly. Note that all the signals of the RIP were stable. Furthermore, the swing up and equilibration time, steady-state error, and controller response time are presented in Table  2 below. Link 2′s angle position and link 1′s arm position α were in symmetry.      K=6 k=4 k=2 Figure 13 shows the reduced time for the swing up and stabilisation. The best value was observed in the case of ; we observed that for the swing up, it took less than 1500 sample steps to get the pendulum angle in the vertical position. The worst value was obtained in the case of ; here, we observed that the swing up and stabilisation took more than 3500 sample steps to get the pendulum angle in the vertical position. Figure 14 shows the reduced time for the swing up and stabilisation. The best value was obtained in the case of ; here, we observed that for the swing up, it took less than 1000 sample steps to get the pendulum angle in the vertical position. The worst values were obtained in the case of and , as the swing up and stabilisation took more than 1800 sample steps to get the pendulum velocity in the vertical position.
Hence, we reduced the time required for the swing up and stabilisation. The best value was obtained in the case of ; we observed that for the swing up, it took less than 800 sample steps to get the pendulum angle in the vertical position. The worst value was obtained in the case of ; here, we observed that the swing up and stabilisation took more than 1000 sample steps to get the pendulum angle in the vertical position. Hence, Figure 15 shows the reduced time taken for the swing up and stabilisation. The best value was obtained in the case of ; we observed that for the swing up, it took less than 870 sample steps and the potential energy in the y direction was −655. 84 to give the pendulum potential energy in vertical position up, technique reaction, and the adjustment procedure reaction of the RIPS by utilising the structured swing-up control.
The worst values were obtained in the case of ; we observed that the swing up and stabilisation took more than 1177 sample steps and the potential energy in the y direction was −424.69. The experiment exhibited the whole procedure of the dynamic reaction including the swing. Figure 19 shows the motions of the RIP, in which 1,2 illustrate the amplitudeincreased simple pendulum motion, 3-5 demonstrate the swing up condition, 6-7 show the inertia swing up procedure, and 11-15 depict the stabilisation process. Figure 19 shows the caught movements of the RIPS, wherein 1-2 illustrate the amplitude-increased simple pendulum motion, 3-5 exhibits the swing up condition, 6,7 show the inertia swing up technique, and 11-15 describe the stabilisation procedure.

Conclusions
In this paper, the control schemes for the RIP system that could be used to swing up the pendulum and balance it in the upright position were presented. A benchmark control, namely control of an RIP system, using sliding control was investigated. The position control of the arm coupled to the shaft of the actuator with sliding mode control was analysed, because of the symmetrical configuration, and to achieve the desired swing up from the RIP system's position down has been used, to bring the pendulum into the linear range where the linear model is valid for control created. A balancing control was additionally utilised in the linear range. The sliding mode controller offered excellent swing up control and adjustment of the vertical upstanding position. The performance of controlling the RIP framework by utilising the sliding mode control for the swing up and the sliding model control for balancing out indicated the preferred performance to that of the controller with a PD controller for swing up and the LQR controller for balancing. The swing up and balancing time of under 1.5 s in the proposed strategy contrasted with the 3-4 s in the other technique was reduced.
The experimental results closely matched the simulation results. Compared with the LQR swing up controller and the single linear equilibration controller, the proposed controller was more flexible and trustworthy.

Conflicts of Interest:
The authors declare that they have no conflict of interest with respect to this paper.