太白金星

smart car

 
Overview

Smart car design based on STC8A8K

I. Introduction:

I have been using the car for about two years, and I have done it 3 or 4 times. From the first time I just learned microcontroller, I made a three-wheeled car with STC89C52 (it has no functions, only forward, backward, left turn, right turn, controlled by infrared remote control, it walks crookedly, and there is no sense of experience at all), to Later, after learning the STC8A8K , an enhanced microcontroller, I thought about doing a project to consolidate the knowledge I had learned. So I just went ahead and bought a base plate and wheels. This time I chose four wheels. (This time it took the longest time, adding module by module, verifying function by function, debugging the code over and over again, fixing bugs over and over again, basically realizing most of the functions, and adding 4 types. The remote control method and the two obstacle avoidance methods basically used everything I learned, and almost all the resources on the board were used. It was a good experience). Later, I accidentally came into contact with the valuable platform of Easy EDA, and happened to participate in the Easy EDA summer training camp. This training camp happened to be a project using STC8A8K, which gave me the opportunity (the cable connected to the development board was very chaos), so I tested the pin drawing board overnight, and with the support of Easy EDA, I completed the main control board of my smart car (this is my second time drawing the board). This summer training camp may also indirectly It affected me. After this event, my frequency of drawing board increased significantly (I made a lot of messy things). This time again, I heard that Lichuang had a small car project, and I immediately ran over to pay attention. After looking at Lichuang's small car, I realized what the hell I was making. It was really ugly, ugly, and bulky, which made me disgusted. a feeling of. I think I have to finish the project well. This project also cost me a lot of effort. It’s time to revise it. This time I will draw a small one, replace it with an N20 motor, replace it with small wheels, use PCB as the base plate, and increase tracking. circuit, adding a charging circuit (this time it was broken, I will improve it next time), and with the support of Lichuang, my fourth version of the car was born. Following Lichuang's footsteps, my car is getting better and better and going further and further.

2. Version

1.First Edition

This version was made when I first came into contact with microcontrollers. It was a while ago. At that time, I just started learning about 51 microcontrollers. I used a cardboard casing (haha), a perforated plate welded light, and a left turn signal. , the right turn signal does not look good. Three-wheel side view.jpgThree wheels front.jpg

2.Second Edition

The second version is made by learning the STC8A8K microcontroller. This time I used the development board directly. The connection lines are really messy, but this time it is a milestone. All functions are basically realized (don’t read if you have trypophobia). , although the functions are very complete, it is really troublesome to use, and each operation takes a long time. Car development board.png

3.Third Edition

This version has been greatly improved compared to the previous version. All circuits are integrated on a PCB, which looks much more pleasing to the eye. Car main control board debugging.pngMain control board car.png

4.Fourth Edition

This version is further integrated on the basis of the previous version. A PCB is directly used as the base plate, which looks better. A tracking module is added to make up for the previous shortcomings. The switch is also replaced by a large ship-shaped switch. The operation convenient. Car overall picture.jpgThe fourth version of the car bottom.jpg (It has not been debugged yet. After debugging, the motor wires will be welded directly)

Speaker part

Speaker.jpg

remote control

Front of remote control.jpg

The reverse side of the remote control.jpg

3. Onboard peripherals

  1. Infrared receiving circuit
  2. Infrared obstacle avoidance circuit
  3. Infrared tracking circuit
  4. Motor drive circuit
  5. Bluetooth interface
  6. esp82266 interface
  7. NRF24L01 interface
  8. OLED interface
  9. JQ8900 interface
  10. Ultrasonic interface
  11. Servo interface
  12. Three independent buttons
  13. Left turn signal, right turn signal rear light
  14. Comes with reset button
  15. an RGB light
  16. 4 WS2812
  17. a boat switch
  18. A 2P DIP switch

4. Function

1. Motor forward and reverse rotation:

Two sets of onboard dual H-bridge drive circuits can drive four motors, and each set of motors can achieve forward and reverse rotation.

2.PWM control speed:

Each group of motors is externally connected to the IO port of the microcontroller. A total of 8 IO ports are used to control 4 groups of motors. The microcontroller IO output PWM can be used to control the motor speed in different ways and is programmable.

3. Manual control:

    3.1 红外控制:可以通过板子上集成的红外接收头用红外遥控控制,这种控制方法简单,外设少,但干扰性强,信号强度弱,距离短。

    3.2 蓝牙和wifi控制:还可以通过手机连接蓝牙或者通过esp8266连接wifi控制,这两种方法都是在手机上安装一个软件,需要一个手机,操作简单,信号较强,使用较为舒适。

    3.3 无线控制:还有一种控制是通过NRF24L01的2.4G传输,这种控制方式需要一对NRF24L01,控制端和接收端下载配套的程序,双方可进行通信。这种方式用遥感电位器输出信号,需要较为复杂的硬件电路。但无论在信号,距离还是手感方面都较为完美。

Remote sensing control diagram (here is connected to the development board, there is no other board. If necessary, you can make your own board). The IMG_20200307_102444.jpg prepared remote control

Remote control.jpg4. Automatic control:

    4.1 超声波控制:超声波是利用发射和接收的时间来判断距离,可通过编程设置最短距离进行改变智能车的方向。另外超声波搭配了一个SG90舵机,可以在左,中,右三个方向进行旋转,提高了检测障碍的正确性。

    4.2 红外避障:红外避障是利用一对红外对管,一个发送和一个接收,判断产生距离的时间判断是否前方有障碍物,若时间间隔较短,则有障碍物,改变智能车的方向。

    4.3 红外循迹:红外循迹是由发射管接收管和配套电路组成,工作时发射管发射红外线,接收管接收发射回来的红外线。当红外线被深色物体吸收较多而发射回来的很少时,OUT端为高电平,否则为低电平。

