智能车制作

标题: 求助 我们的车跑起来有时候走走停停 有时候却是速度很快会冲出去 [打印本页]

作者: j715473086    时间: 2012-9-12 17:47
标题: 求助 我们的车跑起来有时候走走停停 有时候却是速度很快会冲出去
我是新手 用的官方方案 我们的车跑起来有时候就是走走停停 ,有时候甚至停止跑道上,一动不动,但是有时候却是速度很快会冲出去,不知道是怎么回事,求指导啊,还有就是刚发车的时候会冲好一段才会减速,我用液晶显示了一下 速度输出的变量 在跑道上放车时先是g_fSpeedControlOut逐渐增大 放手后g_fSpeedControlOut又逐渐减小 然后停下来g_fSpeedControlOut又逐渐增大 又开始走了 求指导
作者: qinlu123    时间: 2012-9-12 17:58
亲减小速度控制积分项
作者: yukunlinykl    时间: 2012-9-12 18:39
交流分量加上直流分量,就是走走停停的效果。
说明原地站立得还不稳。
作者: wangkunning    时间: 2012-9-12 19:38
同意楼上,直立参数还没调好,先把直立的P和D调好吧
作者: wangkunning    时间: 2012-9-12 20:03
“刚发车的时候会冲好一段才会减速”,这个很正常的,因为刚开机时速度为零,速度控制就要将速度从零调节到你的设定速度,g_fSpeedControlOut一直增大,所以‘刚发车的时候会冲好一段’,对于这个问题可以按一楼的方法做,也可以刚开始时设定一个比较小的速度,后面再逐渐把速度设定值加上去。至于车跑起来有走走停停等不稳定的现象,是行进过程中车身前后摆动(可能不是特明显),重心移动带来的加速度导致的,因为你的直立参数没调好
作者: Hot_Dream    时间: 2012-9-12 20:24
你在 调一下陀螺仪的水平吧 这个真的很重要 好多奇怪的现象都是陀螺仪
作者: j715473086    时间: 2012-9-13 13:53
yukunlinykl 发表于 2012-9-12 18:39
交流分量加上直流分量,就是走走停停的效果。
说明原地站立得还不稳。

站的很稳了啊 就是解决不了问题 楼下的几个方法也试了 是不是PI控制那里不对啊下面是速度控制的一块 我用K10做的

void GetMotorPulse(void)
{

        LeftPulse=DMAGetCtr(DMA_CH0);
    RightPulse=DMAGetCtr(DMA_CH1);

        g_nLeftMotorPulse = (int)LeftPulse;
        g_nRightMotorPulse = (int)RightPulse;
        if(!MOTOR_LEFT_SPEED_POSITIVE)                g_nLeftMotorPulse = -g_nLeftMotorPulse;
        if(!MOTOR_RIGHT_SPEED_POSITIVE)                g_nRightMotorPulse = -g_nRightMotorPulse;
               
        g_nLeftMotorPulseSigma += g_nLeftMotorPulse;
        g_nRightMotorPulseSigma += g_nRightMotorPulse;
}
//==============================================================================
//                    速度控制
//------------------------------------------------------------------------------
void SpeedControl(void) {
       
        float fP,fI,fDelta;

        g_fCarSpeed = (g_nLeftMotorPulseSigma + g_nRightMotorPulseSigma) / 2;
        g_nLeftMotorPulseSigma = g_nRightMotorPulseSigma = 0;
        fDelta = CAR_SPEED_SET - g_fCarSpeed;

        fP = fDelta * SPEED_CONTROL_P;
        fI = fDelta * SPEED_CONTROL_I;

        g_fSpeedControlIntegral += fI;
        if(g_fSpeedControlIntegral > MOTOR_OUT_MAX)        g_fSpeedControlIntegral = MOTOR_OUT_MAX;
        if(g_fSpeedControlIntegral < MOTOR_OUT_MIN)        g_fSpeedControlIntegral = MOTOR_OUT_MIN;

        g_fSpeedControlOutOld = g_fSpeedControlOutNew;
       
        g_fSpeedControlOutNew = fP + g_fSpeedControlIntegral;
        if(g_fSpeedControlOutNew > MOTOR_OUT_MAX)        g_fSpeedControlOutNew = MOTOR_OUT_MAX;
        if(g_fSpeedControlOutNew < MOTOR_OUT_MIN)        g_fSpeedControlOutNew = MOTOR_OUT_MIN;

}

