A robot can be defined as an electro-mechanical system with the capability of sensing its environment, manipulating it and acting according to the preprogrammed sequence. It is a machine that appears intelligent due to the instructions it receives from a computer inside it which handles multiple tasks. This article features a car robot—RoboCar—which uses a microcontroller to detect obstacles and manipulate its direction as per the inputs from three infra-red (IR) sensors mounted in front of the car.
Basic components of RoboCar
The heart of the system is a microcontroller—Atmel AT89C52. It is programmed to accept inputs from its port p0 to sense the obstacles around it and control the steering to avoid any collision.
There are three TSOP1738 IR sensors (Q1, Q2 and Q3) used in this project—one at the centre and the remaining two on the left and right to detect obstructions, if any, in front of the RoboCar (Fig. 1). In case of an obstacle, or a potential collision, the microcontroller controls the steering through a bipolar stepper motor which is driven by an L293D motor driver IC. L293D is a quadruple half-H driver IC with an output current rating of 600mA at voltages ranging from 4.5V to 36V.
A DC motor is used for moving the car forward and backward, depending on the signals received from the three IR sensors. These sensors are used in any remotely-operated home appliance like TV, DVD player, etc. The IR sensor TSOP1738 operates at a frequency of 38 kHz. NE555 timer IC is used for generating a pulse of 38 kHz and transmitted through IR LEDs. There are five IR LEDs—two each on the left and right and one on the front of the robot. The reflected IR that beams from the obstacles are received by the sensors and sent to the microcontroller. The microcontroller is programmed in such a way that it takes the decision and changes the path of the robot as per the sensors’ inputs to avoid the obstacles.
The schematic diagram of an AT89C52-based RoboCar is shown in Fig. 2. This RoboCar is powered by a 12V rechargeable battery connected to a 5V regulator IC 7805 (IC1) through a current limiter R1. This 5V is used for supplying power to the microcontroller AT89C52, IC NE555 and IR sensors TSOP1738.
Switch S1 is used for turning on the circuit to run the robot. An additional filter circuit, comprising a resistor and a capacitor for each IR sensor, is used for preventing interference with noise signals. Switch S2 acts as a hardware reset for the microcontroller in case the robot is not running properly.
The microcontroller AT89C52 (IC4) is responsible for taking decisions if any obstacle is detected by the IR sensors. It drives the stepper motor (M1) so that the car changes track to avoid a collision with the obstacle.
Port 0 (P0.0 through P0.7) of the microcontroller is used as the input port that is connected to the sensors. Each of these port pins (P0.0 to P0.7) is pulled high through pull-up resistors R14-R21. Note that port pins P0.3 through P0.7 are not used in this application. You can use them to extend the application to make it a line following robot by using similar sensors and making some changes in the code. Port 1 (P1.0 through P1.3) is used for driving the stepper motor through the driver IC L293D (IC2) and port 3 (P3.0 and P3.1) is used for driving the DC motor (M2) for forward or backward motion through another L293D (IC3) driver IC.
Each sensor used here is a 3-pin modular device, where the first and second pins are negative and positive supply terminals respectively and the third pin is the output terminal. A filter circuit comprising a 100-ohm resistor and a 4.7µF capacitor is used for powering each sensor. Normally, the output of the sensor is high. When an IR pulse of frequency 38 khz falls on the IR sensor, its output goes low. This low output is sensed by Port 0 of the microcontroller and an action is taken as per preprogrammed instructions.
Pin 31 of the microcontroller has to be pulled high so that it can fetch the codes from its internal memory. But if any external memory is used in the circuit, the pin should be pulled low.
Here, R2 and C2 are used for the power-on reset function. As soon as the power is switched on, a high pulse is applied to pin 9 of the microcontroller to reset it. This action initiates the program and the RoboCar starts moving forward.