Ball Balancing Robot - 21 Steps (With Pictures) - Instructables
Ball Balancing Robot - 21 Steps (With Pictures) - Instructables
By aaedmusa in CircuitsRobots
41.729
415
45
Featured
Introduction:
circuits
Ball Balancing Robot
workshop
craft
Ball Balancing
cooking Robot
living
outside
Log InSignup
Search
Watch on
Mechanical engineering student at Purdue University. 3D printing, robots, and various mechanisms. More »
In this instructable, I'll show you step-by-step how I created a ball-balancing robot. More formally known as a Stewart platform, this
robot has 6DOF robot is omni-rotational and omni-translational. With the addition of a camera, this Stewart platform can be
transformed into a robot that prevents a ball from falling. Let's begin!
Supplies
Here is a list of the tools and parts needed for the build. For a more detailed overview of the supplies needed, download the bill of
material excel file here.
Tools
Parts ($483)
Following
Electronics ($400)
The ball rests on a clear 0.118" thick 8" x 8" polycarbonate platform. You will need to manufacture this platform. I do not have access
to a waterjet, so I used the waterjet service on the Andymark site. I have attached the dxf file below if you take this route. Another
option is to simply cut out an 8" x 8" platform from a sheet of polycarbonate and drill out all of the holes. I have attached a pdf
drawing of the platform below as well.
Attachments
platform.dxf
Download
platform_drawing.pdf
Download
Projects
back
All Projects
Circuits
back
All
Apple
Arduino
I designed this robot in Autodesk Inventor. There are 18 3D-printed parts in total. I printed all of these parts in PLA filament. I have
ArtSTL files below. Keep in mind that some of the parts must be printed multiple times. This number is specified in
attached all of the
the file name. TheAssistive
color ofTech
the parts does not matter except for the ball and the center markers. Those should be printed in red to be
easily detected byAudio
the camera.
Cameras
Clocksthe following printer settings:
I'd recommend using
Computers
20% infill (except
Electronics
for the ball, I printed it at 100% infill to be really heavy)
Auto-generated
Gadgets
supports
PLA (210° extruder
Lasers and 45° bed)
LEDs
The total filamentLinuxusage for all parts is about 183g. It took a cumulative 15 hours to print all of the parts.
Microcontrollers
Stewart Platform
Microsoft
Mobile
Raspberry Pi
Remote Control
Reuse
Robots
Sensors
Software
Soldering
Speakers
Tools
USB
Wearables
Websites
Wireless
Workshop
back
All
3D Printing
AttachmentsCars
CNC
Electric Vehicles
Energy
Furniture
Home Improvement
Home Theater
Hydroponics
Knives
Laser Cutting
Lighting
Metalworking
Molds & Casting1.5_inch_ball_part_1_x2.stl
Download Motorcycles
Organizing
Pallets
Repair
Science
Shelves
Solar
Tools
Woodworking
Workbenches
1.5_inch_ball_part_2.stl
Download
base_plate.stl
Download
Craft
back
All
Art
Books & Journals
Cardboard center_marker_x4.stl
Download Cards
Clay
Costumes & Cosplay
Digital Graphics
Duct Tape
Embroidery
Fashion
Felt
Fiber Arts
Gift Wrapping
Jewelry
Knitting & Crochet
Leather
Mason Jars
No-Sew
Paper
cover_plate.stl
Parties & Weddings
Download Photography
Printmaking
Reuse
Sewing
Soapmaking
Wallets
link_1_x6.stl
Download
pixy2_bottom_mount.stl
Cooking
Download
back
All
Bacon
BBQ & Grilling
Beverages
Bread
Breakfast
Cake
Candy
Canning & Preserving
Cocktails & Mocktails
pixy2_top_mount.stl
Download Coffee
Cookies
Cupcakes
Dessert
Homebrew
Main Course
Pasta
Pie
Pizza
Salad
Sandwiches
platform_frame.stl
Snacks & Appetizers
Download Soups & Stews
Vegetarian & Vegan
Step 3: Assemble the Ball
The ball comes in three parts, the two hemispheres, and the middle connection piece. You simply need to squish all three parts
together to create the ball. If the fit is too tight then sand the middle connecting piece. If the fit becomes too loose, then apply some
super glueLiving
to hold it in.
back
Step 4: Add
AllInserts to the Printed Parts
Beauty
Christmas
Cleaning
Decorating
Education
Gardening
Halloween
Health
Hiding Places
Holidays
Homesteading
Kids
Kitchen
LEGO & K'NEX
Life Hacks
Music
7 out of the 18 parts
Officeneed threaded
Supply Hacksinserts to be pressed into them. These inserts serve as threads for the screws to screw into. You
will need 36 inserts in total. The parts requiring these inserts are:
Organizing
Pest Control
Image #1: Pets
platform frame (6 inserts)
Image #2: Pranks,
base plate (14 inserts)
Tricks, & Humor
Image #3: Relationships
cover plate (12 inserts)
Image #4: Toys
4 x center
& Gamesmarker (1 insert each)
Travel
To press these inserts into the parts, use a heated soldering iron.
Video Games
The pixy2 camera is what we will use for object detection. Nothing on the pixy needs to be modified, but you will need to download
Pixymon v2 in order to view the camera footage and set up an object to be detected. For now, all you need to do with the pixy is to
plug it into your computer and ensure that it works by viewing the footage on Pixymon. I would also suggest testing the object
recognition by setting up a random object to be detected. There are 2 methods to set up object detection. I found that the manual
method works.
Here are some useful resources for setting up the Pixy and getting it to recognize objects:
Note: When the circuit is set up in the next step the Pixy2 camera will not be powered by the 7.4V battery because it draws
too much power. Instead, the camera plugs into the computer via micro usb. In other words, whenever you use the robot, the
teensy, the polulu maestro, and the servos will be powered by the 7.4V battery, and the camera will be powered by the
computer.
So far we have discussed 3 of the 5 main electronics: the teensy 4.1, the polulu maestro, and the pixy2 camera. Here is a brief
explanations of the two remaining electronic components: the Logic Level Converter (LLC) and the Servos.
Logic Level Converter (LLC): Since the teensy 4.1 microcontroller uses a 3.3V logic level and the maestro uses a 5V logic level,
the Pololu maestro's RX and TX pins cannot be connected directly to the Teensy. Instead, they must connect to the LLC (that
steps down the logic level) which then connects to the teensy.
Servos: The 6 servos connect to the 6 channels on the pololu maestro. The specific channel in which each servo connects is
important! I'll discuss this in the next step. I specifically chose the JX CLS6336HV servos because they are high-speed. A fast
reaction time is vital to this project.
Creating the Circuit is as simple as following the schematic shown in Image#3 (also available in PDF form below). You will want to
solder the teensy 4.1 and the LLC onto the protoboard. The maestro and the pixy will be external components that connect to the
teensy through wires.
Electronics Schematic.pdf
Download
The 6 servos
The base plate
The pixy2 bottom mount
m3 x 5mm screws (x8)
m3 x 15mm screws (x4)
Start by using the m3 x 15mm screws to mount the pixy2 bottom onto two of the servos and then to the front of the base plate
(the front of the robot is labeled in Image #1, Image #2, and Image #3).
You will then want to screw the remaining 4 servos onto the other sides of the base plate using the m3 x 5mm screws.
Next, screw the half protoboard onto the top of the base plate. You will need to remove the teensy 4.1 and LLC to get access to
the holes on the protoboard to screw the board on (this is why I recommend using header pins).
Hot glue the polulu maestro onto the base plate.
Finally, you will want to connect the 6 servos to the 6 channels on the maestro. The order is important and is labeled on Image
#1, Image #2, and Image #3. The servos must be connected to the specified channel on the maestro.
Now we will cover the base of the robot. You will need:
link 1 (x6)
25T servo disc (x6)
m3 locknuts (x18)
m3 x 120mm pushrod connector (x6)
22mm long m3 tie rod (x12)
m3 x 12mm screws (x12)
m3 x 22mm screws (x6)
Start by screwing each 25T servo disc onto each 3D printed link using two locknuts and two m3 x 12mm screws per disc as seen
in Image #1 and Image #2.
Assemble the six tie rods by attaching two tie rod ends to each of the pushrod connectors as seen in Image #3.
Screw on the other end of each of the six 3D printed links onto one of the ends of the tie rods using an m3 x 22mm screw and a
locknut for each link to form six servo arms. This is shown in Image #4 and Image #5.
Before we continue with this build, we must install two Arduino Libraries:
We will now mount the servo arms onto the servos. In order to do so we must first upload an Arduino sketch that will move all of the
servos to their home location.
Make sure the battery is plugged in and the switch is turned on, then upload the Arduino sketch below to the teensy. You should
hear all the servos turn to their home positions.
Now screw on the servo arms (using m3 x 12mm screws (x6)) so that they are as close to being perpendicular to the servos as
shown in Image #4. Do this for all of the servos.
As you will notice when the servo arms are attached, they will not be perfectly perpendicular like in Image #4. They will most likely
look more like Image #3. To get these servo arms to be perfectly perpendicular, you will need to change the offset value for each
servo in the code.
In this section of the code, all of the offset values will originally be set to 0 as shown in Image #5. Go through each servo and change
the offset value from 0 to 5. See if the servo arm moves closer to being perpendicular.
If it does move closer to being perpendicular, fine-tune the position of the servo arm by going higher or lower than 5 but still
keeping the value positive. For example, if the servo arm needs to move closer to being perpendicular you may change the
value to 7.
If the servo moves farther away from being perpendicular, then make the offset value -5 and fine-tune the value (while still
keeping it negative) until the arm is completely perpendicular. Do this for all servos. In the end, you will have an offset value for
each servo as shown in Image #6.
None of the servos should exceed the range of offset values between -14 and 14.
Note: Every time you change an offset value, reupload the sketch to see its effects.
Make sure you save these offset values somewhere, you will need to change the offset values of two other programs later.
Once this is done, every time this sketch is uploaded to the robot all of the arms should move to their home positions and be perfectly
perpendicular.
Attachments
Home_Servos.ino
Download
Now let's attach the platform to the main body of the robot. We will need:
Attach each m3 x 14mm screw onto the end of each servo arm. Screw on each m3 x 5mm standoff onto the other side of the screw,
then screw the servo arm onto the platform frame where the threaded inserts are.
Now attach the Pixy2 Camera onto the Pixy2 top mount using:
Ensure that the pixy2 cam has a good view of the platform by viewing the footage on pixymon. When looking at the camera footage,
you should be able to see the entire platform. If not, adjust the placement of the top mount.
In order for the ball balancing program to work properly, we must find the location of the center of the platform from the camera's
view and another value called r_platform that will help determine when the ball is on the platform or not. To do this we will use the
red 3D-printed center markers.
First, attach each center marker onto each corner of the platform using m3 x 5mm screws (x4).
The pixy cam should recognize the center markers as the ball that we trained it to recognize in the previous step. This is why
the ball and the center markers should both be red. Ensure that the pixy cam can recognize each center marker by viewing the
camera footage on pixymon. Make sure you only see four signatures for the four markers. If the pixy detects more or less than
four signatures, this program will not work.
Download the Arduino program below and change the offset values from 0 to the ones that you found in step 13. This section
will look similar to the section in step 13 as shown in Image #4.
Upload the sketch
The program will move each servo to its home position and then display some values on the serial monitor (shown in Image
#5). The first value is the location of the center in the format (X, Y). The second value is a single number labeled r_platform. Save
these three values!
Note: The values will take about 30 secs to be displayed on the Serial monitor
Note: The location of the ball should be in the ballpark of (150, 100) and the r_platform value should be in the ballpark of 113.
I would give an error range of +/- 20 for all three of these values.
Attachments
Pixy2_Calibrate.ino
Download
Attachments
Ball_Balance.ino
Download
Watch on
There are two main components to programming this robot: rotating the platform and balancing the ball. Being able to rotate the
platform in any direction is what allows the robot to balance the ball. So how does the robot accomplish these tasks?
To be able to rotate the platform anyway, the robot must use Inverse Kinematic equations. These equations take in an input (how we
wish the robot to be oriented) and output 6 values (the position for each servo to turn to). For example, when we want the platform
to be completely flat, the robot calculates that all of the servos must move to their home position. I derived all of these equations
using vector calculus. You can see these equations in Image #1.
So in order to balance, the ball the robot must take into account the location of the ball and the velocity of the ball at any given
moment. It then uses those values to simultaneously move the ball closer to the center of the platform and slow the ball down.
If only the position of the ball is considered, then the robot will not be able to slow the ball down and the ball would fall.
If only the velocity of the ball is considered, then the robot would not be able to move the ball closer to the center of the
platform and the ball would eventually fall.
Once the robot determines the most effective direction to angle the platform to slow the ball down and move it closer to the center, it
uses the inverse kinematic equations to determine what position to move the servos to get the platform to move to that angled
position.
Optional: As shown in Image #5 you can change the kp and kd constants in the Ball Balance program to get different levels of
reactiveness from the robot. I discuss the effects of increasing or lowering these values in my video.
View Contest
I Made It
Recommendations
CUBOTino Pocket: Optimal Solver Robot for Rubik's Cube 2x2x2 by AndreaFavero
Comment I Made It
45 Comments
qc782985 22 days ago
good job!!!How do I get the detailed dimensions of a 3D printing file, such as a 2D drawing?
Reply
Hi, can you explain or point me in the right direction as to how you simulated the (inverse)
kinematics beforehand using matlab? I'm making a 3DOF version (not a stewart platform) and I'm
struggling with linkage lengths and design parameters. Thanks in advance as any help would be
greatly appreciated!
Reply
1 reply
Hi, just in the process of building this very interesting project! The Servo numbering seems to be
missing on the images I'm getting. Presumably they number sequentially clockwise starting from the
right of the Pixy2_cam mounting bracket?
Also, the 6 conductor ribbon supplied with the Pixy2_cam to suit it's 10 pin connector end has it's
'conductor 5' connected to the 6 pin connector end 'conductor 5'. The wiring diagram (page 26 of the
pdf) shows it connected to a 'conductor 7' and in turn to Teensy 4.1 pin 10. Leaving it as is means
that Teensy4.1 pin 10 will connect to Pixy2_cam pin 5, not pin 7 as the wiring diagram shows.
A clarification of these two items would be much appreciated!
Thanks, Russ
Reply
6 replies
Hi, can you put a clear picture of the calculations picture of different stages in the ball balancing
instructible.
Reply
You are one smart gentleman, and quite talented, I might add.
Reply
leshemeli a year ago
question: are the motors like those I used on my RC airplanes, controlled by PWM?
Reply
1 reply
Good work
Reply
Reply
1 reply
Reply
1 reply
Nice job!
I was just wondering why you use 6 servos instead of 3. Is that for speed, power or range of motion?
Or even just 2 servos and 1 fixed support. Yes, I am cheap.... ;-)
Reply
1 reply
alfadog67 a year ago
Reply
3 replies
Reply
1 reply
Wow 😯
Just fantastically brilliant 🤩
Reply
1 reply
This is awesome. Really well explained and documented. Thanks for your work.
Reply
1 reply
Wow...Great work
Reply
1 reply
Reply
Reply
would love to see this with a ping pong ball and pre-programed patterns added.
Figure 8
spiral
square
things similar to the sand tables etc
Reply
1 reply
We made one of these at work a few years ago. Nice and big to take to shows and events.
Reply
1 reply
Reply
1 reply
Great Instructable!!! Well documented and presented. Somebody is going to hire this young man
soon and when they do they will have a gold mine with his talent demonstrated here
Reply
1 reply
Great work, wish I could be able to also come up with the algorithms needed :-)
Reply
1 reply
Post a comment
AboutContact
© 2024
I Made It Favorite View Comments Share More Options
Facebook Twitter Pinterest Google Classroom
Flag
Wrong Category
Inappropriate
Incomplete
Spam
Cancel Confirm
Edit