1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 1343|回復(fù): 1
收起左側(cè)

PID控制

[復(fù)制鏈接]
ID:392808 發(fā)表于 2018-9-3 09:47 | 顯示全部樓層 |閱讀模式
int pid_calc(int tem)
{
  char cur_error;
  float incpid;
  float a,b,c;
//  char d_error;
  cur_error=250-tem;
  a=temp_pid.proportion*cur_error;
//  d_error=cur_error-temp_pid.last_error;
  temp_pid.sum_error+=cur_error;
  temp_pid.sum_error-=temp_pid.old_error;
  b=temp_pid.integral*temp_pid.last_error;
  c=temp_pid.derivative*temp_pid.pre_error;
  incpid=a-b+c;

  if(cur_error==temp_pid.last_error && cur_error==temp_pid.pre_error && (temp_pid.sum_error>3 || temp_pid.sum_error<-3))
          incpid+=0.25*temp_pid.sum_error;
  //incpid=temp_pid.proportion*cur_error-temp_pid.integral*temp_pid.last_error+temp_pid.derivative*temp_pid.pre_error;


//  temp_pid.pre_error=temp_pid.last_error;
  temp_pid.last_error=cur_error;
  temp_pid.pre_error=temp_pid.last_error;
  temp_pid.old_error=temp_pid.pre_error;
  return (int)incpid;
}

回復(fù)

使用道具 舉報(bào)

ID:1 發(fā)表于 2018-9-3 18:07 | 顯示全部樓層
詳細(xì)說(shuō)明一下,補(bǔ)全完整代碼 即可獲得100+黑幣
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表