你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

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

[复制链接]
caizhiwei 提问时间:2014-5-30 23:09 /
 硬件平台: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[3];  //输出数据保存数组
float Gyro[3];  //校准值
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[6]*/
                        Demo_GyroReadAngRate(Buffer);
 
                        Buffer[0] = (int8_t)Buffer[0] - (int8_t)Gyro[0];  //x
                        Buffer[1] = (int8_t)Buffer[1] - (int8_t)Gyro[1];  //Y
                        Buffer[2] = (int8_t)Buffer[2] - (int8_t)Gyro[2];  //Z
                                                                               
                        /* Update autoreload and capture compare registers value*/
                        Xval = ABS((int8_t)(Buffer[0]));
                        Yval = ABS((int8_t)(Buffer[1])); 
                                       
                        if ( Xval>Yval)
                        {
                                if ((int16_t)Buffer[0] > 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[0] < -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[1] < -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[1] > 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);
                                } 
                        } 
  }
       
}
QQ图片20140530224540.jpg

QQ图片20140530220041.jpg
 
6.板载MEMS测试.zip (6.47 MB, 下载次数: 626)
收藏 2 评论24 发布时间:2014-5-30 23:09

举报

24个回答
拼命三郎 回答时间:2015-3-1 11:24:05
xxxxxxxxxx.jpg
stm32.jpg
拼命三郎 回答时间:2015-3-1 11:34:56
试了一下,不错,好程序。
MouseCat 回答时间:2015-3-1 00:35:22
好资料,谢谢分享,收藏
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输出

你这个完全是照搬固件库里的
sakurabill 回答时间:2014-6-4 16:28:51

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

~~~
STM32 LOU 回答时间:2014-6-6 17:20:17

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

~~~
友情牵绊-2046836 回答时间:2014-6-24 18:00:54

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

 参考参考!!!
快乐汉 回答时间:2014-6-24 20:57:26

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

STM32F429开发日志
haphard 回答时间:2014-6-25 14:18:53

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

我就发
jcrorxp 回答时间:2014-7-1 15:53:13

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


很牛逼 准备用来开发云台
 
偏科的娃 回答时间:2014-8-30 15:23:20

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

stm32f429i_discovery_l3gd20.cstm32f429i_discovery_l3gd20.cstm32f429i_discovery_l3gd20.cstm32f429i_discovery_l3gd20.c
lky1203 回答时间:2014-8-31 22:15:06

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

下载来试试
10-软件设计 回答时间:2014-9-6 22:17:50

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

在STM32F429DSICOVERY上移植最新ST图形库
sdampttery 回答时间:2014-9-24 10:22:37

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

hao
12下一页
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版