A Robotic Arm, Based on Mg90s Servos and 28BYJ-48 Stepper Motor.
by tagvian in Circuits > Robots
359 Views, 6 Favorites, 0 Comments
A Robotic Arm, Based on Mg90s Servos and 28BYJ-48 Stepper Motor.
Hi! I’m Wiktor, a 13-year-old electronics, robotics, and programming enthusiast. Recently, I created a robotic arm that you can control and program using a computer app (which I also developed!).
I designed this robotic arm using Fusion 360 for 3D modeling and Visual Studio Code for programming. It features MG90s servo motors, a 28BYJ-48 stepper motor, and a lot of 3D-printed parts, screws, and heat inserts.
Supplies
3d printed parts.
- Base compartment x 1
- Base lid x 1
- Left gripper x 1
- Right gripper x 1
- Lower arm x 1
- Upper arm x 1
- Base disc x 1
- Shoulder servo holder x 1
- Gripper servo holder x 1
- Gripper holder x 1
Electronics
- MG90s servo x 2
- SG92R servo x 1 (can be replaced with an MG90s)
- 28BYJ-48 stepper motor x 1
- ULN2003 driver x 1 (I have a red one, bigger green ones are also common)
- Custom "servo driver" board x 1 (See Step 1)
- Arduino Uno
Hardware
- Servo horn x 3 (The type shown in the picture)
- M4x12mm bolt x 2
- M4 nut x 2
- M3x10mm bolt x 2 (12mm also works)
- M2x12mm bolt x 4
- M2 washer x 8
- M2x7mm bolt x 4 (12mm cut down to 7mm)
- M3X12mm bolt x 4
- Screws for securing servo horns x 3
- M2x7mm screw x 1 (From the servo "kit")
- M3x5mm heat insert x 2
Cables
- 20cm Male-Female jumper wire x 9
- 10cm Female-Female jumper wire x 2
- 10cm servo wire extension x 1 (Can be replaced with normal jumper wires)
Custom "servo Driver" Board
Why make this board?
I didn't have access to a normal servo driver when I made this project, so I decided to make my own. It's very simple; it essentially just connects all the anodes and cathodes together.
How to make such a board?
To make such a board you are going to need:
- Small piece of perf board
- Pin headers
- Some small pieces of wire.
- Soldering tools.
Then you should take the board and pins and solder them in place, as shown on the image.
After which you can connect all the positive and negative pins.
You are also going to need to connect the signal pins,
signal pin 1(Next to power rails) - signal pin 1
signal pin 2(Next to power rails) - signal pin 2
etc.
Why is the board designed like this?
The most confusing part is the signal pins so let me explain.
I wanted to be able to plug the servo connectors straight into the board, which means we've got to have 3 pins next to each other. But if I just left the pins like this, there would be no way to connect it to the Arduino.
Base
Now let's start assembling our robot.
The base is designed with pretty loose tolerances so it can be printed on almost any 3d printer.
But this means you have to slightly bend it for it to be a tight fit.
Bending the base
Warning: To bend the base you will need a lighter. Please be careful! Lighters can be very dangerous.
First of all, you will need to pick a spot to bend the base.
I recommend bending slightly above the hole for our USB cable.
Now, because the plastic we print with is very hard it's impossible to bend in normal conditions, so you have to heat it so it becomes elastic.
To do that you can simply use a lighter.
After carefully heating the spot you chose press down with some kind of a round object.
If you've done everything correctly you should be able to press the lid on, and it shouldn't slip off.
If your lid keeps slipping, just repeat the above steps.
The finished product will look similar to the image.
Mounting the stepper motor.
To mount the stepper motor we will use two M4x12 bolts and two M4 nuts.
Place the stepper motor in such a way that the axle goes through the middle hole, and the screw holes align.
Put the bolts through the holes and secure them with nuts.
Make sure that the bolt heads are sticking out of the top, if the nuts are sticking out the top they will collide with the base disc.
If done correctly the result should be similar to the image.
Base disc
Now you can take the base disc, and add the M3 heat inserts.
Warning: Soldering irons are VERY dangerous, when using one please be very careful.
Gently place the heat inserts over the holes on the base disc.
Then take a soldering iron heated to ~300C, and gently push down the heat inserts into the part.
The heat inserts sometimes get stuck the the soldering iron, in this case just grab tweezers and make sure the heat inserts stay where they are supposed to be.
The finished result should be similar to the image.
Putting it all together
Now you can put the base disc on the stepper motor.
And put the lid on the box.
Congratulations!!! You assembled the base.
Wiring
Before we continue with the rest it's a good idea to connect everything.
Stepper
First of all connect the stepper motor to the driver board, as shown in the diagram.
Now you can connect the pins to our Arduino.
- IN1 - 2(Arduino)
- IN2 - 3(Arduino)
- IN3 - 4(Arduino)
- IN4 - 5(Arduino)
The above connections are also shown on the diagram.
Custom board
Connect the topmost two pins to the Arduino in this way:
- Red pin - +5V
- Black pin - GND
Make sure that the power pins from the stepper driver board are connected to this board,
above the 3-pin wide section(Just under where you plugged in the Arduino pins).
You should also connect the signal pins to the Arduino.
- Signal pin 1(Left most) - 9(Arduino)
- Singal pin 2 - 10(Arduino)
- Singal pin 3 - 11(Arduino)
Note:
The bottom signal pin(next to the power rails) corresponds to the leftmost pin from the upper signal header etc.
The lower the servo connector the lower the joint ex. The bottom pins are for the shoulder joint, the next ones are for the elbow, etc.
Servos
Now the servo connections are very easy, just connect them to their corresponding pins as explained above.
Make sure to put all the servo wires through the hole in the lid.
An additional tip, place the Arduino in the same way I placed it in the image, this way you can plug it in without opening the box.
Shoulder Joint
Now it's time to assemble some joints.
Shoulder servo holder
Take your shoulder servo holder and two M3x10 bolts, and secure the servo holder in place.
The finished result should look similar to the image.
Installing the servo
The servo installation is very simple.
Just put it in the holder and secure it with two M2x12mm bolts with two washers added.
The screws should just easily go into the plastic and hold pretty well, if they aren't holding use an M2 heat insert.
The finished result should look similar to the image
Attaching the lower arm
First of all, grab a servo horn, then put one of the little screws for securing horns in the horn.
Then put the horn(with the screw) into the lower arm. You can identify the lower arm by checking if it has a slot for another servo.
And secure it to the arm with an M2X7mm bolt.
Now before we continue we need to set the shoulder servo to the 90-degree position.
To do that we will need to upload a simple sketch to the Arduino.
To do this install Arduino IDE, plug in your Arduino, select your port, select "Arduino Uno" for the board, and upload the following code:
Now you can simply place the lower arm with the horn on the servo and secure it, in such a way that the arm is pointing upwards. Like shown on the image.
Elbow Joint
The elbow joint is also straightforward, and the installation is almost identical to the shoulder joint.
Secure the servo, grab the upper arm, put in the horn(with the screw), and secure it.
Set the elbow joint to 90 degrees, by changing
To
Attach the arm, and you're good to go!
The result should look similar to the image
Gripper
Now the gripper is probably the most complicated step.
First of all, we are going to need to attach the gripper servo holder and gripper holder.
The servo holder will go onto the right side, you can use two m3x12mm bolts to attach it.
You can also attach the gripper holder onto the left side using the same hardware.
Then simply attach the servo to the holder and secure it with two M2x7mm screws.
Then place a servo horn(with a screw) into the right side of the gripper, and secure it with the little servo screw.
Then you can put it on your servo.
Now for the last thing we need to do is put the left side of the gripper on the holder, in such a way that when the gripper servo(pin 11) is set to 180, the gripper is closed.
Uploading the Code to the Arduino
Now we are going to need to upload the code I've written to the Arduino, we can do that the same way we have done it earlier:
- Connect the Arduino to your computer
- Install & open Arduino IDE
- Paste the code from below into the IDE
- Select the right port and board(Arduino Uno)
- Hit upload!
This is the code:
After uploading the code when you open the Serial Monitor, set it to 9600 baud, and send for example '123', the Arduino (after 200-300ms) should respond "Wrong input!". That's because it only accepts inputs that are 12 characters long. I will explain why in the next step.
The Protocol
So the code was written so that you can very easily control the robot over Serial.
First of all, all the messages have to be 12 characters long, why?
It's because the robot has four joints, and you can send a 3-character long position to each one, so 3x4=12.
But what exactly do these numbers mean?
The first three are for the base, keep in mind that the position the base will go to is what you input minus 360.
The second three are for the shoulder, it will simply go to the position you input.
The third three are for the elbow, and work the same as the shoulder joint.
The last three are for the gripper, they work the same as the elbow, but I wouldn't recommend going below 90 degrees.
Why this protocol?
Well, first of all, it's very simple, second of all doing it this way allows you to add your own functionality, like you could for example add an esp32 to make it wi-fi controlled.
The PC Program
So just sending strings of 12 numbers isn't so nice and intuitive is it? That's why I decided to also make a PC program to control it all.
Downloading and (Optionally) compiling
First of all, you will need to figure out which port your Arduino is using A.K.A. the same port you used to upload the code.
Then download the Robo Control.rar file, extract it, and to use it just got to the bin folder and run the program with your port.
The files are located here: Google Drive
If there isn't a pre-compiled .exe for your port you will need to compile it yourself. Luckily for you I made a CMake file.
If you don't know how to compile with CMake, this website should help.
How Do I Use It?
1. Sets the robot to its Pole-like position.
2. Set all the motors to zero.
3. Sends the values from 11,12,13,14, to the robot.
4. Plays the program currently loaded
5. Save the current program
6. Load the program with your input name in the top bar. It is also used to create new files.
7. Take in the name of your program.
8. Remove the last position from the loaded file.
9 . Adds the current values from 11,12,13,14 to the current file.
1 0.Displays roughly what you are about to send to the arm
11. Takes in the value for the gripper,and also shows it
12. Takes in the value for the elbow
13. Takes in the value for the shoulder
14. Takes in the value for the base
15. Displays roughly how the base is oriented
Ending
Thanks for staying with me, also special thanks to my mom for motivating me and supplying me snacks.
Please let me know what you think about this in the comments, it has been my first real big scale project.
Also if you need help, just message me on discord: xtagz_69