mpu6050中文datash:
void mpu6050_init(void)
{
printf("who am i:0x%x\r\n",mpu6050_read_reg(0x75));
mpu6050_write_reg(0x6b,0x80);//PWR_MGMT_1:电源模式 复位 温度使能 时钟源 //reset
tls_os_time_delay(50);
printf("reset(0x6b):0x%x\r\n",mpu6050_read_reg(0x6b));
mpu6050_write_reg(0x6b,0);//start
printf("reset(0x6b):0x%x\r\n",mpu6050_read_reg(0x6b));//确认跳出休眠模式
mpu6050_write_reg(0x6b, 1);//[2:0]time1 pll_x 时钟源
//mpu6050_write_reg(0x6c, 0);//power manage reg2:start jiaosudu,jiasudu 0
mpu6050_write_reg(0x1b,0x18);//陀螺仪配置GYRO_CONFIG reg:full_sr ;
mpu6050_write_reg(0x1c,0);//加速度配置 ACCEL_CONFIG reg
//mpu6050_write_reg(0x38,0);//int_en reg:stop intrupt
//mpu6050_write_reg(0x6a,);//user_ctr reg:stop aux_i2c
//mpu6050_write_reg(0x23,0);//fifo_en reg:stop fifo
mpu6050_write_reg(0x19,2);//陀螺仪输出分频采样率SMPLRT_div reg:50
mpu6050_write_reg(0x1a,4);//配置外部引脚采样和数字低通滤波器DLPF reg:1/2
//mpu6050_write_reg(0x6c, 0);
}
void mpu6050_dispxyz(void)
{
float x1,x2,y1,y2,z1,z2;
int16_t mpu_x,mpu_y,mpu_z;
int16_t spd_x,spd_y,spd_z;
int16_t temp_h,temp_l;
float dtemp;
//各轴角速度GYR
mpu_x=((mpu6050_read_reg(0x43)<<8)+mpu6050_read_reg(0x44));
mpu_y=((mpu6050_read_reg(0x45)<<8)+mpu6050_read_reg(0x46));
mpu_z=((mpu6050_read_reg(0x47)<<8)+mpu6050_read_reg(0x48));
x1=(float)(2000*mpu_x/32768);
y1=(float)(2000*mpu_y/32768);
z1=(float)(2000*mpu_z/32768);
printf("角速度 GYR_x:%f GYR_y:%f GYR_z:%f\r\n",x1,y1,z1);
//各轴加速度计分量ACC
spd_x=(mpu6050_read_reg(0x3b)<<8)+mpu6050_read_reg(0x3c);
spd_y=(mpu6050_read_reg(0x3d)<<8)+mpu6050_read_reg(0x3e);
spd_z=(mpu6050_read_reg(0x3f)<<8)+mpu6050_read_reg(0x40);
x2=(float)(20*spd_x/32768);
y2=(float)(20*spd_y/32768);
z2=(float)(20*spd_z/32768);
//printf("spd_x:%d spd_y:%d spd_z:%d\r\n",spd_x,spd_y,spd_z);
printf("各轴加速度ACC_x:%f ACC_y:%f ACC_z:%f\r\n",x2,y2,z2);
printf("倾斜角: angle[x]=atan2(x,y)*180/3.14 :%f\r\n",atan2(spd_x, spd_y)*180/3.14);
printf("倾斜角: angle[z]=atan2(z,y)*180/3.14 :%f\r\n",atan2(spd_z, spd_y)*180/3.14);
//温度
temp_h=mpu6050_read_reg(0x41)<<8;
temp_l=mpu6050_read_reg(0x42);
dtemp=36.53+(temp_h+temp_l)/340;
printf("temputure:%f \r\n\n",dtemp);
}
原始数据就得到了!