Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing...

download Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

of 125

Transcript of Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing...

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    1/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    2/125

    2

    Aim

    To design, develop and test a PIC based differential drive operated automatic robot.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    3/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    4/125

    4

    Declaration of Originality

    We, Krishneel Prasad, Ritesh Kumar, Kirata Iotam and Benjamin Kunal Chand hereby

    declare that the report that has been written for this project is our own original workdone with the best of our knowledge. All materials adapted from elsewhere have beenappropriately acknowledged and referenced. The material has not been submittedpreviously, either in whole or in part, for a degree at this or any other institution.

    ___________________ ____________________

    Krishneel Ritesh Prasad Ritesh PrasadStudent Id : s11050297 Student Id : s11048886

    ___________________ ____________________Kirata Iotam Benjamin Kunal ChandStudent Id : s11045193 Student Id : s11039935

    30th November, 2010.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    5/125

    5

    ACKNOWLEDGEMENT

    We would like to take this opportunity to thanks the following people for their help,support and encouragement while doing this project.Firstly we are especially thankful to Imran Jannif for giving us the opportunity to do thisproject. Our family for their understanding by the time we dont spend time with themand finally to all Engineering staffs for their support and encouragement.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    6/125

    6

    List of FiguresFigure 1.1 PacSea 2Figure 1.2 Pacsea wave model 3Figure 1.4 Pacificsea 4Figure 1.5 Pacsea surf 4Figure 1.6 PacseaLoa 5Figure 1.7 PacSea-Colata model 5Figure 1.8.1 PacSea-MataiAutomatic 1 6Figure 1.8.2 PacSea-MataiAutomatic 2 6Figure 1.8.3 PacSea-MataiManual Robot 6Figure 1.9 PID Block Diagram 7

    Figure 2.0 Differential Drive Motor Controller Setup 10

    Figure 2.1a IR sensor board 11

    Figure 2.1b Shaft encoder and IR sensor unit 11

    Figure 2.2 12V Cordless drill motor 12

    Figure 2.3 In-house fabricated wooden wheel 13

    Figure 2.4 Wheel calculation 13Figures 2.5a Motor controller board 15Figures 2.5b PIC16F877 boot loader board 15Figures 2.5c LM324 comparator PCB board 15Figures 2.5d IR sensor mounting 15

    Figure 4.1 SN754410 chip 29Figure 4.2 schematic of sn754410 30Figure 4.3 Pin connection for sn754410 31Figure 4.4 Cordless drill motor 32

    Figure 4.5 shows the testing for sn754410 chip 33

    Figure 4.5.1 Graph of current, voltage and rpm for sn754410 chip 34

    Figure 4.6 differential drive 35

    Figure 4.7 A generic H-bridge 35

    Figure 4.8 One output on the SN754410 chip 36Figure 4.9 Shows the PWM signal 37

    Figure 5.1 Heds 5540 a06 39Figure 5.2 Hardware setup for oktec shaft encoder 41

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    7/125

    7

    Figure 5.3 16 slots aluminum plate 41Figure 5.4 The shaft encoder between two ir sensors, shaft encoder circuit 42Figure 5.5 The hardware for the comparator circuit 43Figure 5.6 A smooth square wave signal from the comparator output 44

    Figure 6.1 Graph of Motor Speed versus time at 35% duty cycle 47Figure 6.2 The step response of the Graph of Motor at 35% duty cycle 51Figure 6.3 The graph of Log |1y (t)| vs. time motor at 35% duty cycle 54

    Figure 6.4 The graph of Log (1+A*Exp (- x t) y(t)) Log |1y (t)| vs. time at 35% duty cycle 57

    Figure 6.5 The Graph of Motor Speed versus time at 50% duty cycle 60

    Figure 6.6 The graph of Log |1y (t)| vs. time motor at 50% duty cycle 62

    Figure 6.7 The graph of Log (1+A*Exp (- x t) y (t)) Log |1y (t)| vs. time at 50% duty cycle 64

    Figure 6.8 Step responses for a proportional controller 69

    Figure 6.9 A step response for a PI controller at 0.005 and 80 respectively 70Figure 7.0 A step response for a PI controller at 8.5 and 75 respectively 71

    Figure 7.1.1 Proposed mechanical base platform 74Figure: 7.1.2 Uniform holesreducing the weight of the machine 75Figure 7.1.3 Tricycle wheel 76Figure 7.1.4 ABU Robocon 2009 76Figure 7.1.5(a) (b) Proposed wooden wheel 76Figure 7.1.6 Robot arm design 77Figure 7.1.7 Roller arm design 78Figure 7.1.8 Actual view of arm roller 78

    Figure 7.1.9 Rubber roller 78Figure 7.8 Stress Analyses 81Figure 7.8.1 Krathong Petal 84

    Figure 7.8.2 Krathong Petal 84

    Figure 7.8.3 Candle Light Flame 85

    Figure 7.8.4 Automatic 1 physical diagram 85

    Figure 7.8.5 assembled krathong 87

    Figure 7.8.6 Automatic arm description 87

    Figure 7.8.7 Auto side view 88

    Figure 7.8.8 OSMC motor controller 90

    Figure 7.8.9 LDR Sensor Schematic 93

    Figure 7.9.0 LDR Sensor 93

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    8/125

    8

    Figure 7.9.1 Force sensor diagram 94Figure 7.9.2 PIC18f6722 Prototype board 95Figure 7.9.3 PIC18F4550 microcontroller 96Figure 7.9.4 Crouzet 82862 001 12 volts DC motor 97Figure 7.9.5 SERVO MOTOR 98

    Figure 7.9.6 Battery 99

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    9/125

    9

    List of TablesTable 4.1 Parameters for sn754410 chip 29Table 4.2 Truth table for SN754410 31Table 4.4 No load test for the dc motor 33

    Table 6.1 The data recorded for 35 % duty cycle 45-47Table 6.2 The table below shows the step response figures at 35% duty cycle 49-50

    Table 6.3 The log(y (t)y ()) data at 35% duty cycle 52-53

    Table 6.4 A Log (1 + A*Exp(xt) - y(t)) at 35% duty cycle 55-56

    Table 6.5 Calculating y(t)=1-(exp(- x t)) for 50% duty cycle 58-59

    Table 6.6 Calculating log |1-y(t)| for 50% duty cycle 60-61

    Table 6.7 Calculating Log (1 + A*Exp (xt) - y(t)) at 35% duty cycle 63-64

    Table 7.1.0 The comparison of the base unit from previous years robots 73Table 7.1.1 Different masses and forces applied to the robots arm 79

    Table 7.1.2 Manual machine path length, amount of weight, spring constant 80

    Table 7.2 The summary table of Auto 1s task objects 85Table 7.3 The table shows Auto 2 task object and weight 87Table 7.5.1 Specification for the LDR line tracer sensor 93

    Table 7.5.2 A summary of some important features of PIC 18F6722 95

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    10/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    11/125

    11

    6.2 Calculation of the Transfer function at 35% duty cycle 456.3 Calculation of the Transfer function at 35% duty cycle 586.4 Comparing the Driver Motor Transfer Function 656.5 Obtaining the Driver Motor Transfer Function through Formula 65

    6.7 Selecting the transfer function of the motor by comparing the two methods 68

    6.8 Using MATLAB to derive the gain of the PI controller 68

    Chapter 7

    7.1. Mechanical Aspects of Robocon 2011 Robots 737.1.1 Base Design 1 737.1.2 Mechanical Base Platform 737.1.3 Materials Used 747.1.4 Wheels 757.1.5 Arm Construction 767.1.6 Rubber Rollers 77

    7.1.7 Displacement Calculation for Manual Robot 787.2 Stress Analysis Calculation for Manual Robot 817.2.1 Weight Calculation for Manual Robot 827.2.2 Mechanical Design for Automatics Machines. 837.2.3 Distance travelled by the Auto 1 837.2.4 The tasks to be performed Automatic One 837.2.5 Time Taken by Automatic 1 867.3 Automatic Two 877.3.1 Time Taken by Automatic 2 887.3.2Moment Calculation 887.3.3 Weight Calculation for Automatic 2 Robot 89

    7.4 Total Weight of All three Machines 907.5 Electronics for Automatic machines 907.5.1 Motor Controller 90

    7.5.2 Features of OSMC 91

    7.5.3 Sensors 927.5.4 Force Sensors 947.5.5 MICROCONTROLLER 947.5.5.1 PIC18f6722 947.5.5.2 PIC18F4550 USB DEVELOPMENT BOARD 957.5.5.3 VOLTS DC MOTOR 97

    7.5.5.4 Motors for the Grippers 987.5.5.5 SERVO MOTOR 987.5.5.6 Battery 997.5.5.7 V 2300 mAH NiMH Rechargeable Battery Pack 100

    7.5.5.8 Features and Benefits 100

    7.5.5.9 Technical Specifications 100

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    12/125

    12

    Discussion 101

    Conclusions and Recommendations 102

    References 103

    Appendix 104

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    13/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    14/125

    14

    Chapter 1

    Introduction and Literature Review

    Asia-Pacific Robot Contest or ABU Robocon was developed by the Asia-Pacific

    Broadcasting Union in 2002, and was joined by many universities and colleges aroundAsia and the Pacific. The main purpose of ABU is to develop students technical skills aswell as designing abilities in developing robots that will be able to compete a given tasksin the battlefield/game ground within a set period of time, which will therefore improveengineering and technology in the region. There are many different robots whichRobocon group had developed in the past. One of the most common robots developed bythe Robocon members is a Line tracing automatic robot, this robot will try to follow awhite track and detecting any obstacles that my come in its way.

    Moreover, every year the Robocon group members try to complete at least one automaticrobot and a manual robot. Additionally, the automatic robot with a square base unit has

    two motors connect back to back. The speed of each motor must be the same for the twomotors and the two motors must rotate in different directions. Thus, to achieve this, theshaft encoder is introduced in order for the PIC-Microcontroller to synchronize the speedof the motor [1]. In addition, an LDR (Light Dependent Resistor) sensor with a LED(Light Emitting Diode) compiled together to give the ability for the robot to do linetracing. In most cases, the line tracing PCB (printed circuit board) always face downwardin order for the LDR to receive a reflected light from the LED to detect a white or a blacksurface.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    15/125

    15

    In 2001, the University of the South Pacific joins the competition which was held inTokyo 2002. In the past seven years, the University of the South Pacific has involved in

    ABU Robocon contest and below is the details of some robots designed in Robocon inthe past seven years.

    1.1 Pacsea

    To start off, Pacsea was one of the robotics designed for the competition that was held inBangkok, Thailand in August 2002. The diagram of Pacsea was shown below.

    Figure 1.1 PacSea (Source: Msc. Thesis, R.Singh)

    Additionally, the theme of the contest is Reach for the Top of Mount Fuji. The robot

    must be capable to drop the beach balls into different cylinders at different heights. Inaddition, the task has to be complete by one automatic robot by navigating the ball andplacing the ball in the right place. A PIC16F877 is one major part of Pacsea whichcontrols two relays by switching on and off the wiper window motor; however Pacsea hasno feedback sensor [1]

    1.2 Pacsea Wave

    In 2003 the game was held in Bangkok, Thailand and the theme of the competition was"Takraw Space Conqueror". To win the contest the robot must shoot a Takraw balls intoall the baskets and the robot will also fill the three nets inside one of the centered basketwith balls [1]. The intelligent part of the robot is chosen as a single PIC16F877 and withPIC16F877 students make the robot slightly intelligent by giving the robot the ability totrace a line [1]. The picture of Pacsea wave is shown below:

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    16/125

    16

    Figure 1.2 Pacsea wave model (Source: Msc. Thesis, R.Singh)

    1.3 Pacsea Surge

    Furthermore, in 2004 and The Reunion of the Shepherd and the Weaver is the theme ofthe contest. Each team has to carry red boxes (gifts to the god) and the robot will carrythe box across the bridge. To win, the robot has to carry most items within the allocatedtime. Additionally, the central intelligent part of the machine has upgraded toPIC18F8720 from PIC16F877. Moreover, the advantage of using a PIC18F8720 is thatthere are a lot pins (Input/output pins) compared to PIC16F877, it can handle morecomplex game plans. In addition, the type of motor used in Pacsea surge is a wiperwindow and the speed of the motor is generic controlled by a pulse width modulator(PWM) [x] that was sent by PIC18F8720. The diagram of Pacsea surge is as shownbelow [1].

    Figure 1.3 Pacsea surge (Source: Msc. Thesis, R.Singh)

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    17/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    18/125

    18

    1.6 Pacsea Wave

    In 2008, the robocon was held in India, on August 2008. The theme of the contest wasGovinda, Touch the Sky. The robot is required to grab Styrofoam cubes (buffer cubes)

    and keep holding on it. The Robot that can hold these cubes until the end of the game willbe declared as the winner of the game. PIC18F6720 is the main intelligent part of therobot.

    Figure 1.6 Pacsea - Loa (Source: EE300, K. Chandry)1.7 Pacsea Colata

    In 2009, the robotic contest was held in Tokyo, Japan and the theme of the game isTravel Together for Victory Drums. In contrast, the competition which was held inJapan is quite different with the previous competitions and this because there are threerobots need to be designed. And the designed consist of one manual robot and twoautomatic robots. The automatic robot will complete the task by hitting the three victorydrums whereas will give supports.

    Figure 1.7 PacSea-Colata model (Source: EE300, K. Chandry)

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    19/125

    19

    1.8 Pacsea Matai

    Furthermore, the theme of the robot contest that was held in Cairo, Egypt by the year2010 is Robo-Pharaoh Build Pyramids. The teams need to be accurate and fast. Therewere three robots and this consists of two automatic robots and one Manual robots. The

    three robots will work together as a team and complete the missing blocks of threepyramids. The automatic robot will complete the last part of the pyramid without theintervention of human. Additionally the intelligent part of the automatic robots is a singlePIC18F877 with the OSMC as the main controller board. For the manual machines, carrelays are used interchangeably to control the speed of the two wheels.

    Figure 1.8.1 PacSea-MataiAutomatic 1

    Figure 1.8.2 PacSea-MataiAutomatic 2

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    20/125

    20

    Figure 1.8.3 PacSea-MataiManual Robot

    In this year project, students will work together as team and try to complete oneautomatic robot that has the ability of line tracing as well as speed control. The studentsdecide to use three number of PICs microcontroller as a central processing unit of therobot. Out of the three microcontrollers, one is set as a master controller while the othermicrocontrollers are slaves.

    PID Control

    First of all, PID is one of the most effective close loop speed control for a robot. Inaddition, PID stands for Proportional, Integral and Derivative Control whereas KP standsfor proportional gain, KI stands for Integral gain and KD stands for derivative gain.The diagram below shows how PID is used to control the plant (motor)

    Figure 1.9 PID Block Diagram

    The controller Input is controlled be the feedback such as if the output is quite high ascompared to the reference input. In addition, the three gains (Kp, Ki and Kd) will takeaction to reduce the error and running the plant as per required.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    21/125

    21

    Chapter 2

    Mechanical Design

    2.0 Overview

    For this project, our main objective was to implement PID speed control and line trace

    the mobile vehicle on a given platform. Since due to lack of time and some foreseen we

    could not complete our desired task hence, we discussed with our supervisor with whom

    we found out that we have to complete our project using a differential drive motor

    controller setup which is the major project for EE313. The figure below illustrates the

    following practical setup of the differential drive motor controller setup. Brief detailed

    information of each item indicated below is further discussed in this chapter.

    12V dc

    motor

    Motor Controller Boards Boot loader Boards

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    22/125

    22

    Figure 2.0: Differential Drive Motor Controller Setup

    The mechanical design of above figure is fairly simple, because this project deals with

    PID speed control or synchronising the two driver motors, only few components can be

    built to attain this task. Moreover, the differential drive motor controller can be divided

    into two halves, the component required to make one half of the differential system is one

    12Vdc motor, one PIC16F877,one LM324 comparator , a 12V power supply unit, 16

    slots shaft encoder and a frequency divider. For this project, we are suppose to complete

    the two halfs and complete the loop of the differential drive system. Since the electronics

    of the differential drive setup is mounted on a 15mm wooden board, the positioning of

    the PCB boards like boot loader board was not catered. However, the positioning of the

    feedback or IR sensor and motor controller board was positioned appropriately.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    23/125

    23

    a) b)Shaft encoder

    Figure 2.1: a) IR sensor board, b) Shaft encoder and IR sensor unit

    2.1 Motor

    The differential system drive unit is designed using differential steering system which uses

    two independently cordless drill DC motor with built in gearbox. The motor is rated at 12V

    each and produces a rated current of 1A. The cordless drill motor is also known as the driver

    motor because it drives the whole differential system. It is a two terminal device which has a

    +ve andve terminal to power up the motor and rotate.

    The reasons for choosing this motor:

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    24/125

    24

    1) It is locally available

    2) It is cheap and cost around FJ$50.00

    3) Capable of generating high torque.

    4) And the performance of the motor has been tested in previous Robocon

    competitions.

    Figure 2.2: 12V Cordless drill motor

    The figure shown above is a 12V driver motor which is used in the differential drive system.

    2.2 Wheels

    The wheels of the differential drive were design out of a timber. The timber was

    designed into a wheel shape by using a lathed machine. The wheels of diameter 135mm

    was made out from a wood. Two pieces of the timber of fifty millimetres was given to the

    technicians to make two wheels of the differential drive steering system. The axle which

    connects the shaft encoder to the motor shaft was made out of aluminium. This

    aluminium axle is locked onto the chuck of the drill motor. The end of the aluminium

    axle which is made rectangular in shape was placed inside the chuck. This was done to

    prevent the axle from slipping while in motion. A round collar was made to securely fix

    the axle to the wooden wheel. Furthermore, a hole was drilled through the collar and the

    axle of the drill motor and a machine screw was used to fix the axle to the collar. A self

    tapping screw was used to fix to axle collar to the wooden wheel. The wheel and axle

    connections were checked thoroughly. The wooden wheel was sanded and brushed with

    sanding sealer. It was also varnish to protect and coat the wood. Rubber glue was then

    applied to the circumference of the wheel and the rubber which was cut to shape in the

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    25/125

    25

    lab was placed on top of it and left to dry in order to keep the rubber securely attached to

    the wooden wheel. This rubber which is covering the circumference allows the robot to

    grip the floor firmly while in motion and to avoid any slips. The rubber was important

    because it will allow the robot to grip properly the floor while moving and avoid slips.

    Figure 2.2 below shows the in-house design and fabricated wooden wheel which was

    used as the steering control for the differential drive system.

    Figure 2.3: In-house fabricated wooden wheel

    Wheel circumference calculation

    The wheels circumference calculation was found using the equation 2.0 stated below

    (Equation 2.0)

    The radius of the driver was set to be 67.5mm, and diameter of the wheel is 135mm hence

    the circumference was found to be:

    mC

    mmC

    C

    rC

    42.0

    424

    )5.67(2

    2

    135mm

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    26/125

    26

    Figure 2.4: Wheel calculation

    Advantages of using wooden wheels are:

    Can be made of any size [compatible for robots application]

    Does not deform in shape under stress

    exact length of distance traveled can be determined from the circumference

    easier to mount to shaft encoder

    it is cheap

    It is easily designed by lathing hardwood with appropriate dimensions

    2.3 PCB Mountings

    This project was entirely base on speed control on the differential drive setup as earlier

    mentioned in this chapter. Hence the PCB mounting was done in a logical manner. The pcb

    mounting of the motor controller unit was done closest to the driver motor. Since the drill

    motor is driven from the motor controller chip and not from the power supply, it was

    necessary to mount the motor controller chip closest to the motor. The associated wires

    which are connected directly to the motor were connected to the 5mm dual connector.

    Moreover, in between the two motor controllers designated for each side, a PCB for LM324

    comparator is mounted onto the 15mm thick wooden board. Since the comparator consist of

    four in-built similar circuits, the two motor controllers can be connected and share just one

    LM324 chip, so it was appropriate to mount it in between the two motor controllers. On the

    other hand, the two boot loader board which has PIC16F877 was mounted right next to the

    motor controller board. The positioning of the boot loader was done away from the drill

    motor. This was done to avoid any disruption in the signals or mechanical damage being

    made to the bootloader board. The PIC micro controller board uses RS232 cable to interface

    between PC and PIC16F877. The PCB mounting for the IR sensors was mounted such that

    the shaft encoder is properly in between the IR sensors and that could have no disturbances

    and emitting and receiving the signals. All of the above mentioned PCB was mounted using

    a glue gun and a silicon type clip which holds the PCB for at certain height above the

    surface. The figure below shows the PCB mounting configuration of the differential drive

    setup. The figure below shows zoom-in PCB a component which is mounted on a 15mm

    thick wooden board.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    27/125

    27

    a) b)

    c)

    d)

    Figures 2.5: a) Motor controller board. b) PIC16F877 boot loader board, c) LM324

    comparator PCB board, d) IR sensor mounting.

    The above figures shows the PCB components which was incorporated in our projects for

    the hardware sections. All the PCB etched was done by the school technician and the circuit

    and schematic diagrams were drawn in the simulation software. The hardware components

    like the connectors, resistors LEDs and duplex wiring wires were purchased form RS

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    28/125

    28

    Company in Australia. The materials for the mechanical parts are added into the part list

    which is shown in the Appendix section of this project.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    29/125

    29

    Chapter 3

    Software Implementation

    A PIC16F877 is a single compact microcontroller which is widely used in industries tocontrol many applications such as an automatic guided vehicle, temperature control, solar

    radiation tracker and many more applications [4].The picture of a PIC16F877A and its corresponding pin layouts

    Figure 3.1: A physical diagram of a single PIC16F877 (Source: The MicrochipPIC16F877A,www.solarbotics.com/products/pic16f877a/

    Figure 3.2: Aphysical pin layoutof a singlePIC16F877

    (Source:PIC16F87XA

    memory

    organizationtutorial,www.microcontroller.com)

    http://www.solarbotics.com/products/pic16f877a/http://www.solarbotics.com/products/pic16f877a/http://www.solarbotics.com/products/pic16f877a/http://www.microcontroller.com/http://www.microcontroller.com/http://www.microcontroller.com/http://www.microcontroller.com/http://www.solarbotics.com/products/pic16f877a/
  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    30/125

    30

    Specifications of PIC16F877

    High Performance

    RSC CPU

    Peripheral features Analogue features CMOS

    Technology

    Operation Speed200 MHz clock

    input and 200 nsinstruction cycle

    Three timersTimer 0 (8 bit)

    Time 1 (16 bit)Timer 2 (8 bit)

    8 channels ADCand 10 bit for each

    channel

    Low-power, highspeed

    Flash/EEPROMtechnology

    112 KB Flashmemory2944 bytes Datamemory (RAM)2048 bytes ofEEPROM DataMemory

    PWM modes:Capture16 bit,resolution is 12.5 nsCompare16 bit,resolution is 200 nsTwo PWM pins foreach PIC

    Brown Out Reset Fully static design

    The pins arecompatible betweentwo PIC16CXXXand PIC16FXXXmicrocontrollers

    Communication:SPIMaster mode andSlave modePSP8 bit withexternal RD, WR andCS controls (40/44 pinonly)

    An Analoguecomparator has:-2 analoguecomparators- Programmablevoltage referenceon the chip module-The comparatoroutputs can beaccessed externally

    Operating voltagestarts from 2 V to5.5 VLow powerconsumption

    Figure 3.3: PIC16F877 specifications (source: Microchip Technology Inc,

    http://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf)

    3.1 Reasons of using PIC16F877

    PIC16F877 is chosen to be used in this project due to its availability in the University ofthe South Pacific and if the chip is faulty it is easy to be replaced. The boot loaderdiagram of PIC16F877 is shown below.

    http://ww1.microchip.com/downloads/en/devicedoc/39582b.pdfhttp://ww1.microchip.com/downloads/en/devicedoc/39582b.pdfhttp://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf
  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    31/125

    31

    Figure 3.4: The boot loader diagram of PIC16F877 (Source: R. Singh, Lecture Notes)

    In figure 3.4, the boot loader is designed in such a way that PIC16F877 can be replacedvery easily when the chip is faulty or the chip is malfunctioned.

    3.2 How a PIC microcontroller communicates with a computer

    In order for a PIC microcontroller (PIC16F877) to communicate to the computer, an RS-232 serial cable is used to transmit data from the computer to PIC microcontroller andvise versa. In addition, a hex file is sent through from the computer to the PICmicrocontroller and this hex file is created after compiling the PIC C program using PICC compiler.

    3.3 The development of PIC communication between three PIC microcontrollers

    To begin with, there are many ways to communicate between two or moremicrocontrollers such as using SPI (Serial Peripheral Interface) communication, I2C(Inter-IC) communication and the most common type of communication is a three-buswire configuration.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    32/125

    32

    In this project, the three-bus wire configuration is used to communicate between PICsmicrocontroller since it is simple and fast. There are three PICs used in thiscommunication and out of these three, one is the master and the other two are the slaves.Moving on, the task of the master is to send a duty cycle (50%) to the two slaves so thatthe two slaves can operate the motors using this initial duty cycle (sent by the master)

    respectively. The two motors. And the achieve this, three wires are usedone wire forthe data, one wire for latch and one wire for the clock and these wires are parallel to eachPIC. In addition, this can be illustrated from the diagram shown below.

    Figure 3.5 (A 3 bus-wire configuration)

    3.4 Programming Development

    In order to send a data to each slave, the data has to be packed in a packet and has to bechanged to a binary number for sending purposes. The most challenged part of thecommunication is developing a packet. In this project the data that is send from themaster to the slaves contains the duty cycle and the direction of each motor. Thecalculation of the packet using high level program (PIC C language)

    Packet = (dir1*2) + (dir2*4) + (duty1*256) + (duty2*65536); // packet calculation

    Parameters

    Dir1direction for motor 2Dir2- direction of motor 2

    Duty1-duty cycle of motor 1Duty2-duty cycle of motor 2

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    33/125

    33

    Moreover, all the duty cycle and the directions of the motor has to be put in the packet inthe sense that after sending the packet the respect slave will do another calculation toextract the duty cycle and the direction information. In order to send the data from themaster the total packet has to be changed to binary and then send one by one bit to bothslaves. The flow charts shown below explain how the master can communicates to each

    respective slave.

    Figure 3.6a: Master flow chart

    Figure 3.6b: Master flow chart

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    34/125

    34

    From the two figures there are three pins allocated for the master to communicate the twoslaves. The first pin is used for latch and this pin is used to enable a communication, thenext pin is the clock, the clock trigger when will be the data send (for example: the data issend at the rising edge of the clock) and last the pin is for data transmission. In thefollowing flow chart it shows how each slave communicates to the master PIC.

    Figure 3.7a: Slave 1 flow chart

    Figure 3.7b slave 1 flow chart continued

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    35/125

    35

    Figure 3.7c: Slave 1 flow char continued

    Figure 3.7d: slave 1 flow chart continued

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    36/125

    36

    Figure 3.7e: slave 1 flow chart continued

    In the main program (Figure 3.6a), the program first initialize all the variables, setup aPWM mode by using - setup_ccp2 (CCP_PWM) and setting up a try state buffer pins.Then the program check if the data has been receive by the master(Figure 3.6 b)this isdone by checking the state of latch in the program (if latch highdata is ready to send,data transmitted, if latch lowdata is not ready for transmission). In addition if the datahas received by the respective slave it will return this value to the main to update thepwm value and thus the motor starts to rotate with this pwm value with the initial dutycycle of 50% (receive by the master).Moreover, the main program always checks the #int_timer1 (Figure 3.7c) and incrementsthe counter by 1 at every time the timer is over flow, the final value of the counter isimportant in calculating the speed of the motor. In addition, the speed is calculated inevery one complete revolution and this shows in the equation shown below.Mesr_rpm = 60 / spr (sprseconds per revolution)

    To calculate the time in seconds per revolution is calculated in the equation given below.Spr= ((counter x 0.065536) + (0.000001 x get_timer1 ()))

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    37/125

    37

    The speed calculation is explained in more detailed in the figure 3.7f.

    Figure 3.7f: Speed calculation of one wheel

    Next, the program will try to compare the calculated speed with required speed by theuser. However the speed are different, the difference between the speed is called the error

    and this will then pass to another subroutine called update_pid and this function will tryto correct the error in a minimum number of time (this is shown in figure 3.7d). Theupdate_pid () has three important part such as integral term, derivative term andproportional term. The integral term is just add up the previous error with the currenterror and then multiply it with the integral gain (Ki), however there will the time that thesum of errors exceeds the maximum limit (maximum duty cycle), therefore the sum oferror has to limit within 100 and -100 and this is important in this project. In thederivative term, the previous error has to be subtracted from the current error and thenmultiply with the gain (Kd). For the proportional term, the current error is alwaysmultiply with proportional gain (Kp). (To find the proper gain value for Kp, Ki and Kdeach has to derive the transfer function of the motor and this is done in more detail in

    chapter five of this project). The total sum of all the proportional term the integral termand the derivative term is then add up and stored in correction. The correction value isthen limited again within 100 and -100 before sending this value to another subroutinecalled stabilize. In stabilize function; the correction value is then divided with 100 sincethe correction value must be in percentage form. This correction value will update theduty cycle value every time to change the speed of the motor according the referencespeed given from the user.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    38/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    39/125

    39

    3-State Outputs Minimized Power Dissipation Sink/Source Interlock Circuitry Prevents Simultaneous Conduction No Output Glitch During Power Up or Power Down

    4.1.1 Other Parameters:Table 4.1 Parameters for sn754410 chip

    Output Voltage(Max)(V) 36

    Switching Voltage(Max)(V) 36

    Peak Output Current(mA) 2000

    Drivers Per Package 4

    Input Compatibility CMOS, TTL

    Delay Time(ns) 800

    Operating TemperatureRange(C

    -40 to 85

    Pin/Package 16PDIP

    Fig 4.1 sn754410 chip

    4.2 Advantages of using SN754410 Chip

    One major advantage of using SN754410 chip is that it is really cheap and readilyavailable. One chip costs about US$2.95 that is approximately FJ$7.00 whereas anOSMC power board is about FJ$400. Thus, if the OSMC board gets bad it has a very

    high maintenance cost and is difficult to repair whereas if SN754410 chip goes bad itseasy to replace than to replace an OSMC board.

    4.3 Disadvantages of using SN754410 Chip

    The disadvantage of using the SN754410 chip is that it heats up very quickly. Chips hadto be in parallel since it provides less output current. Since there are four set of Half H-

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    40/125

    40

    bridge in one chip we had to parallel six Half H-bridges (or three full H-bridges) toincrease the current output. This means to drive one motor we used one and half chipalong with a heavy heat sink and a fan to prevent the chip from burning out.

    4.4 Schematic Diagram of SN754410 chips Connection to Motors

    Figure 4.2 schematic of sn754410

    The chip shows that to run two motors we have to loop three chips to increase the currentoutput. One and half chip is looped together for one motor.

    M2M1

    R6

    1k

    R5

    1k

    R4

    1k

    R3

    1k

    R2

    1k

    R1

    1k

    +V5V

    +

    12V

    SN745510

    P1

    P2

    P3

    P4

    P5

    P6

    P7

    P8 P9

    P10

    P11

    P12

    P13

    P14

    P15

    P16

    U3

    SN745510

    P1

    P2

    P3

    P4

    P5

    P6

    P7

    P8 P9

    P10

    P11

    P12

    P13

    P14

    P15

    P16

    U2

    SN745510

    P1

    P2

    P3

    P4

    P5

    P6

    P7

    P8 P9

    P10

    P11

    P12

    P13

    P14

    P15

    P16

    U1

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    41/125

    41

    4.5 Connections to the Chip

    Figure 4.3 Pin connection for sn754410

    EN 1A 2A FUNCTION

    H L H Turn right

    H H L Turn left

    H L L Fast motor stop

    H H H Fast motor stop

    L X X Fast motor stop

    Table 4.2 Truth table for SN754410

    L = Low

    H = High

    X = dont care

    4.5.1 Wiring Diagram for the SN754410

    The table 4.3 below shows how the chip is connected to the motor using two H-bridges.

    Pin Name Full H-BridgeFunction

    Notes

    1 1,2EN Motor 1 Enable 0V (LOW) = disable motor5V (HIGH) = enable motor

    2 1A Motor 1 Clockwise /Forward

    0V (LOW) = ignore5V (HIGH) = apply current in one direction

    3 1Y Motor 1 Power(Output)

    4 Ground Ground All 4 pins are grounded

    5 Ground Ground All 4 pins are grounded

    6 2Y Motor 1 Power(Output)

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    42/125

    42

    7 2A Motor 1Counterclockwise /Reverse

    0V (LOW) = ignore5V (HIGH) = apply current in the otherdirection

    8 VCC2 Motor Power Source(Input

    attached directly to battery

    9 3,4EN Motor 2 Enable 0V (LOW) = disable motor5V (HIGH) = enable motor

    10 3A Motor 2 Clockwise /Forward

    0V (LOW) = ignore5V (HIGH) = apply current in one direction

    11 3Y Motor 2 Power(Output)

    12 Ground Ground All 4 pins are grounded

    13 Ground Ground All 4 pins are grounded

    14 4Y Motor 2 Power(Output)

    15 4A Motor 2Counterclockwise /Reverse

    0V (LOW) = ignore5V (HIGH) = apply current in the otherdirection

    16 VCC1 IC Logic Power(Input)

    Regulated 5v (VCC / VDD)

    4.5.1 12VDC Cordless Drill Motor

    The Robocon Groups have extensively been using the 12VDC cordless drill motors

    mostly because it is very cheap (costing close to $50FJD) compared to other kinds of DC

    motors. Hence, we also used the cordless drill motor for our differential drive setup. The

    speed of this motor is easily controlled by varying either the armature voltage or field

    current. These 12V cordless Drill motors are series-wound DC motors, where the

    stationary and rotating coils are wires in series.

    Figure 4.4 cordlessdrill motor

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    43/125

    43

    4.6 Testing of SN754410

    The chip was tested with a cordless drill motor running in clockwise direction withdifferent voltages and the current output and rpm was tabulated.

    Figure 4.5 shows the testing for sn754410 chip

    Table 4.4 testing results

    Test Number Voltage (V) Current (A) RPM

    1 12 1.17 494.1

    2 11.5 1.12 480

    3 11 1.09 445.8

    4 10.5 1.07 424.4

    5 10 1.04 410.3

    6 9.5 1.03 380.1

    7 9 0.99 351.3

    8 8.5 0.98 325.3

    9 8 0.94 294.6

    10 7.5 0.92 215.9

    11 7 0.88 246.9

    12 6.5 0.87 222.913 6 0.85 195.1

    14 5.5 0.83 168.2

    15 5 0.79 148.4

    16 4.5 0.75 119

    17 4 0.71 99.8

    18 3.5 0.68 80.9

    19 3 0.64 53.5

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    44/125

    44

    20 2.5 0.6 28.8

    21 2 0.02 0

    Figure 4.5.1 Graph of current, voltage and rpm for sn754410 chip

    The graph states that when the voltage decreases the current and the rpm decreasesrespectively. At no load condition the motor can run on a minimum of 2.5 volts. At 2volts the motor stops since the current is very low.

    4.7 Differential Drive

    The term 'differential' means that robot turning speed is determined by the speeddifference between both wheels, each on either side of your robot [5]. The differentialdrive consists of two wheels independently controlled by two motors. Such anarrangement allows the robot to move forward and backwards, turn in place, and turnwhile moving. As our setup is a replica of a differential drive system and has both of themotor placed opposite direction to each other, one wheel has to move in clockwisedirection and the other has to move in anti-clockwise direction. Since the clockwise andanti-clockwise speeds of the motors are different. The Motors speeds need to besynchronized in order to be at the same speed. The motor speeds are synchronized using

    PID control.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    45/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    46/125

    46

    Figure 4.8 One output on the SN754410 chip

    However, to control the speed of the DC motors digitally a Pulse Width Modulation(PWM) signals using the PIC microcontroller was used. The micro-controller, PIC

    16F877 supplies appropriate PWM to the SN754410 which than controls the appropriatemotors.To control the speed of a DC motor we need a variable voltage DC power source.However if you take a 12V motor and switch on the power to it, the motor will start tospeed up: motors do not respond immediately so it will take a small time to reach fullspeed. If we switch the power off sometime before the motor reaches full speed, then themotor will start to slow down. [2]

    If we switch the power on and off quickly enough, the motor will run at some speedbetween zero and full speed. This is exactly what a PWM (pulse width modulation) is [3].The controller switches the motor on in a series of pulses. To control the motor speed it

    varies (modulates) the width of the pulses - hence Pulse Width Modulation.

    PWM, Pulse Width Modulation, involves taking a square wave and, without changingthe frequency, changing how long in each cycle the wave spends high and low. The ratioof t-high/t-low is the signal's duty cycle. The higher the duty cycle, the higher theaverage voltage on the signal line and the higher the power the signal delivers. In thebasic Pulse Width Modulation (PWM) method, the operating power to the motors isturned on and off to modulate the current to the motor. The ratio of "on" time to "off"time is what calculates the speed of the motor.

    Figure 4.9 shows the PWM signal

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    47/125

    47

    4.7.2 Duty Cycle

    The use of PWM to drive the DC motors makes implementation easier because of greatercircuit simplicity. Additionally, the use of PWM signals allows one to vary motor speedsimply by changing the Duty Cycle or the Time on part of the PWM signal shown Duty

    Cycle can be derived as [4]

    %100

    onoff

    on

    TT

    TDutyCycle

    (Eqn

    4.1)Where: - Ton = Time On

    : - Toff= Time Off

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    48/125

    48

    Chapter 5

    Shaft Encoder5.0 Introduction

    The shaft encoder is used to provide feedback from the wheels. the encoder is veryessential in controlling the speed of the automatic vehicle. the encoder provides a signalproduced by the rotation of the wheel is the feedback that is fed back to interrupt port ofthe microprocessor that is port b.The robotic group at the university of the south pacific has used various shaft encoders toget feedback of the motor speed from the wheels. the most common shaft encoders usedby the groups are heds and oktec pair in house built shaft encoder to filter feedback.

    5.1 HEDS 5540 a06

    The previous year project groups have used HEDS 5540 a06 as their shaft encoder. each

    encoder contains a lensed led source, an integrated circuit with detectors and outputcircuitry, and a code wheel which rotates between the emitter and detector IC thisencoder has 1024 counts per revolution and its maximum operating frequency is100Khz.It has three channels (channel i, channel a and channel b).

    Figure 5.1 heds 5540 a06features

    Supply voltage 5 v _ 10 %Output signal ttl compatible

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    49/125

    49

    Phase shift _ (nominal) 90eLogic state width s min. 45eSignal rise time(Typical at cl = 25 pf, rl = 2.7 k_, 25c) 180 nsSignal fall time

    (Typical at cl = 25 pf, rl = 2.7 k_, 25c) 40 nsIndex pulse width (nominal) 90eOperating temperature range -40 ... +100cMoment of inertia of code wheel _ 0.6 gcm2Max. Angular acceleration 250 000 rad s-2output current per channel min. -1 ma, max. 5 ma

    5.1.1 Advantages of using HEDS 5540 a06

    The major advantages of using this shaft encoder are:

    It offers high resolution (that is it gives a high precision).

    Enclosed device therefore it is not affected by external light sources.

    5.1.2 Disadvantages of using heds 5540 a06

    The disadvantage of using this shaft encoder is that it very expensive and maintenance isvery costly. Each HEDS 5540 a06 cost about 114 Australian dollars. Also it has a highresolution which is not needed for our application.HEDS 5540 a06 has 1024 pulses per revolution means it has 512 slots. the wheeldiameter is 140mm so the circumference is:

    Circumference = 2r= 2 x x 0.14= 0.44m

    Each time the wheel makes a turn it rotates 360 and since there are 1024 pulses perrevolution the angle of each pulse is given as:

    =1024

    360

    = 0.35

    Hence, the linear distance that the wheel moves when one of the 1024 pulses passes by isgiven as:

    d =360

    x circumference

    =

    360

    35.0x 0.44m

    = 0.000427m

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    50/125

    50

    Therefore it gives feedback at every 0.35 turn and the linear distance which the wheelmoves is 0.000854m which is very precise and not needed for our application.

    5.2 Oktec pair shaft encoder

    For our application we have used a oktec pair shaft encoder to filter feedback. oktec pairshaft encoder is an in-house built shaft encoder. Its a 16 slot encoder cut out on 5mmaluminum plate together with a pair of IR phototransistor/photodiode (op140/op550)sensors used to design the shaft encoder. Both have the same emitting and receivingfrequency

    Figure 5.2 hardware setup for oktec shaft encoder

    Figure 5.3 16 slots aluminum plate

    This 16-slot encoder is not capable of differentiating between CW and ACW directionwhich incorporates a comparator circuit designed using lm324 operational amplifier. Thetwo 1k ohm resistors are placed such that the comparator threshold voltage is 2.5v.henceany input signals blow this threshold voltage would produce a logic low output and abovethis threshold voltage would produce a logic high output.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    51/125

    51

    Figure 5.4 shows the shaft encoder between two ir sensors along with the comparatorcircuit.

    5.2.1 Advantages of using oktec pair

    The major advantage of using the in-house built shaft encoder is that: Cheaper (as compared to other encoders which are bought).

    Since it is built in-house any problems can be easily resolved.

    it is suitable for this particular application

    A 16 slot shaft encoder generates 32 pulses per revolution. The wheel diameter is 140mmso the circumference is:

    r = 70mm = 0.07mCircumference = 2r

    = 2 x x 0.07= 0.44m

    Each time the wheel makes a turn it rotates 360 and since there are 32 pulses perrevolution the angle of each pulse is given as:

    =32

    360

    = 11.25Hence, the linear distance that the wheel moves when one of the 1024 pulses passes by isgiven as:

    d =360

    x circumference

    =

    360

    25.11x 0.44m

    = 0.01375mTherefore it gives feedback at every 11.25 turn and the linear distance which the wheelmoves is 0.01375m which is applicable for our application.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    52/125

    52

    5.2.2 Disadvantages of using oktec pair

    The major disadvantage of using this shaft encoder is that there could be errors if lightsfrom external sources pass through the shaft encoder. The light can interface with the IR

    sensors and cause errors. Therefore, to reduce this error an external cover is needed.

    5.3 Comparator

    The main purpose comparator circuit (lm324 operational amplifier) is to smoothen theoutput that is coming from the receiving sensor. For the operational amplifier to functiona +5 volts and a ground have to be supplied

    5.3.1 Output from the comparator

    Figure 5.6 shows the signal given by the ir sensors which is amplified by the comparatorcircuit giving a smooth square wave signal (0v and 5v).

    Figure 5.6: Output from the comparator

    CHAPTER 6

    Figure 5.5 shows the hardware for the comparator circuit

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    53/125

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    54/125

    54

    30984 182301 0.182301 267.1916

    29969 212270 0.21227 268.3087

    30815 243085 0.243085 267.3582

    28845 271930 0.27193 269.4353

    32102 304032 0.304032 265.6395

    31457 335489 0.335489 266.508

    33264 368753 0.368753 264.4407

    29894 398647 0.398647 268.268

    29857 428504 0.428504 268.4408

    30026 458530 0.45853 268.3892

    30699 489229 0.489229 267.4059

    29103 518332 0.518332 269.2805

    32742 551074 0.551074 265.0786

    37491 588565 0.588565 259.6178

    43586 632151 0.632151 252.9458

    4493 636644 0.636644 251.34264818 641462 0.641462 248.0302

    48968 690430 0.69043 247.1617

    42646 733076 0.733076 253.7438

    40656 773732 0.773732 255.7959

    41805 815537 0.815537 254.7046

    45116 860653 0.860653 251.2373

    43568 904221 0.904221 252.8733

    43682 947903 0.947903 252.6752

    46146 994049 0.994049 250.0615

    4441 998490 0.99849 251.954845247 1043737 1.043737 251.0429

    47278 1091015 1.091015 248.9596

    46483 1137498 1.137498 249.8772

    45687 1183185 1.183185 250.5272

    4627 1187812 1.187812 250.0365

    47763 1235575 1.235575 248.4277

    4583 1240158 1.240158 250.3902

    46461 1286619 1.286619 249.7409

    4846 1291465 1.291465 247.6688

    46397 1337862 1.337862 249.864746715 1384577 1.384577 249.4958

    48774 1433351 1.433351 247.3829

    46806 1480157 1.480157 249.4357

    47962 1528119 1.528119 248.2396

    48703 1576822 1.576822 247.5217

    45985 1622807 1.622807 250.3327

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    55/125

    55

    47455 1670262 1.670262 248.7645

    48523 1718785 1.718785 247.5697

    48025 1766810 1.76681 248.2663

    4781 1771591 1.771591 248.4092

    46636 1818227 1.818227 249.6495

    49436 1867663 1.867663 246.6781

    46862 1914525 1.914525 249.3735

    4718 1919243 1.919243 249.1415

    49851 1969094 1.969094 246.3236

    47496 2016590 2.01659 248.683

    47298 2063888 2.063888 248.9286

    50898 2114786 2.114786 245.3235

    47915 2162701 2.162701 248.2766

    49274 2211975 2.211975 246.938

    50718 2262693 2.262693 245.3877

    49804 2312497 2.312497 246.36249328 2361825 2.361825 246.9177

    4996 2366821 2.366821 246.2842

    50158 2416979 2.416979 246.0358

    49522 2466501 2.466501 246.7643

    4959 2471460 2.47146 246.5585

    51657 2523117 2.523117 244.4649

    48569 2571686 2.571686 247.6177

    49159 2620845 2.620845 247.058

    51866 2672711 2.672711 244.3066

    Step 2: Draw transient response of the graph

    From the above data, the transient response was drawn using Microsoft Excel. This graph shows

    the transient response of the motor with respect to time.

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    56/125

    56

    Figure 6.1 Shows the Graph of Motor Speed versus time at 35% duty cycle

    From the above graph the settling time is assumed to be 0.860653 seconds as shown

    on the graph.

    ts =0.860653 s

    Step 3: Step Response

    As referenced from the text Feedback control of dynamic systems[9] the step

    response of a motor is given by:

    tety

    1)( (Eqn 6.1)

    Thus, to use the above equation, we need to calculate the value of sigma (). If we

    want the settling time to occur when the decaying exponential reaches 1% ~

    (0.01),the following equations were derived as shown below.

    0

    50

    100

    150

    200

    250

    300

    350

    0 0.5 1 1.5 2 2.5 3

    Graph of Motor Speed Versus Time @ 35% duty

    cycle

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    57/125

    57

    ns

    sn

    sn

    tW

    Wt

    tW

    tW

    e sn

    61.4

    61.4

    )01.0ln(

    01.0

    Since, wn =

    Therefore, we can calculate :

    61.4st (Eqn 6.2)

    st

    61.4 (Eqn 6.3)

    Using equation 6.3 and the settling time from step 2, we can now calculate the value of

    sigma ().

    356.5

    860653.0

    61.4

    61.4

    st

    Now, we know the value of sigma and can use the equation 6.1 from step 3 to calculate thestep response.

    Table 6.2

    The table below shows the step response figures at 35% duty cycle.

    Cumulative Time (s) - x t Exp(- x t) y(t)

    00 1 0

    0.001482 -0.007937592 0.992093827 0.007906173

    0.017756 -0.095101136 0.909280969 0.090719031

    0.03461 -0.18537116 0.830795868 0.169204132

    0.062752 -0.336099712 0.714551853 0.2854481470.087872 -0.470642432 0.624600876 0.375399124

    0.1154 -0.6180824 0.53897699 0.46102301

    0.148382 -0.794733992 0.451701375 0.548298625

    0.151317 -0.810453852 0.444656212 0.555343788

    0.182301 -0.976404156 0.376663088 0.623336912

    0.21227 -1.13691812 0.320806186 0.679193814

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    58/125

    58

    0.243085 -1.30196326 0.271997267 0.728002733

    0.27193 -1.45645708 0.233060529 0.766939471

    0.304032 -1.628395392 0.196244217 0.803755783

    0.335489 -1.796879084 0.165815578 0.834184422

    0.368753 -1.975041068 0.138755614 0.861244386

    0.398647 -2.135153332 0.118226461 0.881773539

    0.428504 -2.295067424 0.1007546 0.8992454

    0.45853 -2.45588668 0.085787096 0.914212904

    0.489229 -2.620310524 0.072780259 0.927219741

    0.518332 -2.776186192 0.062275562 0.937724438

    0.551074 -2.951552344 0.05225852 0.94774148

    0.588565 -3.15235414 0.042751366 0.957248634

    0.632151 -3.385800756 0.033850525 0.966149475

    0.636644 -3.409865264 0.033045653 0.966954347

    0.641462 -3.435670472 0.032203811 0.967796189

    0.69043 -3.69794308 0.024774433 0.9752255670.733076 -3.926355056 0.019715403 0.980284597

    0.773732 -4.144108592 0.015857565 0.984142435

    0.815537 -4.368016172 0.012676363 0.987323637

    0.860653 -4.609657468 0.009955228 0.990044772

    0.904221 -4.843007676 0.007883308 0.992116692

    0.947903 -5.076968468 0.006238793 0.993761207

    0.994049 -5.324126444 0.004872606 0.995127394

    0.99849 -5.34791244 0.004758073 0.995241927

    1.043737 -5.590255372 0.003734074 0.996265926

    1.091015 -5.84347634 0.002898748 0.9971012521.137498 -6.092439288 0.00225989 0.99774011

    1.183185 -6.33713886 0.001769357 0.998230643

    1.187812 -6.361921072 0.001726048 0.998273952

    1.235575 -6.6177397 0.001336448 0.998663552

    1.240158 -6.642286248 0.001304042 0.998695958

    1.286619 -6.891131364 0.001016763 0.998983237

    1.291465 -6.91708654 0.000990712 0.999009288

    1.337862 -7.165588872 0.000772724 0.999227276

    1.384577 -7.415794412 0.000601674 0.999398326

    1.433351 -7.677027956 0.00046335 0.999536651.480157 -7.927720892 0.000360607 0.999639393

    1.528119 -8.184605364 0.000278914 0.999721086

    1.576822 -8.445458632 0.000214874 0.999785126

    1.622807 -8.691754292 0.000167965 0.999832035

    1.670262 -8.945923272 0.000130267 0.999869733

    1.718785 -9.20581246 0.000100454 0.999899546

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    59/125

    59

    1.76681 -9.46303436 7.76706E-05 0.999922329

    1.771591 -9.488641396 7.57069E-05 0.999924293

    1.818227 -9.738423812 5.89734E-05 0.999941027

    1.867663 -10.00320303 4.52547E-05 0.999954745

    1.914525 -10.2541959 3.52095E-05 0.999964791

    1.919243 -10.27946551 3.43309E-05 0.999965669

    1.969094 -10.54646746 2.62862E-05 0.999973714

    2.01659 -10.80085604 2.0382E-05 0.999979618

    2.063888 -11.05418413 1.58208E-05 0.999984179

    2.114786 -11.32679382 1.20458E-05 0.999987954

    2.162701 -11.58342656 9.31927E-06 0.999990681

    2.211975 -11.8473381 7.15758E-06 0.999992842

    2.262693 -12.11898371 5.45497E-06 0.999994545

    2.312497 -12.38573393 4.17777E-06 0.999995822

    2.361825 -12.6499347 3.20777E-06 0.999996792

    2.366821 -12.67669328 3.12307E-06 0.9999968772.416979 -12.94533952 2.38732E-06 0.999997613

    2.466501 -13.21057936 1.83113E-06 0.999998169

    2.47146 -13.23713976 1.78313E-06 0.999998217

    2.523117 -13.51381465 1.35215E-06 0.999998648

    2.571686 -13.77395022 1.04244E-06 0.999998958

    2.620845 -14.03724582 8.01127E-07 0.999999199

    2.672711 -14.31504012 6.06816E-07 0.999999393

    A step response graph was drawn as shown in Figure 6.2.

    Figure 6.2 shows the step response of the Graph of Motor at 35% duty cycle

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    60/125

    60

    From the above graph it can be demonstrated that the settling time of 0.904221s

    is achieved at 0.992116692 as marked on the graph, at this point the exponential

    decay reaches within 1% of the final value. By looking at the step response

    graph above, we can assume that it is given by a sum of exponentials, thus we

    can write

    (Eqn6.4)

    Subtracting off the final value and assuming that

    - (alpha) is the slowest pole, the following equation can be written as:

    (Eqation 6.5)

    The slope of the equation 5.5 gives the value of alpha (), and the intercept gives the value of

    A. If equation 5.5 is plotted (log graph) it should result in the positive value of A because we

    use log(y (t)-y (infinity)). Step 4 shows how A and was calculated.

    0

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    0 0.5 1 1.5 2 2.5 3

    Graph of y(t) vs Time (s)

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    61/125

    61

    Step 4: Drawing log(y (t)-y ()) vs. time graph and calculating the value of constant Aand alpha ().

    Table 6.3

    The table below shows the log(y (t)y ()) data at 35% duty cycle.

    Cumulative Time (s) 1 - y(t) Log |1 - y(t)|

    01 0

    0.001482 0.992093827 -0.003447252

    0.017756 0.909280969 -0.041301899

    0.03461 0.830795868 -0.080505672

    0.062752 0.714551853 -0.14596625

    0.087872 0.624600876 -0.204397411

    0.1154 0.53897699 -0.268429776

    0.148382 0.451701375 -0.3451485870.151317 0.444656212 -0.351975636

    0.182301 0.376663088 -0.424046937

    0.21227 0.320806186 -0.493757266

    0.243085 0.271997267 -0.565435459

    0.27193 0.233060529 -0.632531273

    0.304032 0.196244217 -0.707203133

    0.335489 0.165815578 -0.780374671

    0.368753 0.138755614 -0.857749437

    0.398647 0.118226461 -0.92728531

    0.428504 0.1007546 -0.9967351180.45853 0.085787096 -1.066578033

    0.489229 0.072780259 -1.137986401

    0.518332 0.062275562 -1.205682344

    0.551074 0.05225852 -1.281842896

    0.588565 0.042751366 -1.369050008

    0.632151 0.033850525 -1.470434585

    0.636644 0.033045653 -1.480885668

    0.641462 0.032203811 -1.492092728

    0.69043 0.024774433 -1.605996274

    0.733076 0.019715403 -1.7051943350.773732 0.015857565 -1.799763494

    0.815537 0.012676363 -1.89700532

    0.860653 0.009955228 -2.001948802

    0.904221 0.007883308 -2.10329151

    0.947903 0.006238793 -2.20489939

    0.994049 0.004872606 -2.312238736

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    62/125

    62

    0.99849 0.004758073 -2.322568862

    1.043737 0.003734074 -2.42781706

    1.091015 0.002898748 -2.53778953

    1.137498 0.00225989 -2.645912764

    1.183185 0.001769357 -2.752184438

    1.187812 0.001726048 -2.762947216

    1.235575 0.001336448 -2.874047834

    1.240158 0.001304042 -2.884708265

    1.286619 0.001016763 -2.992780325

    1.291465 0.000990712 -3.004052515

    1.337862 0.000772724 -3.111975707

    1.384577 0.000601674 -3.220638592

    1.433351 0.00046335 -3.334090879

    1.480157 0.000360607 -3.442965437

    1.528119 0.000278914 -3.554528946

    1.576822 0.000214874 -3.6678160811.622807 0.000167965 -3.774780927

    1.670262 0.000130267 -3.885165113

    1.718785 0.000100454 -3.998033553

    1.76681 7.76706E-05 -4.109743605

    1.771591 7.57069E-05 -4.120864599

    1.818227 5.89734E-05 -4.229343724

    1.867663 4.52547E-05 -4.344335876

    1.914525 3.52095E-05 -4.453340696

    1.919243 3.43309E-05 -4.464315147

    1.969094 2.62862E-05 -4.5802726232.01659 2.0382E-05 -4.690752178

    2.063888 1.58208E-05 -4.800771169

    2.114786 1.20458E-05 -4.919164052

    2.162701 9.31927E-06 -5.030618235

    2.211975 7.15758E-06 -5.145233562

    2.262693 5.45497E-06 -5.263207751

    2.312497 4.17777E-06 -5.379055901

    2.361825 3.20777E-06 -5.493796837

    2.366821 3.12307E-06 -5.505417939

    2.416979 2.38732E-06 -5.6220895222.466501 1.83113E-06 -5.737281717

    2.47146 1.78313E-06 -5.748816754

    2.523117 1.35215E-06 -5.868975133

    2.571686 1.04244E-06 -5.981950573

    2.620845 8.01127E-07 -6.096298401

    2.672711 6.06816E-07 -6.216942931

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    63/125

    63

    The graph of Log |1y(t)| vs. time was obtained from table 6.3 above.

    Figure 6.3 shows the graph of Log |1 y (t)| vs. timemotor at 35% duty cycle

    From the graph in Figure 6.3 and equation 6.5, we now calculate the value of A and alpha

    ().

    1

    0log10

    A

    A

    Using equation 6.5 and the slope of the graph in figure 6.3 the value of is calculated as

    shown:

    -7

    -6

    -5

    -4

    -3

    -2

    -1

    0

    0 0.5 1 1.5 2 2.5 3

    Graph of Log |1 - y(t)| vs Time (s)

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    64/125

    64

    383.5

    338.24343.0

    768779.1

    113708.4

    904221.0673.2

    103292.2217.64343.0

    Step 5: Drawing log Be-t

    Vs. time graph and calculating the value of B and.

    Table 6.4

    Cumulative

    Time (s)

    - x t Exp(- x t) 1 + A*Exp(-

    x t)

    1 + A*Exp(-

    x t) y(t)

    Log (1 + A*Exp(-

    x t) y(t))

    00 1 2 2 0.301029996

    0.001482 -0.007977606 0.992054131 1.992054131 1.984147958 0.297574054

    0.017756 -0.095580548 0.908845153 1.908845153 1.818126122 0.259624007

    0.03461 -0.18630563 0.830019877 1.830019877 1.660815746 0.220321454

    0.062752 -0.337794016 0.71334221 1.71334221 1.427894063 0.154695988

    0.087872 -0.473014976 0.623120739 1.623120739 1.247721615 0.0961176990.1154 -0.6211982 0.537300259 1.537300259 1.076277248 0.03192416

    0.148382 -0.798740306 0.449895338 1.449895338 0.901596713 -0.04498768

    0.151317 -0.814539411 0.442843249 1.442843249 0.887499461 -0.051831902

    0.182301 -0.981326283 0.37481366 1.37481366 0.751476748 -0.124084452

    0.21227 -1.14264941 0.318972812 1.318972812 0.639778998 -0.193970021

    0.243085 -1.308526555 0.270217914 1.270217914 0.542215182 -0.265828327

    0.27193 -1.46379919 0.231355639 1.231355639 0.464416167 -0.33309267

    0.304032 -1.636604256 0.194639869 1.194639869 0.390884085 -0.407952011

    0.335489 -1.805937287 0.164320369 1.164320369 0.330135947 -0.481307185

    0.368753 -1.984997399 0.137380971 1.137380971 0.276136585 -0.558876050.398647 -2.145916801 0.116960758 1.116960758 0.235187219 -0.628586283

    0.428504 -2.306637032 0.099595626 1.099595626 0.200350226 -0.698210164

    0.45853 -2.46826699 0.084731572 1.084731572 0.170518669 -0.768228067

    0.489229 -2.633519707 0.071825213 1.071825213 0.144605472 -0.839815271

    0.518332 -2.790181156 0.061410088 1.061410088 0.12368565 -0.907680684

    0.551074 -2.966431342 0.051486721 1.051486721 0.103745241 -0.984031816

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    65/125

    65

    0.588565 -3.168245395 0.042077362 1.042077362 0.084828728 -1.071457046

    0.632151 -3.402868833 0.033277665 1.033277665 0.06712819 -1.173095061

    0.636644 -3.427054652 0.032482472 1.032482472 0.065528125 -1.183572261

    0.641462 -3.452989946 0.03165086 1.03165086 0.063854672 -1.194807324

    0.69043 -3.71658469 0.024316876 1.024316876 0.049091309 -1.308995388

    0.733076 -3.946148108 0.019329012 1.019329012 0.039044415 -1.408441078

    0.773732 -4.164999356 0.015529725 1.015529725 0.03138729 -1.503246178

    0.815537 -4.390035671 0.012400287 1.012400287 0.02507665 -1.600730477

    0.860653 -4.632895099 0.009726559 1.009726559 0.019681787 -1.70593548

    0.904221 -4.867421643 0.007693175 1.007693175 0.015576483 -1.807530583

    0.947903 -5.102561849 0.006081148 1.006081148 0.012319941 -1.909391369

    0.994049 -5.350965767 0.004743568 1.004743568 0.009616173 -2.016997721

    0.99849 -5.37487167 0.004631513 1.004631513 0.009389586 -2.027353535

    1.043737 -5.618436271 0.003630313 1.003630313 0.007364388 -2.132863358

    1.091015 -5.872933745 0.002814604 1.002814604 0.005713352 -2.243109023

    1.137498 -6.123151734 0.002191538 1.002191538 0.004451428 -2.3515006871.183185 -6.369084855 0.001713727 1.001713727 0.003483084 -2.458036027

    1.187812 -6.393991996 0.00167157 1.00167157 0.003397618 -2.468825499

    1.235575 -6.651100225 0.001292599 1.001292599 0.002629047 -2.58020157

    1.240158 -6.675770514 0.001261101 1.001261101 0.002565143 -2.590888422

    1.286619 -6.925870077 0.000982048 1.000982048 0.001998811 -2.699228237

    1.291465 -6.951956095 0.000956762 1.000956762 0.001947474 -2.710528344

    1.337862 -7.201711146 0.000745309 1.000745309 0.001518033 -2.818718733

    1.384577 -7.453177991 0.000579597 1.000579597 0.001181271 -2.927650474

    1.433351 -7.715728433 0.000445761 1.000445761 0.000909111 -3.041383283

    1.480157 -7.967685131 0.00034648 1.00034648 0.000707087 -3.1505268681.528119 -8.225864577 0.000267641 1.000267641 0.000546555 -3.262365868

    1.576822 -8.488032826 0.000205918 1.000205918 0.000420792 -3.375932563

    1.622807 -8.735570081 0.000160764 1.000160764 0.00032873 -3.483161196

    1.670262 -8.991020346 0.000124523 1.000124523 0.00025479 -3.593817426

    1.718785 -9.252219655 9.58986E-05 1.000095899 0.000196352 -3.706963848

    1.76681 -9.51073823 7.40524E-05 1.000074052 0.000151723 -3.818948846

    1.771591 -9.536474353 7.21708E-05 1.000072171 0.000147878 -3.830097202

    1.818227 -9.787515941 5.61482E-05 1.000056148 0.000115122 -3.938843129

    1.867663 -10.05362993 4.30293E-05 1.000043029 8.8284E-05 -4.054117913

    1.914525 -10.30588808 3.34356E-05 1.000033436 6.86451E-05 -4.1633904711.919243 -10.33128507 3.25972E-05 1.000032597 6.6928E-05 -4.174391868

    1.969094 -10.599633 2.49252E-05 1.000024925 5.12113E-05 -4.29063395

    2.01659 -10.85530397 1.9302E-05 1.000019302 3.9684E-05 -4.401384483

    2.063888 -11.1099091 1.49633E-05 1.000014963 3.07841E-05 -4.511673144

    2.114786 -11.38389304 1.13773E-05 1.000011377 2.34231E-05 -4.630356026

    2.162701 -11.64181948 8.79067E-06 1.000008791 1.81099E-05 -4.742083025

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    66/125

    66

    2.211975 -11.90706143 6.74262E-06 1.000006743 1.39002E-05 -4.856978716

    2.262693 -12.18007642 5.13169E-06 1.000005132 1.05867E-05 -4.975241284

    2.312497 -12.44817135 3.92489E-06 1.000003925 8.10266E-06 -5.09137242

    2.361825 -12.71370398 3.0096E-06 1.00000301 6.21737E-06 -5.206393442

    2.366821 -12.74059744 2.92974E-06 1.00000293 6.05281E-06 -5.218042901

    2.416979 -13.01059796 2.2365E-06 1.000002237 4.62382E-06 -5.334999066

    2.466501 -13.27717488 1.71315E-06 1.000001713 3.54428E-06 -5.450472041

    2.47146 -13.30386918 1.66803E-06 1.000001668 3.45116E-06 -5.462035183

    2.523117 -13.58193881 1.2631E-06 1.000001263 2.61525E-06 -5.582486219

    2.571686 -13.84338574 9.7251E-07 1.000000973 2.01495E-06 -5.695736629

    2.620845 -14.10800864 7.46397E-07 1.000000746 1.54752E-06 -5.810362577

    2.672711 -14.38720331 5.64569E-07 1.000000565 1.17139E-06 -5.931300335

    Step 5: Also shows how the value of B and () is calculated.Using the data from table 5.4 the graph was plotted as shown in figure 6.4

    Figure 6.4 shows the graph of Log (1+A*Exp (- x t) y(t)) Log |1 y (t)| vs. time at

    35% duty cycle.

    Using the intercepts and the values obtained from the graph in Figure 6.4, thevalue of B and beta () was calculated.

    2

    30103.0log10

    B

    B

    The graph of Log (1+A*Exp (- x t) y(t)) Log |1y (t)| vs. Time gives a value for

    -7

    -6

    -5

    -4

    -3

    -2

    -1

    0

    1

    0 0.5 1 1.5 2 2.5 3

    Graph of Log (1 + A*Exp(xt) - y(t)) vs Time (s)

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    67/125

    67

    370.5

    1636.2

    046.54343.0

    1484.0312.2

    0458.00914.54343.0

    Step 6: Calculating the transfer function using the values found in previous steps

    Since there is not much difference in the value of (Step 4) and (Step 5), that is

    = 5.383 = 5.370

    Hence, using equation 6.4 from (Step 3), we get the estimate value of y (t) to be:

    370.5383.5 21)(

    )()(

    eety

    BeAeyty

    t

    tt

    Taking the Laplace of the equation gives:

    )370.5)(383.5(

    907.28889.264)(

    )370.5)(383.5(

    )383.5(2)370.5()370.5)(383.5()(

    370.5

    2

    383.5

    11)(

    2

    sss

    sssy

    sss

    sssssssy

    ssssy

    The transfer function of the motor at 35% duty cycle is given as:

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    68/125

    68

    )370.5)(383.5(

    907.28889.264 2

    sss

    ssnctionTransferFu

    6.3 Calculation of Transfer Function at 50% duty cycle

    Table 6.5

    Cumulative Time (s) x t Exp (- x t) y(t)=1-(exp(- x t))0 0 1 0

    0.002109 0.025755614 0.974573232 0.025426768

    0.066574 0.813017666 0.443517657 0.556482343

    0.069393 0.84744397 0.428508815 0.571491185

    0.134515 1.642729464 0.193451303 0.806548697

    0.199853 2.440652801 0.087103971 0.9128960290.204555 2.498074753 0.082243185 0.917756815

    0.207 2.52793368 0.079823791 0.920176209

    0.210009 2.56468031 0.076943776 0.923056224

    0.213404 2.606140865 0.073818872 0.926181128

    0.21475 2.62257854 0.07261538 0.92738462

    0.215564 2.632519303 0.071897103 0.928102897

    0.217154 2.651936765 0.070514511 0.929485489

    0.226254 2.763068149 0.063097877 0.936902123

    0.226285 2.763446728 0.063073994 0.936926006

    0.226469 2.765693781 0.062932423 0.937067577

    0.290745 3.550647719 0.02870604 0.971293960.291581 3.560857151 0.028414459 0.971585541

    0.292105 3.567256365 0.028233209 0.971766791

    0.301493 3.681904874 0.025174974 0.974825026

    0.303374 3.704876098 0.024603266 0.975396734

    0.312841 3.820489374 0.021917073 0.978082927

    0.377494 4.610047327 0.009951347 0.990048653

    0.378904 4.627266585 0.009781459 0.990218541

    0.444224 5.424970102 0.004405198 0.995594802

    0.444323 5.426179114 0.004399875 0.995600125

    0.445621 5.442030601 0.00433068 0.99566932

    0.454847 5.554700727 0.003869226 0.9961307740.455029 5.556923355 0.003860636 0.996139364

    0.519157 6.340069882 0.001764179 0.998235821

    0.583444 7.125158155 0.000804606 0.999195394

    0.648902 7.92454696 0.000361754 0.999638246

    0.657161 8.025407851 0.000327047 0.999672953

    0.721467 8.810728156 0.000149125 0.999850875

    0.722253 8.820326977 0.0001477 0.9998523

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    69/125

    69

    0.730742 8.923996682 0.000133155 0.999866845

    0.739284 9.028313636 0.000119965 0.999880035

    0.74014 9.038767314 0.000118717 0.999881283

    0.748306 9.138492465 0.000107449 0.999892551

    0.81336 9.932947526 4.85485E-05 0.999951452

    0.814846 9.951094915 4.76754E-05 0.9999523250.823322 10.05460586 4.29873E-05 0.999957013

    0.823843 10.06096844 4.27147E-05 0.999957285

    0.824817 10.07286316 4.22096E-05 0.99995779

    0.833874 10.18346942 3.77899E-05 0.99996221

    0.842931 10.29407568 3.38329E-05 0.999966167

    0.843167 10.29695776 3.37356E-05 0.999966264

    0.843235 10.2977882 3.37076E-05 0.999966292

    0.844061 10.30787551 3.33693E-05 0.999966631

    0.908684 11.09706709 1.51567E-05 0.999984843

    0.90905 11.10153677 1.50891E-05 0.999984911

    0.910668 11.12129618 1.47939E-05 0.9999852060.920284 11.23872908 1.31547E-05 0.999986845

    0.921276 11.25084362 1.29963E-05 0.999987004

    0.923002 11.27192194 1.27253E-05 0.999987275

    0.932188 11.38410358 1.13749E-05 0.999988625

    0.93351 11.40024816 1.11927E-05 0.999988807

    0.933654 11.40200672 1.1173E-05 0.999988827

    0.934178 11.40840594 1.11018E-05 0.999988898

    0.934982 11.41822458 1.09933E-05 0.999989007

    1.000016 12.2124354 4.96829E-06 0.999995032

    1.000384 12.2169295 4.94601E-06 0.999995054

    1.002262 12.23986409 4.83387E-06 0.9999951661.011672 12.35478127 4.3091E-06 0.999995691

    1.012116 12.3602035 4.2858E-06 0.999995714

    1.013277 12.37438191 4.22546E-06 0.999995775

    1.078511 13.17103517 1.90499E-06 0.999998095

    1.0801 13.19044042 1.86838E-06 0.999998132

    1.145355 13.98735015 8.42114E-07 0.999999158

    1.146102 13.99647269 8.34467E-07 0.999999166

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    70/125

    70

    Figure 6.5 Shows the Graph of Motor Speed versus time at 50% duty cycle

    Table 6.6

    |1-y(t)| log |1-y(t)|

    1 0

    0.974573232 -0.011185521

    0.443517657 -0.353089086

    0.428508815 -0.36804024

    0.193451303 -0.713428341

    0.087103971 -1.059962044

    0.082243185 -1.084900081

    0.079823791 -1.097867648

    0.076943776 -1.113826507

    0.073818872 -1.131832597

    0.07261538 -1.138971388

    0.071897103 -1.143288607

    0.070514511 -1.151721503

    0.063097877 -1.19998525

    0.063073994 -1.200149665

    0.062932423 -1.201125548

    0.02870604 -1.542026711

    0.028414459 -1.546460612

    0.028233209 -1.549239755

    0.025174974 -1.59903097

    0.024603266 -1.609007245

    0.021917073 -1.659217453

    0.009951347 -2.002118115

    0.009781459 -2.009596344

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    -0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4

    Y(t)

    Time(s)

    Step Response @ o.5

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    71/125

    71

    0.004405198 -2.35603458

    0.004399875 -2.356559647

    0.00433068 -2.36344386

    0.003869226 -2.412375874

    0.003860636 -2.413341149

    0.001764179 -2.7534573640.000804606 -3.094416869

    0.000361754 -3.441587017

    0.000327047 -3.485390345

    0.000149125 -3.82645062

    0.0001477 -3.830619335

    0.000133155 -3.875642516

    0.000119965 -3.920946793

    0.000118717 -3.925486768

    0.000107449 -3.968796851

    4.85485E-05 -4.3138243

    4.76754E-05 -4.321705614.29873E-05 -4.366659843

    4.27147E-05 -4.369423075

    4.22096E-05 -4.374588887

    3.77899E-05 -4.422624575

    3.38329E-05 -4.470660262

    3.37356E-05 -4.471911937

    3.37076E-05 -4.47227259

    3.33693E-05 -4.476653453

    1.51567E-05 -4.819395003

    1.50891E-05 -4.821336161

    1.47939E-05 -4.8299175611.31547E-05 -4.880918021

    1.29963E-05 -4.8861793

    1.27253E-05 -4.895333501

    1.13749E-05 -4.944053367

    1.11927E-05 -4.951064869

    1.1173E-05 -4.951828603

    1.11018E-05 -4.954607746

    1.09933E-05 -4.958871928

    4.96829E-06 -5.303793303

    4.94601E-06 -5.305745068

    4.83387E-06 -5.3157054324.3091E-06 -5.365613329

    4.2858E-06 -5.367968175

    4.22546E-06 -5.374125781

    1.90499E-06 -5.720107897

    1.86838E-06 -5.72853549

    8.42114E-07 -6.074628985

    8.34467E-07 -6.078590855

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    72/125

    72

    Figure 6.6 shows the graph of Log |1 y (t)| vs. timemotor at 50% duty cycle

    Table 6.7

    x t exp (- x t)1 + A*exp (-

    x t)y(t)

    1 + A*exp (-

    x t) - y(t)

    Log (1 +A*exp (- x t)

    - y(t))

    0 1 2 0 2 0.301029996

    -0.02576 0.974573726 1.974573726 0.025426768 1.949146958 0.289844584

    -0.813 0.443524743 1.443524743 0.556482343 0.8870424 -0.052055621

    -0.84743 0.428515951 1.428515951 0.571491185 0.857024766 -0.067006628

    -1.6427 0.193457548 1.193457548 0.806548697 0.386908851 -0.412391335

    -2.4406 0.087108149 1.087108149 0.912896029 0.174212121 -0.758921632

    -2.49803 0.082247222 1.082247222 0.917756815 0.164490407 -0.783859424

    -2.52788 0.079827757 1.079827757 0.920176209 0.159651549 -0.796826864

    -2.56463 0.076947654 1.076947654 0.923056224 0.15389143 -0.812785566-2.60609 0.073822653 1.073822653 0.926181128 0.147641524 -0.830791479

    -2.62253 0.072619122 1.072619122 0.92738462 0.145234502 -0.837930201

    -2.63247 0.071900823 1.071900823 0.928102897 0.143797926 -0.842247377

    -2.65188 0.070518186 1.070518186 0.929485489 0.141032696 -0.850680191

    -2.76301 0.063101304 1.063101304 0.936902123 0.126199181 -0.898943463

    -2.76339 0.06307742 1.06307742 0.936926006 0.126151414 -0.899107876

    -2.76564 0.062935844 1.062935844 0.937067577 0.125868266 -0.900083749

    y = -5.3037x - 9E-13

    -7

    -6

    -5

    -4

    -3

    -2

    -1

    0

    1

    -0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4

    Log(y(t))

    Time(s)

    Log |y(t)-1| @0.5

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    73/125

    73

    -3.55058 0.028708043 1.028708043 0.97129396 0.057414084 -1.240981563

    -3.56079 0.028416447 1.028416447 0.971585541 0.056830906 -1.24541542

    -3.56719 0.028235188 1.028235188 0.971766791 0.056468398 -1.248194536

    -3.68183 0.025176796 1.025176796 0.974825026 0.05035177 -1.297985261

    -3.7048 0.024605057 1.024605057 0.975396734 0.049208323 -1.307961439

    -3.82041 0.021918718 1.021918718 0.978082927 0.043835791 -1.358171153-4.60996 0.009952249 1.009952249 0.990048653 0.019903596 -1.701068446

    -4.62718 0.009782349 1.009782349 0.990218541 0.019563808 -1.708546601

    -5.42486 0.004405668 1.004405668 0.995594802 0.008810865 -2.054981433

    -5.42607 0.004400344 1.004400344 0.995600125 0.00880022 -2.055506494

    -5.44192 0.004331144 1.004331144 0.99566932 0.008661824 -2.06239064

    -5.55459 0.003869649 1.003869649 0.996130774 0.007738875 -2.111322174

    -5.55681 0.003861058 1.003861058 0.996139364 0.007721694 -2.112287439

    -6.33995 0.001764399 1.001764399 0.998235821 0.003528578 -2.452400312

    -7.12502 0.000804718 1.000804718 0.999195394 0.001609324 -2.793356466

    -7.92439 0.00036181 1.00036181 0.999638246 0.000723564 -3.140523202

    -8.02525 0.000327098 1.000327098 0.999672953 0.000654145 -3.184326099-8.81056 0.00014915 1.00014915 0.999850875 0.000298275 -3.525383023

    -8.82015 0.000147726 1.000147726 0.9998523 0.000295426 -3.529551697

    -8.92382 0.000133178 1.000133178 0.999866845 0.000266333 -3.574574435

    -9.02814 0.000119986 1.000119986 0.999880035 0.000239951 -3.619878268

    -9.03859 0.000118738 1.000118738 0.999881283 0.000237455 -3.624418197

    -9.13831 0.000107468 1.000107468 0.999892551 0.000214918 -3.667727855

    -9.93275 4.8558E-05 1.000048558 0.999951452 9.71065E-05 -4.012751913

    -9.9509 4.76847E-05 1.000047685 0.999952325 9.53601E-05 -4.020633147

    -10.0544 4.29958E-05 1.000042996 0.999957013 8.59831E-05 -4.065586938

    -10.0608 4.27231E-05 1.000042723 0.999957285 8.54378E-05 -4.068350143

    -10.0727 4.22179E-05 1.000042218 0.99995779 8.44275E-05 -4.073515904-10.1833 3.77974E-05 1.000037797 0.99996221 7.55873E-05 -4.121551119

    -10.2939 3.38398E-05 1.00003384 0.999966167 6.76727E-05 -4.169586335

    -10.2968 3.37424E-05 1.000033742 0.999966264 6.7478E-05 -4.170837998

    -10.2976 3.37144E-05 1.000033714 0.999966292 6.7422E-05 -4.171198646

    -10.3077 3.3376E-05 1.000033376 0.999966631 6.67453E-05 -4.175579466

    -11.0968 1.516E-05 1.00001516 0.999984843 3.03167E-05 -4.518317649

    -11.1013 1.50924E-05 1.000015092 0.999984911 3.01815E-05 -4.520258787

    -11.1211 1.47971E-05 1.000014797 0.999985206 2.9591E-05 -4.528840103

    -11.2385 1.31576E-05 1.000013158 0.999986845 2.63124E-05 -4.579840062

    -11.2506 1.29992E-05 1.000012999 0.999987004 2.59955E-05 -4.585101289

    -11.2717 1.27281E-05 1.000012728 0.999987275 2.54533E-05 -4.5942554

    -11.3839 1.13774E-05 1.000011377 0.999988625 2.27523E-05 -4.642974787

    -11.4 1.11952E-05 1.000011195 0.999988807 2.23879E-05 -4.649986221

    -11.4018 1.11755E-05 1.000011176 0.999988827 2.23486E-05 -4.650749947

  • 8/3/2019 Designing Development and Testing of a PIC Micro-Controller Based Differential Drive Line Tracing Vehicle-2 With PID

    74/125

    74

    -11.4082 1.11043E-05 1.000011104 0.999988898 2.2206E-05 -4.653529063

    -11.418 1.09958E-05 1.000010996 0.999989007 2.19891E-05 -4.657793203

    -12.2122 4.96948E-06 1.000004969 0.999995032 9.93777E-06 -5.002711188

    -12.2167 4.9472E-06 1.000004947 0.999995054 9.89321E-06 -5.004662934

    -12.2396 4.83503E-06 1.000004835 0.999995166 9.66889E-06 -5.0146232

    -12.3545 4.31015E-06 1.00000431 0.999995691 8.61925E-06 -5.064530606

    -12.36 4.28684E-06 1.000004287 0.999995714 8.57264E-06 -5.06688543

    -12.3741 4.22649E-06 1.000004226 0.999995775 8.45195E-06 -5.073042975

    -13.1708 1.90548E-06 1.000001905 0.999998095 3.81047E-06 -5.419021691

    -13.1902 1.86886E-06 1.000001869 0.999998132 3.73724E-06 -5.427449201

    -13.9871 8.42346E-07 1.000000842 0.999999158 1.68446E-06 -5.773539294

    -13.9962 8.34697E-07 1.000000835 0.999999166 1.66916E-06 -5.777501125

    Figure 6.7 shows the graph of Log (1+A*Exp (- x t) y (t)) Log |1 y (t)| vs. time at

    50% duty cycle.

    From the above tabulated results and graph the value of

    = 12.212

    = 12.212

    y = -5.3037x + 0.301

    -7

    -6

    -5

    -4

    -3

    -2

    -1

    0

    1

    -0.2 0 0.2 0.4 0.6 0.8 1