ahsanullah university of science and...

13
Ahsanullah University of Science and Technology Project Report Department of Electrical and Electronic Engineering Project Name: 2 Wheel Self Balancing Robot. Submitted by: 13-01-05-031 : Md. Faridul Hasan 13-01-05-047 : Sohel Ahmed

Upload: others

Post on 24-May-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

Ahsanullah University of

Science and Technology

Project Report Department of Electrical and Electronic Engineering

Project Name: 2 Wheel Self Balancing Robot.

Submitted by:

13-01-05-031 : Md. Faridul Hasan

13-01-05-047 : Sohel Ahmed

Page 2: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

12-02-05-117 : Imtiyaz Ahmed Khan

12-02-05-120 : Fariha Rahman

Introduction A robot is an automatic device that performs functions usually attributed to humans. The robots are normally controlled by embedded processors that execute a controller algorithm. A robot usually operates autonomously, but sometimes can be assisted by a human over a communication channel.

The robot in this example uses feedback from a single-axis gyro sensor to maintain vertical balance while it moves around on two motorized wheels. The robot's controller handles both driving and vertical balance. The drive control is identical to the one used in the Drive with PID Control example. The balance control is implemented by a two-wheeled inverted pendulum controller.

In this example, you will first verify the robot's controller by running it in simulation. In simulation, you will use simulated hardware to confirm the controller correct operation. Then, you will validate the controller by running it on actual hardware. As you run the controller on the robot, you will be able to change the controller parameters in order to modify the robot's behavior.

Equipment:

Page 3: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

Mechanical Parts: 3 × Acrylic Board 16 × Brass Stud M4x16 2 × encoder motor model number - JGA25-371 2 × Motor Brackets 2 × Shaft Coupling 2 × Wheel Screw M3 Nut M3 Electronic Modules: 1 × Arduino UNO 1 × Motor Driver L298N 1 × MPU6050

Page 4: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

Cicuit Diagram

Page 5: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical
Page 6: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

Codes #include "Wire.h" #include "I2Cdev.h"

#include "MPU6050.h"

//********************* motor

int INA =4 ,INB= 5 , INC = 6 , IND=7 ;

int ENA=3;

int ENB= 11;

int rs=75;

int ls=75;

//***********************************

MPU6050 mpu;

int16_t ax, ay, az;

int16_t gx, gy, gz;

int val ;

int prevVal ;

Page 7: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

int perm=0;

void setup()

{

Wire.begin();

Serial.begin(115200);

pinMode(INA,OUTPUT); // right motor INA

pinMode(INB,OUTPUT); // right MOTOR INB

pinMode(INC,OUTPUT); // left INC

pinMode(IND,OUTPUT); // left IND

Serial.println("Initialize MPU");

mpu.initialize();

Serial.println(mpu.testConnection() ? "Connected" : "Connection failed");

perm=1;

test_motor();

}

void loop()

{

Page 8: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

val = map(-17000, 17000, 10, 179); // only using y axis data

//********************for debug *********************

if(perm)

{

if (val != prevVal )

{

Serial.print(" Accelometer y : ");

Serial.print(val);

Serial.print(" , ");

Serial.println(val_gy_x);

prevVal = val;

}

}

//**************************main code ***************************

if(val >=88 && val <= 92)

stop1();

else if(val <88)

backward(rs,ls);

else if(val> 92)

forward(rs,ls);

Page 9: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

else

;

delay(50);

}

void test_motor()

{

forward(rs,ls);

delay(1000);

stop1();

delay(1000);

backward(rs,ls);

delay(1000);

stop1();

delay(1000);

}

void forward(int r , int l)

{

analogWrite(ENA,r);

digitalWrite(INA,HIGH);

digitalWrite(INB,LOW);

analogWrite(ENB,l);

digitalWrite(INC,1);

Page 10: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

digitalWrite(IND,0);

}

void backward(int r1 , int l1)

{

analogWrite(ENA,r1);

digitalWrite(INA,0);

digitalWrite(INB,1);

analogWrite(ENB,l1);

digitalWrite(INC,0);

digitalWrite(IND,1);

}

void stop1()

{

digitalWrite(INA,0);

digitalWrite(INB,0);

digitalWrite(INC,0);

digitalWrite(IND,0);

}

Page 11: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

Troubleshooting

1. Arduino pin number 9, 10 didn’t work when we connected it with motor driver pin ENB and ENA.

2. We couldn’t figure out the connection diagram of the encoder motor.We faced trouble to find out the data sheet of encoder motor.

Project images

Page 12: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical
Page 13: Ahsanullah University of Science and Technologyfiles.aust-eee-2211-project.webnode.com/200000148...Ahsanullah University of Science and Technology Project Report Department of Electrical

Applications 1. With more adapters like Bluetooth, Wi-Fi, and RC Receiver, we can control the

Balanbot in different ways. 2. We can use it as a 2 wheel car instead of 4 wheel car with more modification.