CCALM 发表于 2013-5-20 19:32:40

四轴飞不起,PID调不好

本帖最后由 CCALM 于 2013-5-21 11:12 编辑

        float P=10.0,I=0,D=32.0;          //灵敏 力度3.9          2.9/0.954
        float rool=0,pitch=0;
        float roolb=0,pitchb=0;//上上一次角度
        float roola=0,pitcha=0;//上一次角度
        float Pmax=180;
        float Rmax=130;

        IMUupdate(GX,GY,GZ,AX,AY,AZ);//更新陀螺仪数据
/*
俯仰角PID---------------------------------------------------------------------------------
*/
        pitch = P * Pitch + I * pitcha - D * GX ;
        pitchb=pitcha;
        pitcha=Pitch;

        if(pitch>Pmax) pitch=Pmax;
        if(pitch<-Pmax) pitch=-Pmax;       

/*
翻滚角PID---------------------------------------------------------------------------------
*/       
        rool = P * Rool + I * roola - D * GY ;
        roolb=roola;
        roola=-Rool;

        if(Rool<1&&Rool>-1) rool=0;
        if(rool>Rmax) rool=Rmax;
        if(rool<-Rmax) rool=-Rmax;
M1=pitch;
M2=rool;
M3=-pitch;
M4=-rool;

不知道代码有没有错,请大神鉴定
老是震荡,PID调很少也震荡,不然就是没反应

js200300953 发表于 2013-5-20 21:03:09

M1=pitch;
M2=rool;
M3=-pitch;
M4=-rool;这段很诡异啊,你的四轴是“+”还是“X”的?

qwe2231695 发表于 2013-5-20 21:15:06

      Motor1=(int16_t)(thr + rool - pitch + yaw);
        Motor2=(int16_t)(thr - rool - pitch - yaw)    ;       
        Motor3=(int16_t)(thr - rool + pitch + yaw);
        Motor4=(int16_t)(thr + rool + pitch - yaw);

符号根据正反奖和排列顺序调整

woshisangao 发表于 2013-5-21 09:25:36

先给个小参数,然后把四轴放手上摆个角度看看效果,首先得保证符号正确才行

CCALM 发表于 2013-5-21 11:12:45

js200300953 发表于 2013-5-20 21:03 static/image/common/back.gif
这段很诡异啊,你的四轴是“+”还是“X”的?

是+模式

CCALM 发表于 2013-5-21 11:17:03

woshisangao 发表于 2013-5-21 09:25 static/image/common/back.gif
先给个小参数,然后把四轴放手上摆个角度看看效果,首先得保证符号正确才行 ...

能感觉到它在用力推,但是好像一点点角度,它的力就很大

CCALM 发表于 2013-5-21 11:19:00

qwe2231695 发表于 2013-5-20 21:15 static/image/common/back.gif
Motor1=(int16_t)(thr + rool - pitch + yaw);
        Motor2=(int16_t)(thr - rool - pitch - yaw)    ...

好的,谢谢

js200300953 发表于 2013-5-21 12:26:08

CCALM 发表于 2013-5-21 11:19 static/image/common/back.gif
好的,谢谢

他那个是X模式的,十字模要这样:    control.throttle = baseThrottle                  - output + output;
    control.throttle = baseThrottle + output                  - output;
    control.throttle = baseThrottle                   + output + output;
    control.throttle = baseThrottle - output                     - output;

enthier 发表于 2013-5-21 12:39:40

把D加大,我开始调也是这样,P小了力很小修正不了,P大了就来回震荡。最后把D加大了就好了。

CCALM 发表于 2013-5-21 20:41:13

enthier 发表于 2013-5-21 12:39 static/image/common/back.gif
把D加大,我开始调也是这样,P小了力很小修正不了,P大了就来回震荡。最后把D加大了就好了。 ...

要是加大了D震荡更加厉害呢?还要加吗?

CCALM 发表于 2013-5-21 20:44:14

js200300953 发表于 2013-5-21 12:26 static/image/common/back.gif
他那个是X模式的,十字模要这样:

看不懂,跟上面的有什么差别?

不是应该分开两个角度的PID输出吗

例如
M1=ROOL;
M2=PITCH;
M3=-ROOL;
M4=-PITCH;

enthier 发表于 2013-5-21 21:58:52

CCALM 发表于 2013-5-21 20:41 static/image/common/back.gif
要是加大了D震荡更加厉害呢?还要加吗?

加大了震荡更厉害?是不是D的控制量反了。

sxjclike 发表于 2013-5-21 22:49:48

楼主加油呀
页: [1]
查看完整版本: 四轴飞不起,PID调不好