pEQnzfP

【LiChuang Development Board】Cobalt Key Gold's smart car

 
Overview

# 1. Functional introduction

1. LED: simulate the lighting system of the car
2. Button: switch mode
3. Active buzzer: simulate the car horn
4. ADC acquisition: detect battery voltage
5. Ultrasonic ranging: Ultrasonic obstacle avoidance allows the car to avoid obstacles while driving
6. Infrared photoelectric tube: realize the car tracking function
7. Bluetooth module: control the car through the mobile phone APP

# 2. Overall design plan

This design uses two 14500 lithium batteries with a total of 7.4V as the system power supply. After stepping down to 5V, it powers the single-chip microcomputer system. The single-chip microcomputer, button circuit, tracking circuit, obstacle avoidance circuit, LED lights, active buzzer, Bluetooth, and motor drive circuit are connected. The circuit composition system block diagram is as follows:
![微信图片_20230226182723.png] The LiChuang Liangshanpai development board is used as the main controller of the smart car to drive the DC motor of the smart car. The motor driver chip RZ7899 micro integrated circuit motor driver chip is used with the single-chip microcomputer to realize the operation of four DC motors and pwm software speed regulation. By changing the voltage of the DC motor duty cycle, the average voltage value is changed, thereby changing the speed of the motor to drive the smart car to run. The driving states of the smart car are: forward, backward, left turn, right turn and stop. When the wheeled robot encounters an obstacle during driving, the car will automatically stop or turn. Bluetooth is used as the transmission medium, and the host computer or mobile phone is used as the control end to control the movement of the car.
The main design steps are:
(1) Design the structure of the smart car according to the functional requirements of the proposed solution.
(2) Design the overall hardware circuit module according to the basic structure and characteristics of the main controller. The design of the overall hardware circuit module includes motor drive circuit design, infrared tracking circuit design, ultrasonic obstacle avoidance circuit design, wireless transmission circuit design, etc.
(3) Select system software that meets the system design requirements, and write driver code and application software code based on the software. According to the specific requirements of the system function, from the perspective of stable transmission of system signals, the motor drive, speed regulation, infrared obstacle avoidance module modification, etc. are analyzed and designed in detail, and the code is written and debugged.
(4) Combine the hardware development board and the software platform to conduct an overall test of the entire system of the video surveillance smart car. Make relevant improvements to the problems encountered in the test to further improve the reliability and stability of the system.

# III. Hardware Introduction

## 3.1 Power Input

The power module is an important part of the entire circuit during the operation of the smart car. It needs to power the microcontroller, motor, major modules and sensors. In terms of power selection, in order to ensure reliable power supply of the system, the project uses two rechargeable 14500 lithium batteries, which provide power to the microcontroller and peripheral devices after passing through a HE6250MPR low-voltage linear regulator, while the motor drive chip is directly provided by the battery 7.4V.
![image.png]
## 3.2 Motor drive circuit

The current directly output by the microcontroller is too small to drive the car. The motor circuit uses the RZ7899 driver chip, which has a simple peripheral circuit. The motor speed can be controlled by cooperating with the microcontroller PWM output.

![image.png]
## 3.3 Tracking circuit

The tracking circuit is designed with the LM393 SOP-8 small package voltage comparator and the ITR8307 infrared pair tube. The car usually follows a black line on a white floor, and uses the reflection of infrared light in different colors for identification. It is equivalent to an infrared electronic switch, which outputs a low level when a black line is detected, and a high level under normal circumstances. When a black line is detected, the infrared signal emitted by the infrared tube is received by the infrared receiving tube, amplified by the integrated chip, and compared, and a low level is output to light up the LED light-emitting tube on the module. At the same time, a low-level signal can be output, which can be used as the signal input of the microcontroller to detect and control various external drive modules.
![image.png]
## 3.4 Other circuits

Ultrasonic module interface
![image.png] LED circuit
![image.png] Buzzer drive circuit
![image.png] Bluetooth module interface
![image.png] Key circuit
![image.png] ADC power supply voltage acquisition circuit
![image.png]
# 4. Software design

