【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《pid》,欢迎阅读!
error = Set_Speed - PulseAccN;
if(error < Speed_Shift && error > -Speed_Shift) {
if(Bang_bang_Flag) {
SpeedPID.vi_PreError = 0; SpeedPID.vi_PreDerror = 0; // SpeedPID.SumError = 0; }
Speed_ADJ(Set_Speed); Bang_bang_Flag = 0; } else {
Bang_bang_Flag = 1; Bang_bang(Set_Speed); }
/*Speed_ADJ(Set_Speed);*/ }
陈泽恒 2011/4/20 13:19:43
这是bangbang的控制语句~Speed_Shift就是阈值~
陈泽恒 2011/4/20 13:20:19
/****************速度调节*******************/
void Speed_ADJ(word Set_Speed) {
SpeedPID.vi_Ref= Set_Speed;
Speed =PIDCalc(&SpeedPID,PulseAccN); //loss data unsolvable
if(Speed>970) {
Speed_Control= 970; //PWMDTY3 = 0; Speed = 970; } else
Speed_Control=Speed; }
/*********************bangbang控制***************/ void Bang_bang(word Set_Speed)
{
if(PulseAccN <= Set_Speed) {
Speed_Control = 970; //PWMDTY3 = 0; } else {
Speed_Control = 5; //PWMDTY3 = 100; } }
本文来源:https://www.wddqxz.cn/8f553dfa941ea76e58fa04ab.html