Requisites:
Hardware:
- 1 x AT89C52 Microcontroller
- 1 x 89C52 Project board _with crystal, resistor array and reset ckt.
- 1 x Programmer (ICSP or any)
- 1 x 12V battery (for powering car)
- 1 x 9V battery & Connector (for powering remote)
- 1 x RF Transceiver (433Mhz)
- 1 x HT12E (8 bit address + 4bit data Encoder)
- 1 x HT12D(8 bit address + 4bit data Decoder)
- 1 x L298 (Dual Full H-Bridge)
- 2 x 7805 (5V regulator)
- 2 x 12V Geared DC Motor (300rpm)
- 1 x Castor wheel
- 1 x 750K Resistor
- 1 x 33K Resistor
- 4 x Micro switch
- 7 x LED
- Connecting wires
- 1 x Metal Chassis or Card board
Software:
- Keil uVision3 or later
- Proteus ISIS (for simulation)
- Programmer application
Car circuit:
figure 2 |
In the above circuit (figure 1), Port 0 of AT89C52 is used as input port and Port 1 is used as output port. Port 0 need to have an external pullup. So by default, all port pins of port 0 is high by default. Port 0 has 8 pins (refer figure 2) with which we can have 2^8=256 combinations. But we need only 4 (Forward, backward, left and right) operations. Pin 0.6 is used as an enable for the car to operate, So the switch SW1 connected to P0.6 must be closed for the car to work. Hence 1011 1111.
Pins P0.0, P0.1, P0.2, P0.3 are used.
By default P0.0 through P0.3 are 1s.
i.e. 1011 1111 (0xBF)
lets asign, (may differ from the actual program)
forward - 1011 1110 (0xBE)
left - 1011 1101 (0xBD)
backward - 1011 1011 (0xBB)
right - 1011 0111 (0xB7)
The above can be achieved simply using the wired circuit in figure 3.
void main(void)
{
P0=0xFF; //Assigning P0 as input
P2=0x00; //Assigning P2 as output
SW1=1;
LE=0;
RE=0;
msdelay(20);
while(1)
{
while(SW1==0)
{
while(P0==0xBE) forward();
while(P0==0xBD) left_f();
while(P0==0xBB) backward();
while(P0==0xB7) right_f();
}
}
}
{
P0=0xFF; //Assigning P0 as input
P2=0x00; //Assigning P2 as output
SW1=1;
LE=0;
RE=0;
msdelay(20);
while(1)
{
while(SW1==0)
{
while(P0==0xBE) forward();
while(P0==0xBD) left_f();
while(P0==0xBB) backward();
while(P0==0xB7) right_f();
}
}
}
Instead, if an wireless circuit as in figure 1 is to be developed, the 4 bit data (first nibble) can be received from a decoder to which the same data can be transmitted from an encoder separated by a wireless RF Transceiver set.
Figure 4 |
The second nibble (1011) is made available in the local circuit itself.
The output port P2 is connected to Dual Full H-Dridge (L298)
The call for forward() will enable both the motors in forward direction. Th
void forward(void)
{
L1=1;//Left Motor
L2=~L1;//Enable forward
{
L1=1;//Left Motor
L2=~L1;//Enable forward
R1=1;//Right Motor
R2=~R1;//Enable forward
R2=~R1;//Enable forward
LE=RE=1;
msdelay(20);
}
msdelay(20);
}
Similarly a call for left() will enable right motor and left motor will be disabled which makes the car turn left.
Remote Circuit:
The remote circuit consists of an Encoder HT12E (4 bit data + 8 bit address) consisting of 4 data pins (AD8-11) and 8 address pins(A0-7).
Figure 5 |
A0-A7 - Either grounded or left open.
AD8-AD11 - Connected to buttons to control the directions.
This data (AD8-AD11) will be encoded and transmitted via RF wireless Transceiver and is received by decoder HT12D and the corresponding data is outputted at pins D8-D11. This output is then given to Port pins P0.0-P0.3 respectively.
Thus the wired Remote in figure 3 is replaced by wireless remote in figure 1 without any change in the program.
AT89S52 can also be used instead of 89C52
AT89S52 can also be used instead of 89C52
Related downloads:
C-Program (Also available in above zip)