super_star

[Single-chip microcomputer] Smart car design based on 51 single-chip microcomputer

 
Overview

1. Project introduction

        Smart cars are a very classic course case. There are various car body models and kits for sale on the market. Can we design a smart car ourselves? Based on this idea, we designed this STC89C52. Mainly controlled smart car. As for why STC is used as the main control, the main reason is that this chip is highly recognized by everyone and is very classic!

Application scenarios:

  • Single-chip microcomputer course teaching, using smart cars to replace development boards throughout the single-chip microcomputer course teaching
  • Microcontroller course design allows students to implement relevant functions according to requirements
  • Electronic cognition and welding exercises, complete the welding of smart cars, stimulate interest in electronic learning

Features:

  • The two left and right car lights simulate the state of the car lights in a passing car.
  • Independent keys to practice key input and interrupt functions
  • Passive buzzer, learning audio frequency generation, simulating sprinkler truck music
  • Four motor drives realize PWM output and speed adjustment functions
  • Tracking and obstacle avoidance functions, learning comparator circuit, realizing obstacle avoidance and tracking functions
  • Wireless remote control, learn wireless transmission theory and realize remote control function

2. Overall design plan

        This design uses two lithium batteries with a total of 7.4V as the system power supply. After the voltage is reduced to 5V, it supplies power to the microcontroller system, including the microcontroller and button circuit, infrared receiving circuit (wireless remote control function), obstacle avoidance circuit, tracking circuit, and LED. The car lights, passive buzzer and motor drive circuit are connected. The system block diagram of the circuit composition is as follows:

wps

Figure 2-1 Smart car system block diagram

3. Hardware introduction

        How is such a feature-rich smart car designed? Next, we will introduce the functional composition of each circuit module one by one.

3.1 Power input

        What is the power supply? Power supply is an important component that provides energy to the entire system. "This is a horse. Although it can run a thousand miles, it is not full of food, lacks strength, and its talent and beauty are not visible. Moreover, if you want to be like an ordinary horse, you cannot get it. How can you expect it to be able to run a thousand miles?" The car is a good car, but it does not have a good power source. , then the performance of the car cannot be exerted. In terms of power supply, this project uses a 7.4V rechargeable lithium battery, which supplies power to the microcontroller and peripheral devices through a 7805 step-down chip, while the motor-driven chip is directly supplied by the 7.4V battery. Diode D1 acts as an anti-reverse connection, and LED2 acts as a power indicator light. When switch SW1 is turned on, the system turns on power supply.

9d4q2tf9cuRlIOTkVNZsDQGfoT9LyiBhsMVGPuGE.png

Figure 3-1 Power input part

3.2 Minimum microcontroller system

        The minimum system of 51 microcontroller consists of main control chip, crystal oscillator circuit, reset circuit, download interface and P0 pull-up resistor. When designing a circuit using a chip, you should not blindly search for reference circuits on the Internet. Instead, you should consult the data sheet provided by the manufacturer. The information provided by the manufacturer is the most reliable. The following picture is the minimum system application diagram in Section 1.6 of the STC89C52 series microcontroller device manual:

4KvWGP9GEm8oCirtyPw7zBtNuUINyD7RwB58oyTx.png

Figure 3-2 Information provided by STC official website ( click to view the data sheet )

        The reset circuit and crystal oscillator circuit are also explained in the minimum system diagram, and there are specific selection parameter descriptions below. The reset function is on the ninth pin. The design officially provides a power-on reset circuit composed of a 10K resistor and a 10uF capacitor. Based on the actual usage, you can add a button and press the button when you need to reset.

        The crystal oscillator function is on pins 18 and 19. The parameter selection given below mentions the size of the crystal oscillator, the size of the resonant capacitors C2 and C3, and the value of the R2 resistor. During the learning process, combined with the characteristics of the 51 microcontroller timer, generally choose 11.0592MHz crystal oscillator, because this clock frequency can accurately divide the clock frequency when dividing, and the value calculated when doing baud rate communication is an integer, maintaining the accuracy of communication.

        In addition to the minimum system application circuit in the figure above, we also need to check the pin description of the device, which can help us better understand the function of each pin of the chip. It is worth noting that the P0 port of STC89C52 (32 to 39 pin) is quite special. It is specifically mentioned in Section 1.8 of the data sheet: There is no pull-up resistor inside the P0 port. When used as an I/O port, an external pull-up resistor of 10K~4.7K is required.

