Line follower robot using 8051
Line follower robots were one of the earliest automatic guided robots. They are able to follow a line marked on a contrasting background, usually a black line on a white surface or a white line on a black surface. Usually, the line follower robot works on a closed loop feedback algorithm where the feedback from the line sensor is used by the controller for correcting the path of the robot. The sensors are usually LED/LDR, LED/Photodiode or LED/Phototransistor pairs and the controller is an electronic circuit which executes the desired feedback algorithm. Gear motors are used for driving the robotic wheels.
Note:- If you are interested in Arduino based development, we have created this same line follower robot using arduino as well. You may try the Arduino based circuit as well to see how the same project is developed using different controllers.
The line follower robot presented here is designed to follow a black line on a white background. It has a pair of sensors (LED / LDR) and works on a simple “align robot on the center of the line algorithm”. Actually you does not need a microcontroller for implementing such a simple robot. A set of comparators and a motor driver circuit will happily do the job. But I am using the microcontroller just to demonstrate the technology. Also this project serves as a platform for advanced line follower robots which works on complex algorithms. AT89S52 from Atmel is the microcontroller used here.
Sensor
The sensor part consists of a set of LED / LDR pairs for the left side and right sides. These LED / LDR pairs detect the black line on the white surface on which the robot is supposed to roam. The LDR has an inverse relationship between its resistance and the light falling on it. When a particular LED / LDR pair is above the white surface the reflected light falls on the LDR and its resistance drops, conversely when the LED / LDR pair is above the black line, its resistance rises. This variation in resistance of the LDRs is used to assess the orientation of the line follower robot in the X-Y plane. The figure shown below depicts the sensor circuit.
Microcontroller (AT89S52).
The task of the microcontroller here is to control the left and right motors according to the feedback signals from the left and right comparators so that the robot remains on the correct path (the black line). The logic executed by the microcontroller for keeping the robot in track is illustrated in the table below.
Motor driver circuit.
Capacitors C4 and C5 isolates the remaining parts of the circuit from the electric interference produced by the motor. The back emf voltage produced when motor is switched and the voltage spikes due to arcing of brushes mainly accounts for the above said electrical interference. These capacitors are very essential and without them you can expect sudden crashes from the microcontroller side.
Complete circuit diagram.
Switch S1, capacitor C3 and resistor R9 forms a debouncing reset circuit for the microcontroller. Capacitors C1, C2 and 12MHz crystal X1 are associated with the microcontroller’s clock circuit. R12 and R13 are pull-up resistors. Remaining sections of the circuit were explained already.
Line Follower Robot Program
ORG 000H // origin MOV P1,#00000011B // sets port 1 as input port MOV P0,#00000000B // sets port 0 as output port BACK: MOV P0,#00000011B // starts both motors JB P1.0, LABEL1 // branches to LABEL1 if left sensor is ON CLR P0.0 // stops left motor SETB P0.1 // runs right motor ACALL WAIT1 // calls WAIT1 subroutine SJMP BACK // jumps back to the BACK loop LABEL1: JB P1.1, LABEL2 // branches to LABEL2 if right sensor is ON SETB P0.0 // runs left motor CLR P0.1 // stops right motor ACALL WAIT2 // calls WAIT2 subroutine SJMP BACK // jumps back to the BACK loop LABEL2: SJMP BACK // jumps back to the BACK loop WAIT1:JNB P1.0,WAIT1 // waits until robot is back from rightward deviation RET // returns from WAIT1 subroutine WAIT2:JNB P1.1,WAIT2 // waits until robot is back from leftward deviation RET // returns from WAIT2 subroutine END // end statement
About the program.
Notes.
- A 6V battery can be used for powering the circuit even though the power supply shown in the circuit diagram is 5V DC.
- For setting up the robot, place the robot on the line so that both the sensor pairs point on white and the black line goes in between them. Then adjust preset resistors R10 and R11 so that the LEDs D3 and D4 glows.
- Sensor LEDs D1 and D2 are ultra-bright green LEDs.
- OPAMP output LEDs D3 and D4 are general purpose, miniature, yellow LEDs.
- Sensor LDRs R4 and R7 are general purpose LDRs.
No comments:
Post a Comment