Sunteți pe pagina 1din 83

JSS Mahavidyapeetha Sri Jayachamarajendra College of Engineering, Mysore 570 006 An Autonomous Institution Afliated to Visvesvaraya Technological University

(VTU), Belgaum

Design and Control of a 5 DOF Robotic Arm


Thesis submitted in partial fulllment of the curriculum prescribed for the award of the degree of Bachelor of Engineering in Electronics & Communication Engineering by 4JC07EC041 4JC07EC055 4JC07EC071 4JC07EC075 Kushal Prasad Nikhil S. Ranga Raghavendra R. Ranjith B.R.

Under the Guidance of Dr. C.R. Nataraj Professor Department of E&C, SJCE, Mysore

Department of Electronics & Communication Engineering June, 2011

JSS Mahavidyapeetha Sri Jayachamarajendra College of Engineering, Mysore 570 006 An Autonomous Institution Afliated to Visvesvaraya Technological University (VTU), Belgaum

Certicate
This is to certify that the work entitled Design and control of a 5 DOF Robotic arm is a bonade work carried out by Kushal Prasad, Nikhil Ranga, Ranjith B. R and Raghavendra R. in partial fulllment of the award of the degree of Bachelor of Engineering in Electronics & Communication Engineering of Visvesvaraya Technological University, Belgaum, during the year 2011. It is certied that all corrections / suggestions indicated during Continuous Internal Evaluation have been incorporated in the report. The project report has been approved as it satises the academic requirements in respect of the project work prescribed for the Bachelor of Engineering Degree.

Guide Dr. C.R. Nataraj Professor Department of E&C SJCE, Mysore 570 006

Head of the Department C.R. Venugopal Associate Professor and Head Department of E&C SJCE, Mysore 570 006

Examiners

1. 2.

Date Place

: : Mysore

3.

Acknowledgement
Firstly, we would like to sincerely thank the Department of Electronics and Communication, SJCE for giving us a wonderful opportunity 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 provided invaluable inputs during the course of our project. Last but not the least we express our gratitude to Sri B.G Sangameshwara, 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 List of Figures List of Tables 1 Introduction 1.1 1.2 2 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Project description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii iii 1 2 2 4 9 9 13 15 22 24 24 25 27 28 29 29 30 32 39 39 47 48 48

Literary review 2.1 2.2 2.3 2.4 Mechanics and Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Material selection For Robotic arm fabrication . . . . . . . . . . . . . . . . . . . Servo motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Hardware Components 3.1 3.2 3.3 3.4 Electronic hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Servo motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Gripper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Piezo-electric transducers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Design and fabrication of robotic arm 4.1 4.2 4.3 Torque calculation of joints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Basic design considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Mechanical fabrication of the arm . . . . . . . . . . . . . . . . . . . . . . . . . .

Control system for the robotic arm 5.1 5.2 Power supply unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . System integration and testing . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Conclusions 6.1 Achievements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ii

6.2 6.3

Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Future extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

49 49 50 50 50 51 51 51 52 53 53 53 54 55 55 56 58 58 60 60

Appendices A Arduino Decimela A.1 A.2 A.3 A.4 A.5 A.6 A.7 A.8 A.9 B Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Input and Output

Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Automatic (Software) Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . USB Overcurrent Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Physical Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Python Programming Language B.1 B.2 B.3 B.4 Programming philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python syntax and semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Source code for the software implementation C.1 Front-End Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

List of Figures
1.1 1.2 1.3 2.1 2.2 2.3 2.4 2.5 5 DOF robotic arm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Robotic arm after completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Robotic arm in action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Servos used in toy helicopters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Servos used in RC airplanes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Servo motor manufacturers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control signals for servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 6 6 16 16 17 17 18

iii

2.6 2.7 2.8 2.9 3.1 3.2 3.3 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9

