Skip to content

96boards-projects/self_balancing_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Self balancing Bot using 96Boards

Self balancing Bot also called as Segway is a bot based on Inverted Pendulum concept. It balances itself steadily by moving forth and back to counteract the fall. IMU (Inertial Measurement Unit) is used to measure the angle of the Bot for detecting the slope. Then, the motor position will be updated to keep the Bot steady. PID controller will be used to adjust the position of motors based on the angle calculated by IMU. All of the computations will be done using CE board and controlling the DC motor will be offloaded to Arduino present on Sensors Mezzanine.

Table of Contents

1) Hardware

1.1) Hardware requirements

2) Software

2.1) Operating System

2.2) Software Dependencies

$ sudo apt-get update
$ sudo apt-get upgrade

Install MRAA library as specified here

3.1) Hardware Setup

  • Make sure the 96Boards CE is powered off
  • Connect I/O devices (Monitor, Keyboard, etc...)
  • Connect Sensors Mezzanine
  • Power on your 96Boards CE with compatible power supply

4) Self Balancing Bot - Rev 1

This is the first revision of Self Balancing Bot. This revision uses complimentary filter for sensor fusion and PID implementation is done in 96Boards CE. Due to gyroscope drift and accelerometer noise, balancing is not stable.

Self Balancing Bot

4.1) Hardware Setup

Schematic Diagram

  • Make sure the 96Boards CE is powered off
  • Assemble the setup in a chasis as per above schematic
  • Connect Arduino to 96Boards CE using USB cable
  • Power on your 96Boards CE with compatible power supply

Note:

  1. Assume Sensors Mezzanine is placed on top of CE board and use groove connector for connecting MPU6050 to I2C0 connector
  2. Use two separate batteries for powering CE board and Motor driver

4.2) Building

src directory in this project contains the source files and inc contains the header files.

$ git clone https://github.com/96boards-projects/self_balancing_bot.git
$ cd self_balancing_bot/rev_1
$ make

4.3) Programming Arduino

Arduino is used to control the DC motors with the help of PWM. 96Boards CE will send the control commands to Arduino, which will get parsed and used to control motors.

For programming Arduino, open src/arduino/bot/bot.ino using the Arduino IDE and select the appropriate Serial port ( /dev/ttyACM* for external arduino, dev/tty96B0 for Sensors Mezzanine). Then, click Upload.

4.4) Self Balancing Bot in action

After building, object files will get listed under obj directory and the final executable binary motor_control would be available in rev_1 directory.

Now, hold the bot in upright position and execute the following command to see Self Balancing Bot in action.

$ sudo ./motor_control

Bot should stabilize itself by moving back and forth.

Note: Due to accelerometer drift, bot may fail to stabilize in few moments. This will be addressed in Rev-2 using DMP.

4.5) Video Demonstration

Demonstration Video

5) Self Balancing Bot - Rev 2

The second revision of Self Balancing bot has the following changes compared to first revision:

  1. Used DMP in MPU6050 for sensor fusion
  2. Offloaded PID calculation to Arduino (Sensors Mezzanine)

5.1) Hardware Setup

From the hardware perspective, there is no change from first revision.

  • Make sure the 96Boards CE is powered off
  • Assemble the setup in a chasis as per above schematic
  • Connect Arduino to 96Boards CE using USB cable
  • Power on your 96Boards CE with compatible power supply

Note:

  1. Assume Sensors Mezzanine is placed on top of CE board and use groove connector for connecting MPU6050 to I2C0 connector
  2. Use two separate batteries for powering CE board and Motor driver

5.2) Building

src directory in this project contains the source files and inc contains the header files.

$ git clone https://github.com/96boards-projects/self_balancing_bot.git
$ cd self_balancing_bot/rev_2
$ make

5.3) Programming Arduino

Arduino is used to control the DC motors with the help of PWM and PID controller. 96Boards CE will send the IMU data to Arduino which will be used as an input to the PID controller to control the motor positions.

This revision uses 2 Arduino libraries:

  1. PID library
  2. Motor Controller library

Both libraries are included in the repository under src/arduino/ . Add both libraries to Arduino by following the guide here. After installing the libraries, open the source code src/arduino/bot/bot.ino using Arduino IDE and select the appropriate Serial port ( /dev/ttyACM* for external arduino, /dev/tty96B0 for Sensors Mezzanine). Then,click Upload.

5.4) Self Balancing Bot in action

After building, object files will get listed under obj directory and the final executable binary motor_control would be available in rev_2 directory.

Now, hold the bot in upright position and execute the following command to see Self Balancing Bot in action.

$ sudo ./motor_control

Bot should stabilize itself by moving back and forth.

5.5) Video Demonstration

Releases

No releases published

Packages

No packages published

Languages