OA5rIEmmLRjgMs9K4cSn1YRR7CCS9f7CM81IMily.png

Figure 3-3 Microcontroller pin description table (part)

        Combining the above theory and calculation foundation, plus a program download interface, the microcontroller can work normally. The minimum system circuit design of the smart car's main control is as follows. The purple ones are network labels. Using the same network labels can reduce connections and make the circuit look simpler. RST uses a network port, and its usage is consistent with the network label. J10 leads out the extra pins and can be connected to other circuits for learning.

JRhoZV9MYGaYW2h3JHzyXxemwpshHQ5i6VfHl0pP.png

Figure 3-4 Minimum system diagram of microcontroller

3.3 Motor drive circuit

        If you want the car to run stably, motor drive is indispensable. The current directly output by the microcontroller is too small to drive the car to move. The motor circuit uses the RZ7899 motor-specific drive chip, which has simple peripheral circuits and is suitable for application circuits such as automatic valve motor drive and electromagnetic door lock drive. It controls the motor forward, backward and braking through the logic input ports BI and FI, and can control the motor speed with the PWM output of the microcontroller. This application circuit has excellent anti-interference capabilities, small standby current, low output internal resistance and other excellent functions. When welding, be sure to connect a 104 ceramic capacitor in parallel to the motor to prevent interference.

ZAGZfAhZI0eP2dW2wJRv22feMyJ9E5JCYWZQZi9z.png

Figure 3-5 RZ7899 motor drive circuit

3.4 Tracking and obstacle avoidance circuit

        The tracking and obstacle avoidance circuits are designed using 393 voltage comparators and two different types of infrared tubes. The ITR9909 device with integrated transmitting and receiving tubes is used as the counter tube of the tracking circuit. The car tracking is generally walking along a black line on the white floor, and uses the reflection of infrared light in different colors for identification. Infrared light is always emitted to the outside. If the bottom of the car is a white floor, the light will be refracted back. At this time, the receiving tube receives the signal and outputs a high level feedback to the microcontroller through the comparator. If the car is driving around the black line, the infrared light will be black. Absorption, the receiving tube cannot receive the transmitted signal, and the output of the comparator circuit is low level at this time. The principle of the obstacle avoidance circuit is similar to that of tracking. You can analyze it by yourself.

8uByIunTv76UdDtpYpur6lHxQUUvZ00IbiU2tonq.png

Figure 3-6 Tracking and obstacle avoidance circuit

3.5 Other circuits

        In addition to realizing the basic tracking and obstacle avoidance functions of the car, in order to further optimize the functions of the car, a button is designed as an external control, which can also be used for function switching and code debugging. Since the car is to be built, the car lights must be Indispensable, two high-brightness LEDs are selected to be distributed on the left and right front of the car to simulate different scenes during driving for functions such as constant light, double flash, low beam and high beam;

ZoSZYchLNHJ4p6AvC9uVfl8zoSdHcBQeOo6Su2KA.png

Figure 3-7 Car light and button circuit

        When we encounter special circumstances while driving, we usually sound the whistle, then we can add a buzzer circuit. Since we have added a buzzer, we can use a passive buzzer, which can Just play music while walking. Since the driving current of the microcontroller is limited, a digital triode can be added for driving to improve the output capability. If there is no suitable triode on hand, direct connection can also be used.

4RP3QDI9lNnX32eZktCd4X7Ej1XmDbxiVcSNaaBJ.png

