📄 postion_reg.c
字号:
#include "Postion_reg.h"
int PostionPid(POSTIONPID *postion)
{
long PostionE;
int k0,k1,k2;
int PostionE0;
k0=postion->PostionKp*10+postion->PostionKi+postion->PostionKd;
k1=postion->PostionKp*10+2*postion->PostionKd;
k2=postion->PostionKd;
PostionE=postion->PostionR-postion->PostionF;
if (PostionE>32767) PostionE0=32767;
else if (PostionE<-32768)PostionE0=-32768;
else PostionE0=PostionE;
postion->PostionU+=k0*PostionE0-k1*postion->PostionE1+k2*postion->PostionE2;
postion->PostionE2=postion->PostionE1;
postion->PostionE1=PostionE0;
postion->PostionU/=1000;
postion->speed_reg->Speed=postion->PostionU;
if (postion->speed_reg->Speed>postion->Speed)
postion->speed_reg->Speed=postion->Speed;
else if (postion->speed_reg->Speed<(0-postion->Speed))
postion->speed_reg->Speed=0-postion->Speed;
postion->speed_reg->updata(postion->speed_reg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -