How a RoboCar works
As soon as the circuit is powered on, the controller IC4 fetches the codes from its internal memory and sets its pin 10 high and pin 11 low. This signal is fed to pin 2 and pin 7 of IC3, which drives the DC motor in one direction. This enables the car to move forward. IC5 is wired as an astable multivibrator to generate a 38kHz pulse.
The 38kHz pulses are amplified by transistor T1 to drive five IR LEDs. The IR sensors and LEDs are arranged in such a way that the output of the sensors is high where there is no obstacle near the car. But if there is any obstacle, the transmitted IR signals from the IR LED are reflected back from the obstacle that comes in the way. This makes the sensor output go low. This low output signal is fed to port 0 of the microcontroller. The output of sensor Q1 is connected to P0.0, Q2 to P0.1 and Q3 to port P0.2.
As soon as the output of the left sensor Q1 is pulled low to P0.0=0, the controller alters the spin of the DC motor, makes port P3=0 and stops the DC motor, thereby stopping the car for a moment. Then it drives port 1 in such a way that the stepper motor is rotated to the right, and the front steering wheels are also turned right, while the car continues to move forward. After a few seconds, the controller drives the stepper motor in the reverse direction (turning it left), which brings the steering wheels to the straight position and moves the car forward. Similar is the case when an obstacle is detected at the right sensor Q2.
In case there is an obstacle in the front, the centre sensor Q3 sends a low signal to port pin P0.2. This makes port P3=0 and the car stops. The steering wheels are turned left making port P3.0=0 and P3.1=1, which moves the car in backward direction with the steering still turned. After a few seconds, the DC motor is stopped by making port P3=0. The steering is set in the straight position and the car moves forward by making the port P3.0=1 and P3.1=0.
Thus, when the port P3.0=0 and P3.1=1, the car moves in the reverse direction; when P3.0=1 and P3.0=0, the car moves in the forward direction and when P3.0=0 and P3.1=0, the car stops.
Fig. 3 shows the plan view of the mechanical model of the car. The rear wheel is driven by a belt, pulley and a DC motor. The pulley and drive belt for the rear wheels are taken from the HP Business Inkjet 1000 ink tank pump assembly.
If the polarity of the DC is reversed, the motor spins in the opposite direction. The same concept is used for driving the dc motor. The front wheels are mounted on a fibre gear which can be rotated in both directions using a gear and a stepper motor. The gears are taken from an old HP DeskJet 3325 paper-feed printer assembly and the stepper motor for steering control is taken from an old Epson Inkjet 460 printer assembly.
In order to avoid collision or friction between the main car chassis and the wheels, enough space has been provided between them for their free rotation. The front PCB is mounted at a height to avoid collision with front wheels while turning. Two gears are used for when the car is running on a rough surface. The main chassis is made of a thick fibre board.
The circuit is assembled on a general-purpose PCB or on a PCB layout. The actual size, single-side PCB layout is shown in Fig. 4 and its component layout in Fig. 5.
The main PCB and the front PCB can be separated by cutting along the dotted line shown in the PCB layout.
The front PCB assembly is mounted on the front side of the robot as shown in Fig. 3. It is attached firmly on the main chassis board with nuts, bolts and spacers. The main PCB is also mounted on the chassis board with nuts and bolts and spacers. Three 4V rechargeable battery cells, taken from a laptop, can be placed between the main PCB and the chassis board (Fig. 6). The ‘charger input’ charging terminal has been provided in the PCB for charging the battery.
The main PCB and the front PCB are connected through CON1 and CON2 with suitable length of wires.
The software code is written in C language using the free small device C compiler or SDCC. You can download SDCC from the link http://sourceforge. net/projects/sdcc/ files/, free of cost. The compiler creates some issues in Windows XP. In this project the code is compiled in a Windows 98 SE environment. The generated hex code is then burnt into the microcontroller unit (MCU) using a suitable Atmel 89 series programmer such as one from Sunrom Technologies or Frontline Electronics. You should not remove the microcontroller from the zero insertion force (ZIF) socket until the programming is complete.
Download source code: click here
Steps for installation
1. Install SDCC using SDCC-2.9.0-setup file. It will automatically install under c:\Program files\SDCC
2. Copy ‘Robo1.c’ file under C:\ program files\SDCC\Robocar
3. Open the MSDOS prompt and give the above path
4. Type ‘SDCC Robo1.c’ against the DOS prompt to compile it. If no errors are found in the code, it will generate the .lst and .ihx files in the same directory where the robo1.c file is located
5. Convert the Robo1.ihx file to generate the robo1.hex file using ‘pack. ihx’ as:
6. Use the robo1.hex file to program the MCU
Once all the parts are assembled, it is necessary to check the operational function of the car on the repair bench itself before leaving it to move on the ground. You can lift the car, switch on the power and check the operation by putting your hand near the sensor to ensure each sensor is working perfectly. You can adjust the range of sensing by varying the preset VR1. It is not recommended to keep the range very long because this would cause the car to keep moving forward and backward as it senses any obstacle, even far away from it. Once you are sure that the car is operating well, you can leave it to move freely.