Inside a servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Inside a servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Feedback cuircuit emploed by servo motor . . . . . . . . . . . . . . . . . . . . . . . control signal for the motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arduino decimilia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Image of the gripper on Robokits website . . . . . . . . . . . . . . . . . . . . . . . . Image of the Piezo electric sensor on Onlinetps website . . . . . . . . . . . . . . . . Robotic arm shape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Top down approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

19 19 20 20 24 28 28 30 31 31 33 33 34 34 35 35 36 36 37 37 40 41 42 44 45 45 46 50

Signal ow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Base joint arrangement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Base joint components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Base joint after completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . schematic for the shoulder and elbow joints . . . . . . . . . . . . . . . . . . . . . . The links used in the robotic arm . . . . . . . . . . . . . . . . . . . . . . . . . . . . Shoulder link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4.10 L-clamps used for the shoulder motors . . . . . . . . . . . . . . . . . . . . . . . . . 4.11 Elbow link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.12 Wrist Schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.13 Wrist link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1 5.2 5.3 5.4 5.5 5.6 5.7 A.1 Servo motor circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The complete circuit board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Blower used to cool the regulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . Screen-shot of user interface software at start-up . . . . . . . . . . . . . . . . . . . Screen-shot of user interface software during keyboard control . . . . . . . . . . . Screen-shot of user interface software during mouse control . . . . . . . . . . . . Inverse kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arduino Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

iv

Design and control of 5 DOF robotic arm

Chapter 0

List of Tables
1.1 1.2 1.3 3.1 4.1 4.2 5.1 5.2 5.3 Project break down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Some Features of the Robotic arm . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sensors and Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arduino Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Torque requirement at each joint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arm dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 8 8 25 30 38 39 43 43

Current requirement of servo motors at 6V . . . . . . . . . . . . . . . . . . . . . . . List of keys for the control software . . . . . . . . . . . . . . . . . . . . . . . . . . . List of keys for the control software . . . . . . . . . . . . . . . . . . . . . . . . . . .

abstract

Dept Of E&C, SJCE, Mysore

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 elds of humanity. Robotics has become very useful in medicine, education, military, research and mostly, in the world of manufacturing. It is a term that has since been used to refer to a machine that performs work to assist people or work that humans nd difcult or undesirable. 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, articial intelligence, 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 mathematician 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 rst 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 rst industrial robots were Unimates developed by George Devol and Joe Engelberger in the late 50s and early 60s. The rst patents were by Devol but Engelberger formed Unimation which was the rst 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 articial arm, which lead to the modern robots. However, mechanical engineer Victor Scheinman, developed the truly exible arm know as the Programmable Universal Manipulation 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 human being to come to harm. A robot must obey the orders given it by human beings, except where such orders would conict with the rst law. A robot must protect its own existence as long as such protection does not conict with the rst 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 signicant 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 efciently in the social community.

Classication 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 classied broadly into two types namely: 1. Autonomous Mobile Robots 2. Manipulator Robots

Dept Of E&C, SJCE, Mysore

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. Autonomous 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 between 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 specied 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 because 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 specic 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 autonomous 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 fundamental disadvantage, which is lack of mobility. A xed 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, Department 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 Denition
The project involves 2 primary objectives 1. Design and fabrication of Robotic arm with ve degrees . 2. Development of a user-friendly control method.

Figure 1.1: 5 DOF robotic arm

Figure 1.1 shows a robotic arm with ve gedrees of freedom. The ve 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

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 modied 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 Python programming 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 ve degrees of freedom. The ve 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 1 2 3 4 5 6 work Information Collection on material for fabrication, servo motors and control methods Information collection on python programming language Fabrication of arm Testing of components and the arm Building the control software Testing Number of weeks 2 2 8 3 2 1

break down of the time taken by each part of the project.

Summary
The features of the robotic arm are listed in table sensors and actuators used in the project
Dept Of E&C, SJCE, Mysore

1.2. Table

1.3 lists the


7

Design and control of 5 DOF robotic arm

Chapter 1

Table 1.2: Some Features of the Robotic arm Feature Robot arm material User Interface Software Circuit Implementation Robot Control Circuitry

