Analysis Report Review Report Title: REPORT DRAFT 4 Report ...
Report
-
Upload
kushal-prasad -
Category
Documents
-
view
161 -
download
2
Transcript of Report
JSS MahavidyapeethaSri Jayachamarajendra College of Engineering, Mysore 570 006
An Autonomous Institution Affiliated toVisvesvaraya Technological University (VTU), Belgaum
Design and Control of a 5 DOFRobotic Arm
Thesis submitted in partial fulfillment of the curriculumprescribed for the award of the degree of Bachelor of
Engineering inElectronics & Communication Engineering by
4JC07EC041 Kushal Prasad4JC07EC055 Nikhil S. Ranga4JC07EC071 Raghavendra R.4JC07EC075 Ranjith B.R.
Under the Guidance of
Dr. C.R. NatarajProfessor
Department of E&C, SJCE, Mysore
Department of Electronics & Communication Engineering
June, 2011
JSS Mahavidyapeetha
Sri Jayachamarajendra College of Engineering, Mysore 570 006An Autonomous Institution Affiliated to
Visvesvaraya Technological University (VTU), Belgaum
CertificateThis is to certify that the work entitled “Design and control of a 5 DOF
Robotic arm” is a bonafide work carried out by Kushal Prasad, Nikhil Ranga,
Ranjith B. R and Raghavendra R. in partial fulfillment of the award of the
degree of Bachelor of Engineering in Electronics & Communication Engineer-
ing of Visvesvaraya Technological University, Belgaum, during the year 2011.
It is certified that all corrections / suggestions indicated during Continuous
Internal Evaluation have been incorporated in the report. The project report
has been approved as it satisfies the academic requirements in respect of the
project work prescribed for the Bachelor of Engineering Degree.
GuideDr. C.R. Nataraj
Professor
Department of E&C
SJCE, Mysore 570 006
Head of the DepartmentC.R. Venugopal
Associate Professor and Head
Department of E&C
SJCE, Mysore 570 006
Date :
Place : Mysore
Examiners : 1.
2.
3.
Acknowledgement
Firstly, we would like to sincerely thank the Department of Elec-
tronics and Communication, SJCE for giving us a wonderful oppor-
tunity to gain experience by working on the practical aspects of the
subjects we have studied during our years at the college. On the
same note, we would like to thank our HOD, Dr C.R.Venugopal for
all the support he has provided.
We are greatly thankful to Sri M.L.Dwarakanath, under whose
able guidance we have undertaken this project. We would also like
to thank Dr.Renukappa .N.M and Smt.B.S.Renuka who have pro-
vided invaluable inputs during the course of our project.
Last but not the least we express our gratitude to Sri B.G Sangamesh-
wara, Principal of SJCE Mysore for providing us the opportunity to
realize this project by providing all the facilities in the college.
We are hereby thankful to Dr B.G.Sangameshwara, Principal
SJCE, Mysore & Dr C.R Venugopal, HOD of E&C, SJCE, Mysore
who encouraged at this venture.
We sincerely thank our guide Dr C.R. Nataraj, Professor, Dept Of
E&C, SJCE, Mysore for constructive and encouraging suggestions.
We thank Mr. Thimappa, proprietor, Vijay Engineering works,
Mysore for his help during the fabrication of the Robotic arm.
We also thank all Teaching and Non-teaching staff of E&C Dept
SJCE, Mysore for their kind co-operation during our course.
Finally we are extremely thankful to our Family & Friends who
helped us in our work & made the project a successful one.
Kushal Prasad
Nikhil S. Ranga
Raghavendra R.
Ranjith B.R.
i
secnumdepth2
Table of Contents
Table of Contents ii
List of Figures iii
List of Tables 1
1 Introduction 2
1.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Project description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Literary review 9
2.1 Mechanics and Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Material selection For Robotic arm fabrication . . . . . . . . . . . . . . . . . . . 13
2.3 Servo motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3 Hardware Components 24
3.1 Electronic hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 Servo motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3 Gripper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4 Piezo-electric transducers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4 Design and fabrication of robotic arm 29
4.1 Torque calculation of joints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2 Basic design considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3 Mechanical fabrication of the arm . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5 Control system for the robotic arm 39
5.1 Power supply unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 System integration and testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6 Conclusions 48
6.1 Achievements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
ii
6.2 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.3 Future extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Appendices 50
A Arduino Decimela 50
A.1 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
A.2 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
A.3 Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
A.4 Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
A.5 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
A.6 Automatic (Software) Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
A.7 USB Overcurrent Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
A.8 Physical Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
A.9 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
B Python Programming Language 55
B.1 Programming philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
B.2 Python syntax and semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
B.3 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
B.4 Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
C Source code for the software implementation 60
C.1 Front-End Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
List of Figures
1.1 5 DOF robotic arm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Robotic arm after completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Robotic arm in action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1 A servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2 Servos used in toy helicopters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3 Servos used in RC airplanes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4 Servo motor manufacturers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.5 Control signals for servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
iii
2.6 Inside a servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.7 Inside a servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.8 Feedback cuircuit emploed by servo motor . . . . . . . . . . . . . . . . . . . . . . . 20
2.9 control signal for the motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.1 Arduino decimilia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 Image of the gripper on Robokits website . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3 Image of the Piezo electric sensor on Onlinetps website . . . . . . . . . . . . . . . . 28
4.1 Robotic arm shape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.2 Top down approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.3 Signal flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4 Base joint arrangement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.5 Base joint components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.6 Base joint after completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.7 schematic for the shoulder and elbow joints . . . . . . . . . . . . . . . . . . . . . . 34
4.8 The links used in the robotic arm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.9 Shoulder link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.10 L-clamps used for the shoulder motors . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.11 Elbow link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.12 Wrist Schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.13 Wrist link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.1 Servo motor circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2 The complete circuit board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.3 Blower used to cool the regulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4 Screen-shot of user interface software at start-up . . . . . . . . . . . . . . . . . . . 44
5.5 Screen-shot of user interface software during keyboard control . . . . . . . . . . . 45
5.6 Screen-shot of user interface software during mouse control . . . . . . . . . . . . 45
5.7 Inverse kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
A.1 Arduino Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
iv
Design and control of 5 DOF robotic arm Chapter 0
List of Tables
1.1 Project break down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Some Features of the Robotic arm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Sensors and Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1 Arduino Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1 Torque requirement at each joint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.2 Arm dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.1 Current requirement of servo motors at 6V . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 List of keys for the control software . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3 List of keys for the control software . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
abstract
Dept Of E&C, SJCE, Mysore 1
Chapter 1
Introduction
1.1 Preamble
Introduction to robotics
In the modern world, robotics has become popular, useful, and has achieved
great successes in several fields of humanity. Robotics has become very useful
in medicine, education, military, research and mostly, in the world of man-
ufacturing. It is a term that has since been used to refer to a machine that
performs work to assist people or work that humans find difficult or undesir-
able. Robots, which could be destructive or non-destructive, perform tasks
that would have been very tedious for human beings to perform. They are
capable of performing repetitive tasks more quickly, cheaply, and accurately
than humans. Robotics involves the integration of many different disciplines,
among them kinematics, signal analysis, information theory, artificial intelli-
gence, and probability theory. These disciplines when applied suitably, lead
to the design of a very successful robot.
History of Robotics
The advent of robotics started in the year 350 B.C. when a Greek mathe-
matician Archytas of Tarentum built a mechanical bird, which was called
the pigeon. This mechanical bird was powered using steam. With further
advancements, Leonardo Da Vinci in the year, 1495 designed a mechanical
device that looked like an armoured knight. The knight was designed to move
as if there was a real person inside. In 1898, Nikola Tesla designed the first
remote-controlled robot in Madison Square Garden. The robot designed was
modelled after a boat.
2
Design and control of 5 DOF robotic arm Chapter 1
The first industrial robots were Unimates developed by George Devol and
Joe Engelberger in the late 50s and early 60s. The first patents were by
Devol but Engelberger formed Unimation which was the first market robots.
Therefore, Engelberger has been called the father of robotics. For a while, the
economic viability of these robots proved disastrous and thing slowed down
for robotics. However, by mid-80s, the industry recovered and robotics was
back on track.
George Devol Jr, in 1954 developed the multi-jointed artificial arm, which
lead to the modern robots. However, mechanical engineer Victor Scheinman,
developed the truly flexible arm know as the Programmable Universal Manip-
ulation Arm (PUMA). In 1950, Isaac Asimov came up with laws for robots and
these were:
• A robot may not injure a human being, or through inaction allow a hu-
man being to come to harm.
• A robot must obey the orders given it by human beings, except where
such orders would conflict with the first law.
• A robot must protect its own existence as long as such protection does
not conflict with the first or second law (Robotics Introduction. 2001).
Mobile Robotics moved into its own in 1983 when Odetics introduced a
six-legged vehicle that was capable of climbing over objects. This robot could
lift over 5.6 times its own weight parked and 2.3 times it weight moving. There
were very significant changes in robotics until the year 2003 when NASA
launched two robots MER-A Spirit and MER-B Opportunity rovers which were
destined for Mars. Up till date, Robotic de have kept researching on how to
make robots very interactive with man in order to be able to communicate
efficiently in the social community.
Classification of Robots
There are various types of robots, which are used now in the modern world
each having one or several tasks that it performs depending on the intelligence
applied to it. However, robots can be classified broadly into two types namely:
1. Autonomous Mobile Robots
2. Manipulator Robots
Dept Of E&C, SJCE, Mysore 3
Design and control of 5 DOF robotic arm Chapter 1
i. Autonomous Mobile Robots
These are mobile robots provided with the mechanisms to perform certain
tasks such as locomotion, sensing, localization, and motion planning. Au-
tonomous mobile robots are capable of adapting to their environment. The
intelligence provided to them enables them to be able to sense conditions
around their environment and respond correctly to the situations.
Examples of Autonomous mobile robots include the autonomous guided
vehicle robots which independent of external human actions deliver parts be-
tween various assembly stations by following special electrical guide wires
using a custom sensor, the HELPMATE service robot which transports food
and medication throughout hospitals by tracking the position of ceiling lights,
which are manually specified to the robot before hand. Also, in the military,
some robots are designed to detect bombs and they are capable of defusing
the bombs. These robots are all autonomous in the task they perform be-
cause they have been provided with the intelligence to detect and adapt to the
environment in which they are supposed to perform their tasks.
ii. Manipulator Robots
These are robots that perform particular tasks. They are usually in the form
of robot arms and are normally stationary. In most cases, they are bolted at
the shoulder to a specific position in the assembly line, and the robot arm
can move with great speed and accuracy to perform repetitive tasks such as
spot welding and painting. Manipulator robots are very much unlike the au-
tonomous mobile robots whereby the intelligence provided to them does not
make them adapt to the environment in which they are. In most cases, most
manipulator robots are capable of handling many end-effectors in order to
increase the versatility of their use. These various end-effectors can be used
for several purposes such as welding, painting, screwing and assembling.
Although manipulator robots can be very versatile, they suffer from a funda-
mental disadvantage, which is lack of mobility. A fixed manipulator robot has
a limited range of motion that depends on where it is bolted down, in contrast
to a mobile robot that is capable of moving about.
1.2 Project description
This project is titled as ”Design and Control of a 5 DOF Robotic Arm”. The
project was done under the guidance of Dr. C.R. Nataraj, Professor, Depart-
ment of Electronics and Communications Engineering, Sri Jayachamarajedra
Dept Of E&C, SJCE, Mysore 4
Design and control of 5 DOF robotic arm Chapter 1
College of Engineering, Mysore, in the 2010/2011 academic session.
Problem Definition
The project involves 2 primary objectives
1. Design and fabrication of Robotic arm with five degrees .
2. Development of a user-friendly control method.
Figure 1.1: 5 DOF robotic arm
Figure 1.1 shows a robotic arm with five gedrees of freedom. The five
degrees of freedom are
• Axis 1 - Rotation of base
• Axis 2 - forward or backward motion of shoulder
• Axis 3 - Up and down motion of elbo.
• Axis 4 - Up and down motion of elbow.
• Axis 5 - Rotation of wrist.
Dept Of E&C, SJCE, Mysore 5
Design and control of 5 DOF robotic arm Chapter 1
Figure 1.2: Robotic arm after completion
Figure 1.3: Robotic arm in action
Figure 1.2 and Figure 1.3 show the robotic arm after completion. The
Robotic arm was fabricated using aluminium links and servo motors. We
bought a ready-made end effector and modified it to incorporate sensors. The
control of the motors was done using Arduino board. The robotic arm can
be connected to a PC or a Linux system and can be controlled using either
a keyboard or a mouse. The computer software was written using Pythonprogramming language.
Required components
The following sections give brief details of the required components for the
project.
Dept Of E&C, SJCE, Mysore 6
Design and control of 5 DOF robotic arm Chapter 1
Servo Motors
We decided to use Servo motors as actuators as they were easy o use and
readily available. Robokits website (www.robokits.co.in) sells servos with
different output toqrues. Servo motors can be easily controlled using PWM
signals. We have used three types of servo motors in the project. Figure 1.1
shows a robotic arm with five degrees of freedom. The five degrees of freedom
are
• Mega Torque quarter scale servos for the base of the robotic arm.
• High torque metal gear servo motors for the shoulder and elbow.
• Standard servo motor for the rest of the joints.
Arduino Decimilia
The Arduino Diecimila is a microcontroller board based on the ATmega168. It
has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6
analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an
ICSP header, and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it
with a AC-to-DC adapter or battery to get started. We chose Arduino as the
controller board as it has an easy to use programming language with a very
good servo library which can control up-to 8 servos. Table 1.1 shows the
Table 1.1: Project break down
Sl no work Numberof weeks
1 Information Collection on material for fabrica-tion, servo motors and control methods
2
2 Information collection on python programminglanguage
2
3 Fabrication of arm 84 Testing of components and the arm 35 Building the control software 26 Testing 1
break down of the time taken by each part of the project.
Summary
The features of the robotic arm are listed in table 1.2. Table 1.3 lists the
sensors and actuators used in the project
Dept Of E&C, SJCE, Mysore 7
Design and control of 5 DOF robotic arm Chapter 1
Table 1.2: Some Features of the Robotic arm
Feature DetailsRobot arm material Aluminium was used. It is lighter and yet possesses reasonable strength.User Interface Software A rich user interface with enhanced functionalities and user friendliness.Circuit Implementation The printed circuit board (PCB) technology was used. This has the advantage of a neater circuit with practically no wires, hence it is easier to trouble shoot.Robot Control Circuitry The Arduino Board provides enough pins for selecting seven servo motors and has an integrated provision for five A/D Converters, hence eliminating the need for decoders and separate motor control circuitry.
Table 1.3: Sensors and Actuators
Component FeaturesPiezoelectric Transduc-ers
The ability to quantize change in pressure interms of voltages makes it very convenient. Theability to measure the rate of change of pres-sure rather than the absolute value is specificallyhelpful for the selected application.
Servo Motors Precise angular rotation achieved with easy togenerate PWM signals. Integrated gears(nylon ormetal) designed for varied torque applications asdemonstrated.
Dept Of E&C, SJCE, Mysore 8
Chapter 2
Literary review
2.1 Mechanics and Motion
This section gives details about the principles used in the design and control
of robotic arm.
Introduction
Mechanics deals with the analysis of the forces that cause a body to be in
physical motion. The motion of the robot arm will be achieved with the use
of servo motors as actuators. Since servo motors are designed to achieve an
accurate resolution of up-to 1 degree, feedback is not necessary and therefore
it is possible to track the position of the respective link with relatively high
accuracy.
Since mechanics involves also the parts of the robot that are acted upon
directly by the motors and the gears to achieve motion, the tensile strengths of
those areas were designed to withstand the stresses generated due to friction
and force of propulsion.
Manipulator
Manipulator is another commonly used name for a robot or mechanical arm
and it will be used intermittently with robot arm in this document. A manip-
ulator is an assembly of segments and joints that can be conveniently divided
into three sections: the arm, consisting of one or more segments and joints;
the wrist, usually consisting of one to three segments and joints; and a gripper
or other means of attaching or grasping. Alternatively, the manipulator can
be divided into only two sections, arm and gripper, but for clarity the wrist
is separated out as its own section because it performs a unique function.
9
Design and control of 5 DOF robotic arm Chapter 2
Industrial robots are stationary manipulators whose base is permanently at-
tached to the floor, a table, or a stand. In most cases, however, industrial
manipulators are too big and use a geometry that is not effective on a mobile
robot, or lack enough sensors (indeed many have no sensors at all) to be con-
sidered for use on a mobile robot. There is a section covering them as a group
because they demonstrate a wide variety of sometimes complex manipulator
geometries. We will review the robot arm based on the three general layouts
of the arm section of a generic manipulator, and wrist and gripper designs.
It should be pointed out that there are few truly autonomous manipulators
in use except in research labs. The task of positioning, orienting, and doing
something useful based solely on input from frequently inadequate sensors is
extremely difficult. In most cases, the manipulator is tele-operated (remotely
controlled using radio transmission technology).
Positioning, Orienting And Degrees Of Freedom
Generally, the arm and wrist of a basic manipulator perform two separate
functions, positioning and orienting. There are layouts where the wrist or
arm is not distinguishable. In the human arm, the shoulder and elbow do
the gross positioning and the wrist does the orienting. Each joint allows one
degree of freedom of motion. The theoretical minimum number of degrees of
freedom to reach to any location in the work envelope and orient the gripper
in any orientation is six; three for location, and three for orientation. In
other words, there must be at least three bending or extending motions to
get position, and three twisting or rotating motions to get orientation.
Actually, the six or more joints of the manipulator can be in any order,
and the arm and wrist segments can be any length, but there are only a few
combinations of joint order and segment length that work effectively. They
almost always end up being divided into arm and wrist. The three twisting
motions that give orientation are commonly labeled pitch, roll, and yaw, for
tilting up/down, twisting, and bending left/right respectively. Unfortunately,
there is no easy labeling system for the arm itself since there are many ways
to achieve gross positioning using extended segments and pivoted or twisted
joints.
A good example of a manipulator is the human arm, consisting of a shoul-
der, upper arm, elbow, and wrist. The shoulder allows the upper arm to
move up and down which is considered one degree of freedom (DOF). It allows
forward and backward motion, which is the second DOF, but it also allows ro-
tation, which is the third DOF. The elbow joint gives the forth DOF. The wrist
Dept Of E&C, SJCE, Mysore 10
Design and control of 5 DOF robotic arm Chapter 2
pitches up, down and rolls, giving two DOFs in one joint. Theoretically the
best wrist joint geometry is a ball joint, but even in the biological world, there
is only one example of a true full motion ball joint (one that allows motion in
two planes, and twists 360) because they are so difficult to power and control.
The human hip joint is a limited motion ball joint. On a mobile robot, the
chassis can often substitute for one or two of the degrees of freedom, usually
fore/aft and sometimes to yaw the arm left/right, reducing the complexity
of the manipulator significantly. Some special purpose manipulators do not
need the ability to orient the gripper in all three axes, further reducing the
DOF. At the other extreme, there are arms in the conceptual stage that have
more than fifteen DOF.
Arm Geometries
The three general layouts for three-DOF arms are called Cartesian, cylindrical,
and polar (or spherical). They are named for the shape of the volume that the
manipulator can reach and orient the gripper into any position within the
work envelope. They all have their uses, but as will become apparent, some
are better for use on robots than others. Some use all sliding motions, some
use only pivoting joints, some use both. Pivoting joints are usually more
robust than sliding joints but, with careful design, sliding or extending can be
used effectively for some types of tasks. Pivoting joints have the drawback of
preventing the manipulator from reaching every cubic centimeter in the work
envelope because the elbow cannot fold back completely on itself. This creates
dead spacesplaces where the arm cannot reach that are inside the gross work
volume. On a robot, it is frequently required for the manipulator to fold very
compactly.
Cartesian or rectangular work envelope
On a mobile robot, the manipulator almost always works beyond the edge of
the chassis and must be able to reach from ground level to above the height of
the robots body. This means the manipulator arm works from inside or from
one side of the work envelope. Some industrial gantry manipulators work
from outside their work envelope, and it would be difficult indeed to use their
layouts on a mobile robot. In fact, that is how it is controlled and how the
working end moves around in the work envelope. There are two basic lay-
outs based on how the arm segments are supported, gantry and cantilevered.
Mounted on the front of a robot, the first two DOF of a cantilevered Cartesian
Dept Of E&C, SJCE, Mysore 11
Design and control of 5 DOF robotic arm Chapter 2
manipulator can move left/right and up/down; the Y-axis is not necessarily
needed on a mobile robot because the robot can move back/forward.
Cylindrical work envelope
This is the second type of robot arm work envelope. Cylindrical types usually
incorporate a rotating base with the first segment able to telescope or slide
up and down, carrying a horizontally telescoping segment. While they are
very simple to picture and the work envelope is intuitive, they are hard to
implement effectively because they require two linear motion segments, both
of which have moment loads in them caused by the load at the end of the
upper arm. In the basic layout, the control code is fairly simple, i.e., the angle
of the base, height of the first segment, and extension of the second segment.
On a robot, the angle of the base can simply be the angle of the chassis
of the robot itself, leaving the height and extension of the second segment. A
second geometry that still has a cylindrical work envelope is the SCARA de-
sign. SCARA means Selective Compliant Assembly Robot Arm. This design
has good stiffness in the vertical direction, but some compliance in the hori-
zontal. This makes it easier to get close to the right location and let the small
compliance take up any misalignment. A SCARA manipulator replaces the
second telescoping joint with two vertical axis-pivoting joints.
Polar or spherical work envelope
The third, and most versatile, geometry is the spherical type. It is the type
used in our project. In this layout, the work envelope can be thought of as
being all around. In practice, though, it is difficult to reach everywhere. There
are several ways to layout an arm with this work envelope. The most basic has
a rotating base that carries an arm segment that can pitch up and down, and
extend in and out. Raising the shoulder up changes the envelope somewhat
and is worth considering in some cases.
The wrist work envelope
The arm of the manipulator only gets the end point in the right place. In order
to orient the gripper to the correct angle, in all three axes, second set of joints
is usually required - the wrist. The joints in a wrist must twist up/down,
clockwise/counter-clockwise, and left/right. They must pitch, roll, and yaw
respectively. This can be done all-in-one using a ball-in-socket joint like a
human hip, but controlling and powering this type is difficult. Most wrists
consist of three separate joints. The order of the degrees of freedom in a wristDept Of E&C, SJCE, Mysore 12
Design and control of 5 DOF robotic arm Chapter 2
has a large effect on the wrists functionality and should be chosen carefully,
especially for wrists with only one or two DOF.
Grippers work envelope
The end of the manipulator is the part the user or robot uses to affect some-
thing in the environment. For this reason it is commonly called an end-
effector, but it is also called a gripper since that is a very common task for
it to perform when mounted on a robot. It is often used to pick up danger-
ous or suspicious items for the robot to carry, some can turn doorknobs, and
others are designed to carry only very specific things like beer cans. Closing
too tightly on an object and crushing it is a major problem with autonomous
grippers. There must be some way to tell how hard is enough to hold the
object without dropping it or crushing it. Even for semi-autonomous robots
where a human controls the manipulator, using the gripper effectively is often
difficult. For these reasons, gripper design requires as much knowledge as
possible of the range of items the gripper will be expected to handle. Their
mass, size, shape, and strength, etc. all must be taken into account. Some
objects require grippers that have many jaws, but in most cases, grippers
have only two. There are several basic types of gripper geometries. The most
basic type has two simple jaws geared together so that turning the base of
one turns the other. This pulls the two jaws together. The jaws can be moved
through a linear actuator or can be directly mounted on a motor gearboxs
output shaft, or driven through a right angle drive which places the drive mo-
tor further out of the way of the gripper. This and similar designs have the
drawback that the jaws are always at an angle to each other which tends to
push the thing being grabbed out of the jaws.
2.2 Material selection For Robotic arm
fabrication
Introduction
In choosing the materials and the shape for the fabrication of the robotic arm,
the following were taken into consideration:
1. The ease of manufacturing the parts
2. The mode of manufacturing
3. Ease of assemblyDept Of E&C, SJCE, Mysore 13
Design and control of 5 DOF robotic arm Chapter 2
4. Strength and durability of the parts
5. Weight of robot
6. Cost
The principal requirements for power transmission of robots are:
• Small size
• Low weight and moment of inertia
• High effective stiffness
• Accurate and constant transmission ratio
• Low energy losses and friction for better responsiveness of the control
system.
• Elimination of backlash
Hence, the combination of these factors has greatly influenced all the
choices made in the design selection of the robotic arm.
Material Selection
In manipulator structures, stiffness-to-weight ratio of a link is very important
since inertia forces induce the largest deflections. Therefore, an increase in
the Elastic modulus, E would be very desirable if it is not accompanied by an
unacceptable increase in specific density, . The Elastic modulus is an indica-
tion of the materials resistance to breakage when subjected to force. The best
properties are demonstrated by ceramics and beryllium but ceramics have a
problem of brittleness and beryllium is very expensive. Structural materials
such as magnesium (Mg), Aluminum (Al), and titanium (Ti) which are light
have about the same E/ ratios as steel and are used when high strength and
low weight are more important than E/ ratios. Factors like aging, creep in
under constant loads, high thermal expansion coefficient, difficulty in joining
with metal parts, high cost and the fact that they are not yet commercially
available make the use of fibre-reinforced materials limited though they have
good stiffness-to-weight ratios. However, with advances in research, some
of the mentioned setbacks have been significantly reduced. Hence, the use
of fiber-reinforced materials (known as composites) is becoming more attrac-
tive. Aluminum lithium alloy have better processing properties and is not very
expensive. Alloyed materials such as Nitinol (nickel titanium Aluminum),
Dept Of E&C, SJCE, Mysore 14
Design and control of 5 DOF robotic arm Chapter 2
Aluminum incramute (copper - manganese Aluminum) are also commercially
available.
Therefore the materials recommended for use in this project are
• Al-Li alloys
• Nitinol (nickel-titanium-Aluminum)
• Incramute (copper-manganese-Aluminum)
• Glass-reinforced Plastic (GRP)
The external dimensions are limited in order to reduce waste of the usable
workspace. They are as light as possible to reduce inertia forces and allow for
the highest external load per given size of motors and actuators. For a given
weight, links have to possess the highest possible bending (and torsional)
stiffness. The parameter to be modified to comply with these constraints is
the shape of the cross-section. The choice is between hollow round and hollow
rectangular cross-section. From design standpoint of view, the links of square
or rectangular cross-section have advantage of strength and machinability
ease over round sections.
Despite the recommendations mentioned above as regards choice of ma-
terials, our options were narrowed down to a choice between steel, GRP, and
Aluminum based on feasibility studies carried out.
Current trend in robotics (especially industrial robotics) shows a quest to
achieve lighter designs with reasonable strength. This design goal has always
meant a trade-off in terms of cost. Composite materials are generally more
expensive than most metals used in industrial robots fabrication.
For the particular case of our project, we narrowed our options down to
composite material glass reinforced plastic otherwise known as GRP and
Aluminum.
After more research and consultations with some lecturers in the Mechan-
ical Engineering department, who are experts in the field, we settled for Alu-
minum mainly on grounds of feasibility, cost and workability.
2.3 Servo motors
Servo refers to an error sensing feedback control which is used to correct the
performance of a system. Servo or RC Servo Motors are DC motors equipped
with a servo mechanism for precise control of angular position. The RC servo
motors usually have a rotation limit from 90 to 180. Some servos also haveDept Of E&C, SJCE, Mysore 15
Design and control of 5 DOF robotic arm Chapter 2
rotation limit of 360 or more. But servos do not rotate continually. Their
rotation is restricted in between the fixed angles.
Figure 2.1: A servo motor
Figure 2.1 shows a commercially available servo motor
Servo Motor applications
The Servos are used for precision positioning. They are used in robotic arms
and legs, sensor scanners and in RC toys like RC helicopter, airplanes and
cars. They are, in fact very popular among hobbyists. Figure 2.2 and Fig-
ure 2.3 show such examples.
Figure 2.2: Servos used in toy helicopters
Servo Motor manufacturers
There are four major manufacturers of servo motors: Futaba, Hitec, Airtron-
ics and JR radios. Futaba and Hitec servos have nowadays dominated the
market. Their servos are same except some interfacing differences like the
Dept Of E&C, SJCE, Mysore 16
Design and control of 5 DOF robotic arm Chapter 2
Figure 2.3: Servos used in RC airplanes
wire colors, connector type, spline etc. The logos of the makers is shown in
Figure 2.4. The motors used in the projects were manufatured by Futaba.
Figure 2.4: Servo motor manufacturers
Servo Motor wiring and plugs
The Servo Motors come with three wires or leads. Two of these wires are to
provide ground and positive supply to the servo DC motor. The third wire is
for the control signal. These wires of a servo motor are color coded. The red
wire is the DC supply lead and must be connected to a DC voltage supply in
the range of 4.8 V to 6V. The black wire is to provide ground. The color for
the third wire (to provide control signal) varies for different manufacturers. It
can be yellow (in case of Hitec), white (in case of Futaba), brown etc. Futaba
provides a J-type plug with an extra flange for proper connection of the servo.
Hitec has an S-type connector. A Futaba connector can be used with a Hitec
servo by clipping of the extra flange. Also a Hitec connector can be used with
a Futaba servo just by filing off the extra width so that it fits in well.
Hitec splines have 24 teeth while Futaba splines are of 25 teeth. Therefore
splines made for one servo type cannot be used with another. Spline is the
place where a servo arm is connected. It is analogous to the shaft of a common
DC motor.
Unlike DC motors, reversing the ground and positive supply connections
does not change the direction (of rotation) of a servo. This may, in fact, dam-
age the servo motor. That is why it is important to properly account for the
order of wires in a servo motor.Dept Of E&C, SJCE, Mysore 17
Design and control of 5 DOF robotic arm Chapter 2
Servo Control
The servo motor can be moved to a desired angular position by sending PWM
(pulse width modulated) signals on the control wire. The servo understands
the language of pulse position modulation. A pulse of width varying from 1
millisecond to 2 milliseconds in a repeated time frame is sent to the servo for
around 50 times in a second. The width of the pulse determines the angular
position.
Figure 2.5: Control signals for servo motor
For example, a pulse of 1 millisecond moves the servo towards 0, while a 2
milliseconds wide pulse would take it to 180. The pulse width for in between
angular positions can be interpolated accordingly. Thus a pulse of width 1.5
milliseconds will shift the servo to 90.
It must be noted that these values are only the approximations. The actual
behavior of the servos differs based on their manufacturer.
A sequence of such pulses (50 in one second) is required to be passed to
the servo to sustain a particular angular position. When the servo receives a
pulse, it can retain the corresponding angular position for next 20 millisec-
onds. So a pulse in every 20 millisecond time frame must be fed to the servo.
Figure 2.5 shows the signals needed to control servo motors.
Inside a Servo Motor
A servo motor mainly consists of a DC motor, gear system, a position sensor
which is mostly a potentiometer, and control electronics. Figure 2.6 shows
the inside of a servo motor. Figure 2.7 shows the step-by-step disassembly of
a servo motor.Dept Of E&C, SJCE, Mysore 18
Design and control of 5 DOF robotic arm Chapter 2
Figure 2.6: Inside a servo motor
Figure 2.7: Inside a servo motor
The DC motor is connected with a gear mechanism which provides feed-
back to a position sensor which is mostly a potentiometer. From the gear box,
the output of the motor is delivered via servo spline to the servo arm. The
potentiometer changes position corresponding to the current position of the
motor. So the change in resistance produces an equivalent change in voltage
from the potentiometer. A pulse width modulated signal is fed through the
control wire. The pulse width is converted into an equivalent voltage that is
compared with that of signal from the potentiometer in an error amplifier.
Figure 2.8 shows the feedback circuit employed by a servo motor. The
difference signal is amplified and provided to the DC motor. So the signal
applied to the DC servo motor is a damping wave which diminishes as the
Dept Of E&C, SJCE, Mysore 19
Design and control of 5 DOF robotic arm Chapter 2
Figure 2.8: Feedback cuircuit emploed by servo motor
desired position is attained by the motor.
Figure 2.9: control signal for the motor
Figure 2.9 shows the signal needed for robotic arm.
When the difference between the desired position as indicated by the pulse
train and current position is large, motor moves fast. When the same differ-
ence is less, the motor moves slow. The required pulse train for controlling
the servo motor can be generated by a timer IC such as 555 or a micro-
controller can be programmed to generate the required waveform.
Power supply for Servo
The servo requires a DC supply of 4.8 V to 6 V. For a specific servo, its voltage
rating is given as one of its specification by the manufacturer. The DC supply
can be given through a battery or a regulator. The battery voltage must be
closer to the operating voltage of the servo. This will reduce the wastage of
power as thermal radiation. A switched regulator can be used as the supply
for better power efficiency. We have used 6 V (using voltage regulator 7806)
for all the servos to achieve maximum torque.Dept Of E&C, SJCE, Mysore 20
Design and control of 5 DOF robotic arm Chapter 2
Selection of a Servo
The typical specifications of servo motors are torque, speed, weight, dimen-
sions, motor type and bearing type. The motor type can be of 3 poles or 5
poles. The pole refers to the permanent magnets that are attached with the
electromagnets. 5 pole servos are better than 3 pole motor because they pro-
vide better torque. The servos are manufactured with different torque and
speed ratings. The torque is the force applied by the motor to drive the servo
arm. Speed is the measure that gives the estimate that how fast the servo
attains a position. A manufacturer may compromise torque over speed or
speed over torque in different models. The servos with better torque must be
preferred. The weight and dimensions are directly proportional to the torque.
Obviously, the servo having more torque will also have larger dimensions and
weight. The selection of a servo can be made according to the torque and
speed requirements of the application. The weight and dimension may also
play a vital role in optimizing the selection such as when a servo is needed
for making an RC airplane or helicopter. The website of the manufacturers
can be seen to obtain details about different models of the servos. Also their
product catalogue can be referred to. Some manufacturers like Futaba also
provide online calculator for the selection of a servo.
Interference and Noise Signal
The PWM signal is given to the servo by the control wire. The noise or in-
terference signals from the surrounding electronics or other servos can cause
positional errors. To eliminate this problem the control signals are supplied
after amplification. This will suppress the noise and interference signals.
Arduino micro-controller board
Arduino is an open-source electronics prototyping platform based on flexible,
easy-to-use hardware and software. It’s intended for artists, designers, hob-
byists, and anyone interested in creating interactive objects or environments.
Arduino can sense the environment by receiving input from a variety of
sensors and can affect its surroundings by controlling lights, motors, and
other actuators. The micro-controller on the board is programmed using the
Arduino programming language(based onWiring) and the Arduino develop-
ment environment (based on Processing). Arduino projects can be stand-
alone or they can communicate with software on running on a computer (e.g.
Dept Of E&C, SJCE, Mysore 21
Design and control of 5 DOF robotic arm Chapter 2
Flash, Processing,MaxMSP). The boards can bebuilt by handorpurchased pre-
assembled; the software can bedownloadedfor free. The hardware reference
designs (CAD files) are availableunder an open-source license.
2.4 Software
A robot, by definition, must have intelligence and this actually means some
software that directs it on what to do, given zero or more input conditions.
This section describes the software tools used in the project. We had chose two
different software design tools, one for the software that runs on the computer,
another for the micro-controller programming.
Choice Of Programming Language for the software on the
computer
From analysis on our project, we arrived at the conclusion that two separate
pieces of software would be required. One would run on the PCs processor
and would take care of the user interface (GUI) or what could be called the
robots dashboard. For this, we did some extensive research on the program-
ming language that would be most suitable. We chose the Python program-
ming language based on some of its desirable characteristics, including the
following: Python Is simple No language is simple, but Python is a bit easier
than the popular object-oriented programming languages C++ and Java,.
In addition, the number of language constructs is small for such a powerful
language. The clean syntax makes Python programs easy to write and read.
Python Is Object-Oriented Object-oriented programming (OOP) models the
real world in terms of objects. OOP provides great flexibility, modularity and
re-usability.
Python Is Interpreted Python interpreter interprets the Python code. The
Python code is machine-independent and can run on any machine that has
Python installed Python Is Robust Robust means reliable. No programming
language can ensure complete reliability. Python puts a lot of emphasis on
early checking of possible errors, because Python compiler can detect many
problems that would first show up at execution time in other languages.
Python has eliminated certain types of error-prone programming constructs
found in other languages. It does not support pointers, for example, thereby
eliminating the possibility of overwriting memory and corrupting data.
Python has a runtime exception-handling feature to provide programming
support for robustness. Python forces the programmer to write the code toDept Of E&C, SJCE, Mysore 22
Design and control of 5 DOF robotic arm Chapter 2
deal with exceptions. Python can catch and respond to an exceptional situ-
ation so that the program can continue its normal execution and terminate
gracefully when a runtime error occurs.
Python Is Architecture-Neutral The most remarkable feature of Python is
that it is architecture-neutral, also known as platform-independent. With
Python, you can write programs that will run on any platform, such as Win-
dows, OS/2, Macintosh, and various UNIX, IBM AS/400, and IBM Main-
frames.
Python Is Portable Python programs can be run on any platform with-
out being recompiled, making them very portable. Moreover, there are no
platform-specific features in the Python language. The Python environment is
portable to new hardware and operating systems. In fact, the Python compiler
itself is written in Python.
Programming language for the micro-controller
The second piece of software was to exist in the micro-controller code mem-
ory, and actually form the intelligence of the robot. It’s written in Arduino Pro-
gramming Language(APL) specifically designed for all range of Arduino boards.
The trade-off in using a high-level language instead of the native instruc-
tion set to program a micro-controller would be a slightly less efficient uti-
lization of the limited code memory and slightly slower programs. Arduino
code is clearer and easier to handle. This outweighed the disadvantages in
the case of our project so we chose the APL which has an almost one-to-one
correspondence with the micro-controller assembly language.
Dept Of E&C, SJCE, Mysore 23
Chapter 3
Hardware Components
This chapter describes, in detail, selected raw materials, harware components and
software resources used by us.
3.1 Electronic hardware
This subsection deals with the components we have selected for the control system
of the robotic arm. The arm is controlled by a micro-controller board called Arduino
Demicilia driving the actuators (servo motors) via latches and transistors. The micro-
controller receives commands from the USB port via Serial Communication.
Arduino Decimilia
We chose Arduino decimilia as the controller to use as we were impressed by its
capabilities. We bought the board from the online shop www.robokits.co.in.
Figure 3.1: Arduino decimilia
Figure 3.1 shows Arduino decimlia displayed on the official Arduino website.
24
Design and control of 5 DOF robotic arm Chapter 3
Overview
The Arduino Diecimila is a micro-controller board based on theATmega168(datasheet).
It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16MHzcrystal oscillator, a USB connection, a power jack, an ICSP header,
and a reset button. It contains everything needed to support the micro-controller;
simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter
or battery to get started.
The Arduino Diecimila can be programmed with the Arduino software. TheAT-
mega168on the Arduino Diecimila comes preburned with a bootloader that allows us
to upload new code to it without the use of an external hardware programmer. It
communicates using the original STK500 protocol.
Summary
Summary of the Arduino is shown in Table 3.1.
Table 3.1: Arduino Summary
micro-controller ATmega168Operating Voltage 5VInput Voltage (recommended) 7-12 VInput Voltage (limits) 6-20 VDigital I/O Pins 14 (of which 6 provide PWM
output)Analog Input Pins 6DC Current per I/O Pin 40 mADC Current for 3.3V Pin 50 mAFlash Memory 16 KB (of which 2 KB used by
bootloader)SRAM 1 KBEEPROM 512 bytesClock Speed 16MHz
3.2 Servo motors
This section describes the servo motors that are used in the project. The motors were
bought from www.robokits.co.in
Mega Torque Quarter Scale Servo Motor
This motor was used for the construction of base joint.
Dept Of E&C, SJCE, Mysore 25
Design and control of 5 DOF robotic arm Chapter 3
Features
• Required Pulse:3-5 Volt Peak to Peak Square Wave
• Operating Voltage:4.8-6.0 Volts
• Operating Temperature Range:-10 to +60 Degree C
• Operating Speed (4.8V):0.19sec/60 degrees at no load
• Operating Speed (6.0V):0.14sec/60 degrees at no load
• Stall Torque (4.8V):20 kg/cm
• Stall Torque (6.0V):25kg/cm
• 360 Modifiable:Yes
• Bearing Type:Double Ball Bearing
• Gear Type:All Nylon Gears
• Connector Wire Length:12”
• Dimensions:2.59” x 1.18”x 1.26” (66 x 30 x 57.6mm)
• Weight:152gm
Standard Dual Ball Bearing Servo Motor
This motor was used in the construction of wrist pitch and wrist rotation joints and
to operate the gripper.
Features
• Required Pulse: 3-5 Volt Peak to Peak Square Wave
• Operating Voltage: 4.8-6.0 Volts
• Operating Temperature Range: -10 to +60 Degree C
• Operating Speed (4.8V): 0.20sec/60 degrees at no load
• Operating Speed (6.0V): 0.16sec/60 degrees at no load
• Stall Torque (4.8V): 5.5 kg/cm
• Stall Torque (6.0V): 7 kg/cm
• 360 Modifiable: Yes
• Potentiometer Drive: Indirect Drive
Dept Of E&C, SJCE, Mysore 26
Design and control of 5 DOF robotic arm Chapter 3
• Bearing Type: Double Ball Bearing
• Gear Type: All Nylon Gears
• Connector Wire Length: 12”
• Dimensions: 1.6” x 0.8”x 1.4” (41 x 20 x 36mm)
• Weight: 41gm
High Torque Metal Gear Standard Servo
this motor was used in the construction of shoulder and elbow joints.
Features
• Required Pulse: 3-5 Volt Peak to Peak Square Wave
• Operating Voltage: 4.8-6.0 Volts
• Operating Temperature Range: -10 to +60 Degree C
• Operating Speed (4.8V): 0.20sec/60 degrees at no load
• Operating Speed (6.0V): 0.16sec/60 degrees at no load
• Stall Torque (4.8V): 14 kg/cm
• Stall Torque (6.0V): 16 kg/cm
• 360 Modifiable: Yes
• Potentiometer Drive: Indirect Drive
• Bearing Type: Double Ball Bearing
• Gear Type: All Metal Gears
• Connector Wire Length: 12”
• Dimensions: 1.6” x 0.8”x 1.4” (41 x 20 x 36mm)
• Weight: 41gm
3.3 Gripper
Based on the feasibility analysis carried out in the last semester, we decided to
purchase the gripper from a commercial supplier. Robokits India (www.robokits.
Dept Of E&C, SJCE, Mysore 27
Design and control of 5 DOF robotic arm Chapter 3
Figure 3.2: Image of the gripper on Robokits website
co.in, Bhopal, is an online store that supplies general purpose robotics compo-
nents.Figure 3.2 shows the image of the General purpose gripper displayed on their
website.
The gripper has provision to attach two standard dual ball bearing servo motors.
The wrist rotation in the arm is actually carried out by one of these motors. The other
motor performs the gripping operation.
3.4 Piezo-electric transducers
To avoid excess strain on the gripper motor, we needed to sense the completion of
gripping operation. We decided to use Piezoelectric trancuders available on the online
store www.onlinetps.com. Figure 3.3 shows the image displayed on the onlinetps
website.
Figure 3.3: Image of the Piezo electric sensor on Onlinetps website
Three primary reasons we chose piezoelectric disks over other methods of pressure
sensing are:
1. they are their very sensitive because they are high impedance, they work well
in a wide variety of equipment.
2. they are rugged
3. they are inexpensive
But, to be used, the sensors needed to be soldered carefully.
Dept Of E&C, SJCE, Mysore 28
Chapter 4
Design and fabrication of roboticarm
In this chapter we first describe the design and fabrication process of the robotic arm.
4.1 Torque calculation of joints
The point of doing force calculations is for motor selection. We had to make sure that
the motor we chose could not only support the weight of the robot arm, but also what
the robotic arm would carry.
Chosen parameters were:
• weight of each linkage
• weight of each joint
• weight of object to lift
• length of each linkage
We calculated the torques, multiplying downward force times the linkage lengths.
This calculation must be done for each lifting actuator. This particular design has
just three DOF that requires lifting, and the centre of mass of each linkage is assumed
to be Length/2. Refer Figure 4.1 Torque about shoulder joint can be calculated as:
T4 = (L3/2)W3+L3M3+(L3+L2/2)W2+(L3+L2)M2+(L3+L2+L1/2)W1+(L3+L2+L1)M1
Torque About Elbow Joint:
T3 = (L2/2)W2 + L2M2 + (L2 + L1/2)W1 + (L2 + L1)M1
Torque about wrist joint:
T2 = (L1/2)W1 + L1M1
where Wi is the weight of link i. Similarly for the other links.
The result of the calculations are listed in Table 4.1. The same table lists the servo
motors chosen for the joints.29
Design and control of 5 DOF robotic arm Chapter 4
Figure 4.1: Robotic arm shape
Table 4.1: Torque requirement at each joint
Joint Calculated torque (Kg-cm) Servo chosenBase 18.4 1 x mega toque
Shoulder 20.6 2 x high torqueElbow 7.9 1 x high torqueWrist 3.7 1 x standard
4.2 Basic design considerations
In the design of systems, there are generally two methods of approach namely:
• Top-down method
• Bottom-Up method
The top-down method is usually applied in designing a system from the scratch while
the down-top method is used for reverse designing of an already existing system or
functional design as in software engineering.Dept Of E&C, SJCE, Mysore 30
Design and control of 5 DOF robotic arm Chapter 4
We employed the top-down approach in the design of the robot arm project and
Figure 4.2 shows how the various modules were integrated to arrive at the entire
system.
Figure 4.2: Top down approach
A block diagram model of the robot arm control is shown in Figure 4.3. The
actuators are the servo motors at each joint. The computer will control the servo
motors indirectly through the control unit.
Figure 4.3: Signal flow
Dept Of E&C, SJCE, Mysore 31
Design and control of 5 DOF robotic arm Chapter 4
4.3 Mechanical fabrication of the arm
It is pertinent to note that this part of the project requires very high expertise in
mechanical design and fabrication, hence, and understandably too, it was a major
source of concern for us considering our limited exposure in the above mentioned
area.
We therefore sought the assistance of experts in the mechanical engineering de-
sign field, and, with grateful hearts, we want to mention that Mr. Thimappa, of Vinay
Engineering Works, Mysore took it upon himself to assist us in the entire mechanical
fabrication. He lent us his valuable time and staff, and helped us fabricate the arm.
Apart from the excitement of seeing abstract drawings transform into real mechanical
components, we learnt some important things in the mechanical engineering design
field while working with him.
We employed the top-down approach (shown in Figure 4.2) in the design of the
robot arm but the fabrication of the arm was done component by component and
eventually, the components were integrated to obtain the whole arm.
Materials for the fabrication were selected based on some constraints that include:
• Weight
• Work envelope
• Workability
• Maintainability
Construction of base
To avoid putting undue weight on the base motor, it was decided that ball bearings
would be used. Figure 4.5 shows the base motor joint just before assembly. The ball
bearing arrangement transfers all the weight onto the base. Figure 4.4 shows the
arrangement of components. Figure 4.6 shows the base joint after completion.
This arrangement presented us with a different sort of problem. The motor was
too powerful and the ball bearing arrangement was too smooth, resulting in a lot
mechanical vibrations. We had to put mechanical dampers made out of packing
material to solve the problem.
Construction of shoulder, elbow and wrist
Based on the results of torque calculated earlier(Ref. Table 4.1), we decided to use
two high torque motors for the shoulder joint. It was initially decided that a single
standard motor should be enough to for the elbow joint, but during the testing we
found out that a high torque servo is needed for the joint. Standard servo motors
were used at the wrist joint, the wrist rotation and gripper.
Dept Of E&C, SJCE, Mysore 32
Design and control of 5 DOF robotic arm Chapter 4
Figure 4.4: Base joint arrangement
Figure 4.5: Base joint components
Figure 4.7 shows the schematic we used to construct the shoulder and the elbow
joint. The design was printed and stuck on the aluminium sheet of 1.6mm thickness.
The we got it cut accordingly with some professional help. Figure 4.8 shows the
result.
Figure 4.9 and Figure 4.11 show respectively the shoulder to elbow link and elbow
to wrist link of the arm.
Figure 4.10 shows the clamps used for holding the shoulder motors on the base.
The clamp was constructed using an aluminium sheet of 1.6mm thickness.
Then we drilled holes on the links and fitted them with servo motors. We used
Dept Of E&C, SJCE, Mysore 33
Design and control of 5 DOF robotic arm Chapter 4
Figure 4.6: Base joint after completion
Figure 4.7: schematic for the shoulder and elbow joints
spacers to keep parallel parts of the links perfectly parallel.
The wrist of the arm was designed using a single aluminium sheet. The design is
shown Figure 4.12. The sheet was bent after cutting. Figure 4.13 shows the wrist of
the robotic arm. The wrist has provision to attach a servo motor that will rotate the
Dept Of E&C, SJCE, Mysore 34
Design and control of 5 DOF robotic arm Chapter 4
Figure 4.8: The links used in the robotic arm
Figure 4.9: Shoulder link
gripper.
Dept Of E&C, SJCE, Mysore 35
Design and control of 5 DOF robotic arm Chapter 4
Figure 4.10: L-clamps used for the shoulder motors
Figure 4.11: Elbow link
The gripper was modified to accommodate piezoelectric sensors. The sensors de-
tect the completion of gripping operation by sensing the change in pressure. The
Arduino board stops the gripping motor from further rotating and damaging itself or
the gripper or the object to be gripped.
Dept Of E&C, SJCE, Mysore 36
Design and control of 5 DOF robotic arm Chapter 4
Figure 4.12: Wrist Schematics
Figure 4.13: Wrist link
Summary
Table 4.2 shows a summary of the arm dimensions. The total arm weight was 7.2
Kg. Most of the weight is at the base to avoid cantilever beam type of problems, that
would otherwise result when the arm is extended.
Dept Of E&C, SJCE, Mysore 37
Design and control of 5 DOF robotic arm Chapter 4
Table 4.2: Arm dimensions
Joint Dimensions(in)Base height 3Base Radius 3
Shoulder to elbow link 4.55Elbow to wrist link 4.18
Wrist 3
Dept Of E&C, SJCE, Mysore 38
Chapter 5
Control system for the robotic arm
This chapter deals with mainly the control system of the robotic arm. First we shall
discuss the power supply unit. In the latter part of the chapter we shall discuss the
5.1 Power supply unit
The current requirement of motors is given in Table 5.1. Also each motor needs 6V to
ensure maximum torque. Hence we decided use a a 12V, 5A power adapter. A total
of 60W of power is available which is more than the required power.
Table 5.1: Current requirement of servo motors at 6V
Servo motor Current required(mA)Quarter scale 900-1000High torque 750-800
Shoulder to elbow link 400-600
Each motor is given a separate voltage regulator to provide enough power. The
voltage regulator used is 7806 which can give a maximum of 1A. LED is used to
indicate if the voltage regulator is working properly. Figure 5.2 shows the circuit
diagram.
These circuits were all implemented using the printed circuit board (PCB) tech-
nology. This process generally involves drawing the circuit diagram with the aid of a
PCB design software. The circuit is printed on paper using a laser jet printer. The
printed circuit diagram is placed on a copper-coated board known as the printed cir-
cuit board. An exact impression of the circuit is made on the board by pressing the
printed circuit unto the board with hot iron. The impressed board is then placed in
some fluid known as etching fluid, and all the copper, apart from the parts coated by
the printed circuit ink (which was transferred by hot iron impression), is etched off
39
Design and control of 5 DOF robotic arm Chapter 5
Figure 5.1: Servo motor circuit
leaving a copper trace that is an exact reproduction of the printed circuit. Appropri-
ate holes are then drilled and the components soldered. The PCB has the advantage
of a neater circuitry with basically no wires and hence easier to troubleshoot.
The only problem we encountered during the power circuit implementation was
the overheating of the voltage regulators. We found out that the overheating was due
to the excess power that is supplied by the adapter. Hence we decided to use heat
sinks and a blower. Figure 5.3 shows the blower used in the project.
Software
This section deals with the design of the software used in the control of robotic arm.
Two separate pieces of software were developed for the robotic arm.
1. User interface software
2. Software on the micro-controller board
User interface software and its implementation
When user interface software was being written, we decided to meet the following
specification.
• The User could choose between the mouse control method and keyboard control
method.
Dept Of E&C, SJCE, Mysore 40
Design and control of 5 DOF robotic arm Chapter 5
Figure 5.2: The complete circuit board
Dept Of E&C, SJCE, Mysore 41
Design and control of 5 DOF robotic arm Chapter 5
Figure 5.3: Blower used to cool the regulators
• The user should be able to control each servo individually or use the inverse
kinematics mode. The control methods above mentioned should have at least
one of the modes.
• The user should be able to see the angles each servo is currently at.
We decided to feed all the angles and the grip status to the Arduino micro-
controller board. Hence the user interface software was designed to generate a string
with 18 characters, three characters each for each degree of freedom.
The graphical user interface (GUI) was designed using Pygame library for python.
Though Pygame is intended to be used for writing games, we decided to use it as it
can recognize both key and mouse inputs easily. GUI is a simple one and it provides
the user with simple information such as control method used (keyboard or mouse),
input to the Arduino board and the angle each motor is at.
Keyboard control
The keyboard control is summarized in Table 5.2
Up to 3 keys can be pressed at one time and the program can respond.
Mouse control
Mouse actions needed to control during the servos are summarized in Table 5.3.
There are five operations can be achieved using the mouse.
Dept Of E&C, SJCE, Mysore 42
Design and control of 5 DOF robotic arm Chapter 5
Table 5.2: List of keys for the control software
Key Action’z’ or ’x’ Roate base servo’a’or ’q’ Rotate shoulder servo’w’or ’s’ Rotate Elbow servo’e’or ’d’ Rotate wrist servo’r’or ’f’ Rotate gripper
LEFT CTRL This key in combination with the keysabove produces twice the normal speed
LEFT SHIFT This key in combination with the keysabove produces five times the normalspeed
’g’ Close or open gripper (Normal Mode)’h’ Close or open gripper (Pressure sens-
ing Mode)’i’ or ’m’ Move the gripper vertically using in-
verse kinematics’j’ or ’k’ Move the gripper horizontally using in-
verse kinematicsSPACE reset robotic arm to default position or
cancel reset modeRIGHT ALT Switch to mouse control
Table 5.3: List of keys for the control software
Mouse action or key ActionLEFT CLICK or RIGHT CLICK switch between base rotation, horizon-
tal movement. vertical movement andgrip rotate modes
MOUSE-WHEEL SCROLL change the angle of base or gripper orchange the horizontal or vertical posi-tion of gripper depending on the modechosen
Middle click Close or open gripper (Pressure sens-ing Mode)
SPACE reset robotic arm to default position orcancel reset mode
RIGHT ALT Switch to keyboard control
• base rotation
• horizontal gripper movement
• vertical gripper movement
Dept Of E&C, SJCE, Mysore 43
Design and control of 5 DOF robotic arm Chapter 5
• gripper rotation
• gripper open and close in the pressure sensing mode
Figure 5.4: Screen-shot of user interface software at start-up
Figure 5.4, Figure 5.5 and Figure 5.6 show the screen-shots of the control software
at three different stages of execution.
Inverse Kinematics
The inverse kinematics is the calculation of the angles of the joints when the gripper
position is given. In this project it is mainly used for achieving horizontal and vertical
movements of the gripper. The following section describes the calculations involved
in inverse kinematics.
Refer Figure 5.7.
Since the program can enter the inverse kinematics mode at any time, we need to
calculate height and the position of gripper. It can be done as follows.
Refer Figure 5.7 for the calculations
If a = 4.55inch and b = 4.18inch, we can calculate x (horizontal gripper position) and
h (vertical gripper position):
c =√a2 + b2 − 2ab cosβ
γ = (b sinβ/c)
Dept Of E&C, SJCE, Mysore 44
Design and control of 5 DOF robotic arm Chapter 5
Figure 5.5: Screen-shot of user interface software during keyboard control
Figure 5.6: Screen-shot of user interface software during mouse control
Dept Of E&C, SJCE, Mysore 45
Design and control of 5 DOF robotic arm Chapter 5
kinematics.png
Figure 5.7: Inverse kinematics
δ = α− γ
x = c cos δ
h = c sin δ
The reverse of these operations can be carried out get new α and β once the new
desired vertical or horizontal position is calculated.
Software on the micro-controller board
The software on the Arduino board was written to take 18 character long string com-
mands from USB port. In other words, the user can not directly interact with Arduino.
Arduino breaks the string down to get the individual servo angles and sets the an-
gles. If normal gripping mode is selected, it writes 25◦ on the gripper servo. When the
object is un-gripped, gripper servo is written with a value 125◦.
When the gripping with pressure sensing is done, the gripper gradually closes
until the pressure felt by sensors is enough. Then the motor holds the angle. This
prevents damage to the gripper and the object due to excess pressure.
Dept Of E&C, SJCE, Mysore 46
Design and control of 5 DOF robotic arm Chapter 5
5.2 System integration and testing
The robot arm design project was split into smaller tasks to reduce complexity and
also to facilitate parallel implementation of independent tasks. The tasks include
robot arm fabrication, gear design and assembly, control circuit design and imple-
mentation, and software development for both the GUI and microcontroller.
Most of the circuits were first implemented on bread boards before transferring
to printed circuit boards apart from the very simple ones. We tested the individual
circuit boards for basic errors and also for functionality where applicable. During
testing, some components were damaged (especially voltage regualtors) and replaced.
Having tested the various modules, the system integration was done in stages.
Some power supply issues were encountered, such as supply voltage dropping sig-
nificantly when loaded and undue heating of the voltage regulators, and we tried
rectifying them but could not do so immediately. Most of the problems we faced
solved themselves with PCB technology. In the PCB, all the control lines were drawn
from the motors and connected to the Arduino.
A test code for testing the movement of each joint was developed in which we
tested control of each of the joint motors, and the system test was carried out. The
results were as follows:
• The gripper motor turned satisfactorily, clockwise and counterclockwise. But
the grip force was observed to be quite high.
• The wrist roll motor perfectly.
• The wrist pitch motor was successfully controlled.
• The elbow motor was successfully controlled.
• The waist or base motor was too powerful. The excessive force caused bad
vibrations in the arm. We used friction based mechanical dampers and solved
the problem.
• There was a slight misalignment in the shoulder motors, This was rectified by
keeping one servo as the reference and aligning the other one. A table was made
and the Arduino code was accordingly modified.
Dept Of E&C, SJCE, Mysore 47
Chapter 6
Conclusions
This chapter deals with our achievements and shortcomings.
6.1 Achievements
In spite of our lack of knowledge in the mechanical fabrication field we were able to
achieve the following:
• Portable robotic arm that can be connected to almost any machine with the
right software installed
• Five degrees of freedom achieved as proposed in the synopsis.
• Inverse kinematics was understood and tailor-made for our application
• Platform for direct control of all 7 servo motors from computer.
• A rich and user-friendly user interface.
• Overheating was avoided using heat-sinks and a blower.
• We developed a respect towards and understanding of mechanical engineering
branch through hands-on experiences whilst fabricating the arm.
• We understood modular embedded systems applications and operations while
working on the project.
• Grip sensing was achieved with pressure sensors so as to avoid gripping an
object too tightly.
• Mechanical damping was employed successfully in the case where the base
arrangement was jerking due to excess torque provided by base motor.
48
Design and control of 5 DOF robotic arm Chapter 6
6.2 Limitations
The project has the following limitations.
• Our lack of mechanical knowledge resulted in a loss of considerable time, which
otherwise could have been used for developing more feedback based robotic
arm.
• Irregularity in the power supply causes excess power loss.
• The servos have unpredictable accuracy outside the limit of 25 to 160. This has
direct consequence because we could not achieve the desired work envelop.
• The total weight of the arm makes it little too heavy. We could not reduce the
weight because we could not avoid the cantilever beam type of problems that
would otherwise result with a light base.
• Inverse kinematics fails when any one of the motors has reached its upper
limit(160◦) or lower limit(25◦).
6.3 Future extensions
The project can be extended to add the following functionality.
• Infrared sensors can be used to sense proximity of the object. This will prevent
the object from being knocked over.
• Image processing can be done to recognize user hand movement and the robotic
arm can imitate.
• Image processing can be used allow the user to pick up the desired object just
by clicking on it in the video feed.
• Sixth degree of freedom in the form of wrist sideways( yaw) motion could be
added. This allows the user to grip the object in any desired position.
Dept Of E&C, SJCE, Mysore 49
Appendix A
Arduino Decimela
This chapter descibes the arduino decimelia in detail.
A.1 Components
Figure A.1 shows the components used in the Arduino board. The design schematic
along with the PCB layout is open source and is available for download at http:
//arduino.cc/en/uploads/Main/arduino-diecimila-reference-design.zip.
Figure A.1: Arduino Components
50
Design and control of 5 DOF robotic arm Chapter A
A.2 Memory
The ATmega168 has 16 KB of flash memory for storing code (of which 2 KB is used
for the bootloader). It has 1 KB of SRAM and 512 bytes of EEPROM (which can be
read and written with the EEPROM library).
A.3 Power
The Arduino Diecimila can be powered via the USB connection or with an external
power supply. The power source is selected by the PWRSELjumper : topowertheboardfromtheUSBconnection, placeitonthetwopinsclosesttotheUSBconnector, foranexternalpowersupply, thetwopinsclosesttotheexternalpowerjack.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart)
or battery. The adapter can be connected by plugging a 2.1mm center-positive plug
into the board’s power jack. Leads from a battery can be inserted in the Gnd and
Vin pin headers of the POWER connector. A low dropout regulator provides improved
energy efficiency.
The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may be
unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts.
The power pins are as follows:
• VIN. The input voltage to the Arduino board when it’s using an external power
source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the
power jack, access it through this pin.
• 5V. The regulated power supply used to power the microcontroller and other
components on the board. This can come either from VIN via an on-board
regulator, or be supplied by USB or another regulated 5V supply.
• 3V3. A 3.3 volt supply generated by the on-board FTDI chip. Maximum current
draw is 50 mA.
• GND. Ground pins.
A.4 Input and Output
Each of the 14 digital pins on the Diecimila can be used as an input or output, using
pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each
pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor
(disconnected by default) of 20-50 kOhms. In addition, some pins have specialized
functions:
Dept Of E&C, SJCE, Mysore 51
Design and control of 5 DOF robotic arm Chapter A
• Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial
data. These pins are connected to the corresponding pins of the FTDI USB-to-
TTL Serial chip.
• External Interrupts: 2 and 3. These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value. See the
attachInterrupt() function for details.
• PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite()
function.
• SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI commu-
nication, which, although provided by the underlying hardware, is not currently
included in the Arduino language.
• LED: 13. There is a built-in LED connected to digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it’s off.
• The Diecimila has 6 analog inputs, each of which provide 10 bits of resolution
(i.e. 1024 different values). By default they measure from ground to 5 volts,
though is it possible to change the upper end of their range using the AREF pin
and some low-level code. Additionally, some pins have specialized functionality:
• I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire
library (documentation on the Wiring website).
There are a couple of other pins on the board:
• AREF. Reference voltage for the analog inputs. Used with analogReference().
• Reset. Bring this line LOW to reset the microcontroller. Typically used to add a
reset button to shields which block the one on the board.
A.5 Communication
The Arduino Diecimila has a number of facilities for communicating with a computer,
another Arduino, or other microcontrollers. The ATmega168 provides UART TTL (5V)
serial communication, which is available on digital pins 0 (RX) and 1 (TX). An FTDI
FT232RL on the board channels this serial communication over USB and the FTDI
drivers (included with the Arduino software) provide a virtual com port to software on
the computer. The Arduino software includes a serial monitor which allows simple
textual data to be sent to and from the Arduino board. The RX and TX LEDs on the
board will flash when data is being transmitted via the FTDI chip and USB connection
to the computer (but not for serial communication on pins 0 and 1). A SoftwareSerial
library allows for serial communication on any of the Diecimila’s digital pins. The
Dept Of E&C, SJCE, Mysore 52
Design and control of 5 DOF robotic arm Chapter A
ATmega168 also supports I2C (TWI) and SPI communication. The Arduino software
includes a Wire library to simplify use of the I2C bus; see the documentation on the
Wiring website for details. To use the SPI communication, please see the ATmega168
datasheet.
A.6 Automatic (Software) Reset
Rather then requiring a physical press of the reset button before an upload, the Ar-
duino Diecimila is designed in a way that allows it to be reset by software running on
a connected computer. One of the hardware flow control lines (DTR) of the FT232RL
is connected to the reset line of the ATmega168 via a 100 nanofarad capacitor. When
this line is asserted (taken low), the reset line drops long enough to reset the chip.
Version 0009 of the Arduino software uses this capability to allow you to upload
code by simply pressing the upload button in the Arduino environment. This means
that the bootloader can have a shorter timeout, as the lowering of DTR can be well-
coordinated with the start of the upload. This setup has other implications. When
the Diecimila is connected to either a computer running Mac OS X or Linux, it resets
each time a connection is made to it from software (via USB). For the following half-
second or so, the bootloader is running on the Diecimila. While it is programmed to
ignore malformed data (i.e. anything besides an upload of new code), it will inter-
cept the first few bytes of data sent to the board after a connection is opened. If a
sketch running on the board receives one-time configuration or other data when it
first starts, make sure that the software with which it communicates waits a second
after opening the connection and before sending this data.
A.7 USB Overcurrent Protection
The Arduino Diecimila has a resettable polyfuse that protects your computer’s USB
ports from shorts and overcurrent. Although most computers provide their own in-
ternal protection, the fuse provides an extra layer of protection. If more than 500 mA
is applied to the USB port, the fuse will automatically break the connection until the
short or overload is removed.
A.8 Physical Characteristics
The maximum length and width of the Diecimila PCB are 2.7 and 2.1 inches respec-
tively, with the USB connector and power jack extending beyond the former dimen-
sion. Three screw holes allow the board to be attached to a surface or case. Note that
the distance between digital pins 7 and 8 is 160 mil (0.16”), not an even multiple of
the 100 mil spacing of the other pins.
Dept Of E&C, SJCE, Mysore 53
Design and control of 5 DOF robotic arm Chapter A
A.9 Software
The Arduino IDE is a cross-platform application written in Java, and is derived from
the IDE for the Processing programming language and the Wiring project. It is de-
signed to introduce programming to artists and other newcomers unfamiliar with
software development. It includes a code editor with features such as syntax high-
lighting, brace matching, and automatic indentation, and is also capable of compiling
and uploading programs to the board with a single click. There is typically no need to
edit makefiles or run programs on the command line. The Arduino IDE comes with
a C/C++ library called ”Wiring” (from the project of the same name), which makes
many common input/output operations much easier. Arduino programs are writ-
ten in C/C++, although users only need define two functions to make a runnable
program:
• setup() a function run once at the start of a program that can initialize settings
• loop() a function called repeatedly until the board powers off
Dept Of E&C, SJCE, Mysore 54
Appendix B
Python Programming Language
Python is an interpreted, general-purpose high-level programming language whose
design philosophy emphasizes code readability. Python aims to combine ”remarkable
power with very clear syntax”, and its standard library is large and comprehensive.
Its use of indentation for block delimiters is unique among popular programming
languages.
Python supports multiple programming paradigms, primarily but not limited to
object-oriented, imperative and, to a lesser extent, functional programming styles. It
features a fully dynamic type system and automatic memory management, similar
to that of Scheme, Ruby, Perl, and Tcl. Like other dynamic languages, Python is
often used as a scripting language, but is also used in a wide range of non-scripting
contexts.
B.1 Programming philosophy
Python is a multi-paradigm programming language. Rather than forcing program-
mers to adopt a particular style of programming, it permits several styles: object-
oriented programming and structured programming are fully supported, and there
are a number of language features which support functional programming and aspect-
oriented programming (including by metaprogramming and by magic methods). Many
other paradigms are supported using extensions, such as pyDBC and Contracts for
Python which allow Design by Contract.
Python uses dynamic typing and a combination of reference counting and a cycle-
detecting garbage collector for memory management. An important feature of Python
is dynamic name resolution (late binding), which binds method and variable names
during program execution.
Rather than requiring all desired functionality to be built into the language’s core,
Python was designed to be highly extensible. New built-in modules can be easily
written in C, C++ or Cython. Python can also be used as an extension language for
existing modules and applications that need a programmable interface. This design
55
Design and control of 5 DOF robotic arm Chapter B
of a small core language with a large standard library and an easily extensible inter-
preter was intended by Van Rossum from the very start because of his frustrations
with ABC (which espoused the opposite mindset).
The design of Python offers only limited support for functional programming in the
Lisp tradition. However, Python’s design philosophy exhibits significant similarities
to those of minimalistic Lisp-family languages, such as Scheme The standard library
has two modules (itertools and functools) that implement proven functional tools
borrowed from Haskell and Standard ML.
While offering choice in coding methodology, the Python philosophy rejects exu-
berant syntax, such as in Perl, in favor of a sparser, less-cluttered grammar. Python’s
developers expressly promote a particular ”culture” or ideology based on what they
want the language to be, favoring language forms they see as ”beautiful”, ”explicit”
and ”simple”. As Alex Martelli put it in his Python Cookbook (2nd ed., p. 230): ”To
describe something as clever is NOT considered a compliment in the Python culture.”
Python’s philosophy rejects the Perl ”there is more than one way to do it” approach to
language design in favor of ”there should be oneand preferably only oneobvious way
to do it”.
Python’s developers eschew premature optimization, and moreover, reject patches
to non-critical parts of CPython which would offer a marginal increase in speed at
the cost of clarity. Python is sometimes described as ”slow”. However, by the Pareto
principle, most problems and sections of programs are not speed critical. When speed
is a problem, Python programmers tend to try using a JIT compiler such as Psyco,
rewriting the time-critical functions in ”closer to the metal” languages such as C, or
by translating (a dialect of) Python code to C code using tools like Cython.
The core philosophy of the language is summarized by the document ”PEP 20 (The
Zen of Python)”.
B.2 Python syntax and semantics
The syntax of the Python programming language is the set of rules that defines how
a Python program will be written and interpreted (by both the runtime system and
by human readers). Python was designed to be a highly readable language. It has
a relatively uncluttered visual layout and uses English keywords frequently where
other languages use punctuation. Python aims towards simplicity and generality
in the design of its syntax, encapsulated in the mantra ”There should be one and
preferably only one obvious way to do it”, from ”The Zen of Python”. Note that this
mantra is deliberately opposed to the Perl mantra of ”there’s more than one way to
do it”.
Dept Of E&C, SJCE, Mysore 56
Design and control of 5 DOF robotic arm Chapter B
Indentation
Python uses whitespace indentation, rather than curly braces or keywords, to delimit
blocks (a feature also known as the off-side rule). An increase in indentation comes
after certain statements; a decrease in indentation signifies the end of the current
block Consider a function, foo, which is passed a single parameter, x, and if the
parameter is 0 will call bar and baz, otherwise it will call qux, passing x, and also
call itself recursively, passing x-1 as the parameter. Here are implementations of this
function in both C and Python:
• foo function in C with KR indent style:
void foo ( int x )
{i f ( x == 0) {
bar ( ) ;
baz ( ) ;
} else {qux ( x ) ;
foo ( x − 1 ) ;
}}
• foo function in Python:
def foo ( x ) :
i f x == 0:
bar ( )
baz ( )
else :
qux ( x )
foo ( x − 1)
Python mandates a convention that programmers in ALGOL-style languages often
follow. Moreover, in free-form syntax, since indentation is ignored, good indentation
cannot be enforced by an interpreter or compiler. Incorrectly indented code can be
understood by human reader differently than does a compiler or interpreter.
Statements and control flow
Python’s statements include (among others):
• The if statement, which conditionally executes a block of code, along with else
and elif (a contraction of else-if).Dept Of E&C, SJCE, Mysore 57
Design and control of 5 DOF robotic arm Chapter B
• The for statement, which iterates over an iterable object, capturing each ele-
ment to a local variable for use by the attached block.
• The while statement, which executes a block of code as long as its condition is
true.
• The try statement, which allows exceptions raised in its attached code block to
be caught and handled by except clauses; it also ensures that clean-up code in
a finally block will always be run regardless of how the block exits.
• The class statement, which executes a block of code and attaches its local
namespace to a class, for use in object-oriented programming.
• The def statement, which defines a function or method.
• The with statement, which encloses a code block within a context manager (for
example, acquiring a lock before the block of code is run, and releasing the lock
afterwards).
• The pass statement, which serves as a NOP and can be used in place of a code
block.
• The assert statement, used during debugging to check for conditions that
ought to apply.
B.3 Methods
Methods on objects are functions attached to the object’s class; the syntax instance.method(argument)
is, for normal methods and functions, syntactic sugar for Class.method(instance, ar-
gument). Python methods have an explicit self parameter to access instance data,
in contrast to the implicit self in some other object-oriented programming languages
(for example, Java, C++ or Ruby).
B.4 Mathematics
Python defines the modulus operator so that the result of a % b is in the open in-
terval [0,b), where b is a positive integer. (When b is negative, the result lies in the
interval (b,0]). However, this consequently affects how integer division is defined.
To maintain the validity of the equation b * (a / b) + a % b = a, Integer division
is defined to round towards minus infinity. Therefore 7 / 3 is 2, but (7) / 3 is 3.
This is different from many programming languages, where the result of integer divi-
sion rounds towards zero and the modulus operator is consequently defined in a way
which can return negative numbers. Python provides a round function for rounding
floats to integers. Version 2.6.1 and lower use round-away-from-zero: round(0.5) is
Dept Of E&C, SJCE, Mysore 58
Design and control of 5 DOF robotic arm Chapter B
1.0, round(-0.5) is -1.0. Version 3.0 and higher use round-to-even: round(1.5) is
2.0, round(2.5) is 2.0. The Decimal type/class in module decimal (since version 2.4)
provides exact numerical representation and several rounding modes.
Python allows boolean expressions with multiple equality relations in a manner
that is consistent with general usage in mathematics. For example, the expression
a < b < c tests whether a is less than b and b is less than c. C-derived languages
interpret this expression differently: in C, the expression would first evaluate a < b,
resulting in 0 or 1, and that result would then be compared with c
Dept Of E&C, SJCE, Mysore 59
Appendix C
Source code for the softwareimplementation
In this section we present the source code for the project.
C.1 Front-End Software
The front end software was written using python
#! /usr/bin/env python
import pygame
from pygame. locals import ∗import ser ia l
import os
import sys
import time
import math
import commands
port num= sys . argv [1 ]
port=”/dev/ttyUSB”+str ( port num )
#ser=ser ia l . Ser ia l ( port ,9600) ;
#Mouse contro l
M B=True
M X=False
M H=False
M R=False
Le f tc l i ck=060
Design and control of 5 DOF robotic arm Chapter C
Rightclick=0
delta=0
#ARM DIMENSIONS
a=4.55
b=4.18
MOUSECONTROL=False
KEY CONTROL=True
f i rs t run=1 #VARIABLE USED TO INITIALIZE DURING THE FIRST TIME RUN
mouse first run=1#VARIABLE USED TO INITIALIZE A FIRST MOUSE CONTROL
LOOP
ik=0#VARIABLE USED TO INDICATE INVERSE KINEMATICS
ik mode=0
reset var=1#VARIABLE USED TO INDICATE RESET
oldtime=time . time ( ) #VARIABLE USED TO STORE TIME
count=0#VARIABLE USED TO STORE COUNT
running = True#VARIABLE USED TO INDICATE LOOP
mouse used=0#VARIABLE USED TO INDICATE IF MOUSE IS USED
j f l a g =k f lag= i f l a g =m flag=0#VARIABLE USED TO INDICATE LIMITS FOR
INVERSE KINEMATICS MODE
i =1
#######VARIABLES USED TO INDICATE ANGLES #######
GRIP=0
base=90
shl=124
elb=160
wri=90
rot=125
grip=0
bf=sf=ef=wf=r f=0
def o f f se t ca l c ( ca , ra ) : #CALUCLATES OFFSETS AS +1 or −1 or 0
i f ( ca>ra ) :
return −1
Dept Of E&C, SJCE, Mysore 61
Design and control of 5 DOF robotic arm Chapter C
e l i f ( ca<ra ) :
return 1
else :
return 0
def int 1 ( angle ) :#LIIMITS ANGLES BETWEEN 30 AND 160
angle=int ( angle )
i f ( angle>160) :
angle=160
e l i f angle<30:
angle=30
return angle
def x and h ( alpha , beta ) : #CALCULATES HEIGHT AND HORIXONAT POSITION
OF GRIPPER
c=math. sqrt ( ( a∗a ) +(b∗b )−(2∗a∗b∗math. cos (math. radians ( beta ) ) )
)
gamma=math. degrees (math. asin (math. sin (math. radians ( beta ) ) ∗b/
c ) )
delta = alpha−gamma
x=c∗math. cos (math. radians ( delta ) )
h=c∗math. sin (math. radians ( delta ) )
return [ x ,h]
def x change (d , alpha , beta ) :# CALUCULATES SHOULDER AND ELBOW ANGLES
WHEN HORSIZONTAL POSTION IS CHANGED
xh=x and h ( alpha , beta )
x=xh [0 ]
h=xh [1 ]
x=x+d
c=math. sqrt ( ( x∗x ) +(h∗h) )
temp= ( ( a∗a ) +(b∗b )−(c∗c ) ) /(2∗a∗b )
i f temp>−1 and temp<1:
new beta=math. degrees (math. acos ( temp) )
else :
i f ( temp<0) :
new beta=180
e l i f ( temp>0) :
new beta=0
new delta=math. degrees (math. asin ( ( h/c ) ) )
Dept Of E&C, SJCE, Mysore 62
Design and control of 5 DOF robotic arm Chapter C
new gamma=math. degrees (math. asin (math. sin (math. radians (
new beta ) ) ∗b/c ) )
new alpha=new delta+new gamma
return [ new alpha , new beta ]
def h change (d , alpha , beta ) :# CALUCULATES SHOULDER AND ELBOW ANGLES
WHEN HEIGHT IS CHANGED
xh=x and h ( alpha , beta )
x=xh [0 ]
h=xh [1 ]
h=h+d
c=math. sqrt ( ( x∗x ) +(h∗h) )
temp= ( ( a∗a ) +(b∗b )−(c∗c ) ) /(2∗a∗b )
i f temp>−1 and temp<1:
new beta=math. degrees (math. acos ( temp) )
else :
i f ( temp<0) :
new beta=180
e l i f ( temp>0) :
new beta=0
new delta=math. degrees (math. asin ( ( h/c ) ) )
new gamma=math. degrees (math. asin (math. sin (math.
radians ( new beta ) ) ∗b/c ) )
new alpha=new delta+new gamma
return [ new alpha , new beta ]
def three char ( i ) :#CONVERTS INTEGER TO THREE DIGIT CHARACTERS
i f i<100:
return ’0 ’+str ( i )
e l i f i<10:
return ’00 ’+str ( i )
else :
return str ( i )
def ard w ( val ) : #WRITES TO ARDUINO
ser . write ( val )
return
Dept Of E&C, SJCE, Mysore 63
Design and control of 5 DOF robotic arm Chapter C
def arduino in ( ) :#CALCULATES ARDUINO INPUT DEPENDING ON ANGLES
global f lag
f lag=0
return three char ( base )+three char ( shl ) +three char ( elb )+
three char ( wri ) +three char ( rot ) + ’00 ’+str (GRIP )
new in=arduino in ( ) #INITIALIZE
def angle change ( angle , o f f se t ) :#CALCULATES CHANGE IN ANGLE DEPENDING
ON OFFSET
i f ( angle<=160) and ( angle>=30) :
angle=angle+o f f se t
i f ( angle>160) :
angle=160
e l i f angle<30:
angle=30
return angle
RESET=False
def printTEXT ( tx t in ) :#PRINT ANYTHING IN MAIN WINDOWS
background . f i l l ( (250 , 250, 250) )
text=font . render ( txt in , 1 , (10 , 10, 10) )
textpos=text . get rect ( txt in ,1 ,(10 ,10 ,10) )
textpos . centerx=background . get rect ( ) . centerx
textpos . centery=background . get rect ( ) . centery
background . b l i t ( text , textpos )
screen . b l i t ( background , (0 , 0) )
pygame. display . f l i p ( )
def TextBox ( ) :#CREATE TEXT BOXES FOR THE DISPLAY
background . f i l l ( (250 , 250, 250) )
t1= ’ base = ’+str ( base )+ ’ shoulder = ’+
str ( shl )
t2= ’ elbow = ’+str ( elb ) + ’ wrist = ’+str (
wri )
t3= ’ wrist rotate = ’+str ( rot ) + ’ grip status = ’
+str (GRIP )
t4= ’ Arduino Input = ’+arduino in ( )
Dept Of E&C, SJCE, Mysore 64
Design and control of 5 DOF robotic arm Chapter C
i f (MOUSECONTROL) :
t5= ’Type of control : Mouse ’
e l i f (KEY CONTROL) :
t5= ’Type of control : Keyboard ’
text1 = font . render ( t1 , 1 , (10 , 10, 10) )
text2= font . render ( t2 , 1 , (10 , 10, 10) )
text3 = font . render ( t3 , 1 , (10 , 10, 10) )
text4= font . render ( t4 , 1 , (10 , 10, 10) )
text5= font . render ( t5 , 1 , (10 , 10, 10) )
textpos1 = text1 . get rect ( )
textpos2 = text2 . get rect ( )
textpos3 = text3 . get rect ( )
textpos4 = text4 . get rect ( )
textpos5 = text5 . get rect ( )
x center=background . get rect ( ) . centerx
textpos1 . centerx = x center
textpos2 . centerx = x center
textpos3 . centerx = x center
textpos4 . centerx = x center
textpos5 . centerx=x center
textpos1 . centery =50
textpos2 . centery = 150
textpos3 . centery = 250
textpos4 . centery = 350
textpos5 . centery = 450
background . b l i t ( text1 , textpos1 )
background . b l i t ( text2 , textpos2 )
background . b l i t ( text3 , textpos3 )
background . b l i t ( text4 , textpos4 )
background . b l i t ( text5 , textpos5 )
# B l i t everything to the screen
screen . b l i t ( background , (0 , 0) )
pygame. display . f l i p ( )
Dept Of E&C, SJCE, Mysore 65
Design and control of 5 DOF robotic arm Chapter C
# I n i t i a l i s e screen
pygame. in i t ( )
screen = pygame. display . set mode((600 ,500) )
pygame. display . set caption ( ’ Robotic arm control ’ )
# F i l l background
background = pygame. Surface ( screen . get s i ze ( ) )
background = background . convert ( )
background . f i l l ( (250 , 250, 250) )
# Display some text
font = pygame. font . Font (None, 40)
printTEXT ( ” Press keys to control . ” ) ;
while running :
i f (KEY CONTROL) : #KEYBOARD
for event in pygame. event . get ( ) :A #WAIT FOR KEYPRESS
i f event . type == pygame.QUIT:
running =not running ;
e l i f event . type == KEYDOWN:
i f ( event . key == K z ) :
bf= i
e l i f event . key == K x :
bf=− i
e l i f ( event . key == K q ) :
s f= i
e l i f event . key == K a :
sf=− i
e l i f ( event . key == K w) :
e f=− i
e l i f event . key == K s :
ef= i
e l i f ( event . key == K e ) :
wf=− i
e l i f event . key == K d :
wf= i
e l i f ( event . key == K r ) :
r f = i
Dept Of E&C, SJCE, Mysore 66
Design and control of 5 DOF robotic arm Chapter C
e l i f event . key == K f :
r f=− i
e l i f ( event . key == K g ) :
i f (GRIP==0) :
GRIP=1
else :
GRIP=0
e l i f ( event . key == K h ) :
i f (GRIP==0) :
GRIP=2
else :
GRIP=0
e l i f ( event . key == K j ) :
ik=1
e l i f ( event . key == K k ) :
ik=−1
e l i f ( event . key == K i ) :
ik=2
e l i f ( event . key == K m) :
ik=−2
e l i f ( event . key == K LSHIFT ) :
i =5
print i
e l i f ( event . key == K LCTRL ) :
i =2
print i
e l i f event . key==K ESCAPE :
running=0
e l i f event . key == K RALT:
MOUSECONTROL=True
KEY CONTROL=False
TextBox ( )
e l i f event . key==K SPACE:
RESET=not RESET
e l i f event . type == KEYUP:
i f ( event . key==K z ) or ( event . key==
K x ) :
Dept Of E&C, SJCE, Mysore 67
Design and control of 5 DOF robotic arm Chapter C
bf=0
e l i f ( event . key==K q ) or ( event . key==
K a ) :
s f=0
e l i f ( event . key==K s ) or ( event . key==
K w) :
e f=0
e l i f ( event . key==K d ) or ( event . key==
K e ) :
wf=0
e l i f ( event . key==K r ) or ( event . key==
K f ) :
r f=0
e l i f ( event . key == K LSHIFT ) :
i =1
print i
e l i f ( event . key == K LCTRL ) :
i =1
print i
e l i f ( event . key == K j ) :
ik=0
e l i f ( event . key == K k ) :
ik=0
e l i f ( event . key == K i ) :
ik=0
e l i f ( event . key == K m) :
ik=0
i f ( ik==0) :
array =[ shl ,193−elb ]
else :
i f ( ik==−1) and k f lag ==0:
array=x change (−.1 , array [0 ] , array
[ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180−int 1 ( array [ 1 ] ) +13
wri=int 1 ( array [0]+ array [1]−98)
i f wri<=30 or shl>=150 or elb>=150:
k f lag=1
i f j f l a g ==1:
Dept Of E&C, SJCE, Mysore 68
Design and control of 5 DOF robotic arm Chapter C
j f l a g =0
i f ik==1 and j f l a g ==0:
array=x change ( .1 , array [0 ] , array [ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180+13−int 1 ( array [ 1 ] )
wri=int 1 ( array [0]+ array [1]−98)
i f wri<=30 or shl<=30 or elb<=30:
j f l a g =1
i f k f lag ==1:
k f lag=0
i f ( ik==−2) and m flag==0:
array=h change(−.1 , array [0 ] , array
[ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180−int 1 ( array [ 1 ] ) +13
wri=int 1 ( array [0]+ array [1]−98)
i f wri<=30 or shl>=150 or elb>=150:
m flag=1
i f i f l a g ==1:
i f l a g =0
i f ik==2 and i f l a g ==0:
array=h change ( .1 , array [0 ] , array [ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180+13−int 1 ( array [ 1 ] )
wri=int 1 ( array [0]+ array [1]−98)
i f wri<=30 or shl<=30 or elb<=30:
i f l a g =1
i f m flag==1:
m flag=0
pygame. time . wait (50)
base=angle change ( base , bf )
shl=angle change ( shl , s f )
elb=angle change ( elb , e f )
wri=angle change ( wri , wf )
rot=angle change ( rot , r f )
Dept Of E&C, SJCE, Mysore 69
Design and control of 5 DOF robotic arm Chapter C
i f (MOUSECONTROL) :#MOUSE CONTROL
i f ( mouse first run==1) :
mouse first run=0
array =[ shl ,193−elb ]
for event in pygame. event . get ( ) :#WAIT FOR EVENT
i f event . type == pygame.QUIT:
running = not running
e l i f event . type == KEYDOWN and event . key ==
K RALT:
MOUSECONTROL=False
KEY CONTROL=True
TextBox ( )
e l i f event . type == pygame.MOUSEBUTTONDOWN
and event . button == 1:
Le f tc l i ck=1
e l i f event . type == pygame.MOUSEBUTTONDOWN
and event . button == 3:
Rightclick=1
e l i f event . type == pygame.MOUSEBUTTONDOWN
and event . button == 2:
i f (GRIP==2) :
GRIP=0
else :
GRIP=2
e l i f event . type == pygame.MOUSEBUTTONDOWN
and event . button == 4:
delta=1
e l i f event . type == pygame.MOUSEBUTTONDOWN
and event . button == 5:
delta=−1
Dept Of E&C, SJCE, Mysore 70
Design and control of 5 DOF robotic arm Chapter C
i f ( Rightclick==1) :
i f (M B) :
M B=not M B
M R=not M R
e l i f (M X) :
M B=not M B
M X=not M X
e l i f (M H) :
M H=not M H
M X=not M X
e l i f M R:
M H=not M H
M R=not M H
Rightclick=0
i f ( Le f tc l i ck ==1) :
i f (M B) :
M B=False
M X=True
e l i f (M X) :
M H=True
M X=False
e l i f (M H) :
M H=False
M R=True
e l i f M R:
M B=True
M R=False
Dept Of E&C, SJCE, Mysore 71
Design and control of 5 DOF robotic arm Chapter C
Lef tc l i ck=0
i f (M X) :
i f ( delta==1) :
array=x change (−.1 , array [0 ] ,
array [ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180−int 1 ( array [ 1 ] ) +13
wri=int 1 ( array [0]+ array
[1]−98)
i f ( delta==−1) :
array=x change ( .1 , array [0 ] ,
array [ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180−int 1 ( array [ 1 ] ) +13
wri=int 1 ( array [0]+ array
[1]−98)
delta=0
i f (M H) :
i f ( delta==1) :
array=h change(−.1 , array [0 ] ,
array [ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180−int 1 ( array [ 1 ] ) +13
wri=int 1 ( array [0]+ array
[1]−98)
i f ( delta==−1) :
array=h change ( .1 , array [0 ] ,
array [ 1 ] )
shl=int 1 ( array [ 0 ] )
elb=180−int 1 ( array [ 1 ] ) +13
wri=int 1 ( array [0]+ array
[1]−98)
delta=0
Dept Of E&C, SJCE, Mysore 72
Design and control of 5 DOF robotic arm Chapter C
i f (M B) :
base=base+delta∗5base=int 1 ( base )
delta=0
i f (M R) :
rot=rot+delta∗5rot=int 1 ( rot )
delta=0
i f ( f i rs t run ==1) :
old in=new in
f i rs t run=0
i f (RESET) :
i f (GRIP!=0) :
GRIP=0
e l i f ( rot !=125) :
rot=125
e l i f shl !=90 and elb !=30 and reset var ==1:
shl=90
elb=30
reset var=0
e l i f ( wri !=90) :
wri=90
e l i f ( shl !=124) :
shl=124
e l i f ( elb !=160) :
elb=160
e l i f ( base !=90) :
base=90
pygame. time . delay (500)
e l i f reset var ==0:
reset var=1
base=int 1 ( base )
shl=int 1 ( shl )
Dept Of E&C, SJCE, Mysore 73
Design and control of 5 DOF robotic arm Chapter C
elb=int 1 ( elb )
wri=int 1 ( wri )
rot==int 1 ( rot )
new in=arduino in ( )
i f ( new in != old in ) :
ard w ( new in )
old in=new in
print arduino in ( )
TextBox ( )
pygame. time . delay (75)
C.2 Arduino software
This part of the software was designed using the Arduino programming language
#include <Servo .h>
Servo base , shl , shr , elb , wri , rotate , grip ; // create servo object to
contro l a servo
// a maximum of eight servo objects can be created
int grip done=0;
int in i t ia l condi t ions ;
int j ;
int binput=90,sinput=124,einput=160,winput=90,rinput=125,ginput=0;
char string [ 6 ] [ 4 ] ;
void shoulder write ( int angle in )
{
i f ( ( ( angle in>=25)&&(angle in<=30) ) | | ( ( angle in>=38)&&(angle in
<=44) ) | | ( ( angle in>=70)&&(angle in<=102) ) )
{ shr . write ( angle in +6) ;
shl . write ( angle in ) ;
}else i f ( ( ( angle in>=31)&&(angle in<=37) ) | | ( ( angle in>=45)&&(
angle in<=69) ) | | ( ( angle in>=103)&&(angle in<=153) ) )
{ shr . write ( angle in +7) ;
shl . write ( angle in ) ;
}
Dept Of E&C, SJCE, Mysore 74
Design and control of 5 DOF robotic arm Chapter C
}
int gr ip fn ( )
{int grip angle=125;
int j =1;
int piezzo1 , piezzo2 ;
while ( j ==1)
{
piezzo1=analogRead (0 ) ;
piezzo2=analogRead (1 ) ;
Serial . println ( piezzo2 ) ;
delay (100) ;
i f ( ( piezzo2<500) )
{i f ( grip angle>30)
{grip angle=grip angle−3;
grip . write ( grip angle ) ;
// Ser ia l . p r in t ln ( grip angle ) ;
}elsej =0;
}else
j =0;
}return grip angle ;
}
void setup ( )
{Serial . begin (9600) ;
base . attach (10) ;
shl . attach (7 ) ;
shr . attach (8 ) ;
elb . attach (9 ) ;
wri . attach (6 ) ;
Dept Of E&C, SJCE, Mysore 75
Design and control of 5 DOF robotic arm Chapter C
rotate . attach (4 ) ;
grip . attach (3 ) ;
Serial . println ( ”Arduino board is ready to accept instructions . ” ) ;
}
void loop ( )
{int i =0,h=0;
int g ang=125;
wri . write ( winput ) ;
elb . write ( einput ) ;
shoulder write ( sinput ) ;
base . write ( binput ) ;
i f ( ginput==1)
{grip . write (30) ;
}i f ( ginput==2)
{i f ( grip done==0)
{h= grip fn ( ) ;
grip done=1;
}elsegrip . write (h) ;
}else i f ( ginput==0)
{grip . write (120) ;
grip done=0;
}
rotate . write ( rinput ) ;
i f ( Serial . avai lable ( ) >0) //========== SERIAL AVAILABILITY
==========
Dept Of E&C, SJCE, Mysore 76
Design and control of 5 DOF robotic arm Chapter 6
{
delay (25) ;//======= FOR READING +++++ DO NOT DELETE
======+++++++++++++++++++
int n=Serial . avai lable ( ) ;
Serial . println (n) ;
for ( i =0; i<n; i ++) // ========== GET INPUT ==========
{string [ i /3] [ i%3]=Serial . read ( ) ;
}
for ( i =0; i<=n/3; i ++) //========== LAST CHARACTER ==========
{string [ i ] [ 3 ]= ’ \0 ’ ;
}
binput=atoi ( str ing [ 0 ] ) ;
sinput=atoi ( string [ 1 ] ) ;
einput=atoi ( string [ 2 ] ) ;
winput=atoi ( str ing [ 3 ] ) ;
rinput=atoi ( string [ 4 ] ) ;
ginput=atoi ( string [ 5 ] ) ;
//Ser ia l . p r in t ln ( ” Input angles are : ” ) ;
//Ser ia l . p r in t ln ( binput ) ;
//Ser ia l . p r in t ln ( sinput ) ;
//Ser ia l . p r in t ln ( einput ) ;
//Ser ia l . p r in t ln ( winput ) ;
//Ser ia l . p r in t ln ( r input ) ;
//Ser ia l . p r in t ln ( ginput ) ;
}
}
Dept Of E&C, SJCE, Mysore 77