STM32 realizes underwater quadrotor (2) hardware list and software design

I. Introduction

In the last article, we wrote about the flight principle of the quadcopter. In this article, we will continue to do preparatory work, mainly to explain the operating system. Our code is based on the operating system. Why use an operating system? Your computer can run multiple programs at the same time, thanks to the operation of the operating system. It is the same for the single-chip microcomputer. The single-chip microcomputer using the operating system can run multiple programs at the same time. Can you bear that your computer can only run Word or a browser or some other single program at the same time? Obviously not, so why can you tolerate only one main function in the microcontroller? Because before that your function was single and simple, or you didn't know that there was an operating system. If you have been letting your beloved board run naked, starting from today, I hope you can equip it with a powerful weapon- an embedded operating system, which can maximize the performance of the CPU, achieve multi-tasking, and achieve real-time performance. It is most suitable for demanding occasions .

Don’t be discouraged if there is no basic operating system for children’s shoes before, the operating system is difficult, but you don’t need to worry about the difficult part, just use it as a tool. Just like you use a computer, do you need to understand how the Win10 system works? Do you need to implement the win10 system by yourself? The answer is no need, just use it! I suggest that I have an STM32 board in my hand to learn the tutorials of Atom's FreeRTOS or UCOS-III operating system, while learning and practicing. It doesn't really matter, I will downplay the operating system in the following article, it is just a framework, we are more concerned about the core code part.

2. Introduction to UCOS-III Operating System

There are many embedded operating systems, among which are FreeRTOS, UCOS-II, and UCOS-III operating systems. The author does not do too much research and explanation, only briefly introduces its use. The first thing to use an operating system is to transplant the operating system. The process of transplantation will be a little troublesome, and different boards will be different. The self-developed master controller based on the STM32F767IGT chip used in this project, the author directly used the project template transplanted from the Apollo development board of Punctual Atom, and you can click to download it .

There are many knowledge points of the operating system. We need to understand the creation, suspension, deletion of tasks, task scheduling, task priority, time slice rotation scheduling, and so on. In my code, there is no semaphore and message passing mechanism, and all global variables are used. In fact, it is very irregular and unsafe. This design method is not recommended. In the author's experience, the STM32 operating system is not easy to use, and the technical requirements are very high. The use of embedded operating system is just a transition. I will concentrate the main algorithms on high-performance Linux motherboards such as Raspberry Pi and Nvidia in the future, and use STM32 as the driver board. The advantage of this kind of upper and lower controllers is that users only need to focus on applications and algorithms, and do not need to spend too much energy on the underlying implementation . Of course, the hardware cost will be much higher.

3. Design a multi-task system for underwater quadrotors

Next, we design a multi-task system for underwater quadrotors. The quadrotor is a typical complete robot architecture, which contains all the core elements needed to realize a robot, from communication, sensing, control, power to hardware circuits, machinery, etc. If you build a quadrotor from beginning to end (Including writing code and debugging by yourself), you will be able to handle general robot design applications.

Here we create 5 tasks, start task (StartTask), communication task (RadioLinkTask), sensor task (SensorTask), attitude control task (StabilizationTask), data transmission task (TransmissionTask). The level of the system is shown in the figure. As I said before, the operating system is just a tool, and our core is at the application layer—applications. The operating system can maximize the function of the CPU downward, and realize the user's application program in the most efficient and stable upward direction. The start task is responsible for creating all other tasks, and then suspends itself (that is, it doesn't work anymore). The communication task (RadioLinkTask) is responsible for communicating with the remote control, analyzing the data of the remote control, and acting in accordance with the instructions. The sensor task (SensorTask) is responsible for parsing all sensor data, including raw data reading, filtering, and fusion. The Stabilization Task is responsible for the PID calculation of the three-axis attitude angle and height loop, outputting the control quantity and controlling the motor. The data transmission task (TransmissionTask) includes uploading and downloading-uploading all the current states of the quadcopter (posture, throttle, power and other information), and at the same time analyzing the data downloaded from the ground station to perform corresponding actions or adjust parameters.
Insert picture description here
The entire project has a large amount of code and many files. I roughly express the relationship between them as follows:
Insert picture description here

4. Hardware circuit design

In fact, this section should be put on top, first design the hardware and then design the software, but it doesn't matter. The introduction of the hardware circuit is mainly to list the devices used and the on-board resources of the STM32 used. The following table shows a list of used hardware.

Insert picture description here
There are 5 motors in it is not necessarily . Among them, four vertical motors are used as quad-rotors to provide vertical power and adjust attitude. We have talked about the flying principle of quad-rotors. Quad-rotors rely on pitching or rolling motions to provide front-to-back or left-to-right horizontal components to achieve Moving back and forth or left and right, is the same for underwater quadcopters? The answer is no! ! ! Because the underwater resistance is very large, the quadrotor generally only has an angular range of about 30 degrees, and the horizontal component provided by it is very limited. You will find that it is very difficult for an underwater quadrotor to achieve horizontal movement.. The author has done experiments on his own. It pitches and rolls in place, but it doesn't move and is dizzy! ! Therefore, a horizontal motor needs to be set up, of course, it can be two, three, or four. The underwater quadrotor does not require strict weight control like the air, because you only need to design the robot's self-weight and buoyancy to offset it, so you can use a large battery. The author himself uses a 10000MAH battery, which has a very long battery life. .

Please design the frame yourself. For simplicity, you can go to Taobao to buy a sealed cabin for robots, and then design the frame yourself, otherwise the sealing will be difficult .
The function of the relay is for safety reasons, because the current of the quad-rotor is relatively large, and ordinary switches cannot withstand that large current .
The multi-core watertight connector is for charging, so when not charging, screw the female plug to seal, and when charging, unscrew the female plug and plug in the plug to charge. The watertight connector looks like this:

Insert picture description here

The hardware connection diagram is shown in the figure.
Insert picture description here
If you are not making an underwater quad-rotor and just want to make an aerial quad-rotor, you can use the same hardware framework as the software framework above. It's just that you don't need to consider waterproofing, sealing, etc., it's much simpler.

From the next chapter, we begin to write code to implement remote control communication, sensor data fusion, attitude control, data transmission and other functions in turn. I've seen it all here, just like it before leaving!

Guess you like

Origin blog.csdn.net/qq_30267617/article/details/113786168