The printed circuit board (PCB) t The Arduino Board provides enough pins for selecting seven

Table 1.3: Sensors and Actuators Component Piezoelectric Transducers Features The ability to quantize change in pressure in terms of voltages makes it very convenient. The ability to measure the rate of change of pressure rather than the absolute value is specically helpful for the selected application. Precise angular rotation achieved with easy to generate PWM signals. Integrated gears(nylon or metal) designed for varied torque applications as demonstrated.

Servo Motors

Dept Of E&C, SJCE, Mysore

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 manipulator 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 attached to the oor, 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 considered 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 difcult. 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 shoulder, 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 rotation, 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 difcult 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 signicantly. 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 fteen 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 difcult 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 layouts based on how the arm segments are supported, gantry and cantilevered. Mounted on the front of a robot, the rst 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 rst 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 rst 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 design. SCARA means Selective Compliant Assembly Robot Arm. This design has good stiffness in the vertical direction, but some compliance in the horizontal. 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 difcult 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 difcult. Most wrists consist of three separate joints. The order of the degrees of freedom in a wrist
Dept 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 something in the environment. For this reason it is commonly called an endeffector, 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 dangerous or suspicious items for the robot to carry, some can turn doorknobs, and others are designed to carry only very specic 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 difcult. 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 motor 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 assembly
Dept 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 inuenced 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 deections. Therefore, an increase in the Elastic modulus, E would be very desirable if it is not accompanied by an unacceptable increase in specic density, . The Elastic modulus is an indication 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 coefcient, difculty in joining with metal parts, high cost and the fact that they are not yet commercially available make the use of bre-reinforced materials limited though they have good stiffness-to-weight ratios. However, with advances in research, some of the mentioned setbacks have been signicantly reduced. Hence, the use of ber-reinforced materials (known as composites) is becoming more attractive. 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 modied 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 materials, 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 Mechanical Engineering department, who are experts in the eld, we settled for Aluminum 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 have
Dept 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 xed 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 Figure 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, Airtronics 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 ange 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 ange. Also a Hitec connector can be used with a Futaba servo just by ling off the extra width so that it ts 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, damage 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 milliseconds. 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 feedback 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 amplier. Figure 2.8 shows the feedback circuit employed by a servo motor. The difference signal is amplied 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 difference 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 microcontroller 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 specic servo, its voltage rating is given as one of its specication 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 efciency. 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 specications of servo motors are torque, speed, weight, dimensions, 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 provide 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 interference signals from the surrounding electronics or other servos can cause positional errors. To eliminate this problem the control signals are supplied after amplication. This will suppress the noise and interference signals.

Arduino micro-controller board


Arduino is an open-source electronics prototyping platform based on exible, easy-to-use hardware and software. Its intended for artists, designers, hobbyists, 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 development environment (based on Processing). Arduino projects can be standalone 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 preassembled; the software can bedownloadedfor free. The hardware reference designs (CAD les) are availableunder an open-source license.

2.4

Software

A robot, by denition, 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 programming language that would be most suitable. We chose the Python programming 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 exibility, 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 rst 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 to
Dept 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 situation 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 Windows, OS/2, Macintosh, and various UNIX, IBM AS/400, and IBM Mainframes. Python Is Portable Python programs can be run on any platform without being recompiled, making them very portable. Moreover, there are no platform-specic 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 memory, and actually form the intelligence of the robot. Its written in Arduino Programming Language(APL) specically designed for all range of Arduino boards. The trade-off in using a high-level language instead of the native instruction set to program a micro-controller would be a slightly less efcient utilization 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 microcontroller 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 ofcial 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. TheATmega168on 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 Operating Voltage Input Voltage (recommended) Input Voltage (limits) Digital I/O Pins Analog Input Pins DC Current per I/O Pin DC Current for 3.3V Pin Flash Memory SRAM EEPROM Clock Speed ATmega168 5V 7-12 V 6-20 V 14 (of which 6 provide PWM output) 6 40 mA 50 mA 16 KB (of which 2 KB used by bootloader) 1 KB 512 bytes 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 Modiable:Yes Bearing Type:Double Ball Bearing Gear Type:All Nylon Gears Connector Wire Length:12 Dimensions:2.59 x 1.18x 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 Modiable: Yes Potentiometer Drive: Indirect Drive Dept Of E&C, SJCE, Mysore 26