## 4.1 Motor driver
The motor drive is mainly the operation of the RZ7899 driver chip, and the PWM speed regulation method is used to complete the drive control of the motor. Pulse width modulation (PWM), referred to as pulse width modulation, is a very effective technology that uses the digital output of the microprocessor to control the analog circuit. The generation of PWM waves can be set by parameters such as clock frequency and automatic reload value, thereby adjusting the duty cycle and output frequency of the PWM wave, that is, the control of the pulse width. The PWM principle is shown in the figure:
![image.png] From the figure, we first assume that the timer is working in the up-counting PWM mode, and when CNT is less than CCRx, it outputs 0, and when CNT is greater than or equal to CCRx, it outputs 1. Then we can get the PWM schematic diagram as above: when the CNT value is less than CCRx, IO outputs low level (0); when the CNT value is greater than or equal to CCRx, IO outputs high level (1); when CNT reaches the ARR value, it returns to zero and then counts up again. By changing the CCRx value in turn, the duty cycle of the PWM output can be changed. By changing the ARR value, the frequency of the PWM output can be changed. This is the principle of PWM output.
![image.png] The specific operation of the motor is shown in the figure:
![image.png] The motor driver uses the PWM function of the microcontroller timer to drive the motor by outputting a PWM wave with variable frequency and duty cycle. The specific implementation method is: First, enable the timer and related IO port clocks. Secondly, initialize the timer and set its automatic reload value and prescale value, and set the counting mode to up counting mode. Finally, enable the preload register, enable the timer, and achieve different duty cycle effects by changing the comparison value CCRX.
## 4.2 Infrared Tracking Program
The infrared obstacle avoidance sensor used in the infrared tracking module is composed of a transmitting tube and a receiving tube. The transmitting tube transmits infrared rays. When a black line is detected, the receiving tube receives the infrared reflection signal. After passing through the comparator, it outputs a low-level signal to the single-chip microcomputer. The single-chip microcomputer performs a series of processing and analysis to coordinate the work of the two wheels of the car to complete the tracking action. The basic principle of the infrared obstacle avoidance control program is to first detect whether there is a black line. When a black line is detected, it is determined whether it is detected by the left sensor or the right sensor. If it is on the left, the car needs to turn right. If it is detected by the right sensor, the car should turn left. If it is detected by the middle sensor, it should move forward.
## 4.3 Ultrasonic Obstacle Avoidance Program
The ultrasonic module is designed based on the principle of sound wave transmission in the air. The module starts the sound wave through the trig pin, and the timing starts at this time. When the sound wave encounters an obstacle, it will bounce back. The rebounded sound wave will be received by the probe of the ultrasonic module. At this time, the state of the echo pin will change, and the timing will stop. According to the propagation speed of the sound wave in the control, it is very convenient to calculate the distance between the ultrasonic wave and the obstacle. The distance calculated by the ultrasonic sensor is transmitted back to the single-chip microcomputer, and the single-chip microcomputer performs a series of processing and analysis. When there is an obstacle at a certain distance, the car stops first, the headlights flash, and then backs up and turns left. Continue to move forward until there is no obstacle in the distance ahead.
## 4.4 Bluetooth remote control program
The single-chip microcomputer receives and reads the data packet sent by Bluetooth to perform the next action. Then different data packets can be set for different actions (for example: forward, turn, accelerate, decelerate). In this way, if the single-chip microcomputer receives a certain data packet, it will then execute the action corresponding to the data packet, thereby completing the speed adjustment of the single-chip microcomputer using Bluetooth.

# 5. The real object display

video is published on the Bilibili video platform.
Link: https://www.bilibili.com/video/BV15j411F79v/?vd_source=d218a5e9780a128d978f6ea26dedb787#reply154007481600
UID:296891597
# 6. Experience
When I participated in this training camp, I was able to use the Lichuang development board quickly because I had the basic knowledge of STM32. However, the hardware was a stumbling block for me. Many problems occurred when making and debugging the car, which made me want to give up several times. For example, the line of the burner was broken. At first, I thought the black line was gnd, so I soldered it to the gnd pad. The development board was burned, and the battery was dead and there was no charger. At that time, I didn’t have time to buy one. I ran around for an afternoon before I found a senior who had one. My car is made of three PCBs. I originally planned to connect each board with pin headers. When drawing the PCB, the spacing between the pin headers was too small, so the pin headers could not be put in. So I used the pins of the LED to connect, which made it difficult for me to weld. When welding the first car, the indicator light of the tracking circuit was always on, the buzzer would only sound when I was grounded, and one motor did not rotate. When measuring the motor drive voltage, I accidentally short-circuited the input pin and GND, which directly lit up a chip, and the chip also took the microcontroller away. I was completely dumbfounded, and then borrowed a development board from a group friend and started to make the second one. Because there was no time, the second car did not use a buzzer, and the tracking also used a five-way grayscale sensor module, so there were a lot of Dupont wires flying on my car. The welding was handed over to the junior brother. After welding, he found that the output voltage was very low. If it was not for the help of the group friends who later found that the GND pin of the power chip was poorly soldered, I even thought that the voltage was eaten by the filter capacitor. Basically, there are no major problems with ultrasonic obstacle avoidance. The most common problem is tracking. It runs randomly while running, or automatically resets while running. Later, it was found that it was due to program problems. Several sensors were fighting, and the microcontroller couldn't fix it, so it just broke. The most interesting thing is that when I transplanted the Bluetooth remote control code, I transplanted the code to my project, and the microcontroller kept sending 0 to Bluetooth. When I transplanted it to the new project, there was no problem, so I transplanted the entire original project to the new project, and there was no problem. If someone said that my original project was cursed, I would not believe it.
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-08-01 14:31: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号