PC-Based Wireless Control for Toy Car

By Bodhibrata Mukhopadhyay, Gourabsil & Subhajit Mazumdar

5735
 

A key feature of the P89V51RD2 is its X2 mode option. You can choose to run the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or select the X2 mode (six clocks per machine cycle) to achieve twice the throughput at the same clock frequency.

The Flash program memory supports both parallel programming and in serial in-system programming (ISP). It is also in-application programmable (IAP), allowing the Flash program memory to be reconfigured even when the application is running.

In this project, timer 1 (TH1) is used in mode 2 (8-bit auto-reload). It is used to set the baud rate. Here it is loaded with a value of E8 hex (or -24) and so the baud rate is set at 1200. The SCON register is loaded with a hex value of 50, indicating serial mode 1, where 8-bit data is framed with a start bit and a stop bit.

After timer TH1 is set, it starts running until the P89V51RD2 microcontroller is made off. The P89V51RD2 waits until it receives a start bit. After receiving the start bit, it receives the 8-bit data and places the data in SBUF register. Then the framing error is checked. If there is framing error, the byte received is discarded. Otherwise, the content of SBUF is compared with the ASCII code of alphabets W, S, D, A, Q, E, C, Z and U. When a match is found, the operation related to each alphabet is executed. Then the toy car stops or moves in a particular direction as per this value.

Driving the DC motors

Port pins p1.1 through p1.4 of the microcontroller drive four relays through a relay-driver circuitry comprising transistors T1 through T4. The four relays, in turn, control four motors of the toy car (Fig.5). Two relays control the forward and reverse rotations of a motor. The left two motors are connected in parallel and so are the two motors of the right. So two motors are controlled simultaneously using two relays.

Each of the four relays is 12V, single- changeover electromagnetic type to control the PMDC motor (12V, 50-rpm). The relays play an important role in isolating the controlling circuit and PMDC motors to protect the microcontroller and other low-current devices from the relatively high-current-driven motors. Basically, these are switches that connect or disconnect the motors from the 12V supply. Control signals from the microcontroller energise or de-energise the relays. That is, when a control signal makes a pin of P89V51RD2 high, the transistor connected to it conducts to energise the corresponding relay.

Here +12V terminal of the battery is connected to normally-open (N/O) contacts of all the relays and the ground terminal is connected to normally-closed (N/C) contacts of the relays.

This means when all the relays are not energised, positive and negative terminal ends of all the motors connect to the ground terminal of the battery, so the motors will not rotate. If all the relays energise, ends of the motors connect to +12V and the motors don’t rotate. If any of the relays energises, one end of the respective motor connects to +12V and the other end to the ground. This makes the motor rotate. Energisation of the relay decides clockwise or anticlockwise movement of the motor.

Q1 output from the microcontroller is fed to the base of transistor T1. When Q1 is high, transistor T1 conducts and relay RL1 energises to make the pole (P) shift towards N/O contact. This connects +12V to the positive terminal of motor M1 on the front left of the toy car.

Relay connections

Relay connections to motors
Relay connections to motors

When Q2 output is high, transistor T2 conducts and relay RL2 energises to make P shift towards N/O contact.This connects +12V to the positive terminal of motor M2 on the left back of the car.

When Q3 output is high, transistor T3 conducts and relay RL3 energises to make P shift toward N/O contact. This connects +12V to the positive terminal of motor M3 on the right front. When Q4 output is high, transistor T4 conducts and relay RL4 energises to make P shift toward N/O contact. This connects +12V to the positive terminal of motor M4 on the right front.

When Q4 output is high, transistor T4 conducts and relay RL4 energises to make P shift toward N/O contact. This connects +12V to the positive terminal of motor M4 on the right back.

SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here