caizhiwei 发表于 2014-5-30 23:09:03

【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

 硬件平台:STM32F429I-DISCORVERY
 软件平台:KEIL MDK5.10
 
 
1.关于pitch yaw roll 的区别: 
http://blog.163.com/vipwdp@126/blog/static/150224366201281935518196/
 
2.Z轴正方向为飞机前进方向
  pitch():俯仰,将物体绕X轴旋转(localRotationX)
  yaw():航向,将物体绕Y轴旋转(localRotationY)
  roll():横滚,将物体绕Z轴旋转(localRotationZ)
 
This example is used as a template project that can be used as reference to build
any new firmware application for STM32F429xx devices using the STM32F4xx Standard
Peripherals Library.
 
@par Hardware and Software environment
 
  - This example runs on STMF429xx Devices.
  - This example has been tested with STMicroelectronics STM32F429I-DISCO board 
    and can be easily tailored to any other supported device and development board.
 
       背景知识:L3GD20是低功耗三轴角速率传感器。它包括一个传感元件和一个集成电路接口,能够提供外部的角速率测量通过数字接口(I2C / SPI)。它是由意法半导体使用专用微加工工艺硅片生产惯性传感器和驱动器。  
L3GD20 数字陀螺仪有用户可自行设定全量程(±250 /±500 /±2000 dps)和可选的带宽。低量程用于高精度测量慢速运动,高量程则用于测量超快速的手势和运动。新产品为用户提供16位数据输出,以及附加的嵌入式数字功能,如可配置的低通高通滤波器。内置智能电源管理所需的先入先出(FIFO)存储块。工作电压范围为2.4V至3.6V.
 
Features:
 Three selectable full scales
(±250/500/2000 dps)
 20+ kHz resonant frequency over the
audio bandwidth
 I2C/SPI digital output interface
 16-bit rate data output
 8-bit temperature data output
 Wide supply voltage: 2.4 to 3.6 V
 Low-voltage compatible IOs (1.8 V)
 Embedded FIFO
 Embedded power-down and
sleep modes
 Embedded temperature sensor
 High shock survivability
 
 
#include "stm32f429i_discovery.h"
#include "stm32f429i_discovery_lcd.h"
#include "l3gd20.h"
#include "key.h"
#include "SysTick.h"
#include "usart.h"
 
float Buffer;  //输出数据保存数组
float Gyro;  //校准值
uint8_t Xval, Yval;
int main(void)
{
 
  SysTick_Init();
  STM_EVAL_LED_Config();
  STM_EVAL_PBInit(BUTTON_MODE_EXTI);
        USART1_GPIO_Config();
 
        printf("\n\rHello, Stm32f429-discovery Board ! \n\r");
        printf("\n\r代码烧录日期: "__DATE__"  @  "__TIME__"\n\r"); 
        printf("\n\r固件库版本: V %x \n\r",__STM32F4XX_STDPERIPH_VERSION);       
        printf("\n\rCPUID IS: 0X%X %X %X.\n\r", *(__IO u32*)(0x1FFF7A10),*(__IO u32*)(0x1FFF7A14),*(__IO u32*)(0x1FFF7A18)); 
        printf("\n\rMCU内部Flash大小:%d K字节.\n\r", *(uint16_t*)(0x1FFF7A22));
        printf("\n\r系统内核时钟频率SystemCoreClock:%dHz.\n\r",SystemCoreClock);
 
 
  /* Initialize the LCD */
  LCD_Init();
  LCD_LayerInit();
  LTDC_Cmd(ENABLE);
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  LCD_Clear(LCD_COLOR_BLUE);
         
  Demo_GyroConfig();   /* Gyroscope configuration */
  Gyro_SimpleCalibration(Gyro);  /* Gyroscope 校准*/
  printf("\n\r陀螺仪L3GD20 ID :0x%x \n\r",L3GD20_ReadID());
 
  while (1)
  {
      
                        /* Read Gyro Angular data ,to save in Buffer*/
                        Demo_GyroReadAngRate(Buffer);
 
                        Buffer = (int8_t)Buffer - (int8_t)Gyro;  //x
                        Buffer = (int8_t)Buffer - (int8_t)Gyro;  //Y
                        Buffer = (int8_t)Buffer - (int8_t)Gyro;  //Z
                                                                               
                        /* Update autoreload and capture compare registers value*/
                        Xval = ABS((int8_t)(Buffer));
                        Yval = ABS((int8_t)(Buffer)); 
                                       
                        if ( Xval>Yval)
                        {
                                if ((int16_t)Buffer > 40)
                                {
                                        /* Clear the LCD */
                                        LCD_Clear(LCD_COLOR_WHITE);
                                        LCD_SetTextColor(LCD_COLOR_MAGENTA);
                                        LCD_DrawFullRect(100, 40, 40, 120);
                                        LCD_FillTriangle(50, 190, 120, 160, 160, 310);
                                        Delay(50);
                                }
                                if ((int16_t)Buffer < -40)
                                {
                                        /* Clear the LCD */
                                        LCD_Clear(LCD_COLOR_WHITE);
                                        LCD_SetTextColor(LCD_COLOR_RED);
                                        LCD_DrawFullRect(100, 160, 40, 120);
                                        LCD_FillTriangle(50, 190, 120, 160, 160, 10);
                                        Delay(50);
                                }
                        }
                        else
                        {
                                if ((int16_t)Buffer < -40)
                                {
                                        /* Clear the LCD */
                                        LCD_Clear(LCD_COLOR_WHITE);
                                        LCD_SetTextColor(LCD_COLOR_GREEN);
                                        LCD_DrawFullRect(120, 140, 100, 40);
                                        LCD_FillTriangle(120, 120, 5, 60, 260, 160);      
                                        Delay(50);
                                }
                                if ((int16_t)Buffer > 40)
                                {      
                                        /* Clear the LCD */ 
                                        LCD_Clear(LCD_COLOR_WHITE);
                                        LCD_SetTextColor(LCD_COLOR_BLUE);
                                        LCD_DrawFullRect(20, 140, 100, 40);
                                        LCD_FillTriangle(120, 120, 235, 60, 260, 160);
                                        Delay(50);
                                } 
                        } 
  }
       
}

:D:D

 
:D:D欢迎大家下载
 
 

caizhiwei 发表于 2014-5-30 23:12:43

RE:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

沙发!呵呵,串口可以输出三轴的

xieyixieyi81093 发表于 2014-5-31 10:14:21

RE:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

你也太有效率了。我顶你。向你学习。

☆笨⊙笨☆ 发表于 2014-6-3 17:08:52

回复:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

看看

☆笨⊙笨☆ 发表于 2014-6-3 17:11:07

RE:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

你这个完全是照搬固件库里的;P;P;P;P

sakurabill 发表于 2014-6-4 16:28:51

回复:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

:lol~~~

STM32 LOU 发表于 2014-6-6 17:20:17

RE:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

;P;P;P~~~

友情牵绊-2046836 发表于 2014-6-24 18:00:54

回复:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

 参考参考!!!

sunwumcu 发表于 2014-6-24 20:57:26

回复:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

STM32F429开发日志

haphard 发表于 2014-6-25 14:18:53

回复:【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出

:lol:lol:lol我就发
页: [1] 2 3
查看完整版本: 【STM32F429开发日志】3.板载mems测试,三轴角加速度Printf输出