Robotic Arm Controlled by Arduino and PC
by freedie666 in Circuits > Arduino
1710 Views, 4 Favorites, 0 Comments
Robotic Arm Controlled by Arduino and PC
Robotic arms are widely used in industry. Whether it is for assembly operations,
welding or even one is used for docking on ISS (International Space Station), they help humans in work or they replace human totally. Arm that I've built is smaller representation of robotic arm that is supposed to be used for moving objects. It is controlled by arduino pro mini which has already built-in library for controlling servos. Servos are controlled by PWM (Pulse Width Modulation) which isn't hard to program but this library makes it easier. User can control those servos by potentiometers that are designed to act as voltage dividers or from program on PC that uses 4 sliders for controlling servo motors.
For this project I had to design my custom PCB and make it, create 3D models of arm and write code which controls it all. On top of it I coded additional program in python that sends signals to arduino which manages to decode that signal and move servos to position that user has set.
Theory Behind Project
Arduino is great in that way that it offers free library to work with. For this project i used library Servo.h that makes controlling servos so much easier.
Servo motor is controlled by PWM -Pulse Width Modulation- which means that in order to control servo you need to make short voltage pulses. Servo can decode length of this signal and rotate to given position. And this is where I used already mentioned library. I didn't had to calculate length of the signal on my own but I used the library's functions to which I just pass parameter in degrees and it makes signal.
For controlling servos I used potentiometers that act as voltage dividers. Arduino boards have several analog/digital converters that I used for the project. Basically arduino is monitoring voltage on middle pin on potentiometer and if it rotates to one side voltage on it is 0 Volts (value = 0) and on the other side it is 5 Volts (value = 1023). This value is then scaled from range 0 - 1023 to 0 - 180 and then it is passed to function already mentioned.
Another topic is serial communication with arduino that i will cover just briefly. Basically program written on PC sends value chosen by user, arduino can decode it and move servo to given position
Designing PCB
I designed 2 PCBs - one for main control where is arduino and pins for servos and on second one are potentiometers. Reason for 2 PCBs is that I wanted to control the robotic arm from safe distance. Both circuits are connected by cable of given length - in my case 80 cm.
For power source I chose external adapter because servos that I used consume much more power than arduino can supply. As you can see there are some capacitors that i haven't mentioned yet. They are capacitors used for filtration. As you know now, servo motor is controlled by short impulses. Those impulses can make that supply voltage drops and potentiometers that had previously range 0-5 volts now have smaller range. That means that the voltage on middle pin changes and arduino gets this value and changes the position that is the servo motor in. This can go on forever and it causes unwanted oscillation that can be eliminated by some capacitors parallel to supply.
Making PCB
For making PCB I suggest you to read this.
I used Iron on Glossy paper method and it worked out great.
Then i soldered parts on the PCB. You can see that I used arduino socket in case that I will need it in the future.
Designing the Arm
This was by no means the hardest part of making this project.
Whole setup is made from 8 parts where 4 are not moving parts - box for potentiometers and base where arduino is located - and other four are the arm itself. I won't go into much of a detail except that design is pretty intuitive and in some way simple. It is designed to fit my custom PCB and servos which I will include in list of parts.
Downloads
Printing the Parts
Parts were printed on Prusa printer. Some faces needed to be ground a bit and holes drilled trough. Also the supporting pillars needed to be removed.
Putting It All Together
In this step as title says I put it all together.
At first I soldered wires on the potentiometers and then those wires on PCB. Potentiometers nicely fit to holes and I hot glued the PCB on the pillars that were printed on the bottom of the box. You can drill holes in the board and into the box but I found out that gluing it is more than enough. Then I closed both parts of the box and secured them in position with 4 screws that fit into holes that i designed.
As a next step I made flat ribbon cable to connect both boards.
In the main box I soldered wires from VCC pin of connector to switch and then to Vcc of board and from GND of board to GND of the connector. Then i hot glued the connector in place and board on pillars. Connector fits right into the hole so no hot glue is needed.
Then, by using screws i attached the bottom servo to the bottom of the box.
After that I put upper part of the box on the bottom part and same as with the potentiometer box I secured it with 4 screws.
Next part was a little bit tricky but I managed to put the rest of the arm together with various nuts and pads and it wasn't as tight as I expected because I designed some tolerances between parts, so it is easier to work with them.
And as the final step I put some tape on bottom of the boxes because otherwise they would be sliding.
Programming Arduino
I've already mentioned how program works in theory behind project, but I'm going to break it up even more.
So at the beginning we need to define some variables. Mostly it is copied 4 times because we have 4 servos and in my opinion it is unnecessary to make more complicated logic just to make program a bit shorter.
Next there is void setup where pins of servos are defined.
Then there is void loop - part of the program that loops infinitely. In this part program takes the value from the potentiometer scales it and puts in on output. But there is one problem that the value from potentiometer jumps quite a bit so I needed to add filter that makes average of last 5 values and then it puts on output. This prevents unwanted wobbling.
Last part of the program reads data from serial port and decides what to do based on data sent.
In order to understand code fully, I suggest you visiting official arduino websites.
Downloads
Programming in Python
This part of this project is not necessary but I think that it only gives more value to this project.
Python offers tons of libraries that are free to use but in this project I'm using only tkinter and serial. Tkinter is used for GUI (Graphical User Interface) and serial as its name says is used for serial communication.
This code creates GUI with 4 sliders that have minimum value of 0 and maximum 180. It might be hint for you that it is in degrees and each slider is programmed to control one servo. This program is rather simple - it takes the value and sends it to arduino. But the way it sends is interesting. If you choose to change value of first servo to 123 degrees it sends to arduino value 1123. First number of each number sent is telling which servo is about to be controlled. Arduino has code that can decode this and move the right servo.
Downloads
List of Parts
- Arduino Pro Mini 1 piece
- Servo FS5106B 1 piece
- Servo Futaba S3003 2 pieces
- Pin header 2x5 1 piece
- Pin header 1x3 6 pieces
- Capacitor 220uF 3 pieces
- Micro Servo FS90 1 piece
- Connector AWP-10 2 pieces
- Connector FC681492 1 piece
- Switch P-B100G1 1 piece
- Socket 2x14 1 piece
- TTL-232R-5v - converter 1 piece
- Potentiometer B200K 4 pieces
- and many more screws,pads and nuts
Final Thoughts
Thank you for reading this and I hope that I have at least motivated you. This is my first bigger project which I made all by myself without copying stuff from the internet and first instructables post. I know that the arm could be upgraded but I am satisfied with it for now. All parts and source codes are free, you are welcome to use it and change it in any way you want. If you have any questions feel free to ask them in comment section. You can also look at the videos, they ain't in great quality but they show functionality of the project.