GithubHelp home page GithubHelp logo

seankin / inverted-pendulum Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 6.95 MB

This project was created whilst studying for my EE degree to learn about control theory and physics in a practical way.

License: MIT License

C++ 100.00%
inverted-pendulum rotary-encoders dc-motor

inverted-pendulum's Introduction

Inverted Pendulum Project

This project was used along side studying my Engineering degree specialising in Electronics to learn about control theory and physics in a practical way.

#explain the control theory prolem The inverted pendulum or cart pole is a classic problem in control theory.

#hardware and material requirements

-PLA driven by a DC motor via a toothed belt -3D printer

-rotary encoder opposite the motor (acts as a pulley for the belt and allows us to track the motion of the cart) -second rotary encoder on the cart is a pivot for the pole and measures its angle.

-The motor is controlled by a 32 amp Sabertooth motor controller.

-Monitored the encoders with an Arduino.

  • piece of extruded aluminum rail called V-Slot, (1.5 m long)

Materials

-V-Slot Linear Rail – 20x20mm - Clear Anodise, 1500mm

-Wisamic Incremental Rotary Encoder Dc5-24V Wide Voltage Power Supply Shaft 6Mm x 2

-20-teeth timing pulley wheel + 5m GT2 toothed belt

-ARDUINO MEGA 2560 REV3 [A000067]

-ICQUANZX DC Gear Motor 12V 200R High Torque Electric Micro Speed Reduction Geared Motor Centric Output Shaft Diameter Gearbox

-L298N DC Motor Driver Module

Method

-The rotary encoders were monitored by an Arduino Uno -Two different controllers (one to pump energy into the system and swing the cart into the upright position, and an linear quadratic regulator to balance it upright) -Python program contains commands the motor controller over serial and can query the Arduino whenever it needs to know the state of the system.

#LQR Controller

-linear quadratic regulator or LQR controller.

Alt text

Alt text

Arduino

// Motor A connections int enA = 9; int in1 = 8; int in2 = 7;

// This function lets you control spinning direction of motors void directionControl() { // Set motors to maximum speed // For PWM maximum possible values are 0 to 255 analogWrite(enA, 255);

Pole Rotary Encoder

#define CLK 2 #define DT 3 #define SW 4

DT (Output B) is the same as the CLK output, but it lags the CLK by a 90° phase shift. This output can be used to determine the direction of rotation.

CLK (Output A) is the primary output pulse for determining the amount of rotation. Each time the knob is rotated by one detent (click) in either direction, the ‘CLK’ output goes through one cycle of going HIGH and then LOW.

Math

-q is the position of the cart -θ is the angle of the pole counter-clockwise from vertical -f is the force on the cart -A and B are matrices that define the dynamics -Q and R are matrices that define the cost.

Resourses

https://lastminuteengineers.com/l298n-dc-stepper-driver-arduino-tutorial/

http://blog.benwiener.com/programming/2018/05/10/cart-pole.html

http://underactuated.mit.edu/index.html

https://github.com/philzook58/cart_pole

https://www.philipzucker.com/cart-pole-using-lyapunov-lqr-control-openai-gym/

http://underactuated.csail.mit.edu/pend.html

http://web.mit.edu/klund/www/papers/UNP_pendulum.pdf

https://www.i-programmer.info/news/105-artificial-intelligence/11336-worm-balanced-a-pole-on-its-tail.html

https://www.i-programmer.info/news/169/6769.html

http://web.mit.edu/klund/www/papers/Roberge1960.pdf

https://www.quanser.com/products/rotary-inverted-pendulum/

https://ocw.mit.edu/courses/mechanical-engineering/2-003sc-engineering-dynamics-fall-2011/lagrange-equations/MIT2_003SCF11_rec8notes1.pdf

inverted-pendulum's People

Contributors

seankin avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.