标题:
stm32f429使用mpu6050检测风力摆角度 四元数法
[打印本页]
作者:
y1887655
时间:
2017-8-10 19:31
标题:
stm32f429使用mpu6050检测风力摆角度 四元数法
mpu6050芯片四元数法计算风力摆摆动角度
所有资料51hei提供下载:
六轴.rar
(1009.29 KB, 下载次数: 71)
2017-8-10 19:30 上传
点击文件名下载附件
角度检测
下载积分: 黑币 -5
stm32f429单片机源程序如下(主程序):
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "key.h"
#include "myiic.h"
#include "mpu6050.h"
#include "siyuanshu.h"
/*简单任务管理*/
uint32_t Task_Delay[3]={0};
//extern AHRS_EulerAngleTypeDef EulerAngle;
int main(void)
{
u8 res=0;
// float pitch_temp1 = 0.0;
// float roll_temp1 = 0.0;
extern float Pitch;
extern float Roll;
HAL_Init(); //初始化HAL库
Stm32_Clock_Init(360,25,2,8); //设置时钟,180Mhz
delay_init(180); //初始化延时函数
uart_init(115200); //初始化USART
LED_Init(); //初始化LED
KEY_Init(); //初始化按键
IIC_Init(); //初始iic
/*
short Acel[3];
short Gyro[3];
float Temp;
*/
short aacx,aacy,aacz; //加速度传感器原始数据
short gyrox,gyroy,gyroz; //陀螺仪原始数据
float temp; //温度
printf("\r\n 欢迎使用阿波罗 STM32 F429 开发板。\r\n");
printf("\r\n 这是一个I2C外设(AT24C02)读写测试例程 \r\n");
MPU_Init();
res=MPU_Read_Byte(MPU_DEVICE_ID_REG); //读取MPU6500的ID
if (res==MPU_ADDR)
{
while(1)
{
// if(Task_Delay[0]==0)
// {
// LED1=0;
//
// Task_Delay[0]=1000;
// }
//
// if(Task_Delay[1]==0)
// {
/*
MPU6050ReadAcc(Acel);
printf("加速度:%8d%8d%8d",Acel[0],Acel[1],Acel[2]);
MPU6050ReadGyro(Gyro);
printf(" 陀螺仪%8d%8d%8d",Gyro[0],Gyro[1],Gyro[2]);
MPU6050_ReturnTemp(&Temp);
printf(" 温度%8.2f\r\n",Temp);
Task_Delay[1]=500; //更新一次数据,可根据自己的需求,提高采样频率,如100ms采样一次
*/
temp=MPU_Get_Temperature(); //得到温度值
printf("温度:%8f",temp);
MPU_Get_Accelerometer(&aacx,&aacy,&aacz); //得到加速度传感器数据
printf("加速度:%8d%8d%8d",aacx,aacy,aacz);
MPU_Get_Gyroscope(&gyrox,&gyroy,&gyroz); //得到陀螺仪数据
printf("陀螺仪:%8d%8d%8d\r\n",gyrox,gyroy,gyroz);
// Task_Delay[1]=500; //更新一次数据,可根据自己的需求,提高采样频率,如100ms采样一次
// EulerAngle.Pitch = Kalman_Filter1(pitch_temp1,gyroy);
// EulerAngle.Roll = Kalman_Filter2(roll_temp1,-gyrox);
//
// printf("俯仰角:%8f",EulerAngle.Pitch);
// printf("横滚角:%8f\r\n",EulerAngle.Roll);
IMUupdate(gyrox,gyroy,gyroz,aacx,aacy,aacz);
printf("俯仰角:%8f横滚角:%8f\r\n", Pitch,Roll);
delay_ms(100);
// }
}
}
else
{
printf("\r\n没有检测到MPU6050传感器!\r\n");
LED0=0;
while(1);
}
}
复制代码
作者:
iYoutudou
时间:
2021-2-4 11:11
请问楼主,实际效果如何?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1