5. Real-time display:

The board integrates OLED, which is controlled by IIC and can display the distance of ultrasonic detection in real time and whether it is automatic mode or manual mode.

6. Voice broadcast:

The board is externally connected to the JQ8900 voice chip. By copying the required voice in advance, when executing the corresponding program, it sends commands through the first-line serial port to play the corresponding voice.

7. Power supply:

The power supply part uses two 3.7V lithium batteries. The board integrates 5V and 3.3V regulated sources, which are well adapted to the battery and meet the normal operation of 5V and 3.3V peripherals.

5. Debugging

Here are some problems I encountered during welding and debugging.

1. Solder the chip and power supply first

This time welding is still based on my previous thinking. Weld the chip and power supply part first, and the power indicator light is also welded, and then power on and test. If the power indicator light is on, it means there is basically no problem. You can proceed to the next step, and then weld the microcontroller. Peripheral circuit, reset, crystal oscillator, test after soldering, you can download the program to see if it can be downloaded normally. (Fortunately, I didn't encounter any problems in this step, it was very smooth).

2. Solder the LED

In the previous step, we have soldered the power supply part and the microcontroller circuit, and tested the download program. In this step, we need to verify that the chip is working properly. We can solder the LED part of the PCB, and then burn a lighting program to test whether the chip is working properly. I have no problem with this step (if there is a problem, check if there are weak solders or poor contact in some places)

3. Welding tracking and obstacle avoidance circuit

This step is to expand the function. After the above is completed, the basic car can work normally. If you want the car to be richer, this step is also very important. With my skilled skills, I completed this part of the welding. However, during the test, I found that 3 None of the tracking modules and the 2 obstacle avoidance circuits work (the LED does not light up when in contact)

Since there is a problem, then look for the problem. First, check whether the circuit is soldered properly, and then check whether the resistor is soldered correctly. I found that both are normal (I am confused, it is not a problem with the circuit), because this is my first time. This is the first time I have used this circuit (I used modules in the past). I am not sure. I searched it on Baidu. It doesn’t matter. TMD, there is really something wrong with the circuit. The two obstacle avoidance circuits have no problem, and the three tracking circuits have. Question (I promise I won’t beat you to death for the classmate who copied my homework). I went to see the circuit of Lichuang again (I am autistic, so I should have copied Lichuang’s circuit at that time).

Tracking circuit problem:

Correct circuit:

image.png

Error circuit:

image.png

I took a quick look and saw that there was no problem. The two pins were connected backwards. What a mess.

I took a quick look and found that the problem is not serious, and there are ways to improve it (will be introduced later)

There's nothing wrong with the infrared obstacle avoidance circuit, so why doesn't it work?

Resistor problem?

At first I thought the adjustable resistor value was wrong. I measured it on the board and it turned out to be wrong (it was only 2K, mine was 10K). I measured the voltage and found that there was also a problem because the product I bought was from Lichuang. , the quality should not be a problem, I think it must be the resistance value affected by the circuit. Because I only bought 5 of them, I had no choice but to remove one from the board and measured it. It was over 9 K, which was normal, which made me even more confused.

Circuit problem?

In order to make sure that there was no problem with the circuit, I took out the original module again. After powering it on and testing that it could be used, I then used a multimeter to test its circuit. I found that it was not much different from my circuit. It was just the resistance of the LED light resistor. The value changes to 1K, which has no effect.

In order to ensure that it was not affected by the circuit, I also used a breadboard to build the circuit of this module, but found that it still could not be used. breadboard.jpgInfrared emission tube problem?

Since there is no problem with the circuit, I wonder if the infrared emitting tube I bought is not the same model as this infrared emitting tube and cannot be used universally? So I removed his infrared emission tube and replaced mine with mine, and found that it still worked.

LM393 problem?

I removed the LM393 from the original module and replaced it with the one I just bought, and it still works, tmd, it’s really strange.

Infrared receiver tube problem?

There are only so many things in the circuit, basically all tested, and the infrared receiving tube, removed and replaced, but it doesn’t work? Could it be that my infrared receiving tube doesn't work? (Looking at the appearance and model, they are all the same.) By chance, I adjusted the positive and negative poles of the infrared receiver tube. It is tmd, and it can be used. It is really tmd, the positive and negative poles are reversed? ( Does it mean that the long pin is not positive and the short pin is not grounded? ) I hope some master can leave a message for me.

Infrared module.jpg

Now that the problem has been discovered, the car board also needs to be modified, disassembled, welded, and powered on. I'll do it. (It's really not easy. It took me all night and several hours.) )

4. Regarding modifications to the tracking circuit

Because I copied the wrong schematic diagram, the tracking module has no effect at all. I have no choice but to modify the circuit. Fortunately, the circuit modification is not complicated. I only need to exchange the positions of the two original tubes. I won’t go into details about the process, it’s quite arduous, so here are some pictures of the finished work.

Tracking.jpg

The original shell can no longer be used, so let's leave it as it is. It can still be used if I make do. I will definitely improve it if I paint it again next time.

6. Programming

Although we have the previous foundation and the basic framework of the program has been written, the new version of the car will definitely be different from the original, and the code will be more or less changed. This time, a tracking module was added, which was not available before. A WS2812 was added, which was not available before. It also added a left turn light, a right turn light, a rear light, and an EGB light. There are some other circuits.

The remote control is freshly made. The original board was left unsoldered. This time I just soldered it and debugged it to put everything to use. I also wrote the code. Now I can realize the front, rear, left and right control and the 1-4 gear control. I can communicate with the car through NRF24L01. There is no delay in the main function. After special processing, the communication speed is still quite impressive. , no delay is felt at all.

7. Effect Demonstration

Watch the video below:

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-15 00:30:47

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号