OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2215|回复: 3

mpu6050读数不稳定,大家看一下有什么问题

[复制链接]

1

主题

1

帖子

0

精华

新手上路

积分
20
金钱
20
注册时间
2019-3-17
在线时间
3 小时
发表于 2019-3-17 17:18:20 | 显示全部楼层 |阅读模式

#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "lcd.h"
#include "usart.h"
#include "mpu6050.h"
#include "usmart.h"   
#include "inv_mpu.h"
#include "inv_mpu_dmp_motion_driver.h"

int main(void)
{
        float pitch,roll,yaw;                
  short aacx,aacy,aacz;                  
        short gyrox,gyroy,gyroz;                                          
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);         
        uart_init(9600);                
        delay_init();       
        MPU_Init();                                       

                        MPU_Get_Accelerometer(&aacx,&aacy,&aacz);                       
MPU_Get_Gyroscope(&gyrox,&gyroy,&gyroz);       
        while(mpu_dmp_init())
        {
    printf("error%d\n",mpu_dmp_init());
                delay_ms(200);
        }  
                while(1)
        {
       
                if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)
                {
                       
                        MPU_Get_Accelerometer(&aacx,&aacy,&aacz);       
                        delay_ms(1);
                        MPU_Get_Gyroscope(&gyrox,&gyroy,&gyroz);       
       
                printf("aacx:%d\n",aacx);
                printf("aacy:%d\n",aacy);
                printf("aacz:%d\n",aacz);
                printf("gx:%d\n",gyrox);
                printf("gy:%d\n",gyroy);
                printf("gz:%d\n",gyroz);
                printf("pitch:%f\n",pitch);
                printf("roll:%f\n",roll);
                printf("yaw:%f\n",yaw);
                delay_ms(1000);
                }
               
        }        
}


正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

35

主题

560

帖子

2

精华

资深版主

Rank: 8Rank: 8

积分
17786
金钱
17786
注册时间
2018-3-3
在线时间
523 小时
发表于 2019-3-18 12:37:49 | 显示全部楼层

回帖奖励 +4 金钱

具体表现呢,读出来是0吗
回复 支持 反对

使用道具 举报

31

主题

2183

帖子

0

精华

资深版主

Rank: 8Rank: 8

积分
14433
金钱
14433
注册时间
2018-8-3
在线时间
1157 小时
发表于 2019-3-18 12:37:59 | 显示全部楼层
参照下原子6050的例程呀!
啊哈~加油!!
回复 支持 反对

使用道具 举报

0

主题

160

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
226
金钱
226
注册时间
2019-3-4
在线时间
4 小时
发表于 2019-3-18 13:53:07 | 显示全部楼层
不清楚哦!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-24 00:39

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表