//------------------------------------------------------------------------------
//   
void SpeedControlOutput(void) {

        fValue1 = g_fSpeedControlOutNew - g_fSpeedControlOutOld;
        g_fSpeedControlOut = fValue1 * (g_nSpeedControlPeriod + 1) / SPEED_CONTROL_PERIOD + g_fSpeedControlOutOld;
       
}



作者: j715473086    时间: 2012-9-13 14:00
wangkunning 发表于 2012-9-12 20:03
“刚发车的时候会冲好一段才会减速”,这个很正常的,因为刚开机时速度为零,速度控制就要将速度从零调节到 ...

站的很稳了啊 就是解决不了问题 楼下的几个方法也试了 是不是PI控制那里不对啊下面是速度控制的一块 我用K10做的

void GetMotorPulse(void)
{

        LeftPulse=DMAGetCtr(DMA_CH0);
    RightPulse=DMAGetCtr(DMA_CH1);

        g_nLeftMotorPulse = (int)LeftPulse;
        g_nRightMotorPulse = (int)RightPulse;
        if(!MOTOR_LEFT_SPEED_POSITIVE)                g_nLeftMotorPulse = -g_nLeftMotorPulse;
        if(!MOTOR_RIGHT_SPEED_POSITIVE)                g_nRightMotorPulse = -g_nRightMotorPulse;
               
        g_nLeftMotorPulseSigma += g_nLeftMotorPulse;
        g_nRightMotorPulseSigma += g_nRightMotorPulse;
}
//==============================================================================
//                    速度控制
//------------------------------------------------------------------------------
void SpeedControl(void) {
        
        float fP,fI,fDelta;

        g_fCarSpeed = (g_nLeftMotorPulseSigma + g_nRightMotorPulseSigma) / 2;
        g_nLeftMotorPulseSigma = g_nRightMotorPulseSigma = 0;
        fDelta = CAR_SPEED_SET - g_fCarSpeed;

        fP = fDelta * SPEED_CONTROL_P;
        fI = fDelta * SPEED_CONTROL_I;

        g_fSpeedControlIntegral += fI;
        if(g_fSpeedControlIntegral > MOTOR_OUT_MAX)        g_fSpeedControlIntegral = MOTOR_OUT_MAX;
        if(g_fSpeedControlIntegral < MOTOR_OUT_MIN)        g_fSpeedControlIntegral = MOTOR_OUT_MIN;

        g_fSpeedControlOutOld = g_fSpeedControlOutNew;
        
        g_fSpeedControlOutNew = fP + g_fSpeedControlIntegral;
        if(g_fSpeedControlOutNew > MOTOR_OUT_MAX)        g_fSpeedControlOutNew = MOTOR_OUT_MAX;
        if(g_fSpeedControlOutNew < MOTOR_OUT_MIN)        g_fSpeedControlOutNew = MOTOR_OUT_MIN;

}

//------------------------------------------------------------------------------
//   
void SpeedControlOutput(void) {

        fValue1 = g_fSpeedControlOutNew - g_fSpeedControlOutOld;
        g_fSpeedControlOut = fValue1 * (g_nSpeedControlPeriod + 1) / SPEED_CONTROL_PERIOD + g_fSpeedControlOutOld;
        
}


作者: yukunlinykl    时间: 2012-9-13 16:35
跑快了自然就看不出来了。
作者: wangkunning    时间: 2012-9-13 19:07
不上跑道,放地上只往前走,能实现匀速跑吗
作者: j715473086    时间: 2012-9-13 19:30
wangkunning 发表于 2012-9-13 19:07
不上跑道,放地上只往前走,能实现匀速跑吗

放地上一动不动 液晶显示 速度输出的变量 g_fSpeedControlOut逐渐增大 然后g_fSpeedControlOut又逐渐减小 然后停下来 你邮箱多少 我把程序发给你
作者: wangkunning    时间: 2012-9-13 19:39
j715473086 发表于 2012-9-13 19:30
放地上一动不动 液晶显示 速度输出的变量 g_fSpeedControlOut逐渐增大 然后g_fSpeedControlOut又逐渐减小 ...

不用发,我今年用的就是官网的程序,一模一样的,单片机选的是128,我邮箱1148068011@qq.com,只是从你的描述中,我不是很清楚你车现在的状况




欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2