CupBots - 3D Printed Robotic Platform for Arduino and Raspberry Pi
5161 Views, 55 Favorites, 0 Comments
CupBots - 3D Printed Robotic Platform for Arduino and Raspberry Pi


 copy.jpg)
Here is a great weekend robotics project to undertake with friends or folks at your local maker space. You will need a 3D printer handy to 3D print the STL files attached as part of the steps below and a Cup, in my case, I am using a venti Cup from Starbucks which i saved after enjoying my ice coffee..
The Cup protects the electronic parts from damage when your bot has a fall, when you drive it to fast or it run over an un-even surface , hence the name CupBot.
Currently there are two version of the 3D printed CupBot robotics platform, which share most of the 3D printed parts , watch the video's below to decide, which one you will make ..
#1 Arduino Uno based Obstacle avoiding CupBot.
To make an obstacle avoiding CupBot you will need an ultrasonic sensor(HC-SR04) and a motor driver, in my case I am using the Adafruit's motor shield v2.3.
#2 Raspberry Pi Keyboard controlled CupBot
If you are an average gamer , you will enjoy making Raspberry Pi version of the CupBot which uses keys that your would normally use with the keyboard while playing them car racing games ! Modify the code and map new keys to add some fun movements to the CupBot..
In addition, as part of Step 18 you will find a Breadboard holder STL file that you can 3D print to make a Breadboard version of the CupBot , this can be used in case you plan yo use a breadboard friendly micro-controller like Arduino Pro Mini/Micro or the Particle photon..
Things You'll Need




Here are the components you'll need to complete the build
- Gear Motors - 2
- Wheels - 2
- 4 AA battery holder - try and get one with an on/off switch so that you can easily switch power to the motor drivers.
- 4 AA battery
- 9V battery if you are building the Arduino Uno version of the CupBot
- Power bank to power the Raspberry Pi version of the CupBot
- Machine screws and nuts , I picked mine up at the local hardware store called Home Depot
- - 4-40X1 - 5 numbers (used hold the motors to the 3D printed parts )
- -4-40 X3/4 - 7 numbers(used to hold the 3D printed parts and electronic components)
- - 4-40 nuts - 12 numbers
In addition you will need the following tools
- Scissors
- Zip ties to hold the Battery holders to the 3D printed part
- Screw driver
- Soldering Iron and solder if you don't have wire soldered to the motors
3D Print the Common Base

Download the STL files attached and using 3D printing software slice and 3D print the files.If you don't have a 3D printer handy you can use one at your local maker club or library or use a 3D printing service like 3D hubs(use the pint using 3D hubs button).
If you plan to print with PLA ,here are suggested slicer setting for all the 3D printed
- Layer height - 0.3
- Infill - 20 %
- Nozzle Temperature - 200-210 C
Printing all the parts should take about 2 hours and is dependent on your 3D printer settings
Polishing the 3D Printed Parts (optional)



Now if you want to impress your friends by adding shine to you robot, spray paint the 3D printed parts Rust-oleum painters touch.
Once you spay the part you will have to leave then to dry for at-least about 4 hours, this is an optional step, but is a great way to finish 3D printed part
Rust-oleum painters touch - Gloss clear version from my local hardware store (Home depot) for about 6.99 $
In addition I also found with two coats it made the part more flexible and stronger.
CupBot - Arduino Uno Version

To make an obstacle avoiding Robot with and Ultrasonic sensor follow the steps below. Feel free to modify the code attached in the step below based on the motor driver you are using , in my case I am using the Adafruits motor shield.
To protest the circuit use a Cup ,you can use large cup if you buy you buy your ice coffee from Tim Hortons in Canada or use the Starbucks Venti cup, after you have enjoyed your green tea concussion !
Electronic Components You Will Need

To make an obstacle avoiding Arduino Uno Cup Bot you will need the following electronic components
- Arduino Uno
- Adafruit Motor/Stepper/Servo Shield for Arduino v2
- Ultra Sonic sensor HC-SR04
- 9V battery snap to connect the battery to DC barrale jack on your Arduino Uno
In addition you will also need female to female jumper cables to connect the Ultra Sonic sensor HC-SR04 to the Arudino Uno via the Adafruit's motor shield
3D Print the Arduino Uno and Ultrasonic Sensor