Design and control of 5 DOF robotic arm Bearing Type: Double Ball Bearing Gear Type: All Nylon Gears Connector Wire Length: 12 Dimensions: 1.6 x 0.8x 1.4 (41 x 20 x 36mm) Weight: 41gm

Chapter 3

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 Modiable: Yes Potentiometer Drive: Indirect Drive Bearing Type: Double Ball Bearing Gear Type: All Metal Gears Connector Wire Length: 12 Dimensions: 1.6 x 0.8x 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 components.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 robotic arm


In this chapter we rst 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 +L3 M3 +(L3 +L2 /2)W2 +(L3 +L2 )M2 +(L3 +L2 +L1 /2)W1 +(L3 +L2 +L1 )M1 Torque About Elbow Joint: T3 = (L2 /2)W2 + L2 M2 + (L2 + L1 /2)W1 + (L2 + L1 )M1 Torque about wrist joint: T2 = (L1 /2)W1 + L1 M1 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 Base Shoulder Elbow Wrist Calculated torque (Kg-cm) 18.4 20.6 7.9 3.7 Servo chosen 1 x mega toque 2 x high torque 1 x high torque 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 ow

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 design eld, 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 eld 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 tted 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 modied to accommodate piezoelectric sensors. The sensors detect 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 Base height Base Radius Shoulder to elbow link Elbow to wrist link Wrist Dimensions(in) 3 3 4.55 4.18 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 Quarter scale High torque Shoulder to elbow link Current required(mA) 900-1000 750-800 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) technology. 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 circuit 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 uid known as etching uid, 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. Appropriate 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 specication. 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 microcontroller 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 ve 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 z or x aor q wor s eor d ror f LEFT CTRL LEFT SHIFT Action Roate base servo Rotate shoulder servo Rotate Elbow servo Rotate wrist servo Rotate gripper This key in combination with the keys above produces twice the normal speed This key in combination with the keys above produces ve times the normal speed Close or open gripper (Normal Mode) Close or open gripper (Pressure sensing Mode) Move the gripper vertically using inverse kinematics Move the gripper horizontally using inverse kinematics reset robotic arm to default position or cancel reset mode Switch to mouse control

g h i or m j or k SPACE RIGHT ALT

Table 5.3: List of keys for the control software Mouse action or key LEFT CLICK or RIGHT CLICK Action switch between base rotation, horizontal movement. vertical movement and grip rotate modes change the angle of base or gripper or change the horizontal or vertical position of gripper depending on the mode chosen Close or open gripper (Pressure sensing Mode) reset robotic arm to default position or cancel reset mode Switch to keyboard control

MOUSE-WHEEL SCROLL

Middle click SPACE RIGHT ALT

base rotation horizontal gripper movement vertical gripper movement Dept Of E&C, SJCE, Mysore 43

Design and control of 5 DOF robotic arm gripper rotation gripper open and close in the pressure sensing mode

Chapter 5

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 commands 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 angles. 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 implementation, and software development for both the GUI and microcontroller. Most of the circuits were rst 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 signicantly 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 rectied by keeping one servo as the reference and aligning the other one. A table was made and the Arduino code was accordingly modied.

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 eld 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 ash 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 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 boards 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 efciency. 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 ve 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 its 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.

