# Intelligent car production based on Lichuang Liangshan School
## 1. Functional requirements analysis
The official extended version of Lichuang development board integrates many functions, which is completely sufficient for smart cars. However, since I had completed infrared tracking for a long time when making a car before, I removed the infrared tracking this time and switched to OPEN MV for tracking and other visual tasks.
Also, as an expansion version, how can it not have a screen? So I connected the spi interface used by NRF24L01 to the screen.
That’s about it.
## 2. Hardware Analysis
### The resources used on the extended version are as follows:
`Serial port 0 ----- used to log when the program is running`
`Serial port 5 ----- used to communicate with OPEN MV `
`Serial port 6 -----used for Bluetooth module communication`
`SPI3------used for NRF24L01 communication and screen display`
`TIMER1 and 2--used for controlling N20 motor`
`TIMER5---- -Used to start scheduled tasks`
`ADC0-------used to measure battery voltage`
`GPIO-------used for control pins of buttons, lights, ultrasonic modules and other modules`
### The specific hardware circuit implementation
emmm, there are too many people writing this. The official version of Lichuang Development Board is already very good, so I won’t write it anymore (~~I’m actually lazy~~).
### Disadvantages:
1. I used the AMS1117-5.0 buck on the board (because it is cheap), and there was no problem in the beginning. But when I connected to OPEN MV, the power consumption increased greatly, 1117 became seriously overheated, and even experienced a brief power outage. These were all caused by overload. . . It can be replaced with a switching power supply and a high-current buck circuit such as
2. When the battery is not used, connecting the development board to the debugger power supply will cause voltage to appear at the input end of the voltage stabilizing chip, and the motor will be driven (although the USB port of my computer was not burned, But it is not safe after all). So I disconnected the power supply between the debugger and the development board. From the hardware point of view, it seems that I can add a diode between the output of the voltage regulator chip and the 5V input of the development board (feeling a safe point?), but there will be a voltage drop. Should I install a MOS tube in conjunction with it? It feels like this is okay. Add a physical button to control on and off (forget it, it feels like it will become complicated, um, pay attention next time).
### This remote control
is directly used with a UP board from station B. It feels enough to be used. Link [https://www.bilibili.com/video/BV1WG4y1U7s6/](https://www.bilibili. com/video/BV1WG4y1U7s6/) Many functions in the software are also transplanted from this UP, thank you! ! !
## 3. The software implementation
draws on official projects and the open source information of Bilibili UP. I transplanted the functions of Bluetooth remote control, handle remote control, gyroscope remote control, ultrasonic obstacle avoidance, ultrasonic following and target tracking (there are still some problems). .
The program runs in two parts, which can be regarded as time-sharing scheduling, haha. One part is under the while loop of the main program, which requires real-time button detection and communication with the remote control handle through NRF24L01. On the other piece, I used a timer to set up a 1-second scheduled interrupt, which is used to refresh the display of screen information,
detect battery voltage (the buzzer will alarm when the voltage is lower than a certain value), and flash the running indicator light.
The starting process of the car is as follows: after powering on and running, press the button once and the start indicator light will light up before the car is allowed to move. Press again and the car stops.
The initial mode is Bluetooth control, which can be controlled by mobile phone Bluetooth (in fact, you can also use Bluetooth on the handle for communication control, but I only have one Bluetooth module left on my hand, so I gave up). The control mode can be switched on the remote control handle.
In the handle remote control mode, the car is controlled by the joystick of the handle to move forward, turn and retreat; in the gyro control mode, the car is controlled by the gyroscope on the handle; in the obstacle avoidance mode, the car automatically drives forward, and when an obstacle is detected ahead, it moves backward. Click once and turn; in follow mode, it will maintain a certain distance (within a certain range) from the object in front; in target tracking mode, it will first identify an object and then follow the target.
See the demonstration video for specific effects~( ̄▽ ̄)~*
### Flowchart
![Flowchart.jpg]

### Added
because compared to the official project, I reduced the infrared tracking function. Therefore, a camera tracking function has been added to display the tracking video of the visible attached camera.
It's just a demonstration of functionality, so it doesn't increase the speed.
![Tracking.jpg]

## 4. Physical display
of the car~~~
![Car1.jpg]

![Car2.jpg]
Remote control~~~
![Remote control handle.jpg]

Screen
![Screen.jpg ]

### Demo video link to station B: [https://www.bilibili.com/video/BV1LY411v7FX/](https://www.bilibili.com/video/BV1LY411v7FX/)
Note: The video in the attachment is simple Rotating display, the specific complete demonstration video is at Station B
### gitee code link: [https://gitee.com/starry-m/liangshan-pi-car](https://gitee.com/starry-m/liangshan -pi-car)
## It’s over~~~