In addition the parts printed as part of step 2, download the 2 STL files attached and using 3D printing software slice and 3D print the files.One of the files is to hold the Arduino Uno to the base and the other is to hold the ultrasonic sensor as shown in the left half of the picture above.
If you don't have a 3D printer handy you can use one at your local maker club or library or use a 3D printing service like 3D hubs(use the pint using 3D hubs button).
If you plan to print with PLA ,here are suggested slicer setting for all the 3D printed
- Layer height - 0.2
- Infill - 15 %Nozzle
- Temperature - 200-210 C
Printing all the parts should take about 40 mins and is dependent on your 3D printer settings
Adding the Motors and Electronics to the 3D Printed Parts









Once you done with you 3D printing it is now time to add the motors to the 3D printed parts using the 4-40X1 screws and nuts as shown in the first picture above.
If you dont have breadboarding wire soldered to the motors you may want to do that first before adding the Motors to the 3D printed part
Now attach the wheels and the 3D printed wheels to the parts
Add the HC-SR04 sensor to Ultrasonic 3D printed part and then attach it to the base using 4-40X3/4 screws.
Also add the Arduino Uno the base holder 3D printed pard and mount it on the circular 3D printed part.
Final add the part for the battery holder as shown in the picture above,and secure the battery holder with Zip ties.
Upload the Code to Arduino Uno


It time to upload the code to the Arduino Uno, but before that follow the guide on the Adafruit learning system to download the Motor Shield Library and place in your Arduino Uno library folder on you laptop
https://learn.adafruit.com/adafruit-motor-shield-v...
Once done download the program ino file attached and upload it to the Arudino Uno using the Arduino IDE.
Don't forget to select the board as Arduino Uno and the port.
Run a quick test by moving your hand close to ultrasonic sensor and update the value to maxDistance if you have to, i have currently set it to 8 cms.
Downloads
Testing CupBot - for Obstacle Avoiding Bot




Before taking the bot out for a test run ,use a Venti cup and add it above the electronic components and batteries as shown in the picture above.
The Cup protects the electronic parts from damage when your bot has a fall, when it run over an un-even surface..
CupBot - Raspberry Pi Version

Here is a great way to show off, your Raspberry Pi/ python programing at your local Makerspace by making Keyboard controlled CupBot.
If you are an average gamer , you will enjoy making Raspberry Pi version of the CupBot using keys that your would normally use with a keyboard while playing those car racing games..
You can modify the code and add more functionality to CupBot , say map the G key on the keyboard to run the CupBot in a loop for 30 seconds..
3D Print Raspberry Pi Holder

In addition the parts printed as part of step 2, download the STL files attached and using 3D printing software slice and 3D print the files.One of the files is to hold the Arduino Uno to the base and the other is to hold the ultrasonic sensor as shown in the left half of the picture above.
If you don't have a 3D printer handy you can use one at your local maker club or library or use a 3D printing service like 3D hubs(use the pint using 3D hubs button).
If you plan to print with PLA ,here are suggested slicer setting for all the 3D printed
- Layer height - 0.2
- Infill - 15 %Nozzle
- Temperature - 200-210 C
Printing all the parts should take about 40 mins and is dependent on your 3D printer settings..
Downloads
Electronic Components You Will Need

Here are the list of electronic compenets you will need to complete the build for the Raspberry Pi CupBot
- Raspberry Pi B+/ 2
- Adafruit DC & Stepper Motor HAT for Raspberry Pi
- Wireless Keyboard for the Pi
- Wi-Fi USB adapter - this is optional for this version of the Bot, but is useful if you plan to SSH into your Pi for debugging and changing values in the program.
- Micro SD card
- 4 AA batteries and a battery holder
- Power bank to power the Pi
Preparing the SD Card



