GithubHelp home page GithubHelp logo

ebrahimabdelghfar / rotary-inverted-pendulum Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 2.3 MB

Hybrid control system using LQR and hardware in loop

License: MIT License

MATLAB 76.95% C++ 12.71% C 10.34%
arduino hardware-in-the-loop inverted-pendulum lqr matlab parameter-estimation simulink

rotary-inverted-pendulum's Introduction

Software used

Matlab 2020a

Introduction

This project involves the design and implementation of a rotary inverted pendulum system using Arduino and Simulink. The system consists of a motor with a built-in encoder and an incremental rotary encoder for measuring the angle of the pendulum. The controller for stabilizing the system is implemented using an LQR controller.

Requirments

  • Arduino uno
  • Incremental encoder
  • motor with built-encoder
  • 12V Battery 2200 mah
  • H-bridge L298N 2A
  • Breadboard

Steps

  1. Desgin the system and assemble it
  2. Parameter estimaton for the motor to get the the motor coffecient
    1. give the motor a $\pm 12V$ signal
    2. Collect of the $V$ and $\frac{rad}{sec}$ in an excel file
    3. Import the reading in the Matlab
    4. Build a simulated model using simscape library as the following fig: image
    5. Using the Parameter-Estimator app of simulink to predict the measurments between simulated and real data
  3. Get the gain of LQR by using the mathmatical model built on Matlab
  4. Use the hardware in loop as following :image

Note

  • When you work with the code and model you must include the repo in Matlab path
  • Include the encoder function
  • Enter the motor parameter in workspace

State Space Model

image

image image2

Electrical circuit

Schematic_New Project_2023-01-02

Mechanical Model

image image2

Video

Inverted.pendulum.mp4

Limitations

There is no swing up functionality in the current model. Additionally, there is some vibration present in the system. The system is able to work within an angle range of +20 to -20 degrees, beyond which it will turn off until the pendulum is returned within this range.

Usage

To use the system, connect the Arduino board to a computer and open the Simulink model. Run the model and the system will start operating. The angle of the pendulum and the control signal can be monitored in the scope blocks in the model.

Files

The repository includes the following files:

  • MotorParameter.mat "which contain the esimtated motor parameter using parameter estimator tool"
  • MotorModelEstimated.slx "A simulink file that contain a simscape model for the motor to be used in parameter estimation"
  • model_inverted_rotary_pendulumV4.mlx "A live matlab script at which the model is applied ,in addition to be used in getting the response and stability gains"
  • RotaryInvertedPendulumHardwareInLoop.slx "A simulink Hardware in loop code for arduino uno that was programmed using simulink"
  • Driver guide "folder that contain the simulink's arduino encoder driver in it"

Credits

This project was developed by Ebrahim Abdelghfar and Hesham Hesham with the help of the following papers and videos:

rotary-inverted-pendulum's People

Contributors

ebrahimabdelghfar avatar hesham-hesham avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

alireza859

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.