2012飞思卡尔智能车速度pid调试

2012飞思卡尔智能车速度pid调试

ID:32594737

大小:59.52 KB

页数:8页

时间:2019-02-13

2012飞思卡尔智能车速度pid调试_第1页
2012飞思卡尔智能车速度pid调试_第2页
2012飞思卡尔智能车速度pid调试_第3页
2012飞思卡尔智能车速度pid调试_第4页
2012飞思卡尔智能车速度pid调试_第5页
资源描述:

《2012飞思卡尔智能车速度pid调试》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、Ctl_P二Kp*SpeedError;//计算比例项Ctl_I二Ki*SpeedError+Ctl_I;if(Ctl」〈-1000)〃积分项限幅Ctl_I=-1000;1000)Ctl_I=1000;//T_Ctl_I=Ctl_I;//T_Ctl_P=Ctl_P;PWM1input二(8*(Ctl_P+Ct1_I)+3*PWM1inputCachc[01+PBllinputCachc[1])/12;voidSpeedCount(void)SpeedCache[3]=SpeedCache[2];Sp

2、ccdCachc[2]=SpccdCachc[1];SpeedCache[1]=SpeedCache[0];SpeedCache[0]=SpeedBack;//缓存NEW_SpeedCache[3]=NEW_SpeedCache[2];NEWSpccdCachc[2]=NEW_SpccdCachc[1];NEWSpeedCache[1]=NEW_SpeedCache[0];NEW_SpeedCache[0]=NEW_SpeedBack;if(PACNT

3、erFlow=l;}"if(PA_0verFlow==0){"SpccdBack=PACNT-LastPulscCountcr;//计算当前速度;}elseif(PA_OverFlow==l){"Counter;SpccdBack=65535*PA_0vcrFlow+PACNT-LastPulscPA_0verFlow=0;}"if(NEW_PACNT

4、=NEW_PACNT-NEW_LastPulseCounter;//计算当前速度;}elseif(NEW_PA_OvcrF1ow==1){""NEW_SpeedBack=65535*NEW_PA_0verFlow+NEW_PACNT-NEWLastPulseCounter;NEW_PA_0verFlow=0;}NEW_LastPulseCounter=NEW_PACNT;LastPulseCounter二PACNT;SpccdBack=SpccdBack/PulscCountDcn;NEWSpeed

5、Back=NEWSpeedBack/PulseCountDen;)voidSpeedControl(void){〃速度控制intErrorSum=0;intSpeedCtl;inttri_speed=20;staticucharSpeedUp;staticucharSpeedDown;uintden;staticuintStraightTime;staticuintStraightLineCounter;SteerlncrementError[2]=SteerlncrementError[l];St

6、eerlncrementError[l]=SteerlncrementError[0];SteerlncrementEiror[0]二SteerlncrementCache[O]・SteerlncrementCache[2];ErrorSum=SteerlncrementError[0]*的+SteerlncrementError[1]+SteerlncrementError[2];SpeedCtl=m_abs(Steerlncrement+ErrorSum);if(SpeedCtl<55){〃50

7、Speedllp=1;讦(SpeedDown二二2)StraightCounter=0;StraightCounter++;SpeedDown=0;StraightCounter++;}elseif(SpeedCtl<65)SpeedUp=0;SpeedDown=0;StraightCounter=0;}else{SpeedDown=1;if(SpeedUp==l){StraightCounter=0;StraightCounter=StraightCounter-2;SpeedUp=0;}Stra

8、ightCounter=StraightCounter-2;}denm_abs(SteerlncrementCache[0]SteerlncrementCache[l])/2;if(den==0)den=1;SpeedAdjust=(int)m_sqrt((long)SPEED_MAXSPEED_MAX*100/den);if(SpeedAdjust>(SPEED_MAX-l))SpeedAdjust二SPEED_MAX-1;elseif(SpeedAdjust<(S

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。