If you have just bought a Raspberry Pi, download Raspbian which is operating system for the Raspberry Pi from the link
https://www.raspberrypi.org/downloads/
Follow the installation link to prepare your SD card from the img you just downloaded
https://www.raspberrypi.org/documentation/installa...
Insert the SD card in the slot of the Pi and boot the Pi up, follow a couple of tutorial to get familiar with the Pi, follow the link below
https://www.raspberrypi.org/resources/learn/
Now for the Adafruit Capacitive Touch HAT to talk to the Raspberry Pi , you will have to enable I2C on your Raspberry PI.
In you Terminal window on the Pi type in the following command
pi@raspberrypi ~ $ sudo raspi-config
and enable I2C in the advance options
pi@raspberrypi ~ $sudo reboot
Now to install python-smbus and to run the commands below you will have have the Pi connected to the Internet , basically run the Pi headless using a Wi-Fi dongle. Or if you have another Raspberry Pi B,B+or 2 that is already connected to the Modem/router via a LAN cable, pop the SD card and run the commands below.
pi@raspberrypi ~ $sudo apt-get install python-smbus
type Y to accept the changes
pi@raspberrypi ~ $sudo apt-get install i2c-tools
Putting the Components Together


.jpg)




Once you done with setting up the SD card with the latest version of Raspbian and enable I2C, it is now time to add the motors to the 3D printed parts using the 4-40X1 screws and nuts as shown in the first picture above.
If you don't have breadboarding wire soldered to the motors you may want to do that first before adding the Motors to the 3D printed part.
Now attach the wheels and the 3D printed wheels to the parts Add the HC-SR04 sensor to Ultrasonic 3D printed part and then attach it to the base using 4-40X3/4 screws.
Also add the Raspberry Pi with the DC motor Hat mounted to the base holder 3D printed pard and mount it on the circular 3D printed part.
Final add the part for the battery holder as shown in the picture above and secure the power bank and the battery holder with Zip ties.
Run the Python Program Attached

Before downloading and running the program,refer to Adafruit's learning system to step up the Libary for the DC motor Pi Hat.
https://learn.adafruit.com/adafruits-raspberry-pi-...
Follow the learning guide to download and setup the required software for the DC motor PI hat
https://learn.adafruit.com/adafruit-dc-and-stepper...
Once done navigate to /home/pi/Adafruit-Motor-HAT-Python-Library/examples
And run through the DCTest.py and run it using the command below to test the back motors are spinning.
pi@raspberrypi ~/Adafruit-Motor-HAT-Python-Library/examples $ sudo python DCTest.py
Download the keyboard.py program and FTP the file to the Pi /home/Pi directory using the FTP tool called filezilla which you installed in the previous step.
Run the program using
pi@raspberrypi:~/MotorShield/keyboard $sudo python cupBotkeyboard.py
as shown in the third picture and give the keyboard controller a test as shown in the video.
Modify the block of code highlighted in the first picture to increase the speed and time interval which kind off drives the sensitivity of the keyboard as the controller.
keyboard.py program, uses key strokes which are similar to most action games that you would play on your computer, that is
- W - for foward
- S - Back
- A - Left turn
- D - Right turn
- Q - to Speed up
- S - Slow down
Add Entry to the Crontab to Auto Start the Program When Pi Boots

If you plan to take Raspberry Pi CupBot, where you wont have Wi-Fi range from your router, setup the program to run when the Raspberry Pi starts up using the following command
pi@raspberrypi ~ $ sudo crontab -e
Once the file opens add the following line at the end of the file and hit ctrl+X to save.
@reboot /usr/bin/python /home/pi/MotorShield/keyboard/cupBotkeyboard.py &
Now when you reboot your Pi your program will be running and you will be able to control the Pi with your key board
Testing the Raspberry Pi CupBot


Before taking the bot out n about for a test ,cut the Venti cup so that you can connect the power cable to the Raspberry Pi comfortable and then add the Venti cup over .
The Cup acts a protects the electronic parts from damage when your bot has a fall when you drive it to fast or it run over an un-even surface ..
STL Files for the CupBot BreadBoard Version



Here is another version of the CupBot which is still a work in progress called the BeardBoard CupBot.
I am sharing the Beadboard holder STL files which you can use to hold Breadboard and an Arduino Pro Mini or Micro . And use a Motor driver like the SparkFun Motor Driver Dual TB6612FNG or the L293D IC.