Figure 3-7 Buzzer circuit

        The remote control function is very useful. We cannot control the walking direction arbitrarily while the car is driving. At this time, the importance of wireless remote control is reflected. There are many remote control methods, such as Bluetooth, WIFI, 4G and other common technologies. Here we have chosen a simpler solution, using the infrared remote control that everyone is very familiar with. You must have used this before, but didn’t expect it? If you think about it, the remote control of the TV and air conditioner at home is an infrared remote control. Haha, infrared technology is actually widely used around us. So how to use an infrared remote control to control the walking of the car? The circuit connection is very simple. You only need to connect a pin between the receiver and the microcontroller for communication, and then match it with a remote control to control it.

        The smart car circuit diagram is organized as follows:

dFJMQC8CqAjaQtUUU8zS4NzB5LWdagK2zb7ljJYM.png

Figure 3-10 Smart car circuit diagram

        Extension: The active buzzer sounds when it is powered on and outputs a fixed frequency tone, while the passive buzzer requires PWM driving and can output different tones.

4. Schematic diagram and PCB design considerations

4.1 Notes on schematic design

4.1.1 Project creation

        Before designing the schematic diagram, you need to create a project folder first. The file can be owned by an individual, or you can choose to save it to a team. If a university uses the education version, it needs to create a project in the corresponding education version workspace and save it to the corresponding class. After creating the project folder, a schematic drawing will be automatically generated, which needs to be manually saved into the project and the file name must be modified according to the schematic content. For example, the project name is: [Single-chip microcomputer] Smart car design based on 51 single-chip microcomputer, and the schematic diagram is named: Smart car design based on 51 single-chip microcomputer_SCH.

jF1lMtvt0OztmEbBk1D27sUikAeLL2AYSBMPkmql.png

Figure 4-1 Project naming reference

4.1.2 Component selection and placement

        The circuit scheme has been introduced before, and then the circuit can be designed on Lichuang EDA. Schematic design is to place components on the drawing and connect the circuit to realize the electrical function. In the process of placing components, we will encounter situations where a device has various packages, such as an LED lamp. Some have two pins inserted into the board and soldered, and some are directly attached to the board and soldered, and the size The spacing is different. When designing, we need to consider what size device we need, whether it is available in the laboratory, whether it can be purchased, whether the selected package can be welded, and other selection issues. Most of the components in this project use direct plug-in components, which is very friendly to novice welders!

cI2zPfRaPUk2Q1NplHowz7dDVV3hoHLk9GREqCRp.png

Figure 4-2 LED symbols and packaging

        When selecting a device, beginners can choose the required device in the basic library of Easy EDA to call. Each device in the basic library can be pulled down to select a different package. If you are not familiar with the device package, you can select it in the component library. Directly search for the required device in the component library, for example, change the search engine to Lichuang Mall in the component library, enter 1K resistor, search, select the plug-in resistor under the category and click Apply Filter. Find the device you need in the search results, click to place it on the canvas, and then place it in the schematic diagram for design.

8qgGlHPulVpBA4JVgicW1PrZpLYnNHPdyovQjGGy.png

Figure 4-3 Searching for components in the component library

        All devices in Lichuang Mall have a unique product number. You can copy this number and search it in the component library. For example, the product number of the car master control STC89C52RC chip in this project is: C14022, which can be found in the component library. Enter the number in, click search, select symbol as the type , and select Lichuang Mall as the library type . You can see the search results in it. Click Place to use this library for design. You can also click Edit to modify the official library and save it as your own. library.

mxU2t6WBXMDrpByIgmbI2I5pKEBALqpvWG93YMeJ.png

Figure 4-4 Search for devices by specifying product number

        Students who are not familiar with component selection can follow the learning videos provided with this project to learn how to select components. There are many types of components, which require continuous accumulation during the learning process. Be sure to check the circuit after the design is completed. An incorrect schematic will generate an incorrect PCB, causing the circuit to not work properly. After checking, organize the schematic diagram and use the line tool (shortcut key L) in the drawing tool floating window to arrange the layout according to each module. You can refer to the case for layout.

