Wheeled Self-Balancing Robot | With Arduino Uno, L293D & Ultrasonic Sensor | Self Balancing Robot Without IMU (MPU-6050) | Arduino Two Wheel Robot

by Python EveryDay in Circuits > Robots

3178 Views, 22 Favorites, 0 Comments

Wheeled Self-Balancing Robot | With Arduino Uno, L293D & Ultrasonic Sensor | Self Balancing Robot Without IMU (MPU-6050) | Arduino Two Wheel Robot

Wheeled Self-Balancing Robot | Without IMU (MPU-6050)? Only Arduino Ultrasonic Sensor & L293D

This is a wheeled self-balancing robot. Powered by Arduino UNO and balanced by ultrasonic sensor. It is able to balance itself vertically.

Supplies

IMG_20220305_164333_HDR.jpg
vlcsnap-00002.jpg
vlcsnap-00003.jpg
IMG_20220326_210756_HDR.jpg
IMG_20220305_164306_HDR.jpg
vlcsnap-00004.jpg
  • Arduino Uno x1
  • Geared DC motor with Wheels x2
  • L293D Motor Driver IC x1
  • Ultrasonic Sensor (HC SR-04) x1
  • Power Supply x1
  • PVC Pipes 1 meter
  • PVC T-Joint x1
  • PVC Elbow Joint x1
  • Breadboard x1
  • Connecting Wires

Geared DC Motor

vlcsnap-00001.jpg

We will be using two geared dc motors to power this robot.

Attaching Wheels to Geared DC Motor

vlcsnap-00002.jpg
vlcsnap-00003.jpg

Now we will attach wheels to the shafts of the motors.

PVC T-Joint

vlcsnap-00004.jpg
vlcsnap-00008.jpg
vlcsnap-00009.jpg
vlcsnap-00005.jpg
vlcsnap-00006.jpg
vlcsnap-00007.jpg

This is a T-joint for PVC pipe. We will be using it to hold the motors. The wires will come out from the top hole. 

Wiring Motors Through T-joint

vlcsnap-00013.jpg
vlcsnap-00014.jpg

Before fixing the motor in this pipe, we have to wire them. We will be passing 4 wires from the top hole. Splitting at two ends, 2 wires for each motor.

Pulling Wires Through Top Hole

vlcsnap-00015.jpg

We will pull the wire from T-joint back so that the motors will be in their place. 

Fixing Motors in Place

vlcsnap-00016.jpg
vlcsnap-00017.jpg

Now we have fixed the motor in the T-joint. 

Adding Pipes in Top Hole to Mount Ultrasonic Sensor

vlcsnap-00028.jpg
vlcsnap-00029.jpg

We have added some pipes at the wire end of the T-Joint. We will mount the sensor on it later.

Circuit Schematic

Self Balancing Wheeled Robot.png
IMG_20220326_210756_HDR.jpg

Here is the Circuit Schematic. We have used L2938 H bridge motor driver IC to rotate motors in both directions.

Concept of the Self Balancing Robot

vlcsnap-00018.jpg
vlcsnap-00019.jpg

The concept for this self-balancing robot is simple. Here we have an ultrasonic sensor. Which measures its distance from the obstacle in front of it.

if the distance is greater than the fixed distance then the robot will move forward and if the distance is less, then the robot will move reverse. to compensate for its fall.

Wiring Ultrasonic Sensor With Arduino for Self Balancing Robot

vlcsnap-00024.jpg
vlcsnap-00025.jpg
vlcsnap-00026.jpg
vlcsnap-00027.jpg

The ultrasonic sensor has 4 pins, which are trigger, echo, power, and ground. 4 wires are connected from the pins to microcontroller.

Watching the Robot Balance Itself

vlcsnap-00022.jpg
vlcsnap-00020.jpg
vlcsnap-00021.jpg

Now, the robot is placed vertically on the ground. And it seems like, it is balanced. It is moving continuously to keep itself balanced.

But, it is also getting some support from the wires, which I am holding in my hand.

It is oscillating back & forth continuously, these oscillations need to be damped. So, the robot will be balanced and stand at a point without any movement.

Issues & Resolutions in Self Balancing Robot

vlcsnap-00030.jpg
vlcsnap-00031.jpg
vlcsnap-00032.jpg
vlcsnap-00033.jpg

If it falls beyond a particular point, then it won't be able to recover itself.

These motors require a lot more power to be fast and responsive.

And while testing, the second H-bridge of the L293D got fried. So, I didn't get the chance to control it via PID.

To truly make it balanced, we could have used the MPU-6050 Inertial measurement unit. Instead, we used this cheap ultrasonic sensor.

CAD Design of the Self Balancing Robot

Self Balancing Wheeled Robot (3).png
Self Balancing Wheeled Robot (2).png
Self Balancing Wheeled Robot (1).png

This is the CAD, design of the wheeled self-balancing robot. Here we can see two motors, connected with two wheels. These motors are mounted in the PVC T-joint. a vertical PVC pipe is attached to T-joint. An ultrasonic sensor is attached to the pipe. Pointing downwards.

View CAD Design of Wheeled Self Balancing Robot

Conclusion

Wheeled Self-Balancing Robot | Without IMU (MPU-6050)? Only Arduino Ultrasonic Sensor & L293D

But, somehow we managed to make it balanced a little bit. We are happy with the results. 


Robotics EveryDay!!!

Code for the Self Balancing Robot


int ip3=2,ip4=3;
int t=8,e=9;


void setup() {
  pinMode(t, OUTPUT);  //trigger pin
  pinMode(e, INPUT);  //echo pin
  
  pinMode(ip3,OUTPUT);
  pinMode(ip4,OUTPUT);


}


float distance(){
  
  float duration, cm;
  
  digitalWrite(t, LOW);
  delayMicroseconds(2);
  digitalWrite(t, HIGH);
  delayMicroseconds(5);
  digitalWrite(t, LOW);
  
  duration = pulseIn(e, HIGH);


  cm = duration/ 29 / 2;
  
  return cm; //returns distance in centimeters
}


void loop() {
  
  float dis = distance();


  if (dis>27){
    digitalWrite(ip3,LOW);
    digitalWrite(ip4,HIGH);
  
  }else if(dis<27){
    digitalWrite(ip3,HIGH);
    digitalWrite(ip4,LOW);
  }


}