智能车制作
标题:
急急 !!小车在设定的平衡位置不能停住(附注电机控制的代码求指导 )
[打印本页]
作者:
没有道理!
时间:
2015-3-10 21:05
标题:
急急 !!小车在设定的平衡位置不能停住(附注电机控制的代码求指导 )
void MotorControl(int Angleout)
{
Leftcontrol=Angleout;//-Speed_control_out_l; //+Speed_control_out_l;
Rightcontrol=Angleout;//-Speed_control_out_r; //+Speed_control_out_r;
/*
if(Leftcontrol >= 0)
Leftcontrol += 600;
else
Leftcontrol -= 600;
if(Rightcontrol >= 0)
Rightcontrol += 690;
else
Rightcontrol -= 690;
*/
if(Leftcontrol > control_max)
Leftcontrol = control_max;
if(Leftcontrol < control_min)
Leftcontrol = control_min;
if(Rightcontrol > control_max)
Rightcontrol = control_max;
if(Rightcontrol < control_min)
Rightcontrol = control_min;
if(Leftcontrol > 0)
{
FTM_PWM_Duty(FTM0,FTM_CH7,2000+Leftcontrol);//ch7
FTM_PWM_Duty(FTM0,FTM_CH6,0); //ch6
}
else if(Leftcontrol < 0)
{
Leftcontrol=-Leftcontrol;
FTM_PWM_Duty(FTM0,FTM_CH6,2000+Leftcontrol); //ch6
FTM_PWM_Duty(FTM0,FTM_CH7,0); //ch7
}
else
{
FTM_PWM_Duty(FTM0,FTM_CH6,2000);
FTM_PWM_Duty(FTM0,FTM_CH7,2000);
}
if(Rightcontrol > 0)
{
FTM_PWM_Duty(FTM0,FTM_CH5,2000+Rightcontrol); //ch5
FTM_PWM_Duty(FTM0,FTM_CH4,0); //ch4
}
else if(Rightcontrol < 0)
{
Rightcontrol=-Rightcontrol;
FTM_PWM_Duty(FTM0,FTM_CH4,2000+Rightcontrol);//ch4
FTM_PWM_Duty(FTM0,FTM_CH5,0); //ch5
}
else
{
FTM_PWM_Duty(FTM0,FTM_CH4,2000);
FTM_PWM_Duty(FTM0,FTM_CH5,2000);
}
if(Angle_car > 34 || Angle_car< -25)
{
FTM_PWM_Duty(FTM0,FTM_CH4,2000);
FTM_PWM_Duty(FTM0,FTM_CH5,2000);
FTM_PWM_Duty(FTM0,FTM_CH6,2000);
FTM_PWM_Duty(FTM0,FTM_CH7,2000);
}
作者:
3121304020
时间:
2015-3-11 11:45
个人感觉原因如,平衡位置选取不当,或角度融合不好,小幅震动可能车调的过硬或死区电压不合适
作者:
qq1358381353
时间:
2015-3-11 12:07
粘贴代码没用的。
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2