### Project Introduction I saw the competition questions released in the group at around 8 a.m. on November 4, 2021. We chose the control questions that we had prepared for a long time. Intelligent medicine delivery car for question F! [image.png]

Idea analysis: This morning I basically spent analyzing the competition questions and discussing the plan. After analysis, I felt that the focus of this question was on digital recognition. At that time, we only had One K210, and N OpenMv4. However, openmv4 does not support neural networks at all. On the other hand, the official deleted the original nn library and could not use its existing digital recognition code. At that time, we felt that if we wanted to recognize accurately, we must run neural networks. At that time, there was only one K210 and I could only let the teammate who had played with it before identify the K210, while I tried other solutions. Basically, the day passed like this. Perhaps the biggest progress was that my teammates had set up the car. - - - ### Introduction to project functions Introduction and introduction to the related functions of the project: * The power supply part of the car uses two 18650 batteries; * DC reduction motor (Hall encoder), TB6612 motor drive, PWM control motor speed; * Gray degree sensor to identify the red line for tracking; * Add two car lights to the front, flash the lights in an emergency to simulate car functions; * Reserve a Bluetooth wireless communication module interface to facilitate communication between two cars; * The camera uses K210 Run the trained model to accurately identify digital ward numbers; * Drug detection uses infrared switches to detect whether drugs are loaded; - - - ### Project properties Here you can fill in the completion progress bar of the project, and select check boxes based on the completed functions The frame can also be used to display the progress of the completion of the function* [x] Schematic design* [x] PCB diagram design* [x] PCB proofing* [x] Welding test* [x] Functional test* [x] Program test - - - ### # Circuit system design
The circuit part mainly includes the power supply circuit and the drive circuit.
1. Power supply circuit
The power supply circuit uses a DC-DC adjustable step-down circuit composed of 2 channels of LM2596S-ADJ as the core. One channel stabilizes the battery output voltage at 8V for car driving, and the other channel stabilizes the battery voltage at 5V for use by each module.
![nPLPQCf0AW73SGsVrtBxZ0TWDg0OLBwuHzlpPwZd.png]
2. Drive circuit
![driver.png]
Main control board circuit
The main control board uses a self-designed PCB circuit board that integrates various functions, including keyboard, TFT display, motor interface, serial port, LED indicator, etc., and the onboard 1117 chip can convert the 5V voltage to 3.3V to supply the chip operation. . The circuit is shown below.
![Master control.png]
# Programming This system uses STM32F407ZGT6 microcontroller as the core control chip.
![Flowchart.png]
Peripheral initialization![image.png]
Regarding peripherals, we mainly use serial ports, PWM, encoders, etc. The above is the related initialization part. ![image.png]
In realizing the function project, we mainly use the distance closed loop. We mainly identify two of the four numbers to determine the location of the ward. ![image.png]
Recognition function, we mainly use the way of shaking the head left and right to identify each number separately. # Automatic path finding method
The seven-channel grayscale sensor uses photosensitive diodes to change the output signal when it recognizes a color change. The microcontroller collects the seven-channel signals at the same time to measure the deviation range, and then passes the deviation into the angle loop for calculation. The deviation value that the two wheels should have is obtained, and finally the PWM control signal is output to change to achieve steering. Different left and right wheel differences can be changed through different deviations. At the same time, the seven-channel grayscale sensor has multiple output levels that change in identifying intersections and T-junctions. The microcontroller collects the signals and processes them to achieve steering control.
# Number recognition method.
The car driving to the target ward requires the camera to accurately identify the ward number and accurately judge the number position. The former can use target classification to achieve good results, but the recognition of the target number position involves multiple numbers in the picture. processing, there is greater difficulty.
The one stage target detection algorithm adopted by Yolov3 has a high computing speed and can detect multiple targets at the same time, annotate the corresponding target values, and obtain various information about the targets. First, the input features are extracted through the feature extraction network to obtain a feature map output of a specific size. The input image is divided into 13×13 grid cells, and then if the center coordinate of an object in the real box falls in a certain grid, then the object is predicted by the grid. Each object has a fixed number of bounding boxes. There are three bounding boxes in Yolov3. Logistic regression is used to determine the regression box used for prediction (Figure 2.1). To detect the position of the target number in the image, position information is needed. That is, bounding box, as shown in Figure 2.1, you need to know the coordinates of the center point, the width and height of the box, which contains 4 values: x, y, w, h, (x, y) represents the center of the box, ( w, h) represent the width and height of the box. ![6.png] ![Regression.png]
The Yolov3 network ultimately needs to obtain this information through regression detection. The regression idea means that there is a regression relationship between the prior box (anchor box) and the ground truth box (ground truth box). The a priori box helps us finally get the real box through some pre-selected boxes. The a priori box information (width and height) is fixed in the code. It contains three sizes, some are large. Some are small, and there are some differences in the aspect ratio. As shown in the figure, after training through the Yolov3 network, an implicit relationship will be obtained. The prior box will return to the real box, and the coordinates of the center point can be used between the Anchor box and the Ground truth box. offset, and the scaling of the width and height of the box to finally get the real box, the formula is shown in Figure 2.2.
We use K210 to collect a large amount of raw data, label the data set, use the LabelImg tool to create and label the data set, and then train the Yolov3 model through the Tensorflow framework. We import 1,200 pictures from different angles, different light and dark contrasts, and different focal lengths. The framework is used for training, and a satisfactory Yolov3 model is finally obtained. As can be seen from Figure 2.3, the loss rate can reach a low level after 9 iterations. After more than 9 iterations, the loss rate decreases no longer significantly.
The relief filter is a commonly used digital filter that can give an image a 3D shadow effect. Just subtract the pixels on the other side from the pixels on one side of the center. At this time, the pixel value may be a negative number. We treat the negative number as shadow and the positive number as light and shadow, and then add an offset to the resulting image. At this time, most of the image becomes gray. The core operation using the relief effect significantly improves digital features while reducing noise. The calculation amount is smaller, the calculation is faster, and it has less impact on the real-time performance of target detection.
# Analysis of test results 1. For the excessive swing amplitude of the car after the path-finding control deviates from the guide line, the PID parameter is too large and needs to be adjusted to make the adjustment direction of the car smoother.






2. If the incoming level of the grayscale sensor is unstable, adjust the sensitivity in a timely manner.
3. During the test, the car occasionally failed to recognize the ward number information. After joint computer debugging, it was found that the accuracy of the numbers recognized by the camera was only 90%, so an embossed kernel filtering program was added to the program to improve the number recognition accuracy to 97%. , effectively improving the runtime recognition accuracy.
4. For the construction of the trolley frame, if the steering wheel sweeps the line, the frame must be machined in time. Reinforcement of hardware connections makes the hardware structure more stable.
#EDAproject# Physical display![1.png]
![2.jpg]
![1.jpg]
### View the demonstration video in the attachment