金牌会员
- 积分
- 2589
- 威望
- 1193
- 贡献
- 768
- 兑换币
- 736
- 注册时间
- 2014-9-25
- 在线时间
- 314 小时
|
本帖最后由 qq904305159 于 2016-3-28 18:06 编辑
方向控制用的清华方案,两个电感,P=2000,D = 0;程序如下,不管P大还是小,都会两边荡,感觉抗干扰能力特别弱,速度稍微快点就很容易跑出弯道.咋回事?
有经验的同学可以给点提示吗?
void DirectionControl(void)
{
float fLeftRightAdd,fLeftRightSub,fValue,fDValue;
float nLeft,nRight;
Read_AD();
AD_Value[0] *= 10;
AD_Value[1] *= 10;
nLeft = AD_Value[1] /= DIRECTION_CONTROL_COUNT;
nRight = AD_Value[0] /= DIRECTION_CONTROL_COUNT;
fLeftRightAdd = nLeft + nRight;
fLeftRightSub = nLeft - nRight;
g_fDirectionControlOld = g_fDirectionControlNew;
fValue = fLeftRightSub * g_dirControl_P / fLeftRightAdd;
fDValue = Get_AngleSpeed_Y();
fDValue *= g_dirControl_D;
fValue += fDValue;
g_fDirectionControlOutNew = fValue;
}
void DirectionControlOutput(void)
{
float fValue;
if(g_nDirectionControlPeriod>=DIRECTION_CONTROL_PERIOD)
{
g_nDirectionControlPeriod = 0;
}
fValue = g_fDirectionControlOutNew - g_fDirectionControlOutOld;
g_fDirectionControlOut = fValue * (g_nDirectionControlPeriod + 1) /DIRECTION_CONTROL_PERIOD
+ g_fDirectionControlOutOld;
}
http://v.youku.com/v_show/id_XMTUxNDk2NTM3Ng==.html?from=y1.7-1.2
补充内容 (2016-4-6 12:40):
补充,后来发现程序写错了,改过来了 |
|