当前位置:网站首页>Aircraft PID control (rotor flight control)
Aircraft PID control (rotor flight control)
2022-07-25 20:05:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
First, let's talk about what is a four rotor aircraft
name : Four rotor aircraft Components : One rack , A gyroscope , Four brushless DC motors , A battery , A single chip computer ( The most basic configuration that can fly ) principle : Use the reaction force generated by the rotation of four motors to lift the aircraft , Using single chip microcomputer and flight control algorithm to control the motor to stabilize the aircraft
Cascade PID Algorithm
However, let's briefly introduce the cascade PID Algorithm name : Cascade PID Algorithm effect : Collect the attitude angle of the aircraft , Output the control quantity to stabilize the aircraft
Attitude angle
Let's talk about the attitude angle first , Now let's imagine a tile in space “ Ten ” word , The word swings left and right , Up and down , And turning around the origin is called three attitude angles . The first two are called pitching , roll , The angle around the origin is called yaw ( For the time being x,y,z Express ) For just keeping stable , Only x,y Horn is enough , How can these three angles be measured ? Use gyroscope , Here we say MPU6050,, Gyroscope is a chip , The only function is to output three pieces with a length of 3 One dimensional array of x[3],y[3],z[3],x,y,z Represents three corners , The length is 3 Because they are angles , angular velocity , Angular acceleration , Cascade pid Only angle and angular velocity .
So how to use these three angles to control the stability of the aircraft ?
Let's have a simple one first , For example, the cross paved in space , We detected the downward deviation of the left side through the gyroscope 10 degree , that x=10, If the right side is downward 10 degree ,x=-10, Up and down ,y=10, The lower side leans downward y=-10, Notice that the left side leans downward and the right side leans upward , The right side is downward and the left side is upward , This is like a lever, so there is no need to repeat it . The values of these two variables will be expressed as global variables in the MCU , We can use it directly . If we detect x=10, Then we need to increase the speed of the left motor , Reduce the speed of the right motor , In the end x,y Keep at 0, In this way, the aircraft will be stable , The other angles are the same . there x and y The value is the error , The system that regulates the input through error in turn is called negative feedback system And cascade PID The algorithm studies the motor speed to be reduced and increased . First introduce the motor speed First , The motor speed is determined by PWM Wave controlled , The larger the duty cycle , The faster , hold PWM Wave duty cycle changes with a int Variable speed Value from 0 To 1000 The changes of , such 0 It means speed 0,1000 It represents the maximum speed .( The duty cycle is the ratio of high-level time to cycle in a cycle ) This constitutes the input of the flight control system , The output comes out , The input is the angle collected by the gyroscope , The output is speed Value , Four motors correspond to four speed, Namely speed1,speed2,speed3,speed4.
Cascade PID Derived from PID,PID It's the ratio 、 Integral and differential
Let's start with PID
PID There are two kinds , Incremental and positional , Incremental direct output control quantity increment , Suitable for stepper motors with integral , Four rotors use position PID
P: The function of is to increase the control quantity in proportion , For example, it detects x=10, here speed1 Should increase 10 however 10 Too small , We can enlarge the adjustment amount , If P yes 5 Then the adjustment amount is expanded to 50 了 But there is a problem with using only proportion , That is, for example, I want to adjust the quantity to 33, and P yes 5 If so, the adjustment amount we can calculate can only be 5 Integer multiple ,30 or 35, And 33 There is always an error If it is reflected in the image, it is the broken line movement of the curve up and down in the balance position
I: In order to eliminate the static error, we must introduce the integral , The characteristic of integral is , As long as there is a little error, he will play a role ( Because it is a direct program judgment x or y And 0 The size relationship of controls the integrator to turn on ) And if the error is not eliminated or the sign is changed ( Changing the sign is positive to negative or negative to positive , For example, the wing changes from right to left ), The integral will be bigger and bigger , The increase in the amount of adjustment will be greater and greater ( So remember to set an upper limit ) Of course, you may wonder how to eliminate the accumulated value of the integral , When the wing deflects from left to right adjusted by proportion and integration , The adjustment quantity has changed , If you add up again, it's equivalent to tiredness , It will be eliminated naturally So the adjustment of the integral is 0 Left right fluctuation , In this way, the curve will change from a broken line above and below the equilibrium point to a small wave
D: As for the differential value, it uses the error value of the last time to change the adjustment quantity this time , His role is to predict , The most interesting thing about his value is , It has nothing to do with the position of your wings , That is to say, even if your wing leans to the left The differential value may also be adjusted to make the wing more inclined to the left , In that case, why do we use differential values , In fact, the differential value is to detect two different algorithm cycles ( I'll focus on this later ) The magnitude of the error variation Suppose the algorithm period is one second Suppose the first second , The plane x=30, The second second second is adjusted by the algorithm x=25, The third second x=10, Then for the differential, the first second error change is 5, The second second second error variation is 15 Then he will stop x Keep getting smaller , Even if x Smaller to make the plane stable , If the first second x=15, The first 2 second x=10 Then he will help x smaller This is the essence of differential action , Regardless of the enemy or me , Try to prevent the expansion of error changes , The function of this is actually to predict the change of error , Then let's analyze the specific events
How to use it
In fact, understand the essence of proportional integral and differential , Different people have different opinions on how to use it
So what is cascade PID Well , It is to use angle and angular velocity as error input at the same time , Two PID Together as a system , Motor speed regulation as output The angle error of the outer ring passes through a PID The difference between the regulation quantity and the angular velocity loop of the inner loop is taken as the input error of the inner loop , The error goes through another PID Then the actual motor speed regulation quantity is obtained
Where to use PI Where to use PD Where to use PID You can adjust yourself according to your actual situation , It is suggested that the outer ring PI, Inner ring PID.
Let's talk about the algorithm cycle
It is controlled by timer , How often do I get the gyroscope data , How often do I get the inner ring calculation data , How often do I get the outer ring calculation data , This must be strictly controlled , The specific value can be compared with PID Value, self debugging
A year ago, I made four axes , Only by memory , If there are any omissions , Xie Zhizheng , Hope to understand .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/127538.html Link to the original text :https://javaforall.cn
边栏推荐
- Yyds dry inventory how to locate browser page crash
- Binarysearch basic binary search
- Successfully solved typeerror: a bytes like object is required, not 'str‘
- 【好书推荐】-- 《以太网权威指南》(第2版)
- Partial interpretation of yolov7 paper [including my own understanding]
- 当AI邂逅生命健康,华为云为他们搭建三座桥
- Export and call of onnx file of pytorch model
- [Infographics Show] 248 Public Domain Name
- Creative drop-down multi choice JS plug-in download
- 9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence
猜你喜欢

Mutual conversion of camera internal parameter matrix K and FOV

Prescan quick start to master Lesson 19: prescan actuator configuration, track synchronization and non configuration of multiple tracks

When the V100 of mindpole 8 card is trained to 101 epochs, an error of reading data timeout is reported

一元函数积分学_分部积分法

随机梯度下降法、牛顿法、冲量法、AdaGrad、RMSprop以及Adam优化过程和理解

10. < tag dynamic programming and subsequence, subarray> lt.53. maximum subarray and + lt.392. Judge subsequence DBC
![[wp]ctfshow-web getting started - Explosion](/img/4b/6d8f4c044578382b9353d4d1c69c8f.png)
[wp]ctfshow-web getting started - Explosion

Univariate function integration_ Partial integral method

Authorized wireless communication standard

如何保证定制滑环质量
随机推荐
推荐系统专题 | MiNet:跨域CTR预测
The query data returned by the print database is null or the default value. Does not match the value returned by the database
【高等数学】【4】不定积分
Timing analysis and constraints based on xlinx (1) -- what is timing analysis? What are temporal constraints? What is temporal convergence?
从瞳代到“瞳代”再到品牌,暴利的美瞳的变与未变
Network RTK UAV test [easy to understand]
Bash does not add single quotes to your string
4、Nacos 配置中心源码解析之 服务端启动
参与开源社区还有证书拿?
Export and call of onnx file of pytorch model
随机梯度下降法、牛顿法、冲量法、AdaGrad、RMSprop以及Adam优化过程和理解
4everland storage node portal network design
Yyds dry inventory how to locate browser page crash
4. Server startup of source code analysis of Nacos configuration center
软件设计师下午真题:2009-2022
redis源码 -ziplist
Application of conductive slip ring in mechanical equipment
Array of sword finger offer question bank summary (I) (C language version)
[CSAPP Practice Problem 2.32] tsub_ok(int x, int y)判断补码减法是否溢出
Add a subtitle of 3D effect to the container