Robot Arm Control With Arduino 3
Robot Arm Control With Arduino 3
net/publication/317277584
CITATIONS READS
0 42,998
2 authors, including:
Abdellatif Baba
Türk Hava Kurumu Üniversitesi
97 PUBLICATIONS 30 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Genetic algorithm-based technique for predicting future generations of hazelnuts chromosomes. View project
All content following this page was uploaded by Abdellatif Baba on 01 June 2017.
BY
Spring 2017
ROBOT ARM CONTROL WITH ARDUINO
Spring 2017
ABSTRACT
Today, technology is developing in the same direction in line with rapidly increasing
human needs. The work done to meet these needs makes life easier every day, and
these studies are concentrated in robotic arm studies. Robot arms work with an
outside user or by performing predetermined commands. Nowadays, the most
developed field of robot arms in every field is the industry and medicine sector.
Designed and realized in the project, the robot arm has the ability to move in 4 axis
directions with 5 servo motors. Thanks to the holder, you can take the desired
material from one place and carry it to another place, and also mix it with the
material it receives. While doing this, robot control is provided by connecting to the
android application via Bluetooth module connected to Arduino Nano
microcontroller.
Page | iii
Table of Contents:
CHAPTERS
1. INTRODUCTION 1
2. THEORETICAL INFRASTRUCTURE 2
2.1. Servo Motors 2
2.2. Arduino Nano Microcontroller 3
2.3. HC-06 Bluetooth Module 5
2.4. Circuit Diagram (Above Board) 6
2.5. Power 6
3. ROBOT ARM MECHANICS 7
3.1. General Characteristics of Robot Arm Mechanics 7
3.2. D & H (Denavit and Hartenberg) Coordinate Frames 11
3.3. Advanced Mechanics 12
3.4. Inverse Mechanics 12
4. DESIGN BRIEF 13
4.1. Mechanical Design 14
5. EXPERIMENTAL STUDIES 21
5.1. Projected Method 21
5.2. Robot Arm Control 21
6. CONCLUSION 22
REFERENCE 24
APPENDIX 1 25
Page | iv
List of Figures
Page | v
List of Tables
Page | vi
1. INTRODUCTION
These days’ people always needed additional help systems. With the rapid increase
in the flow of information, people are now guided to search for different markets and
people have entered the competition to manufacture quality products cheaply.
Automation systems are also needed to realize this. Because standardized automation
systems are required to minimize errors as well as to have experienced and well-
trained employees for quality products. Because of their physical characteristics,
people needed to use auxiliary machines in places where their strength was not
enough. These machines, which are operated with the need for human assistance in
advance, have been made to operate spontaneously without the need of human power
with the progress of technology. One of the most used components of automation
systems is robots. Robotic systems; Mechatronics Engineering, Mechanical
Engineering, Electrical Engineering and Computer Engineering have all come
together to work together.
In the project, researchers have been done and implemented in order to have
knowledge about mechanics and software during the operations carried out by the
robot arm which is designed to fulfill the tasks determined in accordance with
predetermined commands.
First, it was determined what function the robot arm would be and what movements
it could make. Robotic arm made of Android phone or tablet control; it can carry the
desired material, mix it up and perform the commands previously determined by a
user. If this project is also a designated task; the robotic arm takes a piece of material
and brings it to the desired position and then records its movements and lets it do the
same action until we stop it. The servomotor is preferred in order to be able to
perform these operations properly since the motor to be selected must operate
precisely and must be at high torque. The robot arm is composed of 5 servo motors
and can move in 4 axis directions with these motors.
The theoretical background of the project is examined below as main headings and
subheadings.
2.1.Servo Motors
Servo; Detects the operation error of a mechanism, provides feedback and corrects
faults. The servo motor can have alternating current (AC), direct current (DC) or
stepper motors. In addition to these, there are drive and control circuits. Servo motors
are the kinds of motors that can fulfill the commands we want. They can operate
steadily even at very small or very large speeds. In these motors, the large moment
can be obtained from the small size.
Servo motors are used in control systems such as fast operation, excessive axis
movement, condition control and so on. Servo motors are the last control element of
a mechanism. They are highly sensitive and servo motors are used in conjunction
with electronic or programmable circuits. These engines are divided into AC and
DC. When the AC servo motors are brushless type motors, the servo motors brush.
Servo motors are mostly three cables. These are a red cable for power, black for
grounding and yellow cables for control (data, data). One of the servomotors used in
the production phase of the project is shown in Fig.1.
Square wave and working voltage of 4.8-6V. The used servomotor has a working
voltage of 0.12 s / 60 ° and a torque of 1.2-1.6 kg/cm at low operating voltage.
Servo motors are controlled according to the signal condition. In doing so, the
supplied pulse width modulated (PWM) signal is used with the data bus. Each servo
motor is controlled by a PWM signal at 10-20 ms and at 0.5-1.5 ms.the position of
the motor shaft is determined according to the duration (tk) of this signal at logic 1.
These;
Page | 3
With the help of the advanced library, even complex operations can be easily
solved.
Programs written in Arduino can run fast because they are not run on any
other platform.
There is a lot of hardware support that is compatible with Arduino and can
work together.
Communication with the environment is easy because it is open source.
If there are any problems due to a large number of Arduino users, the solution
can be easily reached.
The Arduino Nano is a small, full and breadboard friendly Arduino card that houses
a microcontroller (Arduino Nano 3.x) or Atmega168 (Arduino Nano 2.x)
microcontroller. It has almost the same functions as the Arduino Duemilanove.
Arduino is designed and used by Nano Gravitech.
The Software Serial library allows serial communication over any of the digital pins
of the Arduino Nano. The ATmega328 and ATmega168 microcontrollers also
support I2C (TWI) and SPI communications.
The HC-06 BT module is a slave operating only and uses a serial communication
protocol. In Bluetooth communication, master and slave are determined according to
the state of connection start. A master module can initiate the connection, but the
slave module cannot initiate the connection. In our project, we will provide an
external device to connect to a slave PC or an android device. Bi-directional data can
be sent and received in a healthy way.
Page | 5
Figure 3HC-06 Bluetooth module
After adding the device to the Bluetooth devices, a virtual com port associated with
the module is created on our computer. It is now possible to communicate via
Bluetooth via the module. The codes that we send via UART with the
microcontroller (PIC18F46K22) can be received via Bluetooth with PC, which is
connected to the BT module. Data sent from the PC and COM overreaches the
microcontroller.
Circuit; Servo inputs, Arduino pin inputs, and Bluetooth module inputs. Servo
motors are activated in this way, the Bluetooth module Arduino Nano connections
and power supply connections are shown. Thanks to this circuit we use, it is possible
to distribute the 5V from the power supply to the servo motors.
Page | 6
Figure 4Circuit
2.5.Power
The power supply selected for feeding the control circuit of the servomotors is
capable of delivering the same current even if all the synchronous servomotors are
operating. When all servo motors are operated at the same time, they draw 0.5A
current. In addition, 5 V was needed for the Arduino used for robot movement in the
project. This requirement is provided by a 5V power supply.
Page | 7
multiplied in turn. If the coordinates of the end point are given, limb variables can be
obtained by going backward. These operations are called forward and inverse
kinematics. The next section will explain how to determine forward and reverse
kinematics. The general transformation matrix can be quite complex even for simple
robots. It can be found in standard textbooks such as the Jacobian matrix for standard
robots (2) and (3).
Page | 8
If any of the 3 coordinate axes is possible to rotate, there are 3 rotational transforms
corresponding to the rotations in the x, y, and z-axes up to the q angle. The following
matrix can be written for x-axis;
The matrices representing only the revolutions around the y and z-axes can be
written in a similar manner.
Page | 9
The elements of the transformation matrix can be found by the arithmetic
multiplication of pure rotation and displacement matrices. This can be obtained by a
sequence of rotations about the axes of the stationary reference frame if the
orientation is desired according to the reference frame of the Cartesian space
endpoint. Although there are many ways to do this, one of the best known is the
"roll-pitch-yaw" transformation. 3 turns. First turn around the x-axis, then y and then
around the z-axis.
Kinematics in robotics is the science of motion investigation. The robot examines the
positions of the limb limbs, the relationships between velocities and accelerations,
ignoring forces and other factors that affect movement.
Page | 10
The position and orientation of one of the limbs, or the orientation of the limbs
between this limb and the end point, will change when the serial limb robot arm is
shown in Fig. When the positions and orientations of the limbs change, it is generally
desirable to determine the position and orientation of the end point according to the
basic reference frame.
When this equation is in closed form, any term can be expressed by another and is
very important in the kinematic analysis of the robot arm. Because the robot is used
to analyze the forward and inverse kinematics of the arm.
Page | 11
Figure 6D & H parameters
Ln: the length of the limb is the distance along the common normal between the axes
of the joints. Z and Zi-1.
i: is the positive angle of rotation about the positive X-axis from the positive Zi-1 axis
to the positive Zi axis.
Өi: The positive angle of rotation about the positive Zi-1 axis from the positive Xi-1
axis to the positive Zi axis.
Di is the distance to the intersection of the Zi-1 and xi axes along the Xi-1 axis from
the origin of the first coordinate frame.
Some of the structural parameters may change over time during robot arm
movements. These parameters are called changing parameters, e.g.Өi, I angle in the
rotary joint, joint variables.
Page | 12
The definition of joint space of a robot arm can be related to the definition of
Cartesian space. That is, the position and orientation of the endpoint for a given set
of joint variables can be determined in Cartesian coordinates. This process is known
R
as forwarding kinematics. Advanced kinematics is the discovery of the TH
transformation matrix, which gives the position and orientation of the end point using
the matrices we have already mentioned. The RTH transformation matrix can also be
obtained by multiplying by the general displacement matrix and the orientation
transform matrix of the RPY axes.
For an endpoint position and orientation given in Cartesian coordinates, the process
of finding the values that the joint variables must take is called inverse kinematics.
Reverse kinematics can be difficult to solve according to the advanced kinematics. In
many cases, it is necessary to use techniques that do not guarantee a solution and
include trial and error.
4. DESIGN BRIEF
The design part is divided into two parts, the mechanical part design, and the
mechanical part installation. In the design of the mechanical part, the millimetric
drawings of the parts to be used in the robot arm construction were made through the
help program. In the installation of the mechanical part, the naming of the
servomotors used in the robot arm and the tasks during the operation of the robot are
explained. The construction of the project consists of several steps. These steps are;
Page | 13
Determination of microcontroller and software to be used in the project,
Search and selection of servo motors that will run the robot arm in a proper
way,
Proper selection of mechanical parts,
Implementation of robot arm assembly,
Testing the system to see if it works properly with the microcontroller we
choose,
Possible faults have been given in the form of restructuring the system by
passing through the eye. These steps have been completed and the design of
the robot has been completed.
Arduino and robot arm control are used in the project material are given in the
following chart.
Page | 15
Figure 9Design of mechanical parts
Page | 16
4.2. Mechanical Part Mounting
The cut parts are assembled together with the servo motors and assembly of the robot
arm is completed. The robot arm moves by 4 axes and performs this movement with
5 Mini Servo Motors.
After drawing the parts on SolidWorks and making the necessary parts, the design of
the mechanical part is started and the robot arm is made of a stationary lower body
and movable upper body. There is one servo motor in the stationary lower part of the
robot arm and this robot is called axis 1. The 1st axis provides rotation of the robot
arm to the right or left. There are 2 servo motors in the moving upper body part.
Since these servo motors must operate parallel to each other, both start and end
positions are set simultaneously. These two servo motors are named as 2nd axis and
3rd axis respectively.
The tasks of 2nd and 3rd axes are to move the robot arm up and down. Mounting of
servo motors in 1st and 2nd and 3rd axes is given in Fig.11.
Page | 17
4.3. Android Programming
The Android application we used in this project was done with App Inventor.
What is App Inventor? App Inventor is a free web application developed by Google
and later developed by the Massachusetts Institute of Technology (MIT). Other MIT
projects use a graphical interface, such as Scratch and StarLogo TNG, to drag and
drop visual objects instead of printing lines of code in mobile applications running on
the Android operating system.
App Inventor Design is the part of the application that we will design for visual and
active components of the application, from Buttons, Pictures, Text Fields; it can be
added to the Media Components such as Audio, Video, etc., besides the GPS,
Acceleration and Bluetooth sensor can be added to the device. In this section, you
have a design criterion where many variables like size, color, the position can be
controlled.
The design of the android application we use in the project is shown in Figure 12
Page | 18
Figure 12the design of the android application
In the App Inventorun Block section, we create the code that will work in the
background of the application we are doing with the interlocking blocks with code
fragments, just like a Lego. We make sure that all the components that I add to my
application have all the events/properties that can be used and combine them into the
corresponding blokes.
In the project we have done, android blocks are shown in Figures 13, 14, 15, 16.
Page | 19
Figure 13android blocks
Page | 20
Figure 15android blocks
Page | 21
5. EXPERIMENTAL STUDIES
Experimental studies are within themselves; the method followed in the project,
robot arm control system, and programming. In the method and robot arm control
system part of the project, the basic commands are explained after the basic
information is given and the robot can perform the required tasks. In the program
section, there is the software information required for the movement of the robot.
The programming part of the pro- gram is given in Appendix to the project to make
the project more regular.
First, a historical research on robot arms was carried out and the basic information
needed to establish the system was obtained. The robot used in the project types with
arm joint and can move in 4 axis directions (left and right, up and down) and also can
hold and swing motion thanks to the holder on it. The microcontroller Arduino Nano
is used to provide optimal control of the robot arm. The reason for preferring this
microcontroller is that it is more accessible to be able to get a solution to a possible
error because the open source code is easier to use than the other microcontrollers
and the number of users is higher.
After these studies, detailed information has been obtained about the servo motors to
be used. The servomotor is preferred because it can be carried out smoothly in the
robot project, the motor can be operated precisely and it must be at high torque. The
robot arm, 5 servo motors are formed. Servo motors are numbered from top to
bottom in order to explain their tasks because of the excess.
The connection box is made to distribute the 5V voltage from the supply source to
the servo motors. In doing so, servo motor inputs, Arduino pin inputs, and
communication circuit elements are used. The mechanical part of the robot arm is
designed by combining the pre-selected parts appropriately. In order to move the
Page | 22
robot arm properly, software with the selected Arduino microcontroller has been
implemented and then the experiment with the Bluetooth module and servo motors
has been done to learn about the system operation. The software has been
implemented with the appropriate Arduino microcontroller selected so that the robot
arm can be moved appropriately for the intended purpose. Control of the robot arm is
achieved by moving the axes of the android application in the '-' and '+' directions.
The Android app is shown in Figure 17.
1 Axis + 1 Axis -
2 Axis + 2 Axis -
3 Axis + 3 Axis -
4 Axis + 4 Axis -
Gripper + Gripper -
Save Play
BT Names
6. CONCLUSION
Robotic arms, many areas are developable. Thanks to the robotic arms, many tasks
are made easier and the resulting error level has been reduced to a minimum. For
example; some pharmacy-based drug-giving robots and a projected robot arm have
been developed. In addition to this, the ability to move the robot arm is further
increased, and when the camera is placed in the finger area and the sensitivity is
increased, it can be used in a wide range of applications from the medical sector to
the automation systems. With the robotic arms developed in this way, the risk of
Page | 23
infecting the patient in the medical sector is minimized, while the human errors are
minimized during the surgical intervention. Despite the fact that the robotic arm
made by this project is of prototype quality, it has a quality that can be improved for
more robotic systems. Besides these, robotic arm sector, which is open to
development, will keep its importance in the future.
The purpose of the project is to provide control of 4 axes moving robot arm design
and this robot arm with a suitable microcontroller and Bluetooth module with
android application. The necessary theoretical and practical information for this
purpose has been obtained and the necessary infrastructure has been established for
the project. During the process of making and developing the project, a lot of
theoretical knowledge has been transferred to the practice and it has been ensured
that it is suitable for the purpose of the project.
Page | 24
REFERENCES
Page | 25
APPENDIX 1: PROGRAMMING CODES
The program codes necessary to control the servo motors and perform robot arm
movements are given below.
#include <Servo.h>
#include <EEPROM.h>
bytepackage_order=0; package
byteIncomingdata[200];
byteMMC_packageOrder=0;
byteData_size=0;
byteRead_Data_size=0;
intdata_size=0;
boolsec_btn_up = 0;
boolsec_btn_down = 0;
boolup_btn =0;
booldown_btn=0;
boolsave_btn =0;
boolplay_btn =0;
String hmisend;
byteSecili_Servo=1;
bytehiz=75;
Servo Alt_servo;
Servo Alt_shoulder;
Servo Ust_elbow;
Servo G_wrist;
Servo Gripper;
Page | 26
intAlt_Servo_Degree=90;
intAlt_shoulder_Degree=90;
intUst_elbow_Degree=90;
intG_wrist_Degree=90;
intGripper_Degree=90;
charbt_data;
void setup() {
Serial.begin(9600);
pinMode(2,OUTPUT);
digitalWrite(2,1);
pinMode(13,OUTPUT);
digitalWrite(13,0);
Alt_servo.attach(5);//3
Alt_shoulder.attach(6); //6
Ust_elbow.attach(9);//11
G_wrist.attach(10);//5
Gripper.attach(11);//9
Alt_servo.write(90);
Alt_shoulder.write(90);
Ust_elbow.write(90);
G_wrist.write(90);
Gripper.write(90);
}
voidDegree_updown()
{
delay(hiz);
if(bt_data=='B')
Page | 27
{
// Serial.print("Alt_servo: ");Serial.println(Alt_Servo_Degree);
Alt_Servo_Degree++;
if(Alt_Servo_Degree> 180) Alt_Servo_Degree=180;
Alt_servo.write(Alt_Servo_Degree);
}
else if(bt_data=='D')
{
// Serial.print("Alt_shoulder: ");Serial.println(Alt_shoulder_Degree);
Alt_shoulder_Degree++;
if(Alt_shoulder_Degree> 180) Alt_shoulder_Degree=180;
Alt_shoulder.write(Alt_shoulder_Degree);
}
else if(bt_data=='F')
{
// Serial.print("Ust_elbow: ");Serial.println(Ust_elbow_Degree);
Ust_elbow_Degree++;
if(Ust_elbow_Degree> 180) Ust_elbow_Degree=180;
Ust_elbow.write(Ust_elbow_Degree);
}
else if(bt_data=='H')
{
// Serial.print("G_wrist: ");Serial.println(G_wrist_Degree);
G_wrist_Degree++;
if(G_wrist_Degree> 180) G_wrist_Degree=180;
G_wrist.write(G_wrist_Degree);
}
else if(bt_data=='Y')
Page | 28
{
// Serial.print("Gripper: ");Serial.println(Gripper_Degree);
Gripper_Degree++;
if(Gripper_Degree> 180) Gripper_Degree=180;
Gripper.write(Gripper_Degree);
}
if(bt_data=='A')
{
// Serial.print("Alt_servo: ");Serial.println(Alt_Servo_Degree);
Alt_Servo_Degree--;
if(Alt_Servo_Degree< 0) Alt_Servo_Degree=0;
Alt_servo.write(Alt_Servo_Degree);
}
else if(bt_data=='C')
{
// Serial.print("Alt_shoulder: ");Serial.println(Alt_shoulder_Degree);
Alt_shoulder_Degree--;
if(Alt_shoulder_Degree< 0) Alt_shoulder_Degree=0;
Alt_shoulder.write(Alt_shoulder_Degree);
}
else if(bt_data=='E')
{
// Serial.print("Ust_elbow: ");Serial.println(Ust_elbow_Degree);
Ust_elbow_Degree--;
if(Ust_elbow_Degree< 0) Ust_elbow_Degree=00;
Ust_elbow.write(Ust_elbow_Degree);
}
else if(bt_data=='G')
{
// Serial.print("G_wrist: ");Serial.println(G_wrist_Degree);
Page | 29
G_wrist_Degree--;
if(G_wrist_Degree< 0) G_wrist_Degree=00;
G_wrist.write(G_wrist_Degree);
}
else if(bt_data=='X')
{
// Serial.print("Gripper: ");Serial.println(Gripper_Degree);
Gripper_Degree--;
if(Gripper_Degree< 0) Gripper_Degree=00;
Gripper.write(Gripper_Degree);
}
}
intSaved_Location=0;
intstep=1;
voidSave()
{
if(bt_data=='K')
{
EEPROM.write(step, Alt_Servo_Degree);
step++;
EEPROM.write(step, Alt_shoulder_Degree);
step++;
EEPROM.write(step, Ust_elbow_Degree);
step++;
EEPROM.write(step, G_wrist_Degree);
step++;
EEPROM.write(step, Gripper_Degree);
step++;
Saved_Location++;
Page | 30
// Serial.print("LocationKaydedildi.!
ToplanLocationDizini:");Serial.println(Saved_Location);
}
EEPROM.write(0,Saved_Location);
}
bool play=0;
intplaystep=0;
voidplay()
{
if(bt_data=='P')
{
//Serial.println("Saved Is yapiliyor...");
play=1-play;
}
if(play==1)
{
playstep=1;
Saved_Location= EEPROM.read(0);
for(inti=0;i<Saved_Location;i++)
{
intDegree = EEPROM.read(playstep);
while(Alt_Servo_Degree!=Degree)
{
if(Alt_Servo_Degree>Degree) Alt_Servo_Degree--;
else if(Alt_Servo_Degree<Degree) Alt_Servo_Degree++;
delay(10);
Alt_servo.write(Alt_Servo_Degree);
}
Page | 31
playstep++;
delay(100);
Degree = EEPROM.read(playstep);
while(Alt_shoulder_Degree!=Degree)
{
if(Alt_shoulder_Degree>Degree) Alt_shoulder_Degree--;
else if(Alt_shoulder_Degree<Degree) Alt_shoulder_Degree++;
delay(10);
Alt_shoulder.write(Alt_shoulder_Degree);
}
playstep++;
delay(100);
Degree = EEPROM.read(playstep);
while(Ust_elbow_Degree!=Degree)
{
if(Ust_elbow_Degree>Degree) Ust_elbow_Degree--;
else if(Ust_elbow_Degree<Degree) Ust_elbow_Degree++;
delay(10);
Ust_elbow.write(Ust_elbow_Degree);
}
playstep++;
delay(100);
Degree = EEPROM.read(playstep);
while(G_wrist_Degree!=Degree)
{
if(G_wrist_Degree>Degree) G_wrist_Degree--;
else if(G_wrist_Degree<Degree) G_wrist_Degree++;
delay(10);
G_wrist.write(G_wrist_Degree);
Page | 32
}
playstep++;
delay(100);
Degree = EEPROM.read(playstep);
while(Gripper_Degree!=Degree)
{
if(Gripper_Degree>Degree) Gripper_Degree--;
else if(Gripper_Degree<Degree) Gripper_Degree++;
delay(10);
Gripper.write(Gripper_Degree);
}
playstep++;
}
}
}
void loop()
{
if(Serial.available()>0)
{
bt_data=Serial.read();
}
Degree_updown();
Save();
play();
if(bt_data=='K' || bt_data=='P')
{
digitalWrite(13,1);
Page | 33
bt_data=' ';
}
else digitalWrite(13,0);
Page | 34
Table of Contents
1. INTRODUCTION .............................................................................................. 1
2. THEORETICAL INFRASTRUCTURE .......................................................... 2
2.1. Servo Motors ................................................................................................ 2
2.2. Arduino Nano Microcontroller .................................................................. 3
2.3. HC-06 Bluetooth Module ............................................................................ 5
2.4. Circuit Diagram (Above Board)................................................................. 6
2.5. Power ............................................................................................................ 7
3. ROBOT ARM MECHANICS............................................................................ 7
3.1. General Characteristics of Robot Arm Mechanics .................................. 7
3.2. D & H (Denavit and Hartenberg) Coordinate Frames .......................... 11
3.3. Advanced Mechanics ................................................................................. 12
3.4. Inverse Mechanics ..................................................................................... 13
4. DESIGN BRIEF ................................................................................................ 13
4.1. Mechanical Design ..................................................................................... 14
4.2. Mechanical Part Mounting ....................................................................... 17
4.3. Android Programming.............................................................................. 18
5. EXPERIMENTAL STUDIES .......................................................................... 22
.5.1 Projected Method ...................................................................................... 22
5.2. Robot Arm Control ................................................................................... 22
.6 CONCLUSION ................................................................................................. 23
REFERENCES ......................................................................................................... 25
APPENDIX 1: PROGRAMMING CODES........................................................... 26
Page | 35