查看PID的源代码
←
PID
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== Overview == <source lang=cpp> typedef struct { float Kp; // 比例系数 float Ki; // 积分系数 float Kd; // 微分系数 float integral; // 积分项 float prev_error; // 上次误差 float setpoint; // 目标电流 } PID_Controller; float PID_Calculate(PID_Controller *pid, float actual) { float error = pid->setpoint - actual; // 比例项 float p_out = pid->Kp * error; // 积分项(防饱和) pid->integral += error; if(pid->integral > 1000) pid->integral = 1000; if(pid->integral < -1000) pid->integral = -1000; float i_out = pid->Ki * pid->integral; // 微分项 float d_out = pid->Kd * (error - pid->prev_error); pid->prev_error = error; // 输出 float output = p_out + i_out + d_out; // 限幅 if(output > 0.95) output = 0.95; if(output < 0.05) output = 0.05; return output; } </source> 改进型 PI 控制(消除积分饱和): <source lang=cpp> // 条件积分法 if(!((output >= max_limit && error > 0) || (output <= min_limit && error < 0))) { integral += error; } // 积分分离法 if(fabs(error) > threshold) { // 只用比例控制 output = Kp * error; } else { // 加入积分 integral += error; output = Kp * error + Ki * integral; </source> <br><br> == Reference == * [https://wenku.baidu.com/view/ee44725d9a6648d7c1c708a1284ac850ad02049c.html PID控制算法的C语言实现] * [https://blog.csdn.net/wangshuai_embeded/article/details/45719109?utm_source=blogxgwz3 工业PID控制方法的C语言实现详解] * [https://www.jianshu.com/p/d3b1c3d307e0 我所理解的卡尔曼滤波] * [https://blog.csdn.net/u012554092/article/details/78290223 理解卡尔曼滤波的三重境界] <br><br> <br><br> <br><br>
返回到
PID
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面