当前位置:网站首页>Understanding of PID control motor output as motor PWM duty cycle input
Understanding of PID control motor output as motor PWM duty cycle input
2022-08-09 09:20:00 【running bunny】
This two days have been confusedPIDHow can the output ofPWMPulse control motor output?I asked a few people and they didn't make it clear..
I think that if you can explain it to a beginner, it means you have a good grasp of it.,If you say it and others still don't understand, then you have to reflect on how you have mastered it.,Is in self-deception?Also, everyone's field of expertise is different, don't always say it's so simple and don't understand,那我只能说,You may be a noob in my area of expertise.
Study a day finally understand now,Share with beginners who are as confused as me,仅代表个人理解.
1、设定PIDTarget values and parameters,The target value is the motor speed value.
set_p_i_d(1.5, 0.2, 0.0);
set_pid_target(30.0);
2、PIDis a negative feedback closed-loop system,这点很重要.
float PID_realize(float actual_val)
{
/*计算目标值与实际值的误差*/
DBG_Printf("%s: pid_target:%.2f - PID_actual:%.2f \r\n", __FUNCTION__,pid.target_val, actual_val);
pid.err = pid.target_val - actual_val;
/*积分项*/
pid.integral += pid.err;
DBG_Printf("%s: PID_error:%.2f - PID_sum:%.2f \r\n", __FUNCTION__,pid.err, pid.integral);
/*PID算法实现*/
pid.output_val = pid.Kp * pid.err +
pid.Ki * pid.integral +
pid.Kd * (pid.err - pid.err_last);
/*误差传递*/
pid.err_last = pid.err;
/*返回当前实际值*/
return pid.output_val;
}
3、Specific feedback process
a、首先PID算法第一步 Will do a difference the target value and actual value is calculated,The calculation deviation is very large at the beginning and gradually becomes smaller.
b、每次的PIDThe output will be used as the input of the motor,The encoder will read the speed every time,The speed of reading at first is very small,It will pass in this speed value as the actual valuePIDenter this timePIDIn the target and the actual value comparison,直到误差为0,这个过程会一直进行,just the error is0The accumulated value of the integral term becomes stable,The difference in the differential term is also stabilized,The scale term is also stable.也就是PIDoutput is stable,而这个值就是PWM的占空比,This value is the stable value of the sum of the three terms,In my example,这个PWMIn the duty ratio of stability400左右,It is determined by the negative feedback value during the motor rotation,也就是目标值30对应的占空比,Specifically, the target value is reached30,PIDOutput the cumulative value of the three items,To achieve this speed, it has to be this duty cycle,They have a linear relationship,和你设置的PID参数有直接关系.
c、重新设定PIDTarget values and parameters,The target value is the motor speed value.
set_p_i_d(15.0, 2.0, 0.0);
set_pid_target(30.0);
我把PIDThe parameters are increased tenfold,The speed target value does not change,The final this timePID输出的PWMThe duty cycle will remain stable at400.relative to the previous set of parameters,Its integral accumulation term is exactly one-tenth of the previous set,But the response speed is improved compared to the previous group10倍.
边栏推荐
猜你喜欢
小程序/app触底加载更多数据
这12个GIS软件一个比一个好用
JVM进程诊断利器——Arthas
MySQL lock
Read file by byte and character_load configuration file
Ovie map computer terminal and mobile terminal can not be used, is there any alternative map tool
UE4 RTS frame selection function implementation
Redis基础
[Vulnerability reproduction] CVE-2018-12613 (remote file inclusion)
【场景化解决方案】构建医疗通讯录,“慧医钉”助力医院实现数字化管理
随机推荐
TestNG使用教程详解
问卷问题和答案的合并
Teach you how to get a 0.1-meter high-precision satellite map for free
VoLTE基础自学系列 | IMS的业务触发机制
管理方向发展
MySQL Leak Detection and Filling (3) Calculated Fields
Calendar类和Date类转换时区 && 部分时区城市列表
不支持关键字: 'Provider'
makefile - 学习小结
【场景化解决方案】构建设备通讯录,制造业设备上钉实现设备高效管理
verilog独热码实现译码MIPS指令集
【LeetCode每日一题】——225.用队列实现栈
H5页面px不对,单位不对等问题
MVCC多版本并发控制
C#学习笔记
TypeScript简记(一)
AES/ECB/PKCS5Padding encryption and decryption
MySQL event_single event_timed loop event
常用SQL server语句
RESTful