当前位置:网站首页>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倍.
边栏推荐
猜你喜欢
Teach you how to get a 0.1-meter high-precision satellite map for free
Anaconda4.8.3介绍、安装及使用教程安装(win10)并修改Jupyter默认工作目录
MySQL查漏补缺(五)不熟悉的知识点
When and How to use MALLOC
VoLTE基础自学系列 | IMS的业务触发机制
全球19级谷歌卫星地图免费查看下载
【培训课程专用】CA/TA调用模型-代码导读
Django实现对数据库数据增删改查(二)
【场景化解决方案】构建医疗通讯录,“慧医钉”助力医院实现数字化管理
数理逻辑MOOC+知识点总结(未完无待续)
随机推荐
约瑟夫问题的学习心得
C语言单、双引号的区别
【培训课程专用】CA/TA调用模型-代码导读
这12个GIS软件一个比一个好用
MySQL event_single event_timed loop event
Makefile中的%标记和系统通配符*的区别
Ovie map computer terminal and mobile terminal can not be used, is there any alternative map tool
lateral view explode的另一种实现方式
SQL Server2000 各个版本之间的区别
[Environmental Construction] tensorrt
js实现看板全屏功能
MVCC multi-version concurrency control
Onnx - environment build 】 【 tensorrt
Swap swap partition
多维度LSTM(长短期记忆)神经网络预测未来存款余额走势
MySQL查漏补缺(二)排序检索、过滤数据、模糊查询、正则表达式
Redis缓存设计
微信小程序转支付宝小程序注意事项
verilog独热码实现译码MIPS指令集
firefox e.path无效