Kendini dengeleyebilen iki tekerlekli aracın tasarımı ve kontrolü
Design and control of self-balancing two wheeled vehicle
Yazar: ULAŞ ÇELİK
Danışman: YRD. DOÇ. DR. AYHAN KURAL
İstanbul Teknik Üniversitesi / Fen Bilimleri Enstitüsü / Makine Mühendisliği Ana Bilim Dalı / Sistem Dinamiği ve Kontrol Bilim Dalı
Derece: Yüksek Lisans, 2014
Konu: Makine Mühendisliği = Mechanical Engineering ; Mekatronik Mühendisliği = Mechatronics Engineering
Dizin: Matematiksel modelleme = Mathematical modelling ; Model öngörümlü denetim = Model predictive control ; Optimizasyon = Optimization ; PID denetleme = PID control ; Ters sarkaç = Inverted pendulum

Özet:
20. yüzyılın başlarından itibaren bilimdeki ilerlemeler büyük bir ivme kazanmış ve akademik çevrenin, daha elverişli bir araştırma ortamına kavuşması bu ilerlemeyi tetiklemiştir. Bilimle uğraşmak bir prestij haline gelmiş ve etkilerini göstermeye başlamıştır. Bilimin bu denli gelişimi teknolojik gelişmeleri de beraberinde getirmiştir. Özellikle 20. yüzyılın sonları ile 21. yüzyılın başlarında, bilim ve teknolojinin birlikte gelişmesiyle robotik ve akıllı sistemlerde büyük ilerlemeler kaydedilmiştir. Zaman içerisinde bu sistemler hayatımızın ayrılmaz birer parçaları haline gelmiştir.

Taşıtlar, hayatımızın ayrılmaz birer parçası olmaya başlayan bu akıllı sistemlerin kullanıldığı yerlerden biri olarak gösterilebilir. Taşıtlarda kullanılan bu akıllı sistemlerin amacı; zaman ve yakıt tasarrufu sağlamak, taşıtları daha kompakt hale getirebilmek ve güvenliği en üst düzeye çıkartmaya çalışmaktır. Şüphesiz ki, güvenliğin bu denli ön plana çıktığı ve fosil yakıtların giderek azaldığı dünyamızda; bu sistemlerin önemi her geçen gün artmaktadır. Bununla paralel olarak bu tarz sistemlerin gelişmesi için yapılan çalışmalarda da gözle görülür bir artış söz konusudur. Bu sistemlerin gelişmesiyle birlikte alternatif enerji bazlı ve alternatif özelliklere sahip taşıtlar geliştirilmeye çalışılmaktadır.

Bu çalışmada, iki serbestlik dereceli nonlineer bir sistem olan kendini dengeleyebilen iki tekerlekli elektrikli bir aracın nonlineer modeli elde edilmiş ve tasarımı yapılmıştır. Literatürde incelenen çalışmalarda matematiksel modelin belirlenmesi için Newton hareket denklemleri ve ya Lagrange enerji metodu kullanılmıştır. Bu tez kapsamında modelin belirlenmesi hususunda Lagrange enerji metodundan yararlanılmıştır. Nonlineer model Matlab-Simulink® ortamında oluşturulmuştur. Tasarlanan araç kapsamındaki temel amaç; belirlenen referans denge konumu etrafında sarkaç açısı olan theta açısını kontrol edebilmektir. Bu sebeple oluşturulan modeller için Matlab-Simulink® ortamında PID ve Model Öngörülü Kontrol (MPC) kontrolcüler tasarlanmıştır. Konu ile ilgili çalışmalarda nonlineer model için PID kontrolcü tasarlanırken genellikle deneme yanılma yolu ile PID katsayıları belirleme yöntemi kullanılmıştır. Bu çalışma kapsamında ise PID kontrolcü katsayıları belirlenirken Matlab-Simulink® ortamında bulunan optimizasyon algoritmasından yararlanılmıştır. PID kontrolcü tasarlanırken belirli performans koşulları göz önünde bulundurulmuştur. Sistemin bu performans koşullarına göre çalışması amaçlanmıştır. MPC tasarlanırken, MPC'nin temel elemanlarından olan öngörü modeli seçilmiş, öngörülen davranış başarı ölçütü için bedel fonksiyonu optimize edilmiş ve sistem kontrol giriş sinyali kayan ufuk prensibi ile hesaplanmıştır. 

