Matlab 2020a
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.
- Arduino uno
- Incremental encoder
- motor with built-encoder
- 12V Battery 2200 mah
- H-bridge L298N 2A
- Breadboard
- Desgin the system and assemble it
- Parameter estimaton for the motor to get the the motor coffecient
- Get the gain of LQR by using the mathmatical model built on Matlab
- Use the hardware in loop as following :
- 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
Inverted.pendulum.mp4
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.
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.
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"
This project was developed by Ebrahim Abdelghfar and Hesham Hesham with the help of the following papers and videos:
- https://www.researchgate.net/publication/224178913_Modeling_and_control_of_a_rotary_inverted_pendulum_using_various_methods_comparative_assessment_and_result_analysis
- https://www.st.com/content/dam/AME/2019/Educational%20Curriculums/motor-control/Introduction_to_Integrated_Rotary_Inverted_Pendulum_v2.pdf4
- https://www.youtube.com/watch?v=ZGICyE1pDxo