OPTIMAL CONTROL OF PENDUBOT SYSTEM USING SIMATIC S7-1200

: In optimal control, a common problem is developing a control law that can drive a dynamical system from one state to another as quickly as possible. The objective of paper is to design optimal control approach based SIMATIC S7-1200 for under-actuated Pendubot system. The main contribution of this paper is to introduce and validate control method for laboratory model of Pendubot system by using industrial device, namely, Programmable logic controller (PLC). Besides, Lyapunov Analysis is used to analyze the stability of optimal control. The simulation is performed in MATLAB/Simulink environment and experiment is carried out in TIA PORTAL environment. The simulation results and experimental results illustrate that the proposed control method is effective and robust by using PLC.


Introduction
Pendubot is a combination of Pendu (Pendulum) and bot (robot) -an under-actuated system that has fewer control inputs than degrees of freedom, and is difficult to control with nonlinearities.Then, we propose a solution and build LQR controller to control the system.In this paper, the classic LQR controller is embedded in Siemens S7-1200 to control Pendubot system instead of conventional microprocessors.By using an industrial circuit board with high anti-interference ability like PLC, it will pave the way for the research and application of algorithms in the field of automatic control in industry.Moreover, the Pendubot system together with the LQR algorithm will be pre-simulated by MATLAB software to validate the system's response and find the optimal LQR controller parameters.
Currently, the research of control engineering in Vietnam has been promoted a lot.In [1], the fuzzysliding control method is applied to the Pendubot system.In addition, the Fuzzy intelligent control algorithm is used to optimize the PID controller applied to the Pendubot system in [2].Besides, in recent years, the Pendubot system is often selected as a topic for graduation thesis.In [3], the author designs, manufactures and controls the Pendubot system stably.The LQR algorithm is applied to control of the Pendubot system in the graduate thesis [4].In 1995, Daniel J. Block and Mark W. Spong published a paper on the design and control of the Pendubot system [5].Up to now, based on the nonlinear structure of this system, there have been many papers developing algorithms to control stability for the system such as linear algorithm LQR [6], sliding algorithm [7], method energy [8], backstepping [9], fuzzy [10], adaptive algorithms to control the system in case of noise and uncertainty components [11], [12], [13].
According to studies on Pendubot, it shows that Pendubot is not a new object and has been exploited a lot by authors.However, most of the literature designs the controller and embeds it in microprocessor boards to control Pendubot.The microprocessor has the advantage of fast processing, but it is susceptible to interference by external factors.
The rest of this paper is organized as follow.First, mathematical model of Pendubot is given and control strategy is described in this section.Then, methodology of optimal control is called back, and stability analysis is carried out for optimal control by using Lyapunov Analysis.In the next section, the simulation results and experimental results are shown to discuss the pros and cons when author uses PLC to control the Pendubot.Finally, the conclusion and final remark are given.

Dynamic Analysis
The Pendubot consists of two links linked together by a passive joint as shown in Fig. 1.The bottom of link 1 is attached to active joint, which is the shaft end of the DC motor.Both Pendubot links can rotate freely in the vertical plane., D q q C q q q G q  + + = (1) Where Relationship of torque and voltage is as follows According to (1), we have After obtaining the differential equation of the system, the state space equation is deduced from the differential equation as follows ( ) ( ) ( ) Where

Control Strategy
The Pendubot system has 4 special positions, including 2 stable positions and 2 unstable positions.We can observe that at angular position 1 2 q  − = , 20 q = and 1 2 q  = , 2 q  =− in figures 2 and 3, respectively, Pendubot system is stable naturally.In figures 4 and 5, the pendubot system is no longer stable.With a minor force from gravity, it is enough to make the system fall down and lose stability.The requirement is to design the controller to keep the system balanced at the MID position (Fig. 4) and the TOP position (Fig. 5).To make the system balance at these positions, the motor needs to rotate with the appropriate voltage and must reverse the direction continuously.
In this manuscript, the TOP position is focued on controlling.;0 2     .

LQR Controller
Control law of LQR technique is given by ( ) Where K can be found easily by using MATLAB command K = lqr(A,B,Q,R).

Simulation Results
The validation is performed in MATLAB environment.There are 3 scenarios with difference starting point were set up for Simulink model.The simulation results are shown from Fig. 6 to Fig. 8.The period time of simulation is 10 seconds.In scenario 1, 2 and 3, the first link and the second link are stable at equilibrium point after 2 seconds.The angular velocity of link 1 and link 2 are stable after 2 seconds.After validating with MATLAB, we observe that the LQR control scheme can achieve the controlled requirement which we defined Section 2.2.We continuously developed LQR controller for experiment setup in Section 4.

Kg m ).
Motor's parameters are as given as follows: Kb=0.065( V/ ( / ) rad s ); Kt = 0.0108 ( / Nm A); Ra = 6.836 (  ); Nm rad s ).The input matrices A and B at TOP position are expressed in Eq. ( 16) and the weighting matrices Q and R are selected as expressed in Eq. ( 17 The optimal gain, K is obtained as expressed in Eq. (18).

System Setup
The experimental setup is designed by SolidWork.Figures 9,10        Therefore, the 0-24VDC to 0-5V conversion circuit is designed and described in Figures 18 and 19.

Experimental Results
Based on the successful simulation results, LQR algorithm is programmed to control Pendubot system by PLC S7-1212C.
In the experiment, the system is initially in the BOT position (Fig. 20), then the system is brought to the TOP position (Fig. 21) and the LQR control is used to balance the system in the TOP position.Then, to verify the controllability of the LQR controller, the pendulum is affected by a minor external force at the 9 th second, 12 th second and 17 th second, respectively.The experimental results show that after being impacted, the system quickly returns to the equilibrium point (Fig. 19).The experimental video clip can be watched on YOUTUBE by scanning the QR code in Fig. 22 or via link: https://www.youtube.com/shorts/MR5X4XW3iao.In this video, LQR control scheme is implemented to control Pendubot system in TOP position by using PLC S7-1200.The sample code is used to calculate the angular position of link 1 and link 2 which is captured in Appendix of this paper.

Conclusions
In this manuscript, the LQR controller has been designed and validated in both simulation and experiment for Pendubot system by using industrial device PLC S7-1200 instead.The state responses in experiment show that the system stabilize at equilibrium point with and without disturbance.However, the controlled parameter of LQR control scheme need to be optimized to control system better.Through this paper, we prove that LQR algorithm can be programmed and validated on the underactuated system such as Pendubot.

Appendix
In this section, calculation of angle of link 1 and link 2 are provived.

Fig. 7 .Fig. 8 .
Fig. 7. State responses of system with scenario 2. Scenario 3: 0; 0; 0.5; 0     = = = − = , 11, 12, 13 show the designation of Pendubot system on SolidWork and in laboratory.PLC S7-1200 and control panel are used in this experiment which are shown in Fig. 14.Driver HÍ6 is used which is shown in Fig. 15.In addition, in this subsection, the connection of PLC and Pendubot diagram, dependency circuits are listed from Fig. 16 to Fig. 19.

Fig. 17 .
Fig. 17.Power circuit diagram.The driver's control signal (DIR and PWM pins) requires voltage level from 0-5VDC.However, the output of the PLC has a voltage level of 0-24VDC.