Line Follower Using AT89c51
Line Follower Using AT89c51
Line Follower Using AT89c51
Acknowledgement
It is our privilege to express our sincerest regards to our
project coordinator, Ms. Madhusmita Nahak & Ms Geetanjali
Jena, for their valuable inputs, able guidance,
encouragement, whole-hearted cooperation and
constructive criticism throughout the duration of our project.
CERTIFICATE
INDEX
1. INTRODUCTION
2. OVERVIEW
5. IMPLEMENTATION
a)Design of Microcontroller Programmer
b)What is ISP?
6. SENSORS
a) Design Of Infrared Sensor Circuit
b) Principle of operation of the I.R. L.E.D. and
Phototransistor
c) Positioning of sensors
d) Infra-Red Sensor Array
e) Analog to digital converter
f) LM339 Comparator
g) Pin Diagram Of LM339
h) Function Of the comparator
7. MICROCONTROLLER
a)Pin Diagram of AT89C51
b) Onboard Pin Connections
9. SOURCE CODE
11.PROBLEMS ENCOUNTERED
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.
Prerequisites:
Knowledge of basic digital and analog electronics.
C Programming Sheer interest, an innovative brain and perseverance!
OVERVIEW
EMITTER DETECTOR
0.5cm
The resistance of the sensor decreases when IR (infrared) 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. Whether the sensors are Light Dependent Resistors,
laser diode, Infrared Sensors, Ultrasonic Sensors or anything else,the outputs of
the sensor modules are fed to the Non-inverting input of a comparator . The
reference voltage of the comparator is fed to the inverting input of the
comparator by a trim pot or a tuning device connected between the supply lines.
LM339 is a comparator IC that digitizes the analog signal from the sensor array.
Since the output of LM339 is TTL compatible it can be directly fed to the master
microcontroller.
The generalized connection diagram of Sensor Interfacing with microcontroller is
shown below:-
It is clear that the output of the potential divider is an analog voltage. But
Microcontroller does not accept the analog voltage. So we need to convert the
analog voltage to digital before we feed it to the microcontroller.
For this conversion we can use
1. Comparators
2. ADCs
COMPARATOR LM339
-
V-
LM339 COMPARATOR:-
PIN DI AGRAM OF LM339:-
V+ + HIGH
V + > V-
V- - 0V
V+ + LOW
V+ < V-
V- - 0V
MICROCONTROLLER:-
L293D is a bipolar motor driver IC. This is a high voltage, high current pushpull
four channel driver compatible to TTL logic levels and drive inductive loads. It
has 600 mA output current capability per channel and internal clamp diodes.
The L293 is designed to provide bidirectional drive currents of upto 1 A at
voltages from 4.5 V to 36 V. The L293D is designed to provide bidirectional drive
currents of up to 600-mA at voltages from 4.5 V to 36 V. Both devices are
designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping
motors, as well as other high-current/high-voltage loads in positive supply
applications. All inputs are TTL compatible. Each output is a complete totem-pole
drive circuit, with a Darlington transistor sink and a pseudo-Darlington source.
Drivers are enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3
and 4 enabled by 3,4EN. When an enable input is high, the associated drivers are
enabled, and their outputs are active and in phase with their inputs. When the
enable input is low, those drivers are disabled, and their outputs are off and in the
high-impedance state. With the proper data inputs, each pair of drivers forms a
full-H (or bridge) reversible drive suitable for solenoid or motor applications.
PIN DIAGRAM OF L293D:-
VCC1- LOGIC
SUPPLY= 5V 16 8
L_IN1 1 3 LM+ OUTPUT FOR
MOTOR1
L_IN2 2 14 LM-
INPUT
L_EN 15
LINES
L293D
R_IN1 7 6 RM+ OUTPUT FOR
R_IN2 9 11 RM- MOTOR2
R_EN 10
4 5 12 13
GND
PIN DIAGRAM OF L293D
The Device is a monolithic integrated high voltage, high current four channel
driver designed to accept standard DTL or TTL logic levels and drive inductive
loads (such as relays solenoides, DC and stepping motors) and switching power
transistors. To simplify use as two bridges each pair of channels is equipped with
an enable input. A separate supply input is provided for the logic, allowing
operation at a lower voltage and internal clamp diodes are included. This device is
suitable for use in switching applications at frequencies up to 5 kHz.
The L293D is assembled in a 16 lead plastic packaage which has 4 center pins
connected together and used for heatsinking The L293DD is assembled in a 20
lead surface mount which has 8 center pins connected together and used for
heatsinking.
PIN CONNECTIONS:-
EN IN 1 IN 2 Motor
Status
0 X X Stopped
1 0 0 Stopped
1 1 1 Stopped
1 1 0 CW
1 0 1 CCW
PICTURE OF BIPOLAR MOTOR DRIVER
DC MOTORS:-
These are very commonly used in robotics. DC motors can rotate in both
directions depending upon the polarity of current through the motor. These
motors have free running torque and current ideally zero. These motors have
high speed which can be reduced with the help of gears and traded off for torque.
Speed Control of DC motors is done through Pulse Width Modulation techniques,
i.e. sending the current in intermittent bursts. PWM can be generated by 555
timer IC with adjusted duty cycle. Varying current through the motor varies the
torque.
P0 EQU 080H
P1 EQU 090H
P2 EQU 0A0H
P3 EQU 0B0H
; X X X X 1 X 0 0 - FWD -- 03
; 0 1 - TR 01
; 1 0 - TL 02
; 00 - STOP 00
ORG 0000H
AJMP START
ORG 0050H
START: MOV R1,#0FFH
MOV R2,#004H
MOV P2,#000H
MOV A,P1
ANL A,#003H
CHECK_LEFT:
CJNE A,#001H,CHECK_RIGHT ;////// TURN LEFT ///////////
SETB R_MO1
CLR R_MO2
CLR L_MO1
SETB L_MO2
MOV R1,#0FFH
MOV R2,#004H
HERE_LEFT:
MOV A,P1
ANL A,#003H
CJNE A,#003H,LEFT_CONT
DJNZ R1,LEFT_CONT
DJNZ R2,LEFT_CONT
AJMP STOP
LEFT_CONT:
JB P1.0,HERE_LEFT
AJMP LOOP
CHECK_RIGHT:
CJNE A,#002H,CHECK_STOP ;/////// TURN RIGHT ///////
CLR R_MO1
SETB R_MO2
SETB L_MO1
CLR L_MO2
MOV R1,#0FFH
MOV R2,#004H
HERE_RIGHT:
MOV A,P1
ANL A,#003H
CJNE A,#003H,RIGHT_CONT
DJNZ R1,LEFT_CONT
DJNZ R2,LEFT_CONT
AJMP STOP
RIGHT_CONT:
JB P1.1,HERE_RIGHT
AJMP LOOP
CHECK_STOP:
DJNZ R1,LOOP
STOP: SETB R_MO1
SETB R_MO2
SETB L_MO1
SETB L_MO2
HERE_STOP:
AJMP HERE_STOP
END
HEX CODE GENERATED FOR THE CODE:-
: 020000000150AD
: 1000500079FF7A0475A000A2909286A2919287E51A
: 10006000905403B4000ED283C285D281C28079FF3E
: 100070007A040157B4011ED283C285C281D280792D
: 10008000FF7A04E5905403B40306D904DA0201B8F8
: 100090002090F00157B4021EC283D285D281C28063
: 1000A00079FF7A04E5905403B40306D9E3DAE10159
: 1000B000B82091F00157D99FD283D285D281D280C6
: 0200C00001C07D
: 00000001FF
PROBLEMS ENCOUNTERED:-
• The ISP programmer requires dedicated supply of 9V from the USB of your P.C.
Extern supply of other than 9V generates error while writing the HEX code to the
Microcontroller. The programmer was soldered 3 times before it could
successfully program the chip.
• The program was difficult to implement as it was our first encounter with
microcontroller programming in assembly.
• The large number of interconnections in the circuit made it too difficult to
solder.
• The IR sensors burnt up on soldering so we have to use temperature controlled
soldering iron.
• In the model designed to show line follower robot, electric motors ought to be
bidirectional and of low wattage i.e. should draw lesser current otherwise the
motor can draw current to such a level to burn up the entire circuit.
REFERENCES AND RESOURCES:-
Boo ks :
1) The 8051 Microcontroller and Embedded Systems Using
Assembly and C By Muhammad Ali Mazidi, Janice Gillispie
Mazidi & Ro lin D. McKinlay
Webs ite s r ef er re d:
1) Atmel Corp. Makers of the AVR microcontroller
www.atmel.com
2) One of the best sites AVR site www.avrfreaks.net
3) One of the best site for Microcontroller projects
www.kmitl.ac.th
4) Keil™, the developer of Keilμvision www.keil.com
5) Information from www.wikipedia.com