Sarkaç açısı olan theta  açısının kontrolü için tasarlanan kontrolcü türleri ve sistem, istenilen referansı izleyebilmesi ve performans koşullarını sağlaması için farklı bozucu tür ve büyüklükleri ile birlikte simüle edilmiştir. Simülasyon sonuçları irdelendiğinde, tasarlanan kontrolcüler aracılığıyla sistemin kontrol edilebildiği, performans koşullarını sağladığı ve belirlenen referans denge konumunu takip edebildiği görülmüştür. PID ve MPC kontrolcü performansları karşılaştırıldığında, MPC kontrolcünün PID kontrolcüsüne göre daha hızlı ve daha az aşım performansı ile cevap verdiği aynı zamanda referans denge konumunu daha iyi takip edebildiği görülmüştür. Kontrol eforları karşılaştırıldığında, MPC'nin çok daha az efor ile sistem kontrolünü sağlayabildiği gözlemlenmiştir.

Bu çalışmanın devamında, İ.T.Ü. Makina Fakültesi laboratuvarında kendini dengeleyebilen iki tekerlekli elektrikli araç tasarlanmıştır. Aracı kontrol edebilmek için tasarlanan PID kontrol sistemi deneysel çalışmada kullanılmıştır. Araç, üst kısımda bulunan sarkaç ve alt kısımda bulunan yürüyen aksam olarak iki parça halinde düşünülebilir. Araçta bulunan tekerlekler, sarkaçtaki açı değişimlerine göre motorlar aracılığıyla tahrik edilmektedir. Motorların hareketi için üretilen sinyaller Arduino® Uno gömülü sistemi tarafından hesaplanmakta ve motor sürücüsü ile uygulanmaktadır. Sarkaçtaki açı değişimi ise IMU yardımıyla ölçülerek Arduino® Uno'ya gönderilmektedir. PID kapalı çevrim kontrol sistemi algoritması oluşturulmuş ve Arduino® Uno'nun içerisine gömülmüştür. Yapılan deneyler sonucunda elde edilen veriler işlenerek, simülasyon sonuçları ile gerçek zamanlı çalışmanın sonuçları karşılaştırılmıştır.

Abstract:
From the beginning of the 20th century, improvements in science have gained immense speed. The academic environment to attain a more favorable research environment has triggered this progress. To deal with science started to become a prestigious situation and it began to show some influences. With the development of science has directly affected in technological development.  Especially in the later 20th century and at the beginning of 21th century, with the progress of science and technology, major progress was made in robotics and intelligent systems. These systems became integral parts of our lives in the course of time.

Vehicles can be a good example that these smart systems are used. The purpose of these systems are to increase the safety of the vehicle, to make it more compact, to save time and fuel. Without doubt, increasing of the importance in security and decreasing of the fossil fuels in our world lead to increase the importance of these systems. Therefore there is clearly the necessity to personal human transporters that use less energy and take up less space than cars with the development of these systems. So at the beginning of 2000s, two-wheeled self-balancing electric vehicles took part in literature as segway.

Segway was developed to consume less energy as providing the space-saving. Presented as the invention of the century because of the most important feature that is interested with the user's body movement progress. And segway has high maneuverability. Zero turning radius, fast response, dimensional features and robotic properties make these systems usable in the narrow areas.

This thesis presents the mathematical modelling, control system design and real system design of two wheeled inverted pendulum which is nonlinear system with two degrees of freedom. Nonlinear model of two wheeled inverted pendulum was obtained and the vehicle was designed. To solve this problem, inverted pendulum mechanism were studied. Because the main solve was based on the inverted pendulum. 

In the previous literature studies, Newton's motion equations and Lagrangian method have been used for determination mathematical model. Nonlinear equations of motion has been obtained via Lagrangian method. Many assumptions has been made in order to simplify the equations of motion of the system (like rolling without slipping, no motion horizontal axis etc.). And these equations have been linearized at the linearized points  to use created MPC controller. The linearized points were the points of system operation.

