Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Self-balancing robot using MPU-6050

Self-balancing robot using MPU-6050

Scheduled Pinned Locked Moved Hardware
2 Posts 2 Posters 34 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Henil179
    wrote on last edited by
    #1

    Hi there,
    I recently made a self-balancing robot using Arduino Nano and gyroscope MPU-6050 and DC motors. But I am having issues regarding the setting of PID values in the code in the Arduino IDE. No matter what values I set, the bot seems to have trouble balancing by itself. I saw various videos which told me the change the kp, ki and kd values accordingly but nothing seems to work. Can anyone help me on this?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KevinT
      wrote on last edited by
      #2

      HI @Henil179

      I made one myself a couple of years ago, and yes, it was a fair bit of trial and error to get it working.
      Of course, the gain values will be dependent on a number of factors, for example, the torque constant of your motor, the gear ratio, the mass of the robot, where your centre of gravity is located, your loop rate, and where you've located your mpu-6050.
      I located my mpu-6050 over the axis at 12 o'clock near the vertical centre of my bot.

      What are you control variables?
      I used pitch (angle of rotation around motor axis) calculated from gx, gz and tan function.
      I also used pitch rate from the gyro.

      Are you using the onboard DSP of the mpu-6050 to do the calculations?
      I had no luck with this, the mpu-6050 kept freezing up, bad clone I guess.

      You also have to verify the direction of rotation of your motor versus your control variables.
      If you have the wrong direction, it will just run away.

      My gains are Kp:41, Ki:160, Kd:0.4

      I started with only Kp and kept increasing the value until the system became unstable, then I backed off to a stable point.
      Next, I began increasing Ki. This will bring you to steady state stability. It should balance itself when Kp & Ki.
      You will likely have to reduce Kp somewhat as you move to higher Ki values, if your system becomes unstable.
      Finally, I added Kd, to help it react more quickly to changes in angle.

      How do you change your gains?
      I have a bluetooth module on mine, to allow me to send serial commands to the robot, to set the gains and other things.

      My robot's biggest problem is gear backlash. This generates acceleration noise as it vibrates backward/forward, balancing itself. This vibration can feedback on itself and cause instability (when you increase Kp too high). It looks like the robot has Parkinsons when this happens! :grinning:

      I'd like to update my design to use a belt/gear drive or continuous rotation servo, but I haven't had a chance to get back to it.

      I hope this helps.

      1 Reply Last reply
      1
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      32

      Online

      11.7k

      Users

      11.2k

      Topics

      113.1k

      Posts


      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • MySensors
      • OpenHardware.io
      • Categories
      • Recent
      • Tags
      • Popular