This Instructables is divided into two phases, which makes it suitable for both beginner and intermediate robot designers.
The first phase covers the use of arduino nano board only as the controller. With this, we are going to build a robot:
- that can be controlled manually using an IR remote or a mobile device with IR blaster.
- that moves around autonomously while avoiding obstacles.
The second phase will be posted as a second instructable and can be ignored if you are beginner or you don't wish to do it. The second phase will be an extension of the this first phase using a raspberry pi board. The robot will now have new capabilities like:
- can grip and pick up objects.
- able to detect a ball automatically using a camera and picking up the ball.
- taking the ball to a base station and dropping the ball there.
- identifying base station with the use of symbols or QR codes.
- face detection and tracking
- identification of some objects
Both phases uses the same robot design, no major changes just the addition of a raspberry pi.
I will like to tell you that this is my first ever robot, first time I have ever coded anything and first time to design something, 3d print it and also laser cutting. So, please you will see some "minor" errors in the robot, but I will walk you through how to correct them. If you are ready to start, then lets dig in!.
Step 1: Requirements: Hardware
You will need some components and equipment to get started. Most of them can be gotten from popular components stores or any of the major e-commerce marketplaces. You will also need to do some 3d printings and/or laser cuttings. Depending on your preference you can 3d print your main chassis or laser cut it. I did laser cutting since it was quick and spare materials were used. You can also laser cut or 3d print your grip. All other parts must be 3d printed.
- Resistors 220 ohms - (4 qty minimum)
- 2x Servo motor Futaba S3003
- 6x Micro servo motor SG90 (-1 if just doing one phase)
- 1x Arduino Nano Rev 3 (or alternatives)
- 1x IR receiver TSOP382 or another
- 2x 16mm Marbles
-1x HR SR04 ultrasonic sensor
- Some male to male and male to female jumper wires
- A micro breadboard or prototype board (any one you are comfortable with)
- An IR remote control or/ and a mobile device with IR blaster
- Batteries ( I am using 8 rechargeable AA Ni-mH batteries). You can use any battery that can supply more than 5v Note: you can use 4 AAA batteries if you are not going to do phase 2. I got more batteries because of the raspberry pi. Or use a power bank
- 5v 3A UBEC (voltage regulator) Note: again not necessary as Nano as its own regulator, but you can use it in your circuit from the start if you want to do phase two. but compulsory for the rasp pi.
- M3 screws and nuts (buy pack of different length size - up to 40mm)
- 6 M3 Standoffs or rivets (25mm)- plastic preferable
- 4 M3 Standoffs or rivets (15mm or above)- plastic preferable
- Super glue or/and glue gun.
- Knife/Saw tooth knife
- Hand drill (see pictures)
Step 2: Requirement: Hardware-Body
Files : http://bit.ly/1sYiuDD
3dhub £10 off voucher :http://3dhubs.refr.cc/6ZBHMDF
ONLY PRINT GRIP IF YOU WANT TO DO PHASE 2
You can either laser cut or 3D print the top board, bottom board and the grip body parts. The body parts for the camera are for the second phase
If you want to 3D print the top board, bottom board and the grip body parts, print >TOP BOARD and BOTTOM BOARD in >3Ds folder and the grip parts in >3Ds>GRIP . You will have to print other body parts, the number of how many prints you should have are written on the name of all body parts. If you have no access to 3D printing, you can find people near you on 3dhub.com using the link above to get £10 off. It is cheap and they can send your prints to you or collect them.
If you want to laser cut the top board, bottom board and the grip body parts, use the files in >2Ds any version is all-right.
You can buy a completely ready made two wheel servo chassis anywhere you can find one, and you can drill holes into them where needed. Note the wheels must be controlled by servos not DC motors or the code will not work.
The sketch-up files are provided if you will like to edit anything and covert to STL before printing.
**if you spot any mistake please notify me I will update the files immediately.
Step 3: Requirement: Software, Skills and Setup
- To do this project, you need to be able to edit text files easily.
- If you know how to program in C/C++ then you should be alright, but this is not compulsory as all codes are already written for you. You just need to make some changes.
- If you have not programmed an arduino before, do the `Basic` and `Digital` tutorials @ https://www.arduino.cc/en/Tutorial/BuiltInExamples... . They are really helpful.
- Learn how to install a library @ https://www.arduino.cc/en/Guide/Libraries#toc2
- Access or download all code files from http://bit.ly/1sYiuDD
- You need the free Arduino Software @ https://www.arduino.cc/en/Main/Software
- You might want to use a text editor like Notepad++ or Sublime Text, they are both free. There have number linings and I will be using number lines as reference to the codes
- You can download Sketchup if you want to edit the 3D files, I designed them with Sketchup
- Download zip file for the IRremote library for the arduino @ https://github.com/z3t0/Arduino-IRremote
- Install all software you downloaded and make sure they are working
- Install the IRremote library.
and you are ready to go.
Step 4: Hacking Servo for Continuous Rotation
A servo can only rotate between 0 and 180 degrees. As we want our two servos to serve as wheels, they should keep rotating at 360 degrees. The idea of this hacking is to make servos rotate at a given speed and also stop using your codes in Arduino.
- Between the values of 0 and 89 degrees your servos should rotate clockwise with 0 being the highest speed and 89 being the slowest
- At the value of 90 the servo stops and,
- Between the values of 91 and 180 degrees your servos should rotate anti-clockwise with 180 being the highest speed and 91 being the slowest.
Follow any of the 2 options to hack your servos:
1: Watch this Youtube video on how to hack your servo : https://www.youtube.com/watch?v=SK8mhnEzcvY
After dissembling the servo ,slicing a small space into the potentiometer and expanding the hole in the servo gear as shown in the video and pictures above.
In the files folder: >Codes, download/open the folder >Servo_Con_1 and load Servo_Con_1.ino. Upload it to your nano.
Now connect the servo as illustrated in the schematic. (check the datasheet of your servo so that you connect the right wire to the right place). Usually the black wire is ground ;::; white or orange wire to PWM pin (pin 9 for example) and ;::; red wire to 5v
Connect your arduino uno to your device and upload the code. The servo should start rotating
Now rotate the potentiometer with a screwdriver until the servo stops rotating, adjust until it doesn't twitch and stops rotating completely.
After getting to the point at which it stops twitching and rotating, glue down the potentiometer to avoid it from moving after assembling it. The problem I had with this was that the glue wouldn't hold it down, so I chopped off the head of the potentiometer. See second method, if you are having problem with this one, or if not skip to debugging.
2: If after assembling, the motor starts to rotate or twitch, I suggest you slightly chop off the potentiometer, so that the gear does not rotate the potentiometer when the servo starts rotating . Use a sharp edge knife to adjust potentiometer if needed until it stops rotating and twitching.
Note: Make sure your servo is still connected to your arduino when adjusting potentiometer.
In the file folder: >Codes, download/open the folder >Servo_Con_2 and load Servo_Con_2.ino. Upload it to your nano.
Run the code and your servo should follow a sequence of stop, clockwise rotation, anti clockwise rotation......
If not check connection again or try adjusting potentiometer
Step 5: Assembling
ONLY PRINT GRIP IF YOU WANT TO DO PHASE 2
Now, lets start putting our stuffs together.
All steps are illustrated in the pics above.
1. If you are using a breadboard of prototype board, attach it to the top board.
2. Attach the futaba gears to the two rear wheels with a glue. If the gears don't fit expand by rotating a knife inside the wheel slot.
3. After the glue has dried attach the wheel to servo and check if rotates smoothly. (do not glue them yet).
4. Get your ultrasonic sensor and insert it into ultrasonic sensor f_holder then glue a gear of a mini -servo as shown in the picture to the bottom of the ultrasonic sensor f_holder . Now put this on a servo after the glue as dried and check if it rotates very well. (do not glue to servo yet).
6. Attach a mini servo to a motor stand with screws. Then attach that to the the top board with nuts.
7. Get your front wheel extension and cut the extension to the length you want (obviously not to high or too low). Glue to the caster and then insert the marbles into caster. Attach to bottom board.
Step 6: Calibrating
Please make sure you have gone through the Arduino examples if you have never coded one. Then this will be easy for you to do.
1. Calibrate your sensor neck:
a- connect your servo for the neck of Ultrasonic sensor as shown in schematic.
b- connect arduino to pc
c- Download code Servo_Con_2.ino @ Codes>Servo_Con_2
d- Run you code
e- The servo should now be in a middle position. You can now glue Ultrasonic to the servo
f- Open code and uncomment the codes inside void loop (see picture):
-delete line 13
- Uncomment line 14 to 19.
-Run the new code
g- Your servo should now rotate right, middle and left in sequence continuously.
Step 7: Schematic
WARNING: check datasheet of your components for pin polarities before any connection
Connect your components together as illustrated in the schematic above on a breadboard/ prototype board, or pcb.
a. Get your power source (batteries) and connect them as shown.
b. Left drive Motor:
Vs (Red)- 5v
Gnd (Black)- Gnd
Data pin (white or orange)- Pin 8 of arduino nano
c. Right drive Motor:
Vs (Red)- 5v
Gnd (Black)- Gnd
Data pin (white or orange)- Pin 9 of arduino nano
d. Neck servo (mini servo):
Data pin (white or orange)- Pin 7 of arduino nano
e. IR receiver (you must check datasheet for connection it is not as shown in schematic)
Data pin goes to pin 11 of arduino nano
f. Ultrasonic Sensor
Echo- Pin 5 of arduino nano
Trig- Pin 6 of arduino nano
Step 8: Coding
After assembling hardware and components, you're almost done.
1. Get a your Ir remote (tv remote or any ir remote)
2. Get the ir_remote.ino code @ Codes>ir_remote folder and run it on your arduino nano.
a- Open the serial monitor and change the baud to 115200
b- Press any button on your remote and an HEX number should show up. If you press continuously FFFFF should show up.
c- Click on buttons of choice for the following function and record the HEX code somewhere. You need the HEX codes for these functions:
- Move forward
-Emergency Stop/ Mode switch
3. Now get zobot.ino code @ Codes>Zobot folder and edit it as follows.
a- Edit the code in void manual_mode as shown in the picture. What you have to do is replace every HEX you find there with the ones that you recorded previously corresponding to the comment in front of it.
if your Move backward HEX is 20DF22DD
in [else if (ir_output.value==0x20DF827D)//Move Backward]
change 20DF827D to 20DF22DD
c- No run your code.
Step 9: Controlling Your New Robot
You know the buttons you've chosen for each function and this what they do:
-Emergency Stop/ Mode switch- To switch between automatic mode and other modes and also to stop immediately when automatic mode.
-Mode 1 button is to configure you robot to be in manual mode
- Here you can control the direction of your robot with the buttons for directions you set.
-Mode 2 button is to set to autonomous mode where robot navigates on its own
-Mode 3 button is used to set to watch mode where robot detects motion in front and shakes its head.
Step 10: What Next
Now that you have a working robot, try to add new features and improve its functionalities.
I am sorry there is no full video to show all features. I blew up one leg of the servo recently (my bad, connected 12v to it). The video in the Zobot files show the robot in manual mode and I was using a different front wheel then, so there were lots frictions when turning.
I will be posting phase 2 after my exams in the next few weeks.
Please ask questions and comment below.