新手入门 
 
	- 积分
 - 7
 
        - 金钱
 - 7 
 
       - 注册时间
 - 2024-5-27
 
      - 在线时间
 - 2 小时
 
 
 
 | 
 
1金钱 
用原子STM32F4上的例程植到F103上,数据都已经出来,但pitch和roll延迟很多,yaw响应倒比较快。比如我直接把pitch从0度转到90度,输出的数据将近要1分钟后才逐步到90度。该调整什么参数呢?以下是mpu_dmp_init()中的设置,其中dmp的输出速率设的是100Hz 
 
u8 mpu_dmp_init(void) 
{ 
        u8 res=0; 
    struct int_param_s int_param; 
    unsigned char accel_fsr; 
    unsigned short gyro_rate, gyro_fsr; 
    unsigned short compass_fsr; 
 
        MPU_IIC_Init();                         //初始化IIC总线 
        if(mpu_init(&int_param)==0)        //初始化MPU9250 
        {          
        res=inv_init_mpl();     //初始化MPL 
        if(res)return 1; 
        inv_enable_quaternion(); 
        inv_enable_9x_sensor_fusion(); 
        inv_enable_fast_nomot(); 
        inv_enable_gyro_tc(); 
        inv_enable_vector_compass_cal(); 
//        inv_enable_magnetic_disturbance(); 
        inv_enable_eMPL_outputs(); 
        res=inv_start_mpl();    //开启MPL 
        if(res)return 1; 
                res=mpu_set_sensors(INV_XYZ_GYRO|INV_XYZ_ACCEL|INV_XYZ_COMPASS);//设置所需要的传感器 
                if(res)return 2;  
                res=mpu_configure_fifo(INV_XYZ_GYRO | INV_XYZ_ACCEL);   //设置FIFO 
                if(res)return 3;  
                res=mpu_set_sample_rate(DEFAULT_MPU_HZ);                    //设置采样率 
                if(res)return 4;  
        res=mpu_set_compass_sample_rate(1000/COMPASS_READ_MS);  //设置磁力计采样率 
        if(res)return 5; 
        mpu_get_sample_rate(&gyro_rate); 
        mpu_get_gyro_fsr(&gyro_fsr); 
        mpu_get_accel_fsr(&accel_fsr); 
        mpu_get_compass_fsr(&compass_fsr); 
        inv_set_gyro_sample_rate(1000000L/gyro_rate); 
        inv_set_accel_sample_rate(1000000L/gyro_rate); 
        inv_set_compass_sample_rate(COMPASS_READ_MS*1000L); 
        inv_set_gyro_orientation_and_scale( 
            inv_orientation_matrix_to_scalar(gyro_orientation),(long)gyro_fsr<<15); 
        inv_set_accel_orientation_and_scale( 
            inv_orientation_matrix_to_scalar(gyro_orientation),(long)accel_fsr<<15); 
        inv_set_compass_orientation_and_scale( 
            inv_orientation_matrix_to_scalar(comp_orientation),(long)compass_fsr<<15); 
 
 
                res=dmp_load_motion_driver_firmware();                             //加载dmp固件 
                if(res)return 6;  
                res=dmp_set_orientation(inv_orientation_matrix_to_scalar(gyro_orientation));//设置陀螺仪方向 
                if(res)return 7;  
                res=dmp_enable_feature(DMP_FEATURE_6X_LP_QUAT|DMP_FEATURE_TAP|                    //设置dmp功能 
                    DMP_FEATURE_ANDROID_ORIENT|DMP_FEATURE_SEND_RAW_ACCEL|DMP_FEATURE_SEND_CAL_GYRO| 
                    DMP_FEATURE_GYRO_CAL); 
                if(res)return 8;  
                res=dmp_set_fifo_rate(DEFAULT_MPU_HZ);        //设置DMP输出速率(最大不超过200Hz) 
                if(res)return 9;    
                res=run_self_test();                //自检 
//                if(res)return 10;     
                res=mpu_set_dmp_state(1);        //使能DMP 
                if(res)return 11;      
        } 
        return 0; 
} 
 
 |   
 
 
 
 
 
 |