Detailed explanation of making 51 single chip microcomputer four-wheel drive wireless remote control car

Publisher:石头上种庄稼Latest update time:2012-06-25 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Car parameters: 5 control keys: forward, backward, turn left, turn right, stop; effective distance 200 meters; speed:

I think everyone has played with remote control cars, and there are also detailed instructions for making various DIY cars on the Internet. The remote control car I made is similar to other works, but as a single-chip microcomputer design, this time I mainly emphasized single-chip microcomputer control, that is, this car is controlled by a single-chip microcomputer. This time I took the single-chip microcomputer button sending program, the use of wireless modules, and motor drive as the core content of this tutorial.

1. Hardware Assembly

1 Car movement part

This picture was assembled by my junior brother, please use it as a reference

Required workpieces: 4 DC motors, L293D motor driver module, a battery, chassis

Note: You can buy the chassis and battery according to your own purchasing power. As for the L293D module, it is more expensive on Taobao, but I use the finished module, and the effect is very good. Students with little money can buy chips and make their own modules. The principle is very simple, and the official information is very detailed; or change to relay control, depending on your actual purchasing power. The advantage of using the module is that the module can output 5V power to power the system. Please refer to Taobao for details.

If you buy a ready-made chassis, it will be the same as mine. There is really nothing to say about assembly. Just fix the motor on it. No? Don't be kidding, even elementary school students can do it! As for those who want to make their own chassis, I want to say that it should be sturdy. Our car has enough horsepower because it is driven by a motor and has a relatively fast speed (be careful with a chassis without a reduction gear, as it has a very fast speed). It also has enough stamina, so it is normal to accidentally hit the wall, so be careful with a bad chassis!

After assembly, it is time to connect the motor and driver module. Now I will explain in detail the use of the L293D module:

L293D is a special motor driver chip, with an operating voltage of 5V, a drive voltage input of up to 36V, an output current of positive and negative 600ma, 4 control terminals, and 4 output terminals. The principle is as follows

picture:

A is the output control terminal, Y is the output control terminal, 1A controls 1Y, and so on. 1, 2EN 3, 4EN need to be short-circuited, and the maximum operating voltage of the chip must not exceed 7V.

Package Diagram:

Vcc1 is connected to the working voltage, 5V, and Vcc2 is connected to the motor's driving power supply. Generally speaking, this voltage should be higher than 5V. I use a 12V battery, so I connect the positive pole of 12v to VCC2. Remember that the chip, microcontroller, and battery power supply need to share a common ground. Don't think that your motor is 12V and the microcontroller control part is 5V, so the power supply should be completely independent. It's true that the positive pole is completely independent, but the GND (negative pole) must be connected together.

Connection method between driver chip and motor:

Example: Left front and rear wheels:

1Y connects to the red wire of the motor, 2Y connects to the black wire of the motor, and the left front wheel motor

3Y connects to the red wire of the motor, 4Y connects to the black wire of the motor, and the left rear wheel motor

Forward command: 1A=1 (output 12V), 2A=0 (output 0V), 3A=1 (output 12V), 4A=0 (output 0V)

Backward command: 1A=0 (output 12V), 2A=1 (output 0V), 3A=0 (output 12V), 4A=1 (output 0V)

The connection method on the right is exactly the same as that on the left.

Note: Forward and backward are not absolute, because it is a DC motor, and the positive and negative poles are not emphasized deliberately. It depends on how your motor is connected. The result can be completely opposite to mine. However, the uniformity of the motor wiring must be ensured. It cannot be arbitrary. You cannot say that the front wheel is connected in a clockwise sequence and the rear wheel is connected in a counterclockwise sequence. If the motor connection wire you buy does not have a color, you must measure it yourself to see which connection is clockwise and which is counterclockwise. Otherwise, the front wheel moves forward and the rear wheel moves backward, which is very damaging to the motor, or the rotation directions of the two pairs of motors on the left and right are not unified, resulting in programming troubles.

The chip outputs 0V by default, so when there is no program, you don't need to worry about the motor turning. One chip can only control 2 motors, so just connect another chip to the right. The modules sold online all have 2 driver chips, which is just enough for 4 motors. The advantage of buying a module is that you can connect it directly, and there are numbers on the module, so you don't have to worry about connecting it wrong. I hope beginners will still buy modules. It is expensive, but the speed is guaranteed! The driver module is as shown in the figure:

After connecting, I will talk about the rotation method of the car: forward and backward means that the four motors rotate forward and reverse at the same time; there are two ways to turn left and right: A rotates while not rotating, B rotates forward while rotating in the opposite direction. These two methods have their own advantages. You can determine the turning method according to your actual situation. The chassis effects of different cars are definitely different. The turning method is controlled by the program. This program is method B.
[page]

My car picture:

This kind of motor is decelerated, so it will not be very fast. If the wheel is driven directly by the motor and a 12V power supply is used, the speed will be very fast. The output of the module is directly connected to the motor power line, and the output is connected to the microcontroller according to the label or program.

Wiring of microcontroller:

As shown in the figure:

This is my smallest system board, all IOs are led out, with onboard USB download function, and the P0 port output is connected to 8-way water lights (with a selection switch). This board is designed to specifically check the output status when the P0 port is output. The board is designed by our studio, and all our work debugging is based on it. This kind of USB download board is also sold online, about 40 yuan!