power supply. The power source is selected by the PWRS ELjumper : topowertheboardf romtheU SBc

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-toTTL Serial chip. External Interrupts: 2 and 3. These pins can be congured 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 communication, 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, its 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 ash 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 Diecimilas 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 Arduino Diecimila is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware ow 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 wellcoordinated 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 halfsecond 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 intercept the rst few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time conguration or other data when it rst 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 computers USB ports from shorts and overcurrent. Although most computers provide their own internal 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 respectively, with the USB connector and power jack extending beyond the former dimension. 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 designed to introduce programming to artists and other newcomers unfamiliar with software development. It includes a code editor with features such as syntax highlighting, 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 makeles 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 written in C/C++, although users only need dene 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 programmers to adopt a particular style of programming, it permits several styles: objectoriented programming and structured programming are fully supported, and there are a number of language features which support functional programming and aspectoriented 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 cycledetecting 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 languages 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 interpreter 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, Pythons design philosophy exhibits signicant 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 exuberant syntax, such as in Perl, in favor of a sparser, less-cluttered grammar. Pythons 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. Pythons 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. Pythons 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 denes 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 theres 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 signies 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 ow


Pythons 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 element 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 nally 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 denes 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 objects class; the syntax instance.method(argu is, for normal methods and functions, syntactic sugar for Class.method(instance, argument). 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 denes the modulus operator so that the result of a % b is in the open interval [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 dened. To maintain the validity of the equation b * (a / b) + a % b = a, Integer division is dened to round towards minus innity. Therefore 7 / 3 is 2, but (7) / 3 is 3. This is different from many programming languages, where the result of integer division rounds towards zero and the modulus operator is consequently dened in a way which can return negative numbers. Python provides a round function for rounding oats 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 rst 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 software implementation


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 . l o c a l s import import s e r i a l import os import sys import time import math import commands port num= sys . argv [ 1 ] port= /dev/ttyUSB + s t r ( port num ) #ser= s e r i a l . S e r i a l ( port ,9600) ;

#Mouse c o n t r o l M B=True M X=False M H=False M R=False L e f t c l i c k =0

60

Design and control of 5 DOF robotic arm R i g h t c l i c k=0 delta=0 #ARM DIMENSIONS a=4.55 b=4.18 MOUSE CONTROL=False KEY CONTROL=True

Chapter C

f i r s t r u n =1 #VARIABLE USED TO INITIALIZE DURING THE FIRST TIME LOOP ik=0#VARIABLE USED TO INDICATE INVERSE KINEMATICS ik mode=0 r e s e t v a r =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

RUN

mouse first run=1#VARIABLE USED TO INITIALIZE A FIRST MOUSE CONTROL

mouse used=0#VARIABLE USED TO INDICATE IF MOUSE IS USED j f l a g = k f l a g = 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 r o t=125 grip=0 bf= s f = e f =wf= r f =0

def o f f s e t c a 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 e l i f ( ca<ra ) : return 1 else : return 0 def i n t 1 ( angle ) : #LIIMITS ANGLES BETWEEN 30 AND 160 angle= i n t ( angle ) i f ( angle >160) : angle=160 e l i f angle <30: angle=30 return angle

Chapter C

def x and h ( alpha , beta ) : #CALCULATES HEIGHT AND HORIXONAT POSITION OF GRIPPER c=math . sqrt ( ( aa ) + (bb ) (2abmath . cos ( math . radians ( beta ) ) ) ) gamma=math . degrees ( math . asin ( math . sin ( math . radians ( beta ) ) b/ c) ) d e l t a = alphagamma x=cmath . cos ( math . radians ( d e l t a ) ) h=cmath . sin ( math . radians ( d e l t a ) ) 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 ( ( xx ) + (hh ) ) temp = ( ( aa ) + (bb ) (cc ) ) /(2ab ) 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 ( ( xx ) + (hh ) ) temp = ( ( aa ) + (bb ) (cc ) ) /(2ab ) 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 + s t r ( i ) e l i f i <10: return 00 + s t r ( i ) else : return s t r ( i )

def ard w ( v a l ) : #WRITES TO ARDUINO ser . write ( v a l ) 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 l a g f l a g =0 return three char ( base ) +three char ( shl ) +three char ( elb ) + three char ( wri ) +three char ( r o t ) + 00 + s t r ( GRIP ) new in=arduino in ( ) #INITIALIZE

def angle change ( angle , o f f s e t ) : #CALCULATES CHANGE IN ANGLE DEPENDING ON OFFSET i f ( angle <=160) and ( angle >=30) : angle=angle+ o f f s e t i f ( angle >160) : angle=160 e l i f angle <30: angle=30 return angle RESET=False

def printTEXT ( t x t i n ) : #PRINT ANYTHING IN MAIN WINDOWS background . f i l l ( ( 2 5 0 , 250, 250) ) t e x t =font . render ( t x t i n , 1 , (10 , 10, 10) ) textpos= t e x t . g e t r e c t ( t x t i n ,1 ,(10 ,10 ,10) ) textpos . centerx=background . g e t r e c t ( ) . centerx textpos . centery=background . g e t r e c t ( ) . 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 ( ( 2 5 0 , 250, 250) ) t1= base = + s t r ( base ) + s t r ( shl ) t2= elbow = + s t r ( elb ) + wri ) t3= wrist r o t a t e = + s t r ( r o t ) + + s t r ( GRIP ) t4= Arduino Input = +arduino in ( ) 64 g r i p status = wrist = + s t r ( shoulder = +

Dept Of E&C, SJCE, Mysore

Design and control of 5 DOF robotic arm i f (MOUSE CONTROL) : t5= Type o f control : Mouse e l i f (KEY CONTROL) : t5= Type o f control : Keyboard text1 = font . render ( t1 , 1 , (10 , 10, 10) ) text2= text4= text5= font . render ( t2 , 1 , (10 , 10, 10) ) font . render ( t4 , 1 , (10 , 10, 10) ) font . render ( t5 , 1 , (10 , 10, 10) ) text3 = font . render ( t3 , 1 , (10 , 10, 10) )

Chapter C

textpos1 = text1 . g e t r e c t ( ) textpos2 = text2 . g e t r e c t ( ) textpos3 = text3 . g e t r e c t ( ) textpos4 = text4 . g e t r e c t ( ) textpos5 = text5 . g e t r e c t ( ) x center=background . g e t r e c t ( ) . 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 t o 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 . i n i t ( ) screen = pygame . display . set mode ((600 ,500) ) pygame . display . s e t c a p t i o n ( Robotic arm control ) # F i l l background background = pygame . Surface ( screen . g e t s i z e ( ) ) background = background . convert ( ) background . f i l l ( ( 2 5 0 , 250, 250) ) # Display some t e x t font = pygame . font . Font ( None , 40) printTEXT ( Press keys to control . ) ; while running :

i f (KEY CONTROL) :

#KEYBOARD 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 ) : sf=i e l i f event . key == K a : s f= 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 ) : rf=i

for event in pygame . event . get ( ) : A #WAIT FOR KEYPRESS

Dept Of E&C, SJCE, Mysore

66

Design and control of 5 DOF robotic arm 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

Chapter C

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 : MOUSE CONTROL=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 bf=0

Chapter C

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 ,193elb ] else : i f ( ik ==1) and k f l a g ==0: array=x change ( .1 , array [ 0 ] , array [1]) shl= i n t 1 ( array [ 0 ] ) elb=180i n t 1 ( array [ 1 ] ) +13 wri= i n t 1 ( array [ 0 ] + array [1] 98) i f wri<=30 or shl>=150 or elb >=150: k f l a g =1 i f j f l a g ==1: Dept Of E&C, SJCE, Mysore 68

Design and control of 5 DOF robotic arm j f l a g =0 i f ik==1 and j f l a g ==0:

Chapter C

array=x change ( . 1 , array [ 0 ] , array [ 1 ] ) shl= i n t 1 ( array [ 0 ] ) elb=180+13i n t 1 ( array [ 1 ] ) wri= i n t 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 l a g ==1: k f l a g =0 i f ( ik ==2) and m flag ==0: array=h change ( .1 , array [ 0 ] , array [1]) shl= i n t 1 ( array [ 0 ] ) elb=180i n t 1 ( array [ 1 ] ) +13 wri= i n t 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= i n t 1 ( array [ 0 ] ) elb=180+13i n t 1 ( array [ 1 ] ) wri= i n t 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 ( 5 0 ) base=angle change ( base , bf ) shl=angle change ( shl , s f ) elb=angle change ( elb , e f ) wri=angle change ( wri , wf ) r o t =angle change ( rot , r f ) Dept Of E&C, SJCE, Mysore 69

Design and control of 5 DOF robotic arm

Chapter C

i f (MOUSE CONTROL) : #MOUSE CONTROL i f ( mouse first run ==1) : mouse first run=0 array = [ shl ,193elb ] 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 : MOUSE CONTROL=False KEY CONTROL=True TextBox ( ) e l i f event . type == pygame .MOUSEBUTTONDOWN and event . button == 1: L e f t c l i c k =1

e l i f event . type == pygame .MOUSEBUTTONDOWN and event . button == 3: R i g h t c l i c k=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: d e l t a=1 e l i f event . type == pygame .MOUSEBUTTONDOWN and event . button == 5: d e l t a=1 Dept Of E&C, SJCE, Mysore 70

Design and control of 5 DOF robotic arm

Chapter C

i f ( R i g h t c l i c k ==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 R i g h t c l i c k=0 i f ( L e f t c l i c k ==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

L e f t c l i c k =0

i f (M X) : i f ( d e l t a ==1) : array=x change ( .1 , array [ 0 ] , array [ 1 ] ) shl= i n t 1 ( array [ 0 ] ) elb=180i n t 1 ( array [ 1 ] ) +13 wri= i n t 1 ( array [ 0 ] + array [1] 98) i f ( d e l t a ==1) : array=x change ( . 1 , array [ 0 ] , array [ 1 ] ) shl= i n t 1 ( array [ 0 ] ) elb=180i n t 1 ( array [ 1 ] ) +13 wri= i n t 1 ( array [ 0 ] + array [1] 98) d e l t a=0 i f (M H) : i f ( d e l t a ==1) : array=h change ( .1 , array [ 0 ] , array [ 1 ] ) shl= i n t 1 ( array [ 0 ] ) elb=180i n t 1 ( array [ 1 ] ) +13 wri= i n t 1 ( array [ 0 ] + array [1] 98) i f ( d e l t a ==1) : array=h change ( . 1 , array [ 0 ] , array [ 1 ] ) shl= i n t 1 ( array [ 0 ] ) elb=180i n t 1 ( array [ 1 ] ) +13 wri= i n t 1 ( array [ 0 ] + array [1] 98) d e l t a=0

Dept Of E&C, SJCE, Mysore

72

Design and control of 5 DOF robotic arm i f (M B) : base=base+ d e l t a 5 base= i n t 1 ( base ) d e l t a=0 i f (M R) : r o t = r o t + d e l t a 5 rot=int 1 ( rot ) d e l t a=0

Chapter C

i f ( f i r s t r u n ==1) : o l d i n =new in f i r s t r u n =0 i f (RESET) : i f ( GRIP ! = 0 ) : GRIP=0 e l i f ( r o t !=125) : r o t=125 e l i f shl !=90 and elb !=30 and r e s e t v a r ==1: shl=90 elb=30 r e s e t v a r =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 r e s e t v a r ==0: r e s e t v a r =1 base= i n t 1 ( base ) shl= i n t 1 ( shl ) Dept Of E&C, SJCE, Mysore 73

Design and control of 5 DOF robotic arm elb= i n t 1 ( elb ) wri= i n t 1 ( wri ) r o t == i n t 1 ( r o t ) new in=arduino in ( ) i f ( new in ! = o l d i n ) : ard w ( new in ) o l d i n =new in print arduino in ( ) TextBox ( ) pygame . time . delay ( 7 5 )

Chapter C

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 , g r i p ; c o n t r o l a servo // a maximum o f e i g h t servo o b j e c t s can be created int grip done =0; int i n i t i a l c o n d i t i o n s ; int j ; int binput=90, sinput=124,einput=160,winput=90, rinput =125,ginput =0; char s t r i n g [ 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) ) ) { } else i f ( ( ( angle in >=31)&&(angle in <=37) ) | | ( ( angle in >=45)&&( angle in <=69) ) | | ( ( angle in >=103)&&(angle in <=153) ) ) { } Dept Of E&C, SJCE, Mysore 74 shr . write ( angle in +7) ; shl . write ( angle in ) ; shr . write ( angle in +6) ; shl . write ( angle in ) ; // create servo o b j e c t t o

Design and control of 5 DOF robotic arm } int g r i p f n ( ) { int g r i p a n g l e =125; int j =1; int piezzo1 , piezzo2 ; while ( j ==1) { piezzo1=analogRead ( 0 ) ; piezzo2=analogRead ( 1 ) ; S e r i a l . p r i n t l n ( piezzo2 ) ; delay (100) ; i f ( ( piezzo2 <500) ) { i f ( grip angle >30) { g r i p a n g l e =grip angle 3; g r i p . write ( g r i p a n g l e ) ; // } else j =0; } else j =0; } return g r i p a n g l e ; } void setup ( ) { S e r i a l . begin (9600) ; base . attach ( 1 0 ) ; shl . attach ( 7 ) ; shr . attach ( 8 ) ; elb . attach ( 9 ) ; wri . attach ( 6 ) ; Dept Of E&C, SJCE, Mysore Serial . println ( grip angle ) ;

Chapter C

75

Design and control of 5 DOF robotic arm r o t a t e . attach ( 4 ) ; grip . attach ( 3 ) ;

Chapter C

S e r i a l . p r i n t l n ( Arduino board i s 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) { g r i p . write ( 3 0 ) ; } i f ( ginput ==2) { i f ( grip done ==0) { h= g r i p f n ( ) ; grip done =1; } else g r i p . write ( h ) ; } else i f ( ginput ==0) { g r i p . write (120) ; grip done =0; } r o t a t e . write ( rinput ) ; i f ( S e r i a l . a v a i l a b l e ( ) >0) //========== ========== Dept Of E&C, SJCE, Mysore 76 SERIAL AVAILABILITY

Design and control of 5 DOF robotic arm { delay ( 2 5 ) ; //======= FOR READING +++++ DO NOT DELETE ======+++++++++++++++++++ int n= S e r i a l . a v a i l a b l e ( ) ; Serial . println (n) ; for ( i =0; i <n ; i ++) // ========== { s t r i n g [ i / 3 ] [ i %3]= S e r i a l . read ( ) ; } for ( i =0; i <=n/3; i ++) //========== { s t r i n g [ i ] [ 3 ] = \0 ; } binput= a t o i ( s t r i n g [ 0 ] ) ; sinput= a t o i ( s t r i n g [ 1 ] ) ; einput= a t o i ( s t r i n g [ 2 ] ) ; winput= a t o i ( s t r i n g [ 3 ] ) ; rinput= a t o i ( s t r i n g [ 4 ] ) ; ginput= a t o i ( s t r i n g [ 5 ] ) ; // S e r i a l . p r i n t l n ( Input angles are : ) ; // S e r i a l . p r i n t l n ( binput ) ; // S e r i a l . p r i n t l n ( sinput ) ; // S e r i a l . p r i n t l n ( einput ) ; // S e r i a l . p r i n t l n ( winput ) ; // S e r i a l . p r i n t l n ( r i n p u t ) ; // S e r i a l . p r i n t l n ( ginput ) ; } } LAST CHARACTER GET INPUT ==========

Chapter 6

==========

Dept Of E&C, SJCE, Mysore

77

S-ar putea să vă placă și