### 1. Foreword This is the last competition that my teammates and I have worked hard on in the laboratory for more than two years, and it is also the most important competition. We are very excited to receive the first prize in the national competition. In this competition, a plant protection aircraft was designed based on a self-made flight control board and a quadcopter, which included binocular cameras, lidar, self-made image processing modules, ultrasonic ranging modules and other sensors. The plant protection aircraft can automatically control the spread of pesticides according to the requirements of the competition. - - - ### 2. Team introduction One of my teammates and I are from the Communication Engineering major of the School of Communication, and the other teammate is from the Electronic Information Engineering major of the School of Communication. - - - ### 3. Project analysis![Capture.PNG]

![Capture2.PNG]

- - - ### 4. Introduction to the work After many tests, the aircraft can successfully complete the task of "spreading pesticides". The flight height is stable. The chance of incorrect seeding is extremely low. The average time taken is about 1 minute, which meets the time limit. The landing is accurate and the deviation is always less than 5cm.
After many tests, the aircraft can correctly determine whether the area below is a "spreading area" before "spreading pesticides". Every "spraying" is precise and correct. It can quickly find the tower, correctly identify the barcode content, and land accurately as required. ### 5. Schematic circuit analysis 1. Flight control circuit design MCU schematic diagram: ![3.png]
Feeding schematic diagram: ![1.png]
IMU schematic diagram: ![2.png]
Other external interface principles Picture: ![4.png]
**1.1 **Basic design idea** ** This system uses TM4C129 as the core device to produce flight control. The flight control cost is low and the scalability is strong.
TM4C129 is a microcontroller based on the ARM Cortex-M4 platform, transplanted with the real-time operating system FreeRTOS, and programmed in C language. It has sufficient operating efficiency and flexibility as a flight control. The PCB integrates the NRF24L01 for remote control, the nine-axis sensor MPU9250, and the barometer BMP280 to meet the basic functions of the flight control. It also introduces the programming port, UART, SPI, I2C and PWM ports, so that the flight control can connect to various peripherals to enrich its functionality.
**1.2 ****Circuit Design****** ** ***1.2.1 *********Power Circuit Design********* *** Use AMS-1117 (3V3) converts the 5V voltage input from the distribution board to 3.3V. The front and rear stages are connected in parallel with 100uf tantalum electrolytic capacitors and 0.1uf decoupling capacitors to avoid ripples and self-excitation in the DC power supply. LED lights are used to indicate whether it is working normally. A total of two power supply circuits are designed on the PCB, one of which supplies power to the core TM4C129, gyroscope MPU9250, barometer BMP280, buttons, dials, and LEDs. Multiple 0.1uf decoupling capacitors are connected in parallel to this power supply to filter out high frequencies. clutter to ensure stable operation of all devices. The other channel supplies power to the outgoing expansion interface to prevent problems with the peripherals connected to the interface and protect the control circuit part. All circuits are laid with copper and have a common ground.
***1.2.2 *********Core circuit design********* *** TM4C129 constitutes a basic operational system and requires power supply, crystal oscillator, logic level configuration and reset circuit . The logic level and power supply are both 3.3V. The crystal oscillator uses a 16MHz passive crystal oscillator. The IN and OUT terminals of the crystal oscillator are connected to the 0SC1 and 0SC0 ports of the microcontroller, and a 12pf load capacitor is connected in parallel with the ground. Considering the usage scenario of the drone, it is safer to cut off the power when a reset is needed, and the reset button will occupy the PCB space, so a simple reset circuit composed of a 10K resistor and a 0.1uf capacitor is used, that is, when powering on Relies on capacitor charging time.
***1.2.3 *********Sensor circuit design********* *** Through the I2C bus method, two slave devices, MPU9250 and BMP280, are mounted on an I2C port. The BMP280 barometer is powered by 3.3V and can roughly calculate altitude changes through the returned air pressure and temperature data. MPU9250 uses 3.3V power supply, and the pad under the chip uses through-holes and copper sheets for heat dissipation. MPU9250 comes with a digital motion processor, which is very convenient for attitude calculation. It outputs 16-bit digital quantities through I2C and uses the microcontroller to process data. Interaction, while greatly reducing the difficulty of development.
***1.2.4 *********PWM output circuit design********* *** The ESC interface adopts a 3-hole 2.54mm elbow pin header, and ports 1 and 3 are connected respectively. The PWM pin of the microcontroller is connected to ground, and pin 2 is left floating. The servo interface uses a 3-hole 2.54mm pin header, and ports 1, 2, and 3 are connected to the PWM pin, 5V, and ground of the microcontroller respectively. ***1.2.5 ***Peripheral interface circuit design*** *** The communication interfaces of 4 UART ports, 2 SPI ports and 1 I2C port are derived from the microcontroller. Both SPI ports are powered by 3.3V and are connected to NRF24L01 and optical flow respectively. The NRF wireless module is used for remote control data transmission, and optical flow is used to assist UAV indoor positioning. Both the UART port and the I2C port have voltage selection designs, and the power supply can be selected to be 3.3V or 5V through short circuit to improve the applicability of peripherals. Among them, UART1 is connected to the ultrasonic KS103 by default for accurate height determination of the drone. ** ** - - - ### 6. The PCB design analysis board diagram is as follows: ![777.png]
The signal line width is 0.254mm, the power line width is 0.762mm, for digital circuits, pay attention to copper laying and teardrops. - - - ### 7. Physical display! [WeChat picture_20211219170431.jpg]
Task demonstration video: [https://www.bilibili.com/video/BV1rZ4y1D7yv?spm_id_from=333.999.0.0](https://www .bilibili.com/video/BV1rZ4y1D7yv?spm_id_from=333.999.0.0) - - - ### 8. Work assembly ## 8.1 Demonstration and selection of height-fixing scheme
Option 1: Use laser height-fixing
to determine the height by emitting laser and receiving laser The height of the aircraft is fixed. This solution is easily affected by ground materials, and the optical system needs to be kept clean, otherwise measurements will be affected.
Option 2: Use a barometer to determine the altitude.
Based on the relationship between air pressure and altitude, find the altitude of the aircraft to determine the altitude. This solution is easily affected by air pressure, the air pressure data has a large lag, and the vertical downward wind during the quadcopter flight will also interfere with the air pressure readings.
Option 3: Use ultrasonic waves to determine altitude.
Use ultrasonic emission and sound waves to determine the altitude of the aircraft to achieve altitude determination. Ultrasonic waves are relatively resistant to dirt and will not be affected by dust on the sensor; the ranging range is 3 cm to 5 meters, and the accuracy is 1 cm. It is greatly affected by surrounding obstacles and is suitable for indoor measurements. Considering that there are few obstacles on the site, this solution is highly reliable.
Option 4: Use binocular cameras to determine height.
Obtain the position of the aircraft in the z direction based on the depth of field data of the T265 binocular camera. The z-direction accuracy of the T265 binocular camera is the lowest among the three directions, but because the binocular camera is installed vertically upward, it is not easily affected by obstacles.
Based on the above analysis, we chose to use ultrasonic and binocular cameras to fuse height determination to maximize the reliability of height data.
## 8.2 Demonstration and selection of fixed-point hovering solution
Option 1: Optical flow positioning
uses the PMW3901 module, which is a high-precision and low-power optical tracking sensor with very high sensitivity. Optical flow sensors can achieve precise positioning on complex ground. However, the site of this mission has no texture details, the color is relatively single, the data output by the optical flow sensor has low confidence, and is prone to drift. After preliminary testing, this solution is not feasible.
Option 2: Lidar positioning
The data provided by the A2M8 lidar sensor is extremely accurate, but the algorithm for settling position data based on the original point cloud data requires high computing power and has a large delay. The lidar data refresh rate is related to its own rotational speed. If you want to obtain high refresh rate position data, you need to increase the rotational speed, which will have a negative impact on the attitude control of the aircraft. The lidar sensor itself does not integrate an IMU, and the aircraft attitude data needs to be used to correct the position data, which again increases the delay. After preliminary testing, this solution is not feasible.
Option 3: T265 binocular camera positioning
Install the T265 binocular camera vertically upward, and perform self-positioning by acquiring image information directly above the aircraft. There are no obstacles directly above the aircraft so there is less interference. At the same time, the T265 binocular camera integrates an IMU, so there is no need to call the attitude data of the aircraft to correct the position data, so the delay is small. After preliminary testing, the solution is feasible.
Based on the above three options, choose option three.
## 8.3 Demonstration and selection of image processing module
Option 1: Use Stm32f407 image processing of OV2640 camera.
This module can process a single target, but the chip processing speed and available resources are limited. The barcode to be photographed this time is small and requires Accurate decoding. Therefore this module does not meet the requirements.
Option 2: Use the self-made K210 module.
K210 is an embedded machine vision module based on Python. It has a friendly development environment. In addition to being used for image processing, Python can also be used to call its hardware resources for I/O control. After preliminary testing, this module can well determine whether the area directly below is the sowing area or the non-sowing area, and can directly control the laser pointer to achieve considerable results.
Option 3: Use the Raspberry Pi to drive the USB camera.
The USB camera has a higher resolution and faster refresh rate, and can capture clear barcode images at a longer distance. Raspberry Pi 4b has greater computing power and can run barcode recognition algorithms very well.
Based on the above three options, choose option 2 and option 3 to complete all digital image processing needs.
## 8.4 Demonstration and selection of the pole-finding solution
Option 1: Use the vision module to find the pole.
Fix the camera on the aircraft, and the aircraft will spin around to find the pole tower. Because the pole tower is black and very thin, neither its color characteristics nor its shape characteristics are conducive to identifying the pole through digital images.
Option 2: Use the ultrasonic module to find the rod.
Fix the ultrasonic ranging module on the side of the aircraft and use the ultrasonic module to find the rod. The ultrasonic beam angle is large, and the position of the tower cannot be determined well after measuring the distance from the aircraft. The range that a single ultrasonic module can cover is limited, and if it is not combined with the rotation of the aircraft during rod search, a blind spot will occur.
Option 3: Use laser radar to search for rods.
Lidar can detect in all directions and has high data accuracy. No matter where the tower is in the working area, it can be accurately positioned. After preliminary testing, this recipe works very well.
Based on the above three options, option three was finally selected.
## 8.5 Demonstration and selection of dispersion plan
Option 1:
Use the flight control to fly according to the path, use the visual module to judge its own position, and spread the spray at the appropriate location. Because the ground grid features are very unclear, this solution is difficult.
Option 2:
Use the flight control to perform cruise control. When the binocular camera determines that the position reaches the center of the grid, call K210 to determine and spray pesticides. After preliminary testing, this solution is the fastest, but the reliability is slightly lower.
Option 3:
Use the flight control to move the aircraft step by step to the center of each grid according to the odometer, and then call K210 to judge and spray pesticides. After preliminary testing, this solution has the highest reliability and fastest speed.
Based on the above three options, in order to maximize reliability, option three was finally selected. - - - Installation block diagram: ![400 block diagram.PNG]
The following is an introduction to each module: Flight computer 1 uses the LattePanda development board ([https://item.taobao.com/item.htm?spm=a230r.1.14.16.6 ca542a0deddPY&id=562386233597&ns=1&abbucket=18#detail](https://item.taobao.com/item.htm?spm=a230r.1.14.16.6ca542a0deddPY&id=562386233597&ns=1&abbucket=18#detail)) Standard window can be used s10 operating system, It is very convenient to drive various sensors and the environment is easy to match. Flight Computer 2 uses the Raspberry Pi 4b development board ([https://item.taobao.com/item.htm?spm=a230r.1.14.22.694a261enlqyzG&id=619656726932&ns=1&abbucket=18#detail](https://item. taobao.com/item.htm?spm=a230r.1.14.22.694a261enlqyzG&id=619656726932&ns=1&abbucket=18#detail)) The visual module uses the MaiXy development board ([https://detail.tmall.com/item.htm?spm= a230r.1.14.16.466357ce2j4Dl8&id=620956683354&ns=1&abbucket=18&skuId=4383099480887](https://detail.tmall.com/item.htm?spm=a230r.1.14.16.466357ce2j4Dl8& id=620956683354&ns=1&abbucket=18&skuId=4383099480887)) Simple and good The lightweight digital graphics module used integrates rich IO resources. - - - ### 9. Programming main program flow chart: ![Main flow chart.PNG]
- - - ### 10. Summary After participating in the competition, I only feel one word - tired! Four days and three nights of intense hard work The days have passed, but the feeling of time passing by quickly still seems to remain, and the fulfilling and busy scenes still appear in front of me from time to time. After this competition, I learned a lot, broadened my understanding of electronic information technology, and exercised my thinking. The main gains are as follows:
1. It is beneficial to improve our learning ability. The learning ability mentioned here includes the ability to obtain information, the ability to understand previous ideas, system design ability, hands-on ability, analysis and troubleshooting ability, expression ability and many other aspects. The format of the electronic design competition determines that the above abilities are indispensable.
2. It is conducive to the cultivation of our team spirit. In actual work outside the classroom, we generally have to cooperate with others to complete a certain project, which requires team spirit, which is very limited in regular classroom teaching. The electronic design competition requires three people to form a team to participate and calculate the results collectively. This requires that the three people must trust each other, cooperate with each other, and divide work. Group members should remind each other to stay calm in good times, encourage each other to overcome difficulties in times of adversity, and not blame each other when problems arise. It is best for the three of them to have their own strengths in software, hardware and machinery, and then they must have a tacit understanding of cooperation and a united team;
3. It is conducive to the training of our psychological quality. The format of the electronic design competition determines that there will be great uncertainty in the results of the competition. An extremely accidental mistake will lead to an unsatisfactory final result. Therefore, contestants need to have good psychological quality and devote themselves wholeheartedly to the intense competition. And face the final result with a normal heart. With my strong willpower, I got to know myself again through this competition. After 96 hours of continuous fighting, I couldn’t believe that I had so much physical strength to solve the problem. This competition also made me understand a truth: people The potential is huge, the key is how to tap it.
4. It is conducive to the improvement of our adaptability. The competition system of the electronic design competition requires us to complete the specified questions within the specified time. If time is tight, various unexpected results will occur, so we must solve the problem in the shortest time possible, which requires us to improve our resilience in our daily training. ability. Try more. After the competition question is proposed, only through multiple attempts can you know which solution is the best.
In short, this electronic design competition is a beautiful memory for many of us, and it also made me grow a lot. After fully demonstrating myself, I have a deeper understanding of myself, my own strengths, and my own shortcomings. This will be a valuable asset and will inspire me to move forward on the road to the future. The competition process gave me not only experience in learning and scientific research, but also psychological maturity. My university is also more exciting because of this competition.