I am a lazy person, so I used a motor driver module. The inputs of L293D are numbered, and 1-8 can be directly connected to P1.0-P1.7 in sequence. Having said that, I have to say that the wiring of the microcontroller is very free, because it is program controlled, and there is no way to just change the port. I only explain the wiring according to my program, and those who have a basic understanding can design it by themselves!

After the driver chip and the motor are connected, the wires need to be fixed, leaving 8 control wires to be connected to the microcontroller. Also, be sure to leave a small space for the wireless module.

[page]

Wireless module explanation:

Our studio has been using 433 wireless serial port module. I will attach the specific model and price in the list. Now I will talk about its performance. The biggest advantage of this wireless module is that it has strong anti-interference. Two modules can directly set ID. Only modules under one ID number can communicate, and one-to-many communication can be realized. Moreover, this module does not need programming. Just send data to the serial port. The module will automatically modulate and demodulate. As far as the current use is concerned, it has not been found that it has a modulation and demodulation error. It can be said that in data transmission, the error rate of this module is still very low. However, it should be noted that the interval between the module's two receptions (transmissions) should be greater than 200ms. This is a very important parameter. If you want to do high-speed data transmission, please choose it carefully! (This paragraph is from the manual of Taobao Ruidi wireless module. I have also uploaded it. Please respect the copyright of the store.)

The wiring of the module is quite simple, with 2 power lines and 2 data lines: TX (connected to the microcontroller RX), RX (connected to the microcontroller TX). For the setting scheme of the wireless module, please refer to the data manual of the model XL02-232AP1 of Ruidi Wireless on Taobao. The red and green lights of the module will flash at the same time when it is powered on, and then go out, entering the standby state. When the module sends data, the red light is on; when receiving data, the green light is on.

The picture after assembly:

I use a 12V battery. After connecting it to the driver module, the 5V output of the module can directly power the wireless module and the minimum system. Although it looks bulky, the 12V power supply has substantially improved the speed and endurance of ordinary cars!

Remote control part:

hex code, simulation provides hexadecimal file

[page]

source code:

; Receiving program

ORG 0 ; program starting address

SJMP STAR ; Jump to the main program

ORG 30H ;Serial port interrupt address

sjmp loop ; jump to interrupt service routine

STAR:

MOV SP, #5FH ; Set up the stack

MOV SCON, #50H; serial data format (please refer to the 51 manual for details)

MOV TMOD, #20H; Timer working mode (please refer to 51 manual)

MOV PCON, #0; baud rate is not doubled (please refer to 51 manual)

MOV TH1, #0fdH; Set the baud rate to 9600

MOV TL1, #0fdH; Set the baud rate to 9600

SETB EA ; Enable interrupt

clr ET1 ; Disable timer 1 interrupt

SETB ES ; Enable serial port interrupt

SETB TR1 ; Start timer 1

mov a,#0 ;

mov p1, a; set the initial value, that is, p1 output 00h when powered on, the car does not move

main:

mov p1, a; put the value of a into port p1

sjmp main ; infinite loop main program

LOOP:

jnb ri, $; Determine whether the receiving bit is received

clr ri ; clear the receiving bit after receiving

mov a, sbuf; send data to a

reti; after returning, the value of a will be given to p1

END

; Send program

ORG 0 ; program starting address

SJMP START ; Jump to the main program

ORG 30H ;Serial port interrupt address

START:

MOV SP, #5FH ; Set up the stack

MOV TMOD, #20H; Timer working mode (please refer to 51 manual)

MOV PCON, #0; baud rate is not doubled (please refer to 51 manual)

MOV SCON, #50H; serial data format (please refer to the 51 manual for details)

MOV TH1, #0fdH; Set the baud rate to 9600

MOV TL1, #0fdH

setb EA ; Enable interrupt

clr ET1 ; Disable timer 1 interrupt

setb ES ; Enable serial port interrupt

SETB TR1 ; Start timer 1

main:

lcall kcs ;Call key scanning program

jnz key ;If a key is pressed, jump to the key program segment

sjmp main ; infinite loop main program

kcs:

mov p1, #0ffh; p1 is given an initial value

mov a, p1; the value of p1 is given to a

cpl a ; negate a

anl a,#0ffh ;AND operation

ret

key:

lcall delay; software delay program, key debounce

jb acc.0, send1

jb acc.1, send2

jb acc.2, send3

jb acc.3, send4

jb acc.4, send5

ret

DELAY:

MOV R5, #20

D1:MOV R6, #10

D2:MOV R7, #100

DJNZ R7, $

DJNZ R6, D2

DJNZ R5, D1

ret

send1:

mov r1, #10101010b ; forward instruction

sjmp send

send2:

mov r1, #01010101b ; Backward instruction

sjmp send

send3:

mov r1, #01011010b ; turn left instruction

sjmp send

send4:

mov r1, #10100101b ; right turn instruction

sjmp send

send5:

mov r1, #00h ; stop instruction

sjmp send

send:

MOV SBUF, r1 ; instruction to sbuf

JNB TI, $; Determine whether the sending is completed

reti ;Interrupt return

END

Reference address:Detailed explanation of making 51 single chip microcomputer four-wheel drive wireless remote control car

Previous article:Simulating PLC Control Using Atmel89S51 Single Chip Microcomputer
Next article:High-precision division usage and program list of 51 single-chip microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号