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.
- 1) Hardware
- 2) Software
- 3) Measuring tilt using IMU
- 4) Self Balancing Bot - Rev 1
- 5) Self Balancing Bot - Rev 2
- 96Boards CE
- 96Boards Compliant Power Supply
- Sensors Mezzanine
- Chasis
- IMU 6 DoF - MPU6050
- Motor Driver - L289N
- DC motor
- Dc to DC Boost Converter
- 11.1v Battery for Board
- 11.1v Battery for Motors
$ sudo apt-get update
$ sudo apt-get upgrade
Install MRAA library as specified here
- 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
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.
- 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:
- Assume Sensors Mezzanine is placed on top of CE board and use groove connector for connecting MPU6050 to I2C0 connector
- Use two separate batteries for powering CE board and Motor driver
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
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.
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.
The second revision of Self Balancing bot has the following changes compared to first revision:
- Used DMP in MPU6050 for sensor fusion
- Offloaded PID calculation to Arduino (Sensors Mezzanine)
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:
- Assume Sensors Mezzanine is placed on top of CE board and use groove connector for connecting MPU6050 to I2C0 connector
- Use two separate batteries for powering CE board and Motor driver
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
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:
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.
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.