Self Balancing Sphere

by EuDavinho in Circuits > Arduino

52 Views, 0 Favorites, 0 Comments

Self Balancing Sphere

IMG-20240607-WA0004.jpg
IMG-20240607-WA0005.jpg

Here I present a self balancing sphere that is based on a previous project about an actuating sphere. This project takes inspiration from another based on an actuating sphere controlled with joystick. Here, Instead I took the same premise of the actuating sphere, but adapted it to include an MPU-6050 in order to allow the sphere to self-balance itself. In principle the sphere is also supposed to be fully printable at home given you have access to a 3D-Printer and some standard hardware and tools. The entire process can be completed relatively quickly, although there will be some tinkering with the Arduino code in order to tune the precision and response time of the servos (this is also dependent on the quality of servo motors you have), as well as ensuring that the rest of your parts print adequately.

Supplies

IMG-20240607-WA0042.jpg

You Will Need The Following Supplies:


  • Arduino Uno with USB-B Cable
  • Small breadboard
  • 9V Battery
  • 12-14 Jumper Wires
  • 2 x 20kg Digital Servos
  • 2 x R-O Servo Horns
  • MPU-6050
  • 8 x M3 x 10 screws
  • 3 x M3 x 20 screw
  • 6 x M3 x 30 screws
  • Box of M3 Nuts
  • Uhu Plus Sofortfest Binder or Similar
  • Electric Tape
  • Duct Tape
  • Access to a 3D-Printer

Arduino Set Up

2024.06.07 - CDDF - Useless Machine Sketch2_bb.png
2024.06.07 - CDDF - Useless Machine Sketch2_schem.png

Wiring Steps


Powering the Arduino:

  • Connect the 9V battery to the battery clip.
  • Plug the DC barrel jack from the battery clip into the Arduino's power supply jack. This will power the Arduino board.

Setting Up the Breadboard:

  • Place the breadboard close to the Arduino board.
  • Connect the ground (GND) pin from the Arduino to one of the ground rails on the breadboard using a jumper wire.
  • Connect the 5V pin from the Arduino to the power rail on the breadboard using a jumper wire.

Connecting the MPU6050:

  • Connect VCC on the MPU6050 to the 5V rail on the breadboard.
  • Connect GND on the MPU6050 to the ground rail on the breadboard.
  • Connect SDA on the MPU6050 to the A4 pin on the Arduino (assuming you are using an Arduino Uno).
  • Connect SCL on the MPU6050 to the A5 pin on the Arduino (assuming you are using an Arduino Uno).

Connecting the Servos:

  • Attach the servo motors to the breadboard.
  • Connect the red power wire from each servo to the 5V rail on the breadboard.
  • Connect the black ground wire from each servo to the ground rail on the breadboard.
  • Connect the signal wire from the X-axis servo to pin 9 on the Arduino.
  • Connect the signal wire from the Y-axis servo to pin 10 on the Arduino.


Arduino Code

The Arduino code is written in order to read angles from an MPU6050 sensor and control two servos to keep them at a neutral position based on the sensor's orientation. This allows for the sphere to balance itself as it is rocking back and forth.

Libraries and Objects:

  • Includes necessary libraries for I2C communication, MPU6050 sensor, and servo control.
  • Initializes objects for the MPU6050 sensor and two servos.

Setup Function:

  • Initializes serial communication.
  • Configures the MPU6050 sensor and captures initial angles to set as zero reference.
  • Attaches the servos to pins and sets them to a neutral 90-degree position.

Loop Function:

  • Continuously reads data from the MPU6050 sensor.
  • Calculates elapsed time for integration.
  • Computes current angles from accelerometer and gyroscope data.
  • Applies a complementary filter to combine accelerometer and gyroscope data.
  • Maps the calculated angles to servo positions.
  • Updates the servo positions to maintain a neutral orientation.
  • Prints the angles and servo positions for debugging.
  • Includes a minimal delay for stability.

The code ensures the servos respond quickly to changes in the MPU6050 sensor's orientation by minimizing delays and continuously updating the servo positions based on sensor readings.

3D-Printing Chassis

IMG-20240607-WA0047.jpg

Process for 3D Printing:

  • Use a 3mm Nozzle
  • Print with regular PLA
  • Nozzle Temp 215 deg C
  • Bed Temp 60 deg C'
  • Fan Speed 120

Post Print Assembly:

  • Take the two side pieces that posses the frame to carry the our Arduino and breadboard and adhere them to the completely solid panel (the one missing the square cut out) using the epoxy binder.
  • Let dry
  • Once dry, take the curved bottom piece and also adhere to the previously constructed piece.
  • Once again, let dry


3D-Printing Sphere

IMG-20240607-WA0038.jpg
IMG-20240607-WA0039.jpg
IMG-20240607-WA0040.jpg
IMG-20240607-WA0041.jpg
IMG-20240607-WA0046.jpg
IMG-20240607-WA0052.jpg
IMG-20240607-WA0053.jpg

Process for 3D Printing:

  • Use a 3mm Nozzle
  • Print with regular PLA
  • Nozzle Temp 215 deg C
  • Bed Temp 60 deg C'
  • Fan Speed 120

Building the Contraption

IMG-20240607-WA0039.jpg
IMG-20240607-WA0033.jpg
IMG-20240607-WA0022.jpg
IMG-20240607-WA0023.jpg
IMG-20240607-WA0024.jpg
IMG-20240607-WA0025.jpg
IMG-20240607-WA0026.jpg
IMG-20240607-WA0027.jpg
IMG-20240607-WA0028.jpg
IMG-20240607-WA0029.jpg
IMG-20240607-WA0030.jpg
IMG-20240607-WA0031.jpg
IMG-20240607-WA0021.jpg
IMG-20240607-WA0009.jpg
IMG-20240607-WA0010.jpg
IMG-20240607-WA0003.jpg
IMG-20240607-WA0004.jpg

Step 1: Take your "Servo Brackets" install them onto the "Middle Wall Mount" using the epoxy glue

Step 2: Take "Gear 1" and install it onto the "Back Ring Holder" using 2 M3 x 20 bolts

Step 3: Take the "Back Ring Holder" now mounted onto "Gear 1" and install them onto the "Middle Wall Mount" using 2 M3 x 30 Bolts

Step 4: Now taking your 8 M3 x 10 bolts (4 per servo), you can mount both of your servo motors onto the servo brackets.

Step 5: Take "Servo Gear 1" and one of the "Servo_Gear_X2" gears and adhere them to 2 R-O Servo Horns and let them dry

Step 6: "Servo Gear 1" should be mounted onto the servo paired with "Gear 1" and one of the "Servo_Gear_X2" gears is mounted onto the servo paired with "Gear 2"

Step 7: You can now take the assembled parts and mount them onto the "Inner Moving Sphere" by using 2 more M3 x 30 bolts. Ensure that the 2 hole on "Gear 2" is aligned vertically with the side possessing 2 holes. Here you will screw in your last M3 x 20 Bolt

Step 8: Run all of the wires from the Sphere through the rectangular gap located at the top of the "Outer Moving Sphere". Then Align the holes from the Chassis with those located on the "Back Ring Holder". Here you will screw in your final 2 M3 x 30 Bolts

Step 9: You can now install your Arduino and breadboard into the chassis. Connect your servos to their respective pins (refer to Step 1: Arduino Set Up) and secure them in place using electric tape. You can now also plug in the 9V battery into the Arduino's power supply jack.

Step 10: Adhere the final part of the chassis down using tape in order to maintain access to the internal parts when adjustments are needed.