robotcontroller and manipulator · reprogrammable. thus, manual handling devices (i.e., a device...

87
Robot Controller and Manipulator by Zulkifli Bin Md Zin Dissertation submitted in partial fulfilment of the requirements for the Bachelor of Engineering (Hons) (Electrical and Electronics Engineering) JUNE 2004 Universiti Teknologi PETRONAS Bandar Seri Iskandar 31750 Tronoh Perak Darul Ridzuan

Upload: others

Post on 24-Oct-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

  • Robot Controller and Manipulator

    by

    Zulkifli Bin Md Zin

    Dissertation submitted in partial fulfilment of

    the requirements for the

    Bachelor of Engineering (Hons)

    (Electrical and Electronics Engineering)

    JUNE 2004

    Universiti Teknologi PETRONASBandar Seri Iskandar

    31750 Tronoh

    Perak Darul Ridzuan

  • roved by,

    CERTIFICATION OF APPROVAL

    Robot Controller and Manipulator

    by

    ZuIkiflibinMdZin

    A project dissertation submitted to the

    Electrical and Electronics Engineering Program

    Universiti Teknologi PETRONAS

    in partial nilfilmentof the requirement for the

    BACHELOR OF ENGINEERING (Hons)

    (ELECTRICAL AND ELECTRONICS ENGINEERING)

    d. Noh bin Karsiti)

    UNIVERSITI TEKNOLOGI PETRONAS

    TOONOH,PERAK

    June 2004

  • CERTIFICATION OF ORIGINALITY

    This is to certify that I am responsible for the work submitted in this project, that the

    original work is my own except as specified in the references and acknowledgements,

    and that the original work contained herein have not been undertaken or done by

    unspecified sources or persons.

    DZIN

  • ABSTRACT

    This project, entitled Robot Controller and Manipulator comprises of development of

    a manipulator and controller. The project scopes are to develop an articulated

    manipulator with three degrees of freedom (3-DOF), a PC-based robot controller,

    capability of robot to determine path plan and some graphical user interfaces. The

    invention of robot manipulator aggressively carried out during the industrial

    revolution, starting from twentieth century. The robot manipulator is extensively used

    in industry since it is believed that its implementation has several advantages over

    conventional ways, such as several jobs executed by human are very dangerous,

    designed components are sometimes having defects and long period of time taken to

    execute repetitive jobs.

    Generally, the scope of this project is to develop 3-DOF robot manipulator by

    considering dynamic properties. 3-DOF is purposely for positioning function. If the

    manipulator is needed to be equipped with manipulating function, it is required higher

    than 3-DOF system, usually 6-DOF.

    The project is divided into two parts; manipulator design and controller design. The

    manipulator design involves construction of manipulator from suitable material,

    implementation of forward and reverse kinematics, workspace determination,

    movement analysis and finally integration of the designed components.

    The controller design consists of development of dc motor drive system, controller

    chip by using PIC microcontroller, motor feedback system and graphical user

    interface at host PC. The user will control the manipulator through this user interface

    and this host PC will communicate with PIC microcontroller through serial

    communication.

  • ACKNOWLEDGEMENT

    First of all, I would like to express my highest gratitude to Allah S.W.T for His bless

    and help that finally, I able to complete my project.

    In preparing this project and report, I would like to acknowledge the important

    contribution from the following persons:

    My father and mother, for their supportive help,

    My supportive supervisor, Assoc. Prof. Dr. Mohd. Noh bin Karsiti,

    Supportive lecturer, Mr Haris bin Md. Khir,

    Lab technicians, Mr. Isnani bin Alias, Miss Siti Hawa and Mr. Azhar, and

    All of my supportive collegues for their help and support.

    Also this acknowledgement goes to the companies that involve in my project, where I

    get all of my project materials and support:

    Eng Huat Hardware Trading,

    Perniagaan Aluminium Parit,

    Keang Sen Kun Kee Foundry,

    IP Bearing & Belts Sdn Bhd,

    Syarikat Ipoh Hardware Sdn Bhd,

    State Electronic Trading Co, and

    Caltrus (Electronic) Sdn Bhd

  • TABLE OF CONTENTS

    ABSTRACT i

    ACKNOWLEDGEMENT ii

    TABLE OF CONTENTS iii

    LIST OF FIGURES v

    LIST OF TABLES vii

    ABBREVIATIONS AND NOMENCLATURES viii

    CHAPTER 1 INTRODUCTION 1

    1. BACKGROUND OF STUDY 1

    3. OBJECTIVE 2

    4. SCOPE OF STUDY 3

    5. PROJECT RELEVANCY 3

    6. PROJECT IMPLEMENTATION PLAN 3

    CHAPTER 2 LITERATURE REVIEW 5

    1. THEORY 5

    2. CONCEPT DESIGN 7

    CHAPTER 3 MANIPULATOR DESIGN 11

    1. SELECTION OF ROBOT COORDINATE FRAME 11

    2. STUDY ON EXISTING DESIGN 11

    3. CONCEPTUAL DESIGN AND DIMENSIONING 12

    4. WORKSPACE DETERMINATION 14

    5. FORWARD AND INVERSE KINEMATICS 15

    6. SELECTION OF GEAR RATIO 17

    7. MATERIAL SELECTION 19

    8. FABRICATION AND DEVELOPMENT OF MANIPULATOR 20

    9. CHANGE OF MANIPULATOR DESIGN 21

    CHAPTER 4 CONTROLLER DESIGN 24

    1. PATH PLANNING 24

    2. RS DC MOTOR 26

    m

  • 3. H-BRIDGE CIRCUIT 28

    4. OPTICAL ENCODER 31

    5. SELECTION OF MCU 33

    6. PICmicro 16F877 33

    7. DC MOTOR APPLICATION 36

    8. THE PROGRAMMING OF THE CONTROLLER 38

    8.1 Control Selection 39

    8.2 Limit Right and Limit Left Function 39

    8.3 Reset Function 41

    8.4 Positioning Function 42

    8.5 Emergency Function 43

    9. DC MOTOR APPLICATION SOURCE CODE 44

    10. USER INTERFACE 45

    CHAPTER 5 DISCUSSION 46

    CHAPTER 6 CONCLUSION AND RECOMMENDATION 49

    1. CONCLUSION 49

    2. RECOMMENDATION 50

    REFERENCES 51

    IV

  • LIST OF FIGURES

    Figure 2.1 Robot Controller and Manipulator Block Diagram. 8

    Figure 2.2 The Operation ofRobot Controller and Manipulator 10

    Figure 3.1 The Components of Robot Manipulator In Terms of Joints 12

    Figure 3.2 The Components of Robot Manipulator In Terms of Links 13

    Figure 3.3 The Process of Determining Workspace 14

    Figure 3.4 Robot Mechanisms, (a) Closed-Loop (b) Open-Loop 16

    Figure 3.5 Fitting The Motor into Gearbox 18

    Figure 3.6 The Constructed Manipulator 20

    Figure 3.7 The Midway-to-Complete Manipulator; (a) Front View

    (b) Side View (c) Top View 22

    Figure 4.1 Path Planning for Motor Speed. 25

    Figure 4.2 Acceleration Behaviors for DC Motor. 26

    Figure 4.3 12V 60 rpm RS DC Motor for Joint 1 27

    Figure 4.4 Drawing and Dimension of 12V 60 rpm RS DC Motor for Joint 1 27

    Figure 4.5 12V 2000 rpm RS DC Motor for Joint 2 and 3 27

    Figure 4.6 Detail Drawing of 12V 2000 rpm RS DC Motor 28

    Figure 4.7 Torque - Current and Torque - Speed Characteristic of 12V 2000

    rpm RS DC Motor 28

    Figure 4.8 Application of H-Bridge for Motor Direction 29

    Figure 4.9 H-Bridge Circuit 29

    Figure 4.10 Modified H-Bridge Circuit by Adding TIP 132 At the MCU

    Output Signal. 30

    Figure 4.11 The Final Design of H-Bridge 31

    Figure 4.12 Encoder Circuit 32

    Figure 4.13 PIC 16F877 Pin Layout 35

    Figure 4.14 DC Motor Application Schematic Diagram 37

    Figure 4.15 The Control Selection Function Flowchart 40

  • Figure 4.16 The Limit Switch Function Flowchart 41

    Figure 4.17 Reset Function Flowchart 42

    Figure 4.18 Positioning Function Flowchart 43

    Figure 4.19 Emergency Function 44

    Figure 4.20 HyperTerminal Interface, Displaying the Current Position for The

    Manipulator: Link 1 is 30.99° While Link 2 is 22.99° 45

    VI

  • LIST OF TABLES

    Table 1.1 Project Implementation Plan of Semester 1 and 2. 4

    Table 3.1 Comparison and Characteristics ofMaterials between Carbon

    Steel, Stainless Steel and Aluminum. 19

    Table 4.1 Servo Calculation Bandwidth Comparison 34

    Table 4.2 Program Memory Resources for Servomotor Application 34

    Table 4.3 Data Memory Resources for Servomotor Application 34

    Table 4.4 Key Features of PIC 16F877 36

    vn

  • ABBREVIATIONS AND NOMENCLATURES

    A/D - Analog/Digital

    DOF - Degrees of Freedom.

    EEPROM - Electrically Erasable Programmable Read Only Memory

    LED - Light Emitted Diode

    ISR - Interrupt Service Routine

    MCU - Microcontroller Unit

    MOSFET - Metal Oxide Semiconductor Field-Effect Transistor.

    PID - Proportional, Integral, Derivative

    PWM - Pulse Width Modulation.

    SCARA - Selective Compliance Assembly of Robot Arm

    SPI - Serial Peripheral Interface

    UASART - Universal Asynchronous Receiver Transmitter

    vm

  • CHAPTER 1

    INTRODUCTION

    1. BACKGROUND OF STUDY

    Since the industrial revolution, there are increasing demands to improve quality and

    reduce manufacturing cost. Traditionally, the products are manufactured by

    craftsmen and the quality of the product totally dependant on the skill of the

    craftsmanship.

    At the beginning of twentieth century (1905), Ford Motor Company introduced the

    concept of mass production [1]. This mass production has been proven to reduce

    production cost and a big amount of products can be manufactured. This mass

    production technique uses production machines and called as hard automation. From

    that, the process automation widespread until the introduction of robot manipulators

    that able to perform specific tasks, such as material handling, spot welding, spray

    painting and assembling.

    In this project, a robot controller and manipulator need to be designed. The main

    characteristics of this robot controller and manipulator are movement in three degree

    of freedom (3-DOF) and manipulator design with kinematics properties. The degree

    of freedom is the number of independent inputs required to precisely position all links

    of the mechanism with respect to the ground. The number of DOF of a mechanism is

    also called the mobility. In this project, by specifying three-coordinates system (x, y

    and z) is adequate to represent any points in space.

  • The aim of this project is to develop an articulated robot manipulator and controller

    that exactly locate at any position in space with 3-DOF. To the extent of application

    of this design, the robot manipulator can be improved by introducing machine loading

    application, pick and place operation, welding, painting, inspection, medical

    application and remote location.

    2. PROBLEM STATEMENT

    At the beginning of the project, several problems have been identified that yield the

    relevancy of implementing this project as listed below:

    • Humans are sometimes exposed to the hazardous environment at workplace.

    • Forming and joining of designed components usually problematic especially

    in automotive industry

    • Longer period of time taken for human to execute repetitive works.

    • Technical fault may occur as the result of careless and inadequate skills of

    worker.

    • It is dangerous and not worth for human to carry out hazardous work

    especially in military, underwater and remote locations.

    3. OBJECTIVE

    The objectives of this project are as follow:

    • To carry out research, design, implement and fabricate an articulated 3-DOF

    robot controller and manipulator with the ability to locate the manipulator

    exactly at any position in space.

    • To design a robot controller and manipulator with specific kinematics

    properties.

  • 4. SCOPE OF STUDY

    The scope of study could be understood as per described below:

    • Manipulator design with the selection of appropriate material especially that

    having light property. The manipulator is composed of three joints and those

    joints are designed in such a way that having minimum friction and reliable to

    move in its workspace. The gearing and belting system also specified under

    manipulator design.

    • Controller design hearted by four PIC microcontrollers that have main

    functions to drive the motor appropriately and communicate with PC.

    5. PROJECT RELEVANCY

    The demand for robotic manipulator, especially in fully automated manufacturing

    company keeps increasing for at least two reasons; firstly, to acquire fast processing

    time and secondly, to avoid manufacturing defects commonly done by human. In

    factory, most of the processes are done by automated machines and human will only

    monitor that process or work at the end of production line.

    As the technology keeps changing, the robot manipulator has been experiencing

    advancement of its design and construction to cater the industry's needs. Thus, the

    study and designof robotcontroller and manipulator could be seen as relevantproject,

    as to understand and follow the technology in robot manipulator.

    6. PROJECT IMPLEMENTATION PLAN

    The project planning is divided into two frames of time, Semester 1 and Semester 2.

    Table 1.1 shows the project implementation plan for both Semester 1 and Semester 2.

  • Table 1.1 Project Implementation Plan of Semester 1 and 2.

    Division Semester 1 Semester 2

    Manipulator Design • Study of existingdesign.

    • Manipulator design(drawing anddimensioning).

    • Workspacedetermination.

    • Forward and reverse

    kinematics.

    • Gear design.• Finding the most

    suitable material for

    robot manipulator.• Fabrication of robot

    manipulator.

    • Touch-up on thefabricated

    manipulator.• Integration of

    controller and

    manipulator.

    Controller Design • Path planning.• Pittman motor testing

    and understanding ofits operation.

    • Development of H-Bridge circuit.

    • Microcontroller

    selection.

    • Microcontroller

    programming.• Development of

    software, as aninterface between PC

    and robot controller.

    • Development of motordrive system.

  • CHAPTER 2

    LITERATURE REVIEW

    1. THEORY

    The word robot means different thing to different people. Robot is defined as a

    mechanical device that is capable of performing human tasks or behaving in a human

    like manner [2], Robot also means a device that controlled by computer and easily

    reprogrammable. Thus, manual handling devices (i.e., a device that have multiple

    degrees of freedom and it is actuated by an operator) or fixed-sequence robots (i.e.,

    any device controlled by hard stops to control actuator motions on a fixed sequence

    and difficult to change) are not considered to be robots [3]. Another definition is a

    robot is a re-programmable multi-functional manipulator designed to move material,

    parts, tools or specialized devices, through variable programmed motions for the

    performance of a variety of tasks [4].

    Based on definitions above, we define robot as a combination of mechanical and

    electronic device that can be multi-functionally reprogrammable to execute a specific

    task from variety of tasks depend on its program.

    The word manipulator means the executor of process of handling or controlling

    something with skill or predefined program that is made up of several links connected

    by joints. The word controller means a device that has data processing ability to

    instruct, manage and direct specific function or task from data inputted.

    When talking about robot manipulator, there are several important elements that

    related to manipulator, which are links and joints, robotic system and robot

  • classifications. The individual bodies that make up a mechanism are called links.

    The connection between two links is called a joint. The number of degrees of

    freedom (DOF) depends on the number of links and joints and the type of joints used.

    DOF is the number of independent parameters or inputs needed to specify the

    configuration of mechanism completely. There are five basic types of joints that

    frequently used in robot manipulator, which are revolute joint, prismatic joint,

    cylindrical joint, helical joint and spherical joint. In this project, revolute joint type is

    selected which it permits two paired elements to rotate with respect to each other

    about an axis.

    Robotic system consists of three major parts, which are mechanical manipulator, end

    effectors and controller. Manipulator and controller have been defined above, and the

    end effectors are devices that connected to the output link of a mechanical

    manipulator to grasp, lift and manipulate works piece. In this project, the design only

    considers the development of manipulator and controller without end effectors since

    the required DOF is three. In most cases, the first 3-DOF is important for positioning

    and normally another 3-DOF is required for manipulating. Thus, to obtain a complete

    manipulator, it requires at least 6-DOF, 3-DOF is quite similar with the representation

    of a point in space with three coordinates system as shown in the equation below.

    P=aJ+byj +c,k (1)

    Normally, the robot is classified by DOF, kinematics structure, drive technology,

    workspace geometry and motion characteristics. The kinematics structure is

    differentiated by open-loop and closed-loop chain, drive technology by electric,

    hydraulic or pneumatic, workspace geometry by cylindrical robot, articulated robot or

    spherical robot and finally motion characteristics by planar or spherical mechanism.

    In this project, an articulated, electrical drive 3-DOF of robot controller and

    manipulator will be developed. Since the articulated type is chosen, the joint is

    selected as revolute type. Under articulated type, all joints must revolute.

  • The designing of robot manipulator deals with kinematics that specify the aspects of

    motion without regard to the forces or torques that cause it. The kinematics deals

    with the positioning of manipulator, velocity and acceleration of the position variables

    with respect to the time. The joint variables are related to the positioning of the

    manipulator and kinematics study is said as focal point of robot manipulator since it

    relates positioning of manipulator with the acceleration, velocity and position

    variables. That is why the kinematics study is the first concern in robot manipulator

    design.

    However, kinematics study has two different approaches; kinematics analysis and

    kinematics synthesis. Kinematics analysis deals with the derivation of relative

    motions among various links of a given manipulator [5]. There are two types of

    kinematics analysis, which are forward kinematics and inverse kinematics. For the

    case of to find the set of position and orientation, the corresponding time derivative

    which will bring the manipulator to the desired position is called inverse kinematics.

    On the other hand, the joint variables and its time derivative is obtained from sensor

    or reading, and this data is used to position and orientate the manipulator is called

    forward kinematics.

    Kinematics synthesis is the inverse process of kinematics analysis. In this case, with

    certain desired kinematics characteristics, the manipulator can be developed. For

    example, with a given time derivative and position of manipulator, corresponding

    joint variables and the type of geometry and manipulator can be determined.

    2. CONCEPT DESIGN

    In general, robot manipulator consists of two parts; mechanical and electronics. The

    mechanical part usually related to physical design and construction of manipulator

    whereas electronics part is related to controller and drive system. Figure 2.1 shows

    the general block diagram for controller and robot manipulator.

  • The function of microcontroller is to receive instruction commanded by user, converts

    the input into digital signal and finally sources the signal to the h-bridge to rotate the

    motor. The rotation of the motor is indicated by high and low signal supplied by

    microcontroller into two h-bridge inputs. The coordination of 10 or 01 at a time will

    result the motor to rotate either clockwise or counter-clockwise while 00 will give no

    signal, thus the motor will static. The microcontroller used is PIC 16F877,

    manufactured by Microchip. The details about selection of microcontroller and the

    concept of dc motor application by using PIC 16F877 is discussed in the Chapter 4

    under Controller Design.

    The motor is specified to rotate in its workspace with the specific degree of rotation.

    The RS motors with add-on encoder are chosen to be used in this design. Once the

    motor is rotating, encoder circuit will detect the rotation of motor's shaft and

    generates a pulse signal. A pulse signal generated is very significant to the degree or

    distance of rotation, and inputted back to the microcontroller. In order to achieve the

    required degree of rotation, microcontroller will do some calculation works and will

    stop the motor as the pulse count achieved.

    —•

    —•

    —p.

    H-bridge Motor &Gearbox

    Manipulator1st joint

    PC H-bridgeMotor &

    Gearbox

    Manipulator2nd jointU-controller

    H-bridgeMotor &

    Gearbox

    Manipulator3rd joint

    Figure 2.1 Robot Controller and Manipulator Block Diagram.

  • The motor is not directly driven from output pin of microcontroller, but using a

    device, called h-bridge. This circuit will act to determine the direction of motor,

    normally set as clockwise or anti-clockwise and to totally stop the motor. Note that,

    this circuit cannot control the speed of the motor and only microcontroller is able to

    control the speed with the variety of input voltage signal supplied to the motor.

    The function of motor is to move or revolute the joint. One motor is assigned for a

    joint. The rotational angle of motor must be accurate to ensure that manipulator is

    exactly located at desired coordinate. Manipulator first joint, second joint and third

    joint have the task to position at any coordinate in 3-dimension workspace,

    particularly in x-axis, y-axis and z-axis.

    In this design, a PIC 16F877 microcontroller is used. The controller controls a motor

    and responsible for positioning the joints in its axis. This microcontroller also

    programmed to communicate with PC. The communication with PC is carried out by

    using RS-232 connection through serial communication.

    In order for controller to communicate with PC, the interface must be developed

    where software in PC and programming for microcontroller must be established. This

    user interface is developed by using Visual Basic or HyperTerminal.

    The relationship between computer software and microcontroller is like this; the user

    will specify the location or coordinate for manipulator in computer program,

    computer program will convert it to instruction that understood by microcontroller

    and finally that microcontroller will control motor's operation. The motor will rotate

    accordingly and stops if the required degree is achieved indicated by adequate

    encoder pulse signal. Figure 2.2 shows how robot manipulator and controller work.

  • INPUT

    The command is invokedthrough PC to PICmicrocontroller by usinga user friendly interface.

    PDIP

    The output fromencoder isreturned back to

    PIC to send

    signal to h-bridge to stopthe motor.

    Finally, after the PIC sendssignal to stop the motor, thePIC also send together thelatest state/position ofmanipulator. The position willbe updated by interface foruser reference.

    OUTPUT

    To output from PIC isconnected to h-bridge todrive the motor.

    Figure 2.2 The Operation ofRobot Controller and Manipulator.

    10

  • CHAPTER 3

    MANIPULATOR DESIGN

    1. SELECTION OF ROBOT COORDINATE FRAME

    As has been discussed earlier, the manipulator has several coordinates, namely

    cartesian, cylindrical, spherical, articulated and Selective Compliance Assembly

    Robot Arm (SCARA). The illustration for these types of robot coordinate is shown in

    Appendix A.

    For the purpose of this project, an articulated coordinate frame is more interesting

    than the others. The reason is an articulated robot's joints are all revolute and similar

    to human arm. This configuration is very famous and perhaps mostly used in

    industry. The advantage of this configuration over other types is an articulated has

    greater accessibility in its workspace with the same robot's dimension.

    2. STUDY ON EXISTING DESIGN

    A study on the existing design has been conducted to find the ideas for manipulator

    design. The area of interest is only on developing mechanical and physical design

    and manipulator's orientation. The observations include the method for eachjoint is

    connected, physical orientation and arrangement and shaft connection with

    manipulator's joint.

    11

  • Study and observation of design has been made in Industrial Automation Lab and

    through robotic books and sites. Among the type of robots that has been studied are

    Mitsubishi Robotic Arm, ED Robot 5-Joint Robotic Arm Trainer, Motoman ES165,

    Adept-One robot and Fanuc S-900W robot. The illustration of these robotic types is

    shown in Appendix B.

    Among the important observations found is the arrangement of motor, which to make

    sure that the accessibility of manipulator at its maximum with the proper arrangement.

    Another observation is the mounting of gear and connection ofjoint with the base and

    joint with the joint.

    3. CONCEPTUAL DESIGN AND DIMENSIONING

    The design ofrobot manipulator consists of four parts: a base,joint 1,joint 2 andjoint

    3. Figure 3.1 and 3.2 shows the component ofrobot manipulator.

    Figure 3.1 The Components of Robot Manipulator In Terms of Joints

    12

  • Figure 3.2 The Components ofRobot Manipulator In Terms of Links

    Controller box and dc motor for joint 1 are placed in the base. Joint 1 is used to rotate

    the manipulator with respect to z-axis, joint 2 is used for y-axis and joint 3 is also for

    y-axis. Even though there is no specific joint for rotating with respect to x-axis, by

    catering the rotation in both y- and z-axis for all joints, any 3-dimension position in its

    workspace can be achieved. With the accurate revolution of joint 1Joint 2 andjoint 3

    ensures that the exact location of manipulator could be established. Appendix C

    shows the revolution of eachjoint with respect to the specific axis, indicated by 9i for

    first joint's revolution angle, 62 for second joint's revolution angle and O3 for third

    joint's revolution angle.

    The base width is 11.00 inches. The wide base compared to joint's width is important

    to make sure the stability of manipulator is optimum. The height for base, link 1 and

    link 2 are 6.9 inches, 9.3 inches and 7.00 inches respectively. The height of this

    manipulator, as the all joints are fully stretched upward achieves 26.275 inches

    13

  • including the space occupied by base gear and base joining. The illustration for

    manipulator dimension and its front, side and top view could be seen in Appendix D.

    The manipulator design uses two units of adaptable gearbox, to suit with two dc

    motors. The function of these gearboxes is purposely for speed reduction which robot

    manipulator normally requires quite slow movement, approximately 20 rpm.

    4. WORKSPACE DETERMINATION

    Workspace is defined as the volume of space the end effectors can reach [6]. Two

    different types of workspace are frequently used which are reachable workspace and

    dexterous workspace. A reachable workspace is the volume in workspace which

    every point that can be reached by end effecters by at least one orientation while

    dexterous workspace is the volume in workspace which every point can be achieved

    with any orientations.

    Figure 3.3 The Processof Determining Workspace

    14

  • The workspace of manipulator is firstly determined by specifying the limit of

    rotational angle for eachjoint. In the earlier design stage, the limit of rotational angle

    is determined and then the volume of workspace that can be achieved by manipulator

    might be developed. Then, the movement of robot's manipulator is analyzed to

    determine its workspace. Appendix E shows the workspace for the manipulator.

    Thus, from the design, the workspace of rotational angle for each axis can be

    developed as follow:

    -150° < 0,

  • In a 1-DOF system, all variables can be known upon specification of any variables.

    For example, when a variable is set to a certain value, the mechanism is totally set and

    other variables are known. Normally, the mechanism consists of closed-loop and

    open-loop. Most of the closed-loop system mechanism is in the form of 1-DOF. The

    example of closed-loop mechanism is given by closed-loop four bar mechanism,

    which if we set the movement of one link to certain degree, let say 120°, the other

    links' angle also can be detected.

    3-DOF robot manipulator is open-loop mechanism. Unlike in the closed-loop

    mechanism, if all of the variables are specified in open-loop system, there is no

    guarantee that the manipulator can exactly position at the given location. This is

    because if there is any deflection in one link, it may affect the location of the

    manipulator. As a result, the construction of 3-DOF robot manipulator must strong

    enough to eliminate all deflections. Figure 3.4 below shows the closed-loop and

    open-loop mechanisms.

    Figure 3.4 Robot Mechanisms, (a) Closed-Loop (b) Open-Loop

    Another difference between closed-loop and open-loop mechanism is closed-loop

    mechanism provide feedback while open-loop mechanism is does not. In a feedback

    system, any deflection of a link or error occurs can be detected. For example, if

    deflection occurs at link AB, the link O2B will detect the changes but in open-loop

    16

  • system, there is no detection since the deflection will move all succeeding members

    without feedback.

    To remedy this problem in open-loop robot, the position of the hand is constantly

    measured with devices such as camera, the robot is made into closed-loop system with

    external means such as the use of secondary arms or laser beams [7].

    In this project, the position analysis is done by analyzing at the given location or

    coordinate, what is the angle required for joint 1,joint 2 andjoint 3 to revolute. This

    approach is done by applying trigonometric function. For example, if an articulated

    3-DOF robot manipulator in this design want to move to location from (0,0,0) to (7,

    4,10) the joint variable required is as below:

    6> - +29.75°

  • There are several types of gear, namely spur, helical, bevel and worm. In this project,

    two sets of spur gear combined in two units adaptable gearbox, manufactured by RS

    are used. Spur gear has teeth parallel to the axis of rotation and used to transmit

    motion from one shaft to another parallel shaft.

    The motor used in this project is RS 12V dc motor. From data sheet, the nominal no

    load speed for this motor is 2000 rpm. The gear ratio calculation is as below.

    IfNi is the speedfor motor and N2 is the required speed, the gear ratio needed to

    reduce the speedfrom 2000 rpm to 20 rpm will be

    Gear ratio =N2

    _ 2000rpm20rpm

    = 100:1

    (4)

    It is fortunate since RS provides a gearbox with the ration 100:1. The torque for this

    adaptable gearbox is 4 Nm. Thus, with the proper gear ratio and torque, this

    adaptable gearbox is used in the design. The adaptable gearbox is assembled together

    with RS dc motor. Figure 3.5 below shows the arrangement of RS dc motor and

    adaptable gearbox.

    D

    Figure 3.5 Fitting The Motor into Gearbox

    A - Adaptor PlateB - Pinion

    C - Motor

    D- 12.5 mm

    E - Gearbox

    The size of gear is expressed as pitch, which is roughly by counting the number of

    teeth on the gear and dividing it by the diameter of the gear. In order to ensure that

    the transfer of energy between gears is efficient, the pitch between these gears must

  • be the same. The same pitch also important since different value of pitch may result

    easy to wear over several period of operation time and non-matching between gears.

    7. MATERIAL SELECTION

    There are several suitable materials to be used in fabricating the manipulator. Among

    the materials that can easily be found in market are carbon steel, stainless steel and

    aluminum. Table 3.1 below shows the comparison and characteristics of these

    materials.

    Table 3.1 Comparison and Characteristics ofMaterials between Carbon Steel,

    Stainless Steel and Aluminum.

    Characteristic Carbon steel Stainless steel Aluminum

    Weight Highest Medium Lightest

    Strong Acceptable Acceptable Acceptable

    Cost Cheapest Medium Highest

    Easiness to fabricate (in

    terms of easiness to drill, cut

    and shape)

    Lowest Medium Highest

    Thus, from the above comparison, aluminum is selected as material for constructing

    robot manipulator. The highest weightage of material characteristic falls to materials'

    weight since we need to find the lightest material as possible in order for motor to

    revolute thejoint efficiently. Note that, forRS motor, the maximum affordable torque

    is 4 Nm, if equipped with adaptable gearbox.

    From the comparison, the price for aluminum is the highest. Even its price is high, it

    is still affordable to use this material for fabricating purpose.

    19

  • 8. FABRICATION AND DEVELOPMENT OF MANIPULATOR

    The fabrication of manipulator's model is carried out in the lab. The fabrication

    process needs machining and drilling skills, and all other skills that related to metalwork. The process of constructing robot manipulator takes quite long time and the

    most important thing during the fabrication process is the machined and cut materialis capable to combine together with a stable joint to develop several strong links.

    Figure 3.6 below shows the picture ofdeveloped manipulator.

    Figure 3.6 The Constructed Manipulator

    20

  • It is targeted that, the manipulator is constructed from used material as to minimize

    the total cost, since the cost for new material, especially aluminum is quite high. The

    suitable used materials can be obtained from thorough finding process from used

    equipments. Among the potential places to get this such materials are second hand

    goods dealer, bicycle, motorcycle and car workshop and used equipments at home e.g

    VCRs, CD player, washing machine and mechanical toys. In case of there is difficult

    to find used material for certain manipulator's part, new material is chosen.

    In manipulator design, we have specified our own dimension and all materials needed

    must be suited with the dimension. The most probable problems for this condition is

    unable to find the suitable specific material for needed parts. That is the disturbance

    and defector while doing robotic project. If the material cannot be found over set time

    range, there is a solution here which is by fabricating ourselves the manipulator's

    parts.

    9. CHANGE OF MANIPULATOR DESIGN

    The current manipulator design has been reviewed for several times. The initial

    design is quite distinct compared to final design. As noted, the big differences

    between initial design and final design particularly on its gear implementation and

    type of motor used.

    During initial design, the design involves a lot of gear to be located at each link, to

    rotate the joint. For example, instead of gear boxes used, there is another gear

    purposely to mount the joint with motor, driven by belt. Several problems have been

    identified and difficult to solve, which are difficult to find the suitable gears with

    specific gear ratio and belt that suits with that gear. Most of the industrial suppliers

    only supply belts or gears for heavy usage for example big machines, tractors and

    other industrial equipments. The detail of initial robot manipulator design is shown in

    Appendix G. The pictures for initial design are shown in Figure 3.7.

    21

  • Figure 3.7 The Midway-to-Complete Manipulator; (a) Front View (b) Side View (c)Top View.

    Thus, due to unsolved problems for nearly one semester, achange of design must becarried out This new design (Appendix D) implements as less as possible the usageof gear. It stresses more on implementation of adaptable gearbox and direct drivefrom the gearbox to manipulator's joint. According to this design, the motor used forinitial design which Pittman motor need to be changed to RS since RS motor offers an

    22

  • attractive adaptable gearbox. Furthermore, the gearboxes offered by RS are having a

    lot of gear ratio varieties. In the new design, several suitable couplers also must be

    fabricated for the purpose of to obtain direct drive from the output of gearbox to

    respectivejoint.

    23

  • CHAPTER 4

    CONTROLLER DESIGN

    1. PATH PLANNING

    In the previous chapter, under forward and inverse kinematics topic, the kinematics

    analysis of robot manipulator and its links has been discussed. Under kinematics

    analysis, by usingequationof motion, we can knowwhere the positionof manipulator

    will be if we have joint variables. Path planning actually refers to the way of robot

    will move from one location to another location. In manipulator study, the movement

    ofrobot will be in two types: the normal movement and relative movement.

    Normal robot movement is specified as the movement of manipulator to certain

    position from origin. For example, the positioning of manipulator from (0, 0, 0) or

    base to (4, 10, 3) is said as normal movement. On the other hand, the relative

    movement is specified as the movement of manipulator from specificcoordinate point

    to another coordinate point, except base coordinate. For example, the movement of

    manipulator from coordinate point (4, 10, 3) to (-3, 9, 5) is said as relative movement

    since the positioning is referred to as another specific point, not at the origin. During

    setting up the equation of motion, the movement of manipulator always refers to the

    difference between these points.

    A path is defined as a sequence or robot configurations in a particular order without

    regard to the timing of these configurations. So, if a robot goes from point (and thus,

    configuration) A to point B to point C, the sequence of configuration between point A

    and B and C constitutes a path [8]. The most important concern in developing a path

    24

  • is the movement of robot from one point to another point regardless of the time

    consumed to achieve the desired point.

    As the concept applies, in order to move a robot manipulator from a point to another

    point, the microcontroller signals motor to rotate the gear together with the arm. By

    realizing the motor behavior and manipulator's path planning, it will accelerate at the

    beginning of operation until motor's speed reaches maximum speed, indicated as

    phase 1 and decelerate at the end of operation, indicated as phase 2. For instance, let

    say if we want to move a link for 10°. The microcontroller gives a signal to motor

    and motor will rotate. The encoder signal pulse becomes another input to the

    microcontroller. If an encoder signal for each high pulse indicates 1° of rotation, it

    requires 10 pulses for microcontroller to stop the motor rotation.

    The motor will exactly locate an arm if the speed of motor always constant, starting

    from beginning until the end. But the reality is not that way. In path planning

    concept, motor acceleration takes several times, then the motor will be constant in its

    speed and finally decelerates for several times, Figure 4.1, yielding a small variance in

    the final destination.

    Motor speed, a>

    Constant speed phase

    Accelerationphase

    Total time, t

    Deceleration

    phase

    10 pulses Time, s

    Figure 4.1 Path Planning for Motor Speed.

    Note that, the variance in final destination is due to variance in speed, smaller during

    both acceleration and deceleration phase, making the total travel would be lesser. It

    will be getting a clear picture from graph of acceleration, as shown in Figure 4.2,

    25

  • which positive during acceleration phase, zero during constant speed and finally

    negative for deceleration phase.

    J v Motor acceleration, a

    Time, s

    Figure 4.2 Acceleration Behavior for DC Motor.

    The above-mentioned problem is a kind of challenge in path planning. This problem

    is difficult to eliminate but can be minimized by using light material for manipulator

    and also using intelligent microcontroller that can compensate between operation

    time, acceleration and distance traveled. Beside that, error calculation function in

    source code is very useful to minimize this effect.

    2. RS DC MOTOR

    There are three motors used in this robotic project, type RS 12V dc motor. The motor

    has ratings of 12V input voltage, 2000 rpm nominal speed at no load and 4 Nm

    maximum torque when attach to adaptable gearbox.

    This motor has a built in encoder at the bottom part. The function of encoder is to

    calculate the rotation generated by the motor, indicated by pulse. A pulse generated

    equals to a rotation has been done.

    26

  • 4139

    Figure 4.3 12V 60 rpm RS DC Motor for Joint 1

    t - 4 MOLES2,7 DIA"ft "

    32-

    34-

    ZB-- T"

    1-5—1 -37-

    [•nin- ,.•d.^-i""™!?^" *

    loS?

    n

    1.5

    -27

    •'•'toatw

    Figure 4.4 Drawing and Dimension of 12V 60 rpm RS DC Motor for Joint 1

    Figure 4.5 12V 2000 rpm RS DC Motor for Joint 2and 3

    27

  • 47.7

    84.8

    20M3 2.5 -+-'K

    5-H

    25.9

    -aw' -0.012

    on

    Figure 4.6 Detail Drawing of 12V 2000 rpm RS DC Motor

    mfv

    120

    80

    40

    1

    .m Vt\bJ,m

    48V 24V 12V/120

    BO

    40

    §y^v_ / // / /_^

    n _i ' / /

    2.-•

    -12V •I

    /T 7 I

    t /[ ^

    ^fs - I i \'234 0 1ooo 2O0O 3000

    rorque/Gurrent Torque/Speed

    Figure4.7 Torque- Current and Torque - Speed Characteristic of 12V2000 rpm RS

    DC Motor

    3. H-BRIDGE CIRCUIT

    Another aspect under controller design is development of h-bridge circuit. The

    function of h-bridge is to control the direction of motor, whether clockwise or anti

    clockwise. This circuit actually does not have the ability to control the motor speed.

    In robotic design, it is desirable to change the direction of motor by changing the

    direction of current flow. In other words, if the h-bridge is connected to

    microcontroller, the changing of motor direction can be performed by changing the bit

    information signaled to h-bridge circuit.

    A simple h-bridge circuit can accomplish this as shown in Figure 4.8. As the output

    from microcontroller change from high to low or vice versa, the direction might be

    28

  • changed. When the transistor SW1 and SW4 are high, the current flows in the

    direction from A to B. If the transistor SW2 and SW3 are high, the current flows in

    the direction from B to A. Thus, the polarity will change and motor direction also

    will be changed.

    -i:Y-

    - L0W: -j. " lagiK. ••--—&

    Figure 4.8 Application ofH-Bridge for Motor Direction.

    The circuit inFigure 4.8 is a simple andfor illustration purpose only on its operation.

    The h-bridge circuit design in this project is shown inFigure 4.9.

    MCU_agnail

    D—, •_

    kR3"IQkohrr

    HCU_Signal

    • 1

    R2

    2.2kchm

    .R1

    L10hohm

    R4'22kofti

    !Q2TIP132

    Q1TIM 32

    D12\lH400d

    D2DC MOTOR

    7\ 1H4004-

    T

    D3 G3 l.T1P132 _>

    D47^1H40Q4 Q4

    TIP132

    Figure 4.9 H-bridge Circuit

    T

    V1

    ,12V

    In h-bridge circuit above, Rl and R3 consist of 10 Ul pull-up resistors. Its function isto eliminate jerk when the microcontroller powers up and down. There are four

    D1N4004 diodes used. Dl and D3 function is to protect the chips from over voltage

    29

  • by turning on when more voltage is coming from the motor than is coming from the

    batteries. Finally, D2 and D4 protect the chips from under voltage by turning on

    when the voltage in the motor is below GND.

    The h-bridge circuit shown in Figure 4.9 is the first design of motor drive control. It

    uses low complementary silicon power darlington transistor, TIP 132 that has current

    gain, hFE typically at 1000. The required current to drive dc motor is 0.5 A at its

    nominal speed. Even the current gain is quite high for TIP 132,the transistor still not

    able to provide sufficient current to drive the dc motor. Note that, the measured

    output current from PIC output pin is 0.02 mA.

    As the above problem is identified, the design is modified by adding TIP 132 at the

    PIC output pin to amplify the MCU signal as shown in Figure 4.10. The result is also

    the same where the motor cannot operate properly.

    MCU_Slg*a11

    p

    MCU_Si^ial2

    TIP132

    Q5

    TIP132

    Q6

    ,H3MOkohir

    R2

    22Vo\\m-R1»10kohm

    02TIP132

    <-R4-22kohm

    Q1TIP132

    D1A 1M4O04

    DZ

    1W004£'"~ £1

    ^>

    T

    , D3

  • MCU_Signd1

    MCU_$ignd2

    M3

    BS170

    m

    BS17Q

    TIP132

    Q5

    TIP132

    Q6

    j.R3MOkohm >Ms >22kdim

    R2

    -wv-

    TIP132

    Q1TIP 132

    D1

    ^\ 1NdflOd

    D2

    AlN4Mil

    ^>

    D3 Q3kl£l)WW Tlf>132 J

    D4 04AlW0WTHtt

    VI,12V

    V2

    _8V

    Figure 4.11 The Final Design of H-Bridge

    For the implementation of this project, a specific h-bridge IC, L6203 manufactured by

    SGS-Thomson is also used. This kind of driver IC uses a technology called

    Multipower BCD which allows the integration on the same chip of isolated power

    DMOS elements, bipolar transistors and C-MOS logic. The maximum supply voltage

    that this IC can withstand is 60V, maximum current of 1.5A and total power

    dissipation of 1.5 W.

    4. OPTICAL ENCODER

    Optical encoder is one of the famous encoders since it is least expensive to buy and

    the easiest to build its parts. The encoder consist hollow disk or marked transparent

    diskand an optical sensor. Commercial encoders have segments in the range of 16 to

    1024. The more segments we have, the finer the measurement is possible.

    There are two ways to detect light and dark pattern on the disk which are transmission

    and reflection. In transmission type, the lightwill go through transparent segment and

    received by phototransistor or photodiode. On the other hand, in reflection type, the

    emitter and receiver will be placed on the same side of disk. The light will be

    reflected by white areas while dark areas will absorb the light.

    31

  • In this project, transmission type is chosen. For transmission type disk, the pattern

    can be printed on clear plastic or heavy white paper with a laser printer. Then, the

    pattern is laminated to ensure its toughness and to avoid scratch in case of

    accidentally contact with the detector or environment.

    By utilizing an encoder, the idea is this device will give the pulse for every angle of

    rotation. A pulse given by an encoder represents certain angle of rotation. Let say

    that the encoder disk has 64 segments (32 white and 32 black). The angle of one

    pulse is suggested by calculation below:

    360°Angle per pulse

    32 segments= 11.25° per pulse (5)

    The pulses generated by this encoder become an input to microcontroller. For every

    process, the microcontroller will remember the last pulse generated by encoder and

    will count the new pulse inputted from encoder. If the required angle is achieved, the

    microcontroller will send a signal to motor to stop the movement. Figure 4.12 below

    shows the circuit for encoder.

    V1

    9V -=±=

    R1

    AA/V2.2k

    IR LED\L

    PHOTO

    TRANSISTOR

    Na

    Q2<

    R2

  • 5. SELECTION OF MCU

    There are various types of MCU in market in the manufacturing line of Microchip

    Technology Inc. First thing to know is there are lot of MCU manufacturers instead of

    Microchip Technology Inc such as Motorola, Intel, Atmel, Siemens and several other

    companies. The selections of MCU from production line of Microchip Technology

    Inc are based on its program or source code that easily understood, the MCUs that

    easily obtained and wide availability of its resources in terms of its program, source

    code and programmer. The type of MCUs is usually differentiated by their function,

    pin arrangement and application; PDIP, SOIP, SSOP, PLCCand TQFP.

    The MCUs also are differentiated by their functions or applications such as EEPROM

    capacity, AID conversion, serial communication, addressable universal asynchronous

    receiver transmitter (UASART) andpulse width modulation (PWM) function.

    For controlling robot manipulator function, it requires serial communication function

    to communicate between PC and MCU. Furthermore, the function also requires

    PWM generated signal to drive the motor through h-bridge. Beside that, since the

    program for controller is in the form of receiving previous input, stores it and

    compare to the newgenerated input, it requires bigEEPROM capacity.

    Thus, based on these applications needed, PIC 18C452 and PIC 16F877 meet the

    above features and the selection is based on the availability of that microcontroller in

    market and selling price.

    6. PICmicro 16F877

    There are two types of Microchip microcontrollers that are very suitable for this

    project, namely PIC 18C452 and PIC 16F877. The suitability is measured to the

    features that owned by microcontrollers.

    As discussed earlier, the controller project for robot manipulator requires at least the

    following functions; EEPROM capacity, A/D conversion, serial communication,

    33

  • addressable universal asynchronous receiver transmitter (UASART) and pulse width

    modulation (PWM) function. The PIC 18C452 and PIC 16F877 are said suitable for

    this project since it has the above-mentioned functions. The comparison between PIC

    18C452 and PIC 16F877 is shown in specific tables below.

    Table 4.1 Servo Calculation Bandwidth Comparison

    DeviceOperatingFrequency

    Hardware

    Multiplier

    Servo

    UpdatePeriod

    Maximum

    Servo Calculation

    Time

    MCU Bandwidth

    Used

    PIC16CXXX 20 MHz Mo 563 fisec 540 fisec 96%

    PIC18CXXX 20MHZ Yes 563 fisec 97 ^isec 17%

    Table 4.2 Program Memory Resources for Servomotor Application

    DeviceAvailable Program

    MemoryProgram Memory Used

    by ApplicationPercentage Used

    PIC16F877 8192 X 14 3002 X 14 37%

    P1C18C452 32768 X 8 8265 X 8 25%

    Table 4.3 Data Memory Resources for Servomotor Application

    DeviceTotal Data Memory

    Available

    Data Memory Used

    by ApplicationData Memory Used

    by Compiler*1'Available Data

    Memory

    PIC16F877 368 bytes 78 bytes 44 bytes 246 bytes

    PIC18C452 1536 bytes 78 bytes 386 bytes 1072 bytes

    Note 1: The amount of data memory will depend on the compiler used- This memory is used Tora software stack,temporary variable storage, etc.

    The difference bandwidth used between PIC 16CXXX and PIC 18CXXX is quite

    significant, showing that PIC 18CXXX has greater bandwidth. From the table above,

    there is 17% of bandwidth used for PIC 18CXXX compared to 96% of bandwidth

    used by PIC 16CXXX. Again, for program memory resources, PIC 18C452 has

    lower percentage usage than PIC 16F877 with 25% and 37% respectively. From the

    last table above, it shows that PIC 18C452 has greater data memory resources. Thus,

    it is concluded that PIC 18C452 is better than PIC 16F877 in terms of its

    performance.

    When come to the decision process, which one microcontroller to be chosen, the

    requirement might be expanded to certain extent, which another factors might be

    included. In this case, there are at least two criteria that are interrelated comprising of

    34

  • availabihty in market and cost. Basedon these points, below are the comparisons of

    these microcontrollers. PIC 16F877 is easier to obtain in market compared to PIC

    18C452. Furthermore, PIC 16F877 is cheaper than PIC 18C452 by the difference of

    price reaches RM 20.00 each. Thus, upto this point, PIC 16F877 is chosen.

    The above paragraph discusses in general the requirements needed for the project.

    This paragraph, in turn will explain further about PIC 16F877 chip. PIC 16F877 is

    CMOS flash-based 8-bit microcontroller. It features 256 bytes of EEPROM data

    memory, selfprogramming, anICD, 8 channels ofAnalog-to-Digital (A/D) converter,

    2 additional timers, 2 capture/compare/PWM functions, the synchronous serial port

    can be configured as either 3-wire Serial Peripheral Interface (SPI) or the 2 wire

    Integrated Circuit bus and a Universal Asynchronous Receiver Transmitter (USART).

    PIC 16F877 comes together with 40 pin package. The pin layout chosen is PDIP.

    The microcontroller layout andpinassignment could be seen as in Figure 4.13 below.

    Onthe otherhand, the key features of PIC 16F877 is shown in Table 4.4 compared to

    other PIC 16 series.

    PDIP

    ^.CLRj'vpp -

    RAtt'AND

    RA1?AN1

    RA2'AN2iV'.REF-

    RA3/AN3/Vre=+

    R.M/T0CK1

    3vAS/AN4/$S

    REQ/RD/AN5

    REI/WR/AN8

    Rt2/C3/AN7Vcc

    VS3

    OSCVCIKIN

    OSCl'CLKOUT

    RCGTIOSO/TIGK

    3cimost/ccP2

    RC2/CCF1

    RC3SCK/3CL

    Raa'-pspo

    RDIjPSP^

    RB7/PGD

    RBS.;?3C

    RS5

    R.S4

    RB3/PGM

    RB2

    RBI

    RBO/IKT

    RD7/PSP7

    RDS/PSP8-

    RD5/F8PS-

    RD4/P3P4

    RC7/RX/QT

    RC6/TX/CK

    RC5/SDO

    RC4/SSi''"SDA

    RD3/PSF3

    RD2/P8P2

    Figure 4.13 PIC 16F877Pin Layout

    35

  • Table 4.4 Key Features ofPIC 16F877

    Key Features

    PiCmicro™ MUMtenge ReferenceManual {DS33023}

    PC16F873 PIC16FB74 PIC16F876 PICK3F877

    Operating Frequency DC - 20 MHZ DC-20 MHz DC - 20 MHz DC - 20 MHz

    RESETS {anrJO slays] FOR. BOR[PWRT. GST)

    POR, BOR(PWRT, OST)

    POR. BOR

    (PWRT, OST;POR. BOR

    tPWRT, OST;

    FLASH Progran? "emc*v("4-bit words)

    4K 4K 8K 8K

    'Date Memory (bytes) 192 192 36-5 36S

    EEPROM Data Memory 125- 128 256 2ES

    .Interrupts 13 '[•4 13 14

    I/O ?ort& Ports A=B,C Ports A.B=C,D,£ Ports A.B,C Ports A,BfC3.H

    Tmers "; 3 3 3

    Ca^ure/ComparefP'ArM Mediates-

    2 on

    Serai Communications VS3F, JSART MSSP, LJSART MSS= USART MSSP. USA3T

    Parallel Communications — PS? —~»o z*

    10-bit Analog-to-Dlgltai JVlodu^e 5 input channels 8 mp& channels 5 input channels S input channels

    ^strjcbcnSet 35 instructions 35 instructions 35 instructions 35

  • driven by self-developed h-bridge with the combination of TIP 132 and BS 170

    transistors.

    LMirtjiBm-

    FWjtt

    na_>u

    — n*_f4

    H*_*l

    rasi

    — cees

    H»_ffl

    •H»_CI

    C3

    I0UF

    hh_b» —

    H»JS

    «»J»

    BUJB

    R«UK —

    3 ItEl

    HliJJr

    biijw

    HHJH

    HILM

    fhj»

    £-fcfc

    C1

    U? M«F

    TrSm

    Figure 4.14 DC Motor Application Schematic Diagram

    The movement or rotation of motors is controlled by several inputs, namely

    MOTIJUGHT, MOTl_LEFT, MOT2_RIGHT, M0T2JLEFT, MOT3_RIGHT and

    MOT3 LEFT. These switches will give high input signal to the input pin of

    microcontroller once they are pushed. For example, as the MOTl_RIGHT switch is

    pushed, the motor will rotate in clockwise direction and vise versa when

    MOTlJLEFT switch is pushed.

    The input from switch will give correspondence output to the h-bridge. INI in h-

    bridge circuit indicates motor to rotate clockwise. IN2 indicates the motor to rotate

    anti-clockwise. As the MOTJRIGHT switch is pushed, it will correspondent^ trigger

    high output signal at the outputpin connected to INI.

    Thefunction of LMIT_RIGHTandUMITLEFT switch is to stopthe manipulator if

    maximum workspace has been achieved. At maximum position for each link,

    37

  • whether rightmost position and leftmost position, the manipulator will hit these limit

    switches and automatically the manipulator stops from moving.

    Practically, when dc motor is rotating, it will generate pulse from encoder circuit.

    This pulse is very useful to determine how much the motor is rotating. The pulse is

    then sent to PINA4 and PIN_C0, so that the signal can be processed in such a way

    that how much degreethe motor is rotatingcan be determined.

    The primary user interface is a RS-232 connection between the MCUand hostPC. A

    MAX232 IC is used in the design. The serial port in PC uses the voltages from the

    range of-10 V to 10Vwhile IC chips use 0V to 5V. Thus, the ideaof MAX232 IC is

    to convertthe voltage signal from -10V- 10Vto 0V - 5V when communicating from

    PC to IC chips and vise versa.

    The above paragraphs almost describe about the circuit or hardware of controller. For

    dc motor software, it performs position calculation and provides a command

    interpreter to create and control motion profiles. Dc motor position calculation is

    implemented to must perform the following tasks:

    • Get current motor position, and

    • Get desired motor position.

    8. THE PROGRAMMING OF THE CONTROLLER

    The general design is the system implements one PIC 16F877 microcontroller. The

    microcontroller receives variety of input from control console via various input pins.

    Then, the data is processed internally to generate the required output. The function of

    microcontroller also to communicate with PC through RS-232 serial communication.

    38

  • 8.1 Control Selection

    The mode of operation for controller is designed in two states, namely MANUAL

    CONTROL and PC CONTROL. During MANUAL CONTROL state, the

    manipulator is controlled by using a console. As the manipulator moves, the degree

    of rotation is recorded and transmitted via RS-232 Tx pin, so that the manipulator

    position is displayed at HyperTerminal or specific user interface. The program only

    considers inputs from console and output into Tx pin and ignore whatever incoming

    input from PC.

    As PC CONTROL is selected, the controlling of manipulator is done totally by PC.

    During this condition, all of RS-232 pins are used; Rx, Tx and Interrupt pin. During

    this state, the program only considers inputs from PC and output into Tx pin while

    ignoring whatever input coming from console. Figure 4.15 shows the flowchart of

    Control Selection function.

    8.2 Limit Right and Limit Left Function

    The limit switch function is designed for several purposes; first, to limit the

    movement of the manipulator in its workspace and second, for resetting function of

    the manipulator. This section only discusses the limit of the manipulator's movement

    while resetting function will be discussed in section 8.3.

    From the above section, the workspace is determined as below:

    -150° ,

  • MANUAL CONTROL

    Ignores whatever inputfrom PC

    Receives input fromconsole

    Run the dc motor

    according to the inputfrom console

    Encoder pulses aregenerated

    Calculate the pulsegenerated into equivalent

    degree

    Transmit to PC throughTx pin for current

    position

    YES

    END

    ProgramInitialization

    PC CONTROL

    Ignores whatever inputfrom console

    Receives input from PC

    Run the dc motor

    according to the inputfrom PC

    Encoder pulses aregenerated

    Calculate the pulsegenerated into equivalent

    degree

    Transmit to PC throughTx pin for current

    position

    YES

    END

    Figure 4.15 The Control Selection Function Flowchart

    40

  • The idea is every link will be placed two limit switches, placed at both positive and

    negative maximum position. When one of those switches is hit, the switch will send

    signal to microcontroller to stop the movement. Figure 4.16 shows the flowchart for

    limit switch function.

    ( START J'r

    DC motor run

    /itch hit?

    YES

    --___ NO

    '

    DC motor stop

    ' r

    ( END J

    Figure 4.16 The Limit Switch Function Flowchart

    8.3 Reset Function

    The purpose of reset function is to reset all of the manipulator's operation and return

    back the manipulator to its original position. The concept is as the reset command is

    invoked, the manipulator will move to the rightmost or maximum position until the

    maximum limit switch is hit. Then, the dc motor will run on opposite direction until

    predefined pulse count is achieved. Now, the manipulator is said to be placed at its

    original position. Figure 4.17 below shows the flowchart of reset function for a link.

    41

  • START

    Normal operation

    YES J*

    Manipulatormoves to the rightmostor maximum position

    YES

    Manipulator moves in the reversedirection from previously

    NO

    NO

    NO

    Manipulator stop

    END

    Figure 4.17 Reset Function Flowchart

    8.4 Positioning Function

    Positioning function is normal operation for the manipulator. The concept is as user

    instructs the manipulator either using console or PC, the program will do as whatuser

    wants. Forexample, letsay the user want to move link 1by 30°, the program receives

    the instruction and convert this 30° into equivalent pulse count. Then, the

    microcontroiier signals the dc motor to rotate. The encoder pulse is generated and fed

    into another input pin of microcontroller. If the pulse count is adequate, the motor

    42

  • will stop, indicating that the link 1 has been moved by 30° of rotation. Figure 4.18

    shows the flowchart for positioning function.

    NO

    START

    Receive input from PC orconsole

    Convert the data into

    equivalent pulses

    5DC motor run

    Motor stop

    ITransmit to PC through

    Tx pin for currentposition

    NO

    Figure 4.18 Positioning Function Flowchart

    8.5 Emergency Function

    The emergency function is purposely for halting immediately the operation of

    manipulator. There might be an unexpected occurrence during the operation, such as

    data floating or manipulator hitting person in workspace. Figure 4.19 shows the

    flowchart for emergency function.

    43

  • START

    Positioning Function

    YES

    Send interrupt tomicrocontroller to stop all dc

    motors

    END

    Figure 4.19 Emergency Function

    NO

    9. DC MOTOR APPLICATION SOURCE CODE

    The code implements a brush dc servomotor using PIC 16F877 microcontroller. The

    code also contains the process of controlling dc motor as discussed above.

    Initially, the code will instruct the motor to rotate. After that, it receives encoder

    pulse signal from the motor for position calculation. Then, the result from position

    calculation will be transmitted to PC for displaying purpose through RS-232 serial

    communication.

    This source code is compiled using PIC C Compiler version 2.7333 available at

    Microprocessor Lab. The generated source code is shown in Appendix I

    44

  • 10. USER INTERFACE

    Instead of console, a HyperTerminal program is used to communicate between PC

    and microcontroller. HyperTerminal is used by applying the setting at COMl to

    select serial port communication.

    Figure 4.20 HyperTerminal Interface, Displaying theCurrent Position for TheManipulator: Link 1 is 30.99° WhileLink 2 is 22.99°.

    45

  • CHAPTER 5

    DISCUSSION

    The development of robot controller and manipulator involves both electrical and

    mechanical skills. In general, the development of controller relates a lot with

    electrical skill while development ofmanipulator relates a lot with mechanical skill.

    There are several aspects that play important role in determining the successful of

    manipulator design, which are stability, reliability, matching and accuracy.

    The designed manipulator must be stable in the way that the base can support all three

    arms. And the lower arm is able to support correctly the upper arms. This condition

    can be achieved by implementing design carefully. The analysis is suggested to be

    more done at preliminary and detailed design stage by carefully analyze the full

    dimensional drawing. This is because any changes during design stage are easier to

    alter and involve lower cost compared in the construction or operation phase. If any

    of the designproblems occur during construction phase, the design shouldbe revisited

    and do necessary changes. Among the basic design strategies to ensure that the

    manipulator is stable are by allocating wide base area and lowering the centre of

    gravity at base.

    Reliability in manipulator design means the manipulator can easily and properly

    operate. If the specified workspace is -90° to +100° (total 190°), the manipulator

    must achieve any position in this limit. The disturbance of achieving this limit might

    be improper arrangement of parts, for example improper placing of motor that disturb

    the movement of arm. This kind of disturbance can be eliminated by designing the

    parts' position properly including testing the model and improve the design if any

    46

  • problems arise. The manipulator also should move in such a way that having the

    lowest friction at joint and strong link or arm. This consideration can be achieved by

    implementing bearing at each joint and strong material is used. Note that, strong

    material is important to avoid links' deviation during its operation.

    All parts in manipulator must be matched together to maximize its operability. The

    parts matching may include all parts are tightly placed at manipulator body,

    disallowing vibration between them. In case of vibration is allowed, it may disturb

    the rotation or revolution of manipulator. The most important thing is the gear must

    be matched in all of its application. These requirements may be achieved by properly

    applying screw or bolt and nut to tight the parts together and also use gears with same

    pitch only.

    The final consideration in manipulator design is it must provide accuracy in

    positioning. The accuracy is very difficult to obtain since it involve a lot of criteria.

    But the most vital parts to achieve accuracy are the above-mentioned aspects that

    have been discussed earlier. Accuracy means how close for the manipulator to

    achieve the right position, which is if the controller sends the signal that want to go to

    coordinate (3, 4, 5), the manipulator can achieve that point. The most possible

    defector for the manipulator to achieve accuracy is the tightening and loosening

    process of belt during motor on and off. As the motor on, the belt is tightened while

    during motor off, the belt might loose. As the belt loose, the manipulator will slightly

    fall down from right coordinate after some manipulator's operation. This problem

    should be always reminded by applying belt tightening shaft for all belts used for the

    sake of minimizing this effect. This condition is also might be the advantage of using

    belt over chain since the belt can be vigorously tightened and chain might little loose

    during motor stop.

    Another problem that might appear is during power off, which the motor also will off.

    Analytically, as the motor off, the motor is not holding arm anymore to a specific

    location. Thus, arm will fall down. If the power supply on, the arm then will up

    again. In order to remedy this problem, latching gearbox might be used to counter

    that effect, which latching gear box will restrict the gear or link to move during power

    off.

    47

  • For controller, the determining aspects for the successful of controller are the

    goodness of microcontroller programming. The good programming will yield to the

    reliability of the program. The program should not mismatch or misinterpret between

    user interface (program at PC) and output signal established by microcontroller.

    We could say that controller is a heart for manipulator's operation. Whatever things

    processed in heart is interpreted in the movement of manipulator. If the program has

    very little mismatch between the calculation of desired position and measured

    position, this difference will be accumulated throughout the manipulator's movement.

    Finally, let say after 50 movements or 60 movements, the error is quite significant.

    Thus, it is essential for that program to be equipped together with error calculation

    and compensation function.

    48

  • CHAPTER 6

    CONCLUSION AND RECOMMENDATION

    1. CONCLUSION

    As the conclusion, the designing and fabricating process starts from studythe existing

    design, followed by preliminary design, detailed design, construction and finally

    testing the constructed model.

    At study stage, the study of robotic arms or robot manipulators of existing design is

    carried out. The functions are to find the idea to develop the designand setting up the

    best design parameters.

    Then the process is followed by preliminary and detailed design. At this stage, the

    drawings and dimensions are established. The design alsoconsiders 3-DOF principle,

    selection of robot coordinate frame, workspace determination, forward and inverse

    kinematics and gearing design.

    After the design is properly established and satisfied, the construction of robot

    manipulator is initiated. The construction process is started by selection of best

    material that posses light, strong and affordable characteristics. Then, construction

    process might be preceded by combining or joining all materials with specific

    dimension to be a robot manipulator. During construction stage, these skills are

    important such as cutting, drilling, grinding and combining the parts. During

    construction stage also, anotheractivities are done such as developing microcontroller

    programming, developing the PC interface and generating relevant circuits.

    49

  • The final stage is testing the manipulator. If there are any defects found, the design

    should be revisited, altered if necessary and executed on the model.

    The controller designing stage is initiated by selection the best MCU in market. Then,

    the specification of this MCU must be understood for example its bandwidth, data

    memory capacity, program memory capacity and the most important things are pin

    layout and registers assignment.

    The process of controller design is continued by understanding its program. There are

    two ways of developing source code, which are generated ourselves or alteration from

    the existing source code. Generating the source code ourselves consumes greater time

    than alteration the existing one. There might be nearly same source code in our

    resources, e.g book or internet and some alterations to suit our needs must be done.

    After the program is generated and compiled with compiler results no error, the

    program is ready to be burned in PIC 16FF877. The program is testing again in real

    application, with our manipulator and the operation is observed. If the operation does

    not meet our design, the program or source code must be reviewed again.

    2. RECOMMENDATION

    Up to this stage, a robot manipulator and controller is completely designed and

    implemented. The application ofrobot manipulator covers only 3-DOF operation. It

    is restricted to the positioning function only.

    It is recommended that for next stage, this robot manipulator is revamped with

    improved design and covers wide application, equipped together with manipulating

    function. Thus, the design will require high DOF, 6-DOF or higher. This is

    important to observe that better application could be implemented for example the

    process of lifting something, drawing, painting and several othersuitable applications.

    The design also should be equipped with sensor system, for example it identifies

    which material to be picked up and more efficient user interface.

    50

  • REFERENCES

    [1] Lung-Wen Tsai, 1999, Robot Analysis: The Mechanics ofSerial and ParallelManipulators, Canada, John Wiley & Sons, Inc., pg 1.

    [2] Gordon McComb, 2000, The Robot Builder's Bonanza, Martinsburg,McGraw-Hill, pg. ix.

    [3] Saeed B. Niku, 2001, Introduction to Robotics: Analysis, Systems,Applications, New Jersey, Prentice Hall, Inc., pg. 2.

    [4] Lung-Wen Tsai, 1999, Robot Analysis: The Mechanics ofSerial and ParallelManipulators, Canada, John Wiley & Sons, Inc., pg2.

    [5] Lung-Wen Tsai, 1999, Robot Analysis: The Mechanics ofSerial and ParallelManipulators, Canada, John Wiley & Sons, Inc., pg 46.

    [6] Lung-Wen Tsai, 1999, Robot Analysis: The Mechanics ofSerial and ParallelManipulators, Canada, John Wiley &Sons, Inc., pg 25.

    [7j Niku,, S., "Scheme for Active Positional Correction of Robot Arms,"Proceedings ofthe 5th International Conference on CAD/CAM, Robotics andFactories ofFuture, Springer Verlag, pg. 590 - 593, 1991.

    [8] Brady, M„ J. M. Hollerbach, T. L. Johnson, T. Lozano-Perez, and M. T.

    Mason, editors, Robot Motion: Planning and Control, MIT Press, Cambridge,Mass., 1982.

    51

  • Appendix A

    Types ofRobot Coordinate Frame

  • .^*.™\:

    ROBOT COORDINATE FRAME

    '.'>.-r'-' :,,-'

    I

    %'.

    •':,''.s

  • Appendix B

    Types ofExisting Robot Manipulator in Market

  • SAMPLE OF CURRENT ROBOTS IN MARKET

    Kuka Robot from Kuka Roboter GmbH.

    Adept-One Robot from Adept Technology, Inc.

    MotomanESI65 from Motoman Inc.

  • Appendix C

    Revolution Joint Indication

  • Th

    eM

    an

    ipu

    lato

    r's

    An

    gle

    Assig

    nm

    en

    t

  • Appendix D

    Detailed Drawing ofRobot Manipulator

  • Fro

    nt

    Vie

    w

    ft

    =3

    L

    Leg

    end

    s)

    A-

    RS

    dc

    mo

    tor

    wit

    had

    d-o

    nen

    co

    der

    B-

    4N

    nad

    ap

    tab

    leg

    earb

    ox

    C-

    Co

    ntr

    oll

    er

    bo

    xD

    -B

    elt

    an

    dg

    ear

    E-

    Mo

    tor

    mo

    un

    tin

    gp

    late

    No

    te"

    All

    dim

    en

    sio

    ns

    are

    (nin

    ch

  • Sid

    eV

    iew

    2.4

    00

    0

    «3

    00

    0

    Leg

    en

    dsi

    A-

    RS

    dc

    no

    tor

    wit

    had

    d-o

    nen

    co

    der

    B-

    4N

    nad

    ap

    tab

    leg

    earb

    ox

    C-

    Co

    ntr

    oll

    er

    bo

    xD

    -B

    elt

    an

    dg

    ear

    EI-

    Mo

    tor

    mo

    un

    tin

    gp

    late

    No

    tei

    AU

    dim

    en

    sio

    ns

    are

    InIn

    ch

  • OO

    99

    r-0

    1.3

    80

    0

    11

    .00

    00

    •9.0

    00

    0-

    op

    vie

    w

    •15

    .67

    50

    - L ZEL

    eg

    en

    ds:

    A-

    RS

    dc

    no

    tor

    wit

    had

    d-o

    nen

    co

    der

    B-

    4N

    nad

    ap

    talo

    leg

    earb

    ox

    C-

    Co

    ntr

    oll

    er

    bo

    xD

    -B

    elt

    an

    dg

    ear

    E-

    Mo

    tor

    mo

    un

    tin

    gp

    late

    No

    te:

    Atl

    dim

    en

    sio

    ns

    are

    inin

    ch

    3.1

    50

    0

  • Appendix E

    Robot Manipulator's Workspace

  • To

    pV

    iew

    Wo

    rksp

    ace

  • Appendix F

    Detailed Calculation ofPosition Analysis

  • DETAILED CALCULATION OF POSITION ANALYSIS

    10

    i

    r'(7,4,10)

    x

    y

    *

    /74

    1

    r

    Analyzingx- and z-axis

    Z A

    10(7, 4, 10)

    Analyzingx- andy-axis

    y

    Setting upa parameter:LengthA-B =4.7

    -l#2=90°-cos

    = 16.71°

    J238

  • Appendix G

    Detailed Drawing ofFirst Manipulator Design

  • 150

    1,4748

    50

    1.7150

    (_

    •3.4380-

    _>D _

    —0,3750

    •7.0000

    H h-0.3580— 4.6650-

    •10.0000-

    B

    Robot Manipulator: Front View

    LegendsiA - Controller BoxB - Gear

    C - Pittman Lo-Cog MotorD - RS Adaptable Gearbox€ - Copper RodF - Koyo Bearing & Bearing PlasticHolder

    G - Belt Tightening RodH - Belt

    Material used* AluminiumNotei All dimensions are in inch

    3.3150

    0.7150 -1

    5.0000

    1.6350

    8.000

  • 5.0000

    •4.0000-

    -M7190

    Robot Manipulator' Side View

    Legends)BoxA - Controller

    B - GearC - Plttnan Lo-Cog MotorD - RS Adaptable GearboxE - Copper RoadF - Koyo Bearing 8> BearingPlastic HolderG - Belt Tightening RoadH - Belt

    Material used" Alumlnlun

    Notet AU dlnenslons areinch

    B.0000

    In

    B m

    00.7158.

    ^i

    ik —'A01.6250

    i

    tf-w-r-j

    •L6150-J

    -6.0000-

    -8.0000-

    5.0000

    4.0000

  • 10

    .00

    00

    3C

    B

    04

    .66

    50

    -

    -8.0

    00

    0-

    I1

    -E

    2=

    TK

    ?-6

    .00

    00

    -

    1

    0.^5

    93

    Ro

    bo

    tM

    an

    ipu

    lato

    r!T

    op

    Vie

    w

    Leg

    en

    ds'

    A-

    Co

    ntr

    oll

    er

    Bo

    xB

    -G

    ea

    rs

    C-

    Plt

    tnan

    Lo

    -Co

    gM

    oto

    rD

    -R

    SA

    da

    pta

    ble

    Gea

    rbo

    xE

    -C

    op

    per

    Ro

    dF

    -K

    oyo

    Bea

    rin

    g8.

    Bea

    rin

    gP

    last

    icH

    old

    erG

    -B

    elt

    Tig

    hte

    nin

    gR

    od

    H-

    Belt

    Ma

    teria

    lu

    sed

    'A

    lum

    inu

    m

    No

    te'

    All

    dim

    en

    sio

    ns

    are

    InIn

    ch

    F

    -5.0

    00

    0-

    -8.0

    00

    0-

  • Appendix H

    DC Motor Application Schematic Diagram

  • LIM

    IT1_

    RIG

    HT

    -O

    O

    LIM

    IT1_

    LE

    FT

    -OO

    -

    M0

    T1

    _R

    IGH

    T

    -OO

    M0

    T1

    _L

    EF

    T

    OO

    -

    Osc

    4M

    HZ

    LIM

    IT2_

    RIG

    HT

    -OO

    -

    LIM

    IT2_

    LE

    FT -O

    O

    M0

    T2

    RIG

    HT -O

    O-

    MO

    T2_

    LE

    FT -

    OO

    -

    L1M

    IT3_

    RIG

    HT

    -OO

    LIM

    IT3_

    LE

    FT -o

    o-

    Pu

    lse

    INE

    NC

    0D

    ER

    1

    Pu

    tse

    INE

    NC

    OD

    ER

    2

    mo

    t:i_

    RIG

    HT

    MC

    LR

    1

    PIN

    _A0

    PIN

    _A1

    PlN

    J\2

    PIN

    A3

    PtN

    _A

    4

    •PIN

    JUS

    PIN

    J30

    PIN

    _E1

    PlN

    _E2

    Vd

    d

    .Vss

    0S

    C1

    OS

    C2

    PIN

    -CO

    PIN

    ,C1

    PIN

    C2

    PtN

    _C3

    WN

    _D

    0

    -PIN

    D1

    oo

    M0

    T3

    _L

    EF

    T

    P1

    C1

    6F

    87

    7

    PIN

    .B7

    PIN

    J36

    PIN

    _8B

    PIN

    _B4

    PIN

    _B3

    P1N

    _B2

    PIN

    _B1

    PIN

    _B0

    Vd

    d

    Vss

    PIN

    _D7

    PIN

    _D6

    PIN

    _D6

    PIN

    _D4

    PIN

    _C7

    PIN

    _C6

    PIN

    _C5

    PIN

    „C4

    PIN

    _D3

    PIN

    D2

    fr 1

    0U

    F

    10

    uF

    -O

    o_

    C3

    H-

    !

    10

    uF

    C1

    U7

    10uF

    C1

    +

    V-

    C1

    -

    -C2

    +

    C2

    -

    -V-

    T2

    ou

    t

    R2

    in

    MA

    23

    2

    Vcc

    Vss

    T1

    ou

    t

    R1

    in

    R1

    ou

    t

    Tli

    n

    T2

    in

    R2

    oti

    t

    vcc

    SV

    J9

    _ o

    o o--

    o

    DS

    UB

    9F

    INI

    IN2

    1N1

    IN2

    IN1

    IN2

    12

    V

    Vcc

    0U

    T2

    OU

    T1

    OU

    T2

    OU

    T1

    BR

    IDG

    E1

    12

    V

    Vcc

    OU

    T2

    0U

    T1

    HB

    RID

    GE

    2

    H_B

    RID

    GE

    3

    Til

    le:

    DC

    Mo

    App

    lica

    tion

    -R

    ob

    otC

    on

    tro

    ller

    &M

    anip

    ulat

    or

    UT

    PF

    inal

    Yea

    rP

    roje

    ct

    Des

    ign

    edby

    :Z

    ulki

    fli

    Ch

    eck

    ed

    by;

    App

    rove

    dby

    :

    Do

    cu

    men

    tN

    00

    01

    Date

    Jun

    09

    ,2

    00

    4

    Sh

    eet

    1o

    f1

    Rev

    isio

    n1

    .0

    Siz

    eA

  • Appendix I

    Program Source Code

  • ftinclude

    #fuses XT, NOPROTECT, NOWDT#use delay(clock=4000000)#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7

    float movement_l();float movement_2 ();void reset {) ;

    //declaration of motor 1#define LIMIT1JUGHT PIN^AO#define LIMITl_LEFT PIN_A1#define M0T1_RIGHT PIN_A2#define M0T1_LEFT PIN_A3#define IN_ENC0DER1 PIN_A4#define H_BRIDGE1_1 PIN__B4#define H_BRIDGE1_2 PIN_B5

    //declaration of motor 2#define LIMIT2_RIGHT PIN__C1#define LIMIT2_LEFT PIN_C2#define MOT2_RIGHT PIN_C3#define MOT2_LEFT PIN_C4#define IN_ENCODBR2 PIN_C0#define H_BRIDGE2_1 PIN_D4#define H_BRIDGE2_2 PIN_D5

    //declaration of motor 3#define MOT3_RIGHT PIN_D2#define MOT3_LEFT PIN_C5#define H_BRIDGE3_1 PIN_D6#define H_BRIDGE3_2 PIN_D7

    //general declaration#define IN RESET PIN A5

    //main function

    main()

    {float position;

    set_tris_a(Oxff) ;set_trisjD(OxOO);set_tris_c(Oxff);set_tris_d(OxfO);

    printf("\nRobot Controller and Manipulator\n");printf("\nCalculating the degree of rotation of robot manipulator\n");

    // controlling motor 1while (true)

    {if (MOTl_RIGHT)

    {if (!LIMIT1_RIGHT && !LIMITl_LEFT)

    output_high(H_BRIDGElJL);

    if (LIMIT1_RIGHT)output_low(H_BRIDGEl_l);

    if (LIMIT1_LEFT)output_high{H_BRIDGEl_l);

    }else

    output_low(H_BRIDGEl_l);

    if (MOTl_LEFT){if (!LIMIT1__RIGHT && !LIMIT1_LEFT)

    output_high{H_BRIDGEl_2);

    if (LIMIT1_LEFT)output_low(H_BRIDGE1_2);

    if (LIMIT1_RIGHT)output high(H_BRIDGEI_2);

  • }else

    output_low(H_BRIDGEl_2);

    //controlling motor 2if (MOT2__RIGHT)

    {if (!LIMIT2_RIGHT && !LIMIT2_LEFT)

    output_high(H_BRIDGE2_l);

    if (LIMIT2_RIGHT)output_low(H__BRIDGE2_1);

    if (LIMIT2_LEFT)output_high(H_BRIDGE2_l);

    }else

    output_low(H_BRIDGE2_1);

    if (MOT2_LEFT){if (!LIMIT2_RIGHT && !LIMIT2_LEFT)

    outputJiigh(H_BRIDGE2_2);

    if (LIMIT2_LEFT)output_low(H_BRIDGE2_2);

    if (LIMIT2_RIGHT)output_high(H_BRIDGE2_2) ;

    }else

    output_low(H_BRIDGE2_2) ;

    //controlling motor 3if (MOT3_RIGHT)

    outputJligh(H__BRIDGE3_l) ;

    if (MOT3_LEFT)output_high(H_BRIDGE3_2);

    position_l=movement_l();position_2=movement_2();

    printf("\n The current position for link 1 is %f degrees.\n", positional);printf("\n The current position for link 2 is %f degrees.\n", position_2);

    reset() ;

    }

    >

    //Calculating the degree of rotation-

    float movement_l(){float pos, count_pulse;

    pos=0, count_pulse=0;

    while (input(MOTl_RIGHT) ){

    if (input(IN_ENC0DER1))count_pulse = count_pulse + 1;

    }

    while (input(M0T1_LEFT)J{

    if (input(IN_ENC0DER1))count_pulse = count_pulse - 1;

    }

    }

    pos = count_pulse/2; //2 pulses = 1 degree of rotationreturn pos;

    float movement_2()

    {float pos, count pulse;

  • pos=0, count_pulse=0;

    while (input(M0T2_RIGHT)){

    if (input(IN_ENC0DER2))count__pulse = count_pulse

    }

    while (input(M0T2_LEFT))

    {if (input(IN_ENC0DER2))count_pulse = count_pulse

    }

    pos = count_pulse/2;return pos;

    //Function for resetting-

    void reset(void)

    {int i, j;while (IN_RESET)

    {if (!input(LIMITl^RIGHT))

    output_high(H_BRIDGE1_1) ;

    for (i=300;i==0;i—)

    output_high(H_BRIDGEl_2);

    if (!input(LIMIT2_RIGHT))output high(H BRIDGE2 1);

    for (j=180;j==0; j—)output_high(H_BRIDGE2_2);

    }

    l;

    - 1;

    //2 pulses = 1 degree of rotation

    //calculating the rotation pulse to initial state