当前位置:网站首页>PID debugging of coding motor (speed loop | position loop | follow)
PID debugging of coding motor (speed loop | position loop | follow)
2022-04-23 03:07:00 【Taochengqi 2.0】
List of articles
In the previous article, we talked about the coding motor cascade PID Relevant knowledge , As well as some PID Debugging experience , Here, I happened to touch the motor again recently , At the same time, the tool of waveform is added , I think this way can help more people understand this process , At the same time, we can better understand PID This thing .
At the same time, during the school recruitment interview , Some embedded posts do robot control related , Including when I introduce my project, I usually ask some PID Debugging process of ,PID The role of several parameters , Description of inner ring and outer ring, etc , therefore PID It's more important .
If you have any comments on this article, you are welcome to put forward !
1、 Recognition of coding motor
The content of data reading of coded motor has been introduced in the previous article , The corresponding links are as follows , If necessary, you can understand by yourself :
Double closed loop control of DC coded motor ( Speed + angle ) control
There is no repetition here , Here we can add some contents , Mainly the data processing part of the encoder , This is to better obtain the angle data , Steps are as follows :
First, we need to turn on the corresponding interrupt , Data accumulation in interrupt , In this way, you can make some records, such as angle and number of turns
Here, let's review the encoder harness , The harness here is the number of pulses per revolution of the motor , But we are AB Then there are captures that can be on the upper and lower edges , So we can do it 4 Frequency doubling sampling
The final number of turns is designed as follows , The first thing here is to design a positive and negative , If it's positive, add it up , The direction is subtracted , Then the final lap count here is the same .
In this way, we can intuitively show the record of the number of laps , Source code is as follows :
int Angle = 0;// angle
int circr = 0;// Number of turns
const int Step_Angle = 360/4/30;
void Motor_Get_Angle(TIM_HandleTypeDef *htim)
{
if(htim == &htim2)
{
if((htim->Instance->CR1 & 0x0010)>>4)// Direction judgment
// It can also be used here htim->Instance->CR1 To judge 0X01 Better ahead of time ,0X11 It's counter clockwise
Angle -= Step_Angle;
else
Angle += Step_Angle;
}
if(Angle == 360)
{
circr++;
Angle = 0;
}
if(Angle == -360)
{
circr--;
Angle = 0;
}
}
2、 Upper computer waveform display
1、 Function is introduced
Here is the recommended VOFA+ This serial assistant , With waveform display function , More powerful , About VOFA+ I won't explain this here , There are a lot of information on the Internet , Basically, Baidu can see a lot of relevant information as soon as it searches
If you want to use his blog display function here, you should follow my following operations
After pulling out the waveform function, we need to fill in here for full screen display , As shown below
Select the type of graph and the waveform
Generally we x Just set the axis directly to time
y The axis can be used to set our curve , Note here , There has to be , If the data hasn't been sent, you can't see it
Then we automatically zoom under selection
2、 Agreement that
Enter our agreement and connection first :
You can see the protocol description as follows :
Here you can see the description of the agreement , As shown below :
Another explanation
Mainly the debugging instructions here , Here you can see the first direct use printf That's all right. , But both give examples , So I decided to use the first method to realize , Use printf add , It can be realized .
3、 Speed loop adjustment test certificate
Here I still build the same as the previous article PID framework , See Double closed loop control of DC coded motor ( Speed + angle ) control
About PID Debugging effect of , You can see my article , This article uses simulink To simulate the PID:Matlab Use simulink Set up PID Record
The speed loop used PID As shown below , You can see that the parameters printed are the target value and the current value :
Here, let's take a look at pure p When adjusting , here KP=200, It's quite big , There are still steady-state errors
Then add I Eliminate the error , here I Just gave 0.1
We simply continue to grow KP, You can see the obvious overshoot
At this time, if one person increases i You can see that the stability of the system decreases
Finally, we can see the debugging effect , As shown below :
4、 Position ring adjustment test certificate
Here, the position ring controls the position of the motor , The direct way to think of here must be to use it directly PID Calculation , It's perfectly possible , It's just not very stable , The effect is not very good , Anti disturbance is not very good , Therefore, you can choose cascade PID To realize the relevant functions , As follows, I introduce both schemes :
The following is the direct use location PID Calculate P[ID The situation of
、
Here's how to use speed and position PID The situation of calculation
This process feels like following the parameter adjustment scheme I mentioned above , It's still convenient , It can be debugged quickly , The final effect is as follows :
5、 Achieve the following effect
Following is actually a PID Linkage with another , The essential situation is to put one of the rings PID The input quantity is replaced by the data collected by the sensor of another motor , But the final control quantity is another motor .
The final effect is as follows :
版权声明
本文为[Taochengqi 2.0]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230306011387.html
边栏推荐
- Some problems encountered in setting Django pure interface, channel and MySQL on the pagoda panel
- AOT和单文件发布对程序性能的影响
- [ncnn] - the meaning of - 23300 in param
- 7-11 重排链表 (25 分)
- tf. keras. layers. Conv? D function
- Thoughts on the 2022 national network security competition of the national secondary vocational group (only one idea for myself) - network security competition questions (9)
- Niuke white moon race 5 [problem solving mathematics field]
- Golden nine silver ten interview season, you are welcome to take away the interview questions (with detailed answer analysis)
- [new version release] componentone added Net 6 and blazor platform control support
- Blazor University (11)组件 — 替换子组件的属性
猜你喜欢
Golden nine silver ten interview season, you are welcome to take away the interview questions (with detailed answer analysis)
Introduction and use of openfeign component
Opencv fills the rectangle with a transparent color
Array and collection types passed by openfeign parameters
C#中切片语法糖的使用
Niuke white moon race 5 [problem solving mathematics field]
Source code interpretation of Flink index parameters (read quantity, sent quantity, sent bytes, received bytes, etc.)
Small companies don't make formal offers
tf. keras. layers. MaxPooling? D function
Tips in MATLAB
随机推荐
宁德时代地位不保?
[ncnn] - the meaning of - 23300 in param
Use of MySQL command line client and common commands
Numpy append function
Blazor University (11)组件 — 替换子组件的属性
編碼電機PID調試(速度環|比特置環|跟隨)
Using positive and negative traversal to solve the problem of "the shortest distance of characters"
Notes sur le développement de la tarte aux framboises (XII): commencer à étudier la suite UNO - 220 de la tarte aux framboises de contrôle industriel advantech (i): Introduction et fonctionnement du s
最通俗易懂的依赖注入之服务容器与作用域
AspNetCore配置多环境log4net配置文件
. net tip: talk about the problem that the scoped service cannot be obtained in the middleware structure
Golden nine silver ten interview season, you are welcome to take away the interview questions (with detailed answer analysis)
Detailed explanation of distributed things
How to count the number of all files in a directory under win10 system
樹莓派開發筆記(十二):入手研華ADVANTECH工控樹莓派UNO-220套件(一):介紹和運行系統
Redis Cluster集群,主节点故障,主从切换后ip变化,客户端需要处理不
求二叉树的叶子结点个数
MYSQL03_ SQL overview, rules and specifications, basic select statements, display table structure
be based on. NETCORE development blog project starblog - (1) why do you need to write your own blog?
C# 读写二进制文件