Final Mini Project Documentation

Embed Size (px)

Citation preview

  • 8/2/2019 Final Mini Project Documentation

    1/33

    Chapter 1

    INTRODUCTION

    The line following robot is programmed to follow a white line on a black background and

    detect turns or deviations and modify the motors appropriately. The optical sensor is an array of

    commercially available IR reflective type sensors.

    The core of the robot is the AT89C2051 microcontroller. The speed control of the motors

    is achieved by the two PWM modules in the microcontrollers. The direction control is provided

    by 2 I/O pins. The H-Bridge motor driving/control chip takes these signals and translates it into

    current direction entering the motor armature. The motors require separate supply for operation.

    The differential steering system is used to turn the robot. In this system, each back wheel

    has a dedicated motor while the front wheels are free to rotate. To move in a straight line, both

    the motors are given the same voltage (same polarity). To manage a turn of different sharpness,

    the motor on the side of the turn required is given lesser voltage. To take a sharp turn, its polarity

    is reversed.

    The sensor is an array IR LED-Phototransistor pairs arranged in the form of an inverted

    V. The output of each sensor is fed into an analog comparator with the threshold voltage (used to

    calibrate the intensity level difference of the line with respect to the surface). These 7 signals

    (from each photo-reflective sensor) is given to a priority encoder, the output of which to the

    microcontroller.

    The control has 6 modes of operation, turn left/right, move left/right, and drift left/right.

    The actual action is caused by controlling the direction/speed of the two motors (the two back

    wheels), thus causing a turn. The actual implementation is a behavior based (neural) control with

    the sensors providing the inputs. The robot can also be programmed to find the line by pseudo-

    random movement in case no line is detected by the optical sensor.

  • 8/2/2019 Final Mini Project Documentation

    2/33

    What is a line follower?

    Line follower is a machine that can follow a path. The path can be visible like a black

    line on a white surface (or vice-versa) or it can be invisible like a magnetic field.

    Why build a line follower?

    Sensing a line and maneuvering the robot to stay on course, while constantly correction

    wrong moves using feedback mechanism forms a simple yet effective closed loop system.

    We have seen how ants always travel in a line, following an invisible route in search

    of food, or back home. How on roads we follow lanes to avoid accidents and traffic jams.

    Programming intelligence into a robot (or computer) is a difficult task and one that

    has not been very successful to date even when supercomputers are used. This is not to say

    that robots cannot be programmed to perform very useful, detailed, and difficult tasks; t h e y

    ar e. Some t as ks a re impossible for hu ma ns t o pe r fo rm qu i ck l y an d productively.

    For instance, imagine trying to solder 28 filament wires to a 1/4in square sliver of silicon in

    2 s to make an integrated circuit chip. Its not very likely that a human would be able to

    accomplish this task without a machine. But machine task performance, as impressive as it is,isnt intelligence.

    1.1 PROBLEM DEFINITION

    In the industry carriers are required to carry products from one manufacturing plant

    to another which are usually in different buildings or separate blocks.

    Conventionally, cars or trucks w e r e u se d w i t h human drivers. Unreliability and

    inefficiency in this part of the assembly line formed the weakest link. The project is toautomate this sector, using carts to follow a line instead of laying railway tracks which are both

    costly and an inconvenience.

  • 8/2/2019 Final Mini Project Documentation

    3/33

    1.2 OBJECTIVES OF THE STUDY

    The robot must be capable of following a line. It must be prepared of a situation that it runs into a territory which has no line to

    follow. (Barren land syndrome) The robot must also be capable of following a line even if it has breaks.

    The robot must be insensitive to environmental factors such as lighting and noise.

    It m ust allow calibration of the lines darkness threshold.

    The robot must be reliable

    Scalability must be a primary concern in the design.

    The color of the line must not be a factor as long as it is darker than the

    surroundings.

  • 8/2/2019 Final Mini Project Documentation

    4/33

    Chapter 2

    BLOCK DIAGRAM & CIRCUIT DIAGRAM

    2.1 BLOCK DIAGRAM

    The infrared sensors are used to sense the line. When the infrared signal falls on the white

    surface, it gets reflected and if it falls on the black surface, it is not reflected this principle is used

    to scan the Lines for the Robot. The microcontroller AT89C51 is used to control the motors. It

    gets the signals from the infrared sensors and it drives the motors according to the sensor inputs.

    Two stepper motors are used to drive the robot. The block diagram as shown in figure 2.1

    Figure -2.1 Block diagram of Line Following Robot

    The Comparator present after the sensor array will help in the noticing the line that is

    sensed, i.e. it will compare the sensed line with the needed one. This will indeed result in the

    proper functioning of the microprocessor to give instructions to the motor. The working of the

    robot involves the movement of the wheels. If the IR sensor senses the line, both the wheels are

    in motion. However, when there is a case when a line in not sensed, i.e. during the turnings then

    the microcontroller controls the wheels in such a fashion that when there is a right turn, the left

    wheel will rotate while the right one is motion-less so that the total body will turn to the right and

    vice-versa.

  • 8/2/2019 Final Mini Project Documentation

    5/33

    2.2 CIRCUIT DIAGRAM

    The schematic of the Line Following R obot is shown in the figure 2.2. The main

    component is the AT89C51 microcontroller. The schematic is divided into two sections; one

    the Sensor Array Board, and the other the motor-control or main board.

    The main features incorporated into the circuit are given below

    The at89c51 microcontroller

    The voltage regulator

    Crystal oscillator (4MHz)

    The H-bridge motor control IC (L293D)

    Motors, with coupled reduction gears.

    The LM324 quad comparator IC

    A POT to calibrate the reference voltage.

  • 8/2/2019 Final Mini Project Documentation

    6/33

    Figure 2.2 Circuit Diagram of Line Tracking Robot

    The motors are connected to port-1 of micro-controller using motor driver L293D and the sensor

    array is connected to port-3.

  • 8/2/2019 Final Mini Project Documentation

    7/33

    Figure 2.3 Sensor Circuit with Comparator IC LM324

  • 8/2/2019 Final Mini Project Documentation

    8/33

    CHAPTER 3

    HARDWARE DESCRIPTION

    3.1. ATMEL 89C51 MICRO CONTROLLER

    3.1.1. Introduction

    The AT89C2051 is a low-voltage, high-performance CMOS 8-bit microcontroller with

    2K bytes of Flash programmable and erasable read-only memory (PEROM). The device is

    manufactured using Atmels high -density nonvolatile memory technology and is compatible with

    the industry-standard MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on

    a monolithic chip, the Atmel AT89C2051 is a powerful microcomputer which provides a highly-

    flexible and cost-effective solution to many embedded control applications.

    The AT89C2051 provides the following standard features: 2K bytes of Flash, 128 bytes

    of RAM, 15 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a

    full duplex serial port, a precision analog comparator, on-chip oscillator and clock circuitry. In

    addition, the AT89C2051 is designed with static logic for operation down to zero frequency and

    supports two software selectable power saving modes. The Idle Mode stops the CPU while

    allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The

    power-down mode saves the RAM contents but freezes the oscillator disabling all other chip

    functions until the next hardware reset.

    3.1.2. Features

    Compatible with MCS-51Products

    2K Bytes of Reprogrammable Flash Memory Endurance: 10,000 Write/Erase Cycles

    2.7V to 6V Operating Range

    Fully Static Operation: 0 Hz to 24 MHz

  • 8/2/2019 Final Mini Project Documentation

    9/33

    Two-level Program Memory Lock

    128 x 8-bit Internal RAM 15 Programmable I/O Lines

    Two 16-bit Timer/Counters

    Six Interrupt Sources

    Programmable Serial UART Channel

    Direct LED Drive Outputs On-chip Analog Comparator

    Low-power Idle and Power-down Modes

    Green (Pb/Halide-free) Packaging Option

    3.1.3 Pin Diagram & Description

    Figure - 3.1 Pin Diagram

  • 8/2/2019 Final Mini Project Documentation

    10/33

    VCC:

    Supply voltage.

    GND:

    Ground.

    Port 0:

    Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink

    eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance

    inputs. Port 0 can also be configured to be the multiplexed low order address/data bus during

    accesses to external program and data memory. In this mode, P0 has internal pull ups. Port 0 also

    receives the code bytes during Flash programming and outputs the code bytes during program

    verification. External pull ups are required during program verification.

    Port 1:

    Port 1 is an 8-bit bi-directional I/O port with internal pull ups. The Port 1 output buffers

    can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the

    internal pull ups and can be used as inputs. Port 1 pins that are externally being pulled low will

    source current (IIL) because of the internal pull ups. In addition, P1.0 and P1.1 can be configured

    to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input

    (P1.1/T2EX) respectively, as shown table 3.1.1. Port 1 also receives the low-order address bytes

    during Flash programming and verification.

    Port 2:

    Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The Port 2 output buffers

    can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the

    internal pull ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled

    low will source current (IIL) because of the internal pull ups. Port 2 emits the high-order address

    byte during fetches from external program memory and during accesses to external data memory

    that uses 16-bit addresses (MOVX @DPTR).

    In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses

    to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of

  • 8/2/2019 Final Mini Project Documentation

    11/33

    the P2 Special Function Register. Port 2 also receives the high-order address bits and some

    control signals during Flash programming and verification.

    Port 3:

    Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3 output buffers

    can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the

    internal pull ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled

    low will source current (IIL) because of the pull ups. Port 3 also serves the functions of various

    special features of the AT89C51, as shown in table 3.1.2. Port 3 also receives some control

    signals for Flash programming and verification.

    Port Pin Alternate Functions

    P3.0 RXD (Serial input port)

    P3.1 TXD (Serial output port)

    P3.2 INT0 (external interrupt 0)

    P3.3 INT1 (external interrupt 1)

    P3.4 T0 (timer 0external interrupt)

    P3.5 T1 (timer 1 external input)

    P3.6 WR (external data memory write strobe)P3.7 RD (external data memory read strobe)

    Table - 3.1 Alternate Functions of Port 3

    RST:

    Reset input. A high on this pin for two machine cycles while the oscillator is runningresets the device.

    ALE/PROG :

    Address Latch Enable, output pulse for latching the low byte of the address during

    accesses to external memory. This pin is also the program pulse input (PROG) during Flash

    programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator

    frequency and may be used for external timing or clocking purposes. Note that one ALE pulse is

  • 8/2/2019 Final Mini Project Documentation

    12/33

    skipped during each access to external Data Memory. If desired, ALE operation can be disabled

    by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or

    MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no

    effect if the microcontroller is in external execution mode.

    PSEN:

    Program Store Enable is the read strobe to external program memory. When the

    AT89C51 is executing code from external program memory, PSEN is activated twice each

    machine cycle, except that two PSEN activations are skipped during each access to external data

    memory.

    EA/VPP:

    External Access Enable, EA must be strapped to GND in order to enable the device to

    fetch code from external program memory locations starting at 0000H up to FFFFH. Note

    however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be

    strapped to VCC for internal program executions. This pin also receives the 12volt programming

    enable voltage (VPP) during Flash programming.

    XTAL1:

    Input to the inverting oscillator amplifier and input to the internal clock operating circuit

    XTAL2:

    Output from the inverting oscillator amplifier.

  • 8/2/2019 Final Mini Project Documentation

    13/33

    3.1.4. Architecture of AT89C51

    Program Counter and Data Pointer:-

    Figure - 3.2 Internal Architecture of AT89C51

    The 89C51 contains two 16-bit registers: the Program Counter (PC) and the data pointer

    (DPTR). Each is used to hold the address of a byte in memory. The PC is the only register thatdoes not have an internal address. The DPTR is under the control of program instructions and

    can be specified by its 16-bit name, DPTR, or by each individual byte name, DPH and DPL.

    DPTR does not have a single internal address; DPH and DPL are each assigned an address.

  • 8/2/2019 Final Mini Project Documentation

    14/33

    A & B Registers:

    The 89C51 contains 34 general purpose working registers. Two of these registers A and

    B, hold results of many instructions, particularly math and logical operations of the 89C51 CPU.

    The other 32 are arranged as part of internal RAM in four banks, B0-B3 of eight registers. The A

    register is also used for all data transfers between the 89C51 and any external memory. The B

    register is used with the A register for multiplication and division operations.

    The Stack and Stack Pointer:

    The stack refers to an area of internal RAM that is used in conjunction with certain

    opcodes to store and retrieve data quickly. The 8-bit stack pointer register is used by the 89C51

    to hold an internal RAM address that is called the top of the stack. The address held in the SP

    register is the location in internal RAM where the last byte of data was stored by a stack operation. When data is to be placed on the stack, the SP is incremented before storing data on

    the stack. As data is retrieved from the stack, the SP decrements to point to the next available

    byte of stored data.

    Program Status Word (PSW):

    Flags may be conveniently addressed, they are grouped inside the program status word

    (PSW) and the power control (PCON) registers. The 89C51 has four math flags that respond

    automatically to the outcomes of math operations and three general-purpose user flags that can

    be set to 1 or cleared to 0 by the programmer as desired. The math flags include Carry (C),

    Auxiliary Carry (AC), Overflow (OV), and Parity (P).

    Timers:

    Timer 0 and 1:

    Timer 0 and Timer 1 in the AT89C51 operate the same way as Timer 0 and Timer 1 in

    the AT89C51.

    3.2 D.C MOTORS

    DC motors are widely used, inexpensive, small and powerful for their size.

    Reduction gearboxes are often required to reduce the speed and increase the torque output of

  • 8/2/2019 Final Mini Project Documentation

    15/33

    the motor.

    Several characteristics are important when selecting DC motors and these can be split

    into two specific categories. The first category is associated with the input ratings of the motor

    and specifies its electrical requirements, like operating voltage and current. The second

    category is related to the motors output characteristics and specifies the physical limitations

    of the motor in terms of speed, torque and power.

    Example specifications of the motors used are given below in table 3.2

    Characteristic Value

    Operating Voltage: 6V to 12V

    Operating Current: 2A Max. (Stall)

    Speed: 2400 rpm

    Torque: 30 gm-cm

    Table - 3.2 Specifications of Motor

    As noticed, the torque provided can hardly move 30gm of weight around with wheel

    diameter of about 2cm. This is a fairly a huge drawback as the robot could easily weigh

    about a kg. This is accomplished by gears which reduce the speed (2400 rpm is highly

    impractical) and effectively increase the torque. If the speed is reduced by using a gear

    system by a factor of t hen the torque is increased by the same factor. For

    example, if the speed is reduced from 2400 rpm, to 30 rpm, then the torque is increased by a

    factor of (2400/30 = 80) in other words the torque becomes 30 80 2400 gm-cm or

    2.4 kg-cm which is more than sufficient.

    3.3 H-BRIDGE MOTOR CONTROL

    DC motors are generally bi-directional motors. That is, their direction of rotation can

    be changed by just reversing the polarity. But once the motors are fixed, control becomes

  • 8/2/2019 Final Mini Project Documentation

    16/33

    tricky. This is done using the H-Bridge. The table 3.4 shows the H-Bridge operation

    Table - 3.3 H-Bridge action

    Figure 3.3 H-Bridge Using Relays.

    If A & D are turned on, then the current flows in the direction shown in the figure 3.4

    A B C D ACTION

    1 0 0 1 CLOCKWISE

    0 1 1 0 COUNTER-CLOCKWISE

    0/1 0/1 1/0 1/0 BRAKE

    ANY OTHER STATE FORBIDDEN

  • 8/2/2019 Final Mini Project Documentation

    17/33

    Figure - 3.4 Clockwise Rotation

    If B & C are turned on, then the motor rotates in counter clockwise direction as shown in

    figure 3.5

    Figure - 3.5 Counter-Clockwise Rotation

  • 8/2/2019 Final Mini Project Documentation

    18/33

    3.4. POWER SUPPLY

    A power supply can be broken down into a series of blocks, each of which performs a

    particular function as shown below.

    For example a 5V regulated supply

    Figure 3.6 Block Diagram of Regulated Power Supply

    The Transformer steps down high voltage AC mains to low voltage AC. The Rectifier is

    used to convert AC to DC, but the DC output is varying. The Smoothing filter smoothes the DC

    from varying greatly to a small ripple. The Regulator eliminates ripple by setting DC output to a

    fixed voltage. The blocks of power supply unit are as shown in figure 3.7

    Figure - 3.7 Block diagram of power supply unit

    The regulated DC output is very smooth with no ripple. It is suitable for all electronic

    circuits.

    http://www.kpsec.freeuk.com/powersup.htm#transformerhttp://www.kpsec.freeuk.com/powersup.htm#transformer
  • 8/2/2019 Final Mini Project Documentation

    19/33

    3.5. VOLTAGE REGULATOR

    It has been shown that practically all electronic devices need DC supply. A direct

    voltage of constant magnitude requires to be supplied, for the smooth and efficient

    functioning of these devices. A properly designed voltage regulator ensures that,

    irrespective of change in supply voltage, load impedance or temperature, the DC supply is

    maintained at a constant level. This is achieved by incorporating some type of feedback in the

    regulator circuit.

    An IC voltage regulator unit contains all the circuitry required in a single IC. Thus there

    are no discrete components and the circuitry needed for the reference source, the comparator

    and control elements are fabricated on a single chip. Even the over load and short-circuit

    protection mechanism is integrated into the IC. IC voltage regulators are designed to provide

    either a fixed positive or negative voltage, or an adjustable voltage which can be set for any

    value ranging between two voltage levels.

    Figure - 3.8 Voltage Regulator

    The circuit requires two voltage sources, one for the digital ICs (+5V) and a+12V to

    the motors. The motor is supplied 12V unregulated supply directly from the battery as

    regulation would be difficult and unnecessary; whereas the digital ICs and the microcontroller

  • 8/2/2019 Final Mini Project Documentation

    20/33

    require a perfect ripple free +5V to function properly. The L7805C is a5V voltage regulator

    IC. The capacitors added to the input of the voltage regulator are to isolate the spikes generated

    by the motor from the input and to reduce noise. The 10 F capacitor at the output is to

    maintain stability and improve regulation. These are standard values. The 0.1 F capacitor is

    used at the input because of the fact that high value capacitors have poor high frequency

    response.

    IC Voltage Regulator:

    Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable

    output voltages. They are also rated by the maximum current they can pass. Negative voltage

    regulators are available, mainly for use in dual supplies. Most regulators include some automatic

    protection from excessive current ('overload protection') and overheating ('thermal protection').

    Many of sthe fixed voltage regulator ICs have 3 leads and 7805 +5V 1A regulator shown in the

    figure 3.9

    Figure - 3.9 Regulator

    3.6 D.C Motors

    The D.C. motors have a speed of 2400rpm and a torque of 15gm-cm. The gears

    decrease the speed to 30rpm at 6V and thus considerably increasing the torque so that the robotcan carry the load of its frame and the lead-acid battery. Two such motors are used in the rear

    of the robot, and a dummy castor is fixed to the front to stabilize the robot.

  • 8/2/2019 Final Mini Project Documentation

    21/33

    3.7. THE H-BRIDGE CONTROL HARDWARE

    Figure 3.10 Motor Control .

  • 8/2/2019 Final Mini Project Documentation

    22/33

    The entire motor control circuitry is shown in the above figure 3.7.1 along with the

    internal circuitry of the L293D motor control IC. The table below clearly indicated the operation

    of the IC.

    Table 3.4 Motor Movement

    Figure 3.11 Motor Driver L293D Pin Diagram

    IN1 IN2 IN3 IN4 OPERATION

    1 0 1 0 BOTH MOTORS FORWARD

    (MOVE FORWARD)

    0 1 0 1 BOTH MOTORS BACKWARD

    (MOVE BACKWARD)1 0 0 1 RIGHT MOTOR BACKWARD

    LEFT MOTOR FORWARD

    (TURN RIGHT)

    0 1 1 0 RIGHT MOTOR FORWARD

    LEFT MOTOR BACKWARD

    (TURN LEFT)

  • 8/2/2019 Final Mini Project Documentation

    23/33

    3.10 THE IR SENSORS

    The MOC7811 consists of an infrared emitting diode ( = 950nm) and an NPN

    silicon phototransistor mounted to face each other on a converging optical axis in a black

    plastic housing. The photo-transistor responds to radiation from the emitting diode only when

    no object is present within its field of view. This sensor is physically modified so that the

    emitter and detector face the same direction and thus the modified sensor serves the purpose

    of an optical-reflective sensor. The sensor has a focal length of 8mm, thus the surface must be

    at an optimum distance of 1.6cm.

    Figure - 3.12 Sensors Working

    If a reflective (white) surface is present at the optimal distance (d = 1.6cm) then the

    reflected waves will strike the detector which on radiation will start to conduct. The circuit

    diagram is shown in the figure 3.13

    Figure - 3.13 The Sensor

  • 8/2/2019 Final Mini Project Documentation

    24/33

    The drop across the emitter when forward biased is around 1.4V. According to the data

    sheets, to have sustained radiation, a max of 40mA must flow through to avoid damage. A

    safe margin is allowed and a current of 16mA is considered for the design.

    R = Vcc Vd

    Ic

    for, Vcc = 5V Vd

    = 1.4V

    Ic = 16mA

    R is calculated to be approximately 220 .

    For the emitter, the collector resistor was determined experimentally on a trial and error

    basis. It was decided to use a value of 56 k . For this value, the potential across the detector is

    normally 4.6V, when an object reflects the rays towards the detector, then the potential drops

    to 0.6V. The output is obviously analog in nature.

    3.10. COMPARATOR

    A comparator is a circuit which compares a signal voltage applied at one input of an

    op-amp with a known reference voltage at the other input, and produces either a high or a

    low output voltage, depending on which input is higher. The input / output

    characteristics of a comparator is as shown.

    Figure - 3.14 Comparator transfer characteristics.

  • 8/2/2019 Final Mini Project Documentation

    25/33

    Figure 3.15 Comparator LM324 Pin Diagram

    The reference voltage is generated by the 20k POT and given to all the

    comparators to the non-inverting input. When the respective sensor is on the line, theemitted light is absorbed by the line and the transistor is the cut-off mode, thus a potential of

    4.6V is given to the inverting input which is greater than V ref (which is chosen to be 2.5V),

    thus the output of the comparator goes low. When the sensor is not on the line the potential

    across the detector is usually 0.6V. Thus the output of the comparator goes high. Thus the

    output of the comparator goes low only when the sensor is over the line. The comparator is

    open collector, and hence a pull-up resistor of 10 k is required at the output.

    3.11. SENSOR ARRAY

    The resistance of the sensor decreases when IR light falls on it. A good sensor will have near zero

    resistance in presence of light and a very large resistance in absence of light. The schematic of a single

    sensor is shown in figure 3.16

  • 8/2/2019 Final Mini Project Documentation

    26/33

    Figure - 3.16 Schematic of a Single Sensor

    We have used this property of the sensor to form a potential divider. The potential at point 2 isRsensor / (Rsensor + R1). Again, a good sensor circuit should give maximum

    change in potential at point 2 for no-light and bright-light conditions. This is especially

    important if you plan to use an ADC in place of the comparator .

    To get a good voltage swing, the value of R1 must be carefully chosen. If Rsensor = a

    when no light falls on it and Rsensor = b when light falls on it . The transfer characteristics of

    a resistance and voltage swing in shown in figure 3.17

    Figure 3.17 transfer characteristics of Resistance and Voltage swing

  • 8/2/2019 Final Mini Project Documentation

    27/33

    The difference in the two potentials is

    Vcc * {a/ (a+R1) - b/ (b+R1)}

    Relative voltage swing = Actual Voltage Swing / Vcc

    = Vcc * {a/ (a+R1) - b/ (b+R1)} / Vcc

    = a/(a+R1) - b/(b+R1)

    The sensor used has a= 930 K and b= 36 K.If we plot a curve of the voltage swing over a

    range of values of R1 we can see that the maximum swing is obtained at R1= 150 K. There is a

    catch though, with such high resistance, the current is very small and hence susceptible to bedistorted by noise. The solution is to strike a balance between sensitivity and noise immunity.

  • 8/2/2019 Final Mini Project Documentation

    28/33

    CHAPTER5

    SOURCE CODE

    THE SOFTWARES USED

    5.1 KEIL VISION 4: KEIL implemented the first C compiler designed from the ground up specifically for

    8051 microcontroller. Keil provides broad range of development tools like ANSI C Compiler,

    macro assembler, debuggers and simulators, linkers, IDE library managers, real time operating

    system & evaluation boards for 8051 & ARM families. It is used to write programs for an

    application. The programs can be written in embedded C or in assembly language. The program

    thus written is dumped into the microcontroller using flash magic software.

    5.2 FLASH MAGIC SOFTWARE :

    The FLASH MAGIC software is one of the best known microcontroller programs

    dumping software. It has the compatibility with the KEIL software. The HEX file generated by

    the KEIL is used by the FLASH MAGIC to program the microcontroller. The software uses the

    computer serial port to transmit data into microcontroller.

    To dump the code program first the FLASH MAGIC has to be provided with necessary

    information about the target, the baud rate supported, the clock frequency, etc, then the software

    checks for the device connected to the computer serial port. If the target is not connected, an

    error is generated.

    The software then checks for the available memory and the size of file to be dumped.

    Then it checks whether the target (microcontroller) is in ISP (In system programming) mode or

    not. If everything is fine then, it starts writing into the microcontroller using the serial data

    transfer pins Txd and Rxd pins on the microcontroller.

  • 8/2/2019 Final Mini Project Documentation

    29/33

    THE SOURCE CODE AS FOLLOWS:

    sbit ir1=p1^0;

    sbit ir2=p1^1;

    sfr dcmotors=0x80;

    void sensors (void);

    void delay (unsigned char value)

    {

    int i, j;

    for (I=0, i

  • 8/2/2019 Final Mini Project Documentation

    30/33

    {

    if (ir1==0)

    {

    dcmotors=0x04;

    delay (2);

    }

    if (ir2==0)

    {

    dcmotors=0x01;

    }

    if (ir1==0&&ir2==0)

    {

    dcmotors=0x0A;

    delay (100);

    dcmotors=0x00;

    }

    }

  • 8/2/2019 Final Mini Project Documentation

    31/33

    APPLICATIONS & CONCLUSION

    APPLICATIONS AND LIMITATIONS

    APPLICATIONS Industrial automated equipment carriers

    Entertainment and small household applications.

    Automated cars.

    Tour guides in museums and other similar applications.

    Second wave robotic reconnaissance operations.

    LIMITATIONS Choice of line is made in the hardware abstraction and cannot be changed by

    software.

    Calibration is difficult, and it is not easy to set a perfect value.

    The steering mechanism is not easily implemented in huge vehicles and

    impossible for non-electric vehicles (petrol powered).

    Few curves are not made efficiently, and must be avoided.

    Lack of a four wheel drive, makes it not suitable for a rough terrain.

    1.3.SCOPE OF STUDY

    The robot can be further enhanced to let the user decide whether it is a dark line on a

    white background or a white line on a dark background. The robot can also be programmed

    to decide what kind of line it is, instead of a user interface. The motor control could be

  • 8/2/2019 Final Mini Project Documentation

    32/33

    modified to steer a convectional vehicle, and not require a differential steering system. The

    robot could be modified to be a four wheel drive. Extra sensors could be attached to allow

    the robot to detect obstacles, and if possible bypass it and get back to the line. In other

    words, it must be capable predicting the line beyond the obstacle. Speed control could also be

    incorporated

  • 8/2/2019 Final Mini Project Documentation

    33/33

    BIBLIOGRAPHY

    PICmicro Mid-Range MCU Family Reference Manualby

    MICROCHIP

    Digital logic and computer design

    by M. Morris Mano - Prentice Hall of India PVT limited

    Digital Systems Principles & applications

    by Ronald J. Tocci Sixth Edition - Prentice Hall of India PVT limited

    Kenneth J. Ayala, The 8051Microcontroller, West Publishing Company, 1991.

    Muhammad Ali Mazidi,The 8051 Microcontroller and Embedded Systems, second

    edition, Prentice Hall, 2005.

    http://www.electrotech.com

    http://www.electrotech.com/http://www.electrotech.com/http://www.electrotech.com/