4.2 PCB design considerations

4.2.1 Frame shape

        After designing the schematic diagram, it’s time to design the PCB. The design of the PCB shape is the first step that needs to be determined. Since we are making a smart car, the frame we want to design is the chassis of the car. Use the frame layer in Lichuang EDA for design. The frame size is controlled within 10cm*10cm. This is mainly for free proofing, which is also satisfactory when designing this car. Use the straight line and arc tools in the drawing tools to design, and you can also make full use of the grid size and grid size to assist in drawing lines, which can help us design the outer frame more accurately. Regarding the car models and styles, you can design them according to your own preferences without sticking to the reference pictures, such as go-karts, four-wheel drive vehicles, racing cars, etc. Everyone has a different car in their mind, and what we do is we need to express what we have in mind. The design reference outline drawing is as follows:

hN5oyhSAzDqdLDMS6Q3tZhhmicvI2BGCEZQ8xcCf.png

Figure 4-5 Smart car appearance reference diagram

 

4.2.2 PCB layout

        After the PCB frame shape is determined, the components can be laid out. Combined with the characteristics of the smart car, the wheels are placed on both sides, the tracking, obstacle avoidance and light circuits are placed in front of the car, and the four drivers are placed on the four sides. A motor accessory, the smallest main control system is placed in the middle, the power circuit is placed at the bottom of the board, and the switch faces outward. The layout of components after the schematic is converted to PCB is relatively random. It needs to be placed in the appropriate position and adjusted slowly. When laying out components, be good at using the layout transfer of the top menu bar selection tool in the Easy EDA schematic diagram. Function (shortcut key: CTRL+SHIFT+X) can quickly classify and display components. There are several principles to consider in device layout:

(1) According to the circuit module layout, the core devices and peripheral devices of each circuit are placed together;

(2) According to the functional layout of the circuit, components cannot be placed around the special device layout to avoid interference, etc.;

(3) According to the layout of the device characteristics, the input and output interfaces should be placed on the edge of the board for easy operation.

4.2.3 PCB routing

        A good component layout has completed more than half of the entire PCB design work, but the previous layout can only be a rough layout. In fact, it needs to be adjusted during the PCB routing, and it is adjusted while drawing until it is completed in our mind. Medium look. The following points need to be noted for PCB routing. More design points require us to continuously accumulate experience in design and improve our design and drawing capabilities.

(1) The power supply and signal wiring should be laid out according to the signal current flow direction and strictly according to the schematic design drawing. Even if they are all connected and no error is reported, the order must be considered, first through A, then B, and finally to C. , you cannot go directly from A to C to B. This is especially important when you are a beginner.

MGxNFEKR2bmOKKF4HnmlDvDZ9nRESHBz9REtVyC7.png

Figure 4-8 Routing reference

        As shown in the figure, chip U1 is a step-down chip. The power is input from the left side of C1, passes through capacitor C1, flows to chip U1 for step-down, and is output through C2. When placing the layout, the capacitor and chip must be close and neat. Place.

(2) Pay attention to the line width setting during PCB routing. The power line should be slightly thicker than the signal line, which can be set to 30mil, and the conventional signal line should be set to 15mil. The line width cannot be set too thin, and the factory production process should be considered. The PCB production process of Jialichuang is shown in the figure below:

ffM4T5hNVCx7fvSPtHoshAxhNnWXs79cTmEKHCkq.png

Figure 4-9 Jialichuang process drawing

        During the actual wiring process, the pads connecting two identical networks are connected with wires. The wires should be given priority in straight lines, horizontally and vertically. You can adjust the device layout to make the connection between the two points the shortest. If a straight line cannot be maintained, it should be used first. 135° obtuse angle or arc routing keeps the design beautiful.

UMhOtM5BnrApKWbySHxl0AH52JJIVpi9xIm803n.png

5. Project information

Click to view the welding video: https://www.bilibili.com/video/BV1ff4y1H7aw

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-19 21:50:35

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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号