Self Balancing Bot with PID


In my previous project, I dealt with self-balancing robot without PID controller in this version of embedded the PID control on the same boat and the results are a better than the previous version obviously I am using the control systems part where our main objective is to achieve a critically damped robot. It should reach the steady state as it should have fewer oscillations and it should also recover from light to medium push.

In my previous bot without PID, I had to face problems where the robot will run away with a certain angle. Let's said it x and the Motors will move forward to balance the boat, however, the force or better say pseudo force that acts on the bot will be equal to the force that is pulling the robot downloads at a certain time. When these two forces balance the Robot full neither fall down nor it attain its vertical position. In this Mod, the robot will keep moving forward and forward in forward and finally, it will fall down
Obviously controlling this robot without PID has drawbacks, therefore, I worked on PID and the results are pretty good now.

The construction is same as it was in the previous Bot so if you have made the boat using my previous post then, of course, this will also work. All you have to do is to change the code and will be as good as new.

One thing you must remember while tuning the PID is, first of all, you must set everything parameters to zero that means P is equal to zero I is equal to zero and similarly is D is equal to zero. The Proportional part deals with the force part. It describes the force of your robot for any tilt i.e how vigorously it's gonna react.

So, first of all, you have to keep increasing your P-value until your oscillating. It may even oscillate wildly or it may even oscillate like a drowsy lump. All you have to do is to make the boat oscillate. After that increase the Derivative value to reduce these oscillations. Your robot will stand a bit still not exactly still at the center point without oscillating much. Largest the value of D, quicker it will attain the steady state. Now increase the I value. I value will deal with the response to the tilt. It will tell the bot how quickly you want your bot to recover from a tilt.

The circuit for the bot is same as the previous one.

Working 



Working Updated



*Latest Updated* Source_Code
Ping me if you face any problem. PID tuning takes luck and not the time I guess. In my next post, I'll deal with PID automatic tuning for this bot. So Long.

Comments

  1. Hello Suman,
    Greetings!

    Firstly Congratulations on this wonderful project, and I wish to make one myself.
    I want to know, can Arduino Nano be used for this? If so, need any changes be made to the coding?

    Also, what's the use of the Bluetooth Module? I went through your blogpost and noticed that perhaps you hadn't included Bluetooth Module while listing down for "self balancing bot without PID". But you did include it in your post on INSTRUCTABLE.

    Lastly, from your write ups i believe you are using the Capacitors as Filters. Where & how to use them?

    Thank You,
    Devdeep Dutta

    ReplyDelete
    Replies
    1. Hello,
      Indeed you can use Arduino Nano. However, a small change is required. Nano outputs 5v whereas Bluetooth Module uses 3.3v logic level. So TX of Nano would go to a voltage divider. The Voltage divider will divide the voltage and provide 3.3v logic for RX of Bluetooth. TX of Bluetooth can straight go RX of Nano as TX of Bluetooth will be at 3.3v level which is acceptable for Nano.

      The Bluetooth I used is HC 05.
      If you can get a 5V logic level Bluetooth, no divider is required. This is the reason I used Pro Mini.

      I have used Bluetooth module to wirelessly upload the code from Arduino IDE (PC or Mac) to my bot without messing with wires. I can even use it as a wireless serial monitor.

      Capacitors are used here to provide a delay output. Whenever HC05 is connected to a device, it's state pin will go high otherwise low. So when my PC is connected to HC05 to upload code, the pin goes high which in turn charges the capacitor. This capacitor then discharges to reset the Arduino.
      Reset is required here to upload the code to Arduino,

      State pin of HC05 will go to one end of Capacitor. The other end of the capacitor will go to the reset pin of Arduino.

      Regards

      Delete
    2. This comment has been removed by the author.

      Delete

Post a Comment