Modeling, Control and Automatic Code Generation for a Two-Wheeled Self-Balancing Vehicle Using Modelica

University essay from Lunds universitet/Institutionen för reglerteknik

Abstract: The main goal of this project was to use the Modelica features on embedded systems, real-time systems and basic mechanical modeling for the control of a two-wheeled self-balancing personal vehicle. The Elektor Wheelie, a Segway-like vehicle, was selected as the process to control. Modelica is an object-oriented language aimed at modeling of complex systems. The work in the thesis used the Modelica-based modeling and simulation tool Dymola. The Elektor Wheelie has an 8-bit programmable microcontroller (Atmega32) which was used as control unit. This microcontroller has no hardware support for floating point arithmetic operations and emulation via software has a high cost in processor time. Therefore fixed-point representation of real values was used as it only requires integer operations. In order to obtain a linear representation which was useful in the control design a simple mechanical model of the vehicle was created using Dymola. The control strategy was a linear quadratic regulator (LQR) based on a state space representation of the vehicle. Two methods to estimate the platform tilt angle were tested: a complementary filter and a Kalman filter. The Kalman filter had a better performance estimating the platform tilt angle and removing the gyroscope drift from the angular velocity signal. The state estimators as well as the controller task were generated automatically using Dymola; the same tasks were programmed manually using fixed-point arithmetic in order to evaluate the feasibility of the Dymola automatically generated code. At this stage, it was shown that automatically generated fixed-point code had similar results compared to manual coding after slight modifications were made. Finally, a simple communication application was created which allowed real-time plotting of state variables and remote controlling of the vehicle, using elements of Modelica EmbeddedSystems library.

  AT THIS PAGE YOU CAN DOWNLOAD THE WHOLE ESSAY. (follow the link to the next page)