Nonlinear model was created in Matlab-Simulink®. The main purpose is to control the theta  angle around equilibrium position. theta angle is pendulum angle. Firstly performance conditions were determined. According to performance conditions the system were simulated with real system's parameters. 

To determine real system's parameters, the real system were demontaged. And the parameters were measured. To calculate the moment of inertia of the system, selfbalancing two wheeled vehicle was designed in SolidWorks®. Each parts of vehicle were made by using appointment materials. Then the moment of inertia of the system was calculated. Also for calculate friction coefficient, losses in reducer and motor were considered. Friction model was obtained. For obtaining the friction model, equation were written between motor torque and wheel torque. Therefore the friction coefficient were obtained using wheel dynamic.

For the closed control system, two types of controllers were used. Firstly PID controller that is commonly preferred controller was used. To creat PID controller, nonlinear dynamic equations were modelled in Matlab-Simulink®. To determine coefficients of PID controller, special optimization block was used in Matlab-Simulink®. Thus the best PID controller was obtained. Therefore PID controllers were designed on Matlab-Simulink®. 

Then MPC controller that is advanced control method was used. MPC optimizes estimated future behavior of the system for success criteria. To do this, it uses system dynamical model. MPC controller's basic elements are prediction model, cost function and sliding horizon. While designing MPC, elements must be selected properly to control problem. To design MPC controller, nonlinear dynamic equations were modelled in Matlab-Simulink®. To determine parameters of MPC controller, trial-error method was used. To do this, a lot of experiments were done. 

When designing the MPC, MPC prediction model, that is one of basic elements, was chosen and cost function was optimized for success criteria, then system control input signal was calculated via the principle of sliding horizon.

Each controller was tested on the system which were under the effect of different disturbances. These disturbances affect arm angular position. Disturbances were step and impulse effect.

Controllers were designed to control that pendulum angle, theta, were simulated with different disturbances. According to the results of simulation, the system can be controlled through the controllers, which provides performance requirements and specified reference has been shown to be able to follow the equilibrium position.  

In the simulations, it was seen that both designed controllers can control the system and each given reference can be followed by system. And also seem that, on simulations made with step disturbances, according to closed loop system with PID controller, closed loop system with MPC replied faster with less oscillation. When made comparison about control effort, MPC control signal provides the control with a little bit more effort according to MPC control signal.

Moreover, It was observed that while increasing the step disturbance among that is applied to the system with MPC controller, the oscillation amplitude is increasing a little but there is no changing on time that is spent to get normal position.

While observing the same situation for the system with PID controller, It was seen that while increasing the disturbance effect, the oscillation amplitude and the time that is spent to get normal position is increasing. 

In the simulations made with impulse disturbance, it was realized that MPC controller closed loop system replies with less oscillation according to PID controller closed loop system. Also the time that is spent to get normal positions for both controllers are approximate. At the same time, MPC controller system followed the reference angle much better than PID controller system. It is observed that PID controller system had steady-state error. As increasing the disturbance effect that is applied to MPC controller system, the oscillation amplitude increased but the time to spend to get normal position didn't change. While observing the same situation for PID controller system, as increasing the disturbance effect, the oscillation amplitude increased a bit more and the time to spend to get normal position also increased.

In continuation of this work, The self-balancing two-wheeled vehicle was designed and it can be found in ITU Faculty of Mechanical Engineering laboratory. The designed control system was implemented for experimental control. In the vehicle wheels, the pendulum was driven by the engine according to the angle change. The signals were generated by the motor driver and Arduino® Uno embedded system were provided to motors drive. It is measured that the change in the angle of the pendulum with the help of the IMU that is sent to the Arduino® Uno. Closed-loop control system algorithm was created and embedded into the Arduino® Uno. Experiments performed when processing the data obtained as a result of the actual system. It was observed that it can be controlled with the PID controller.

Dynamics simulations of the real system as the cause of the difference; the variability of the size of the disturbance applied, real-growing troubles in the system snapshot, the assumptions of the model show differences, the parameters can not be measured in accurately and precisely and control was made for the force input. 

In the continuation of this study, changes will be made about the actual system hardware and software necessaries for the implementation of the MPC controller.