OpenEdv-开源电子网

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

MPU6050检测晃动

[复制链接]

4

主题

8

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2016-8-2
在线时间
15 小时
发表于 2016-8-8 19:19:11 | 显示全部楼层 |阅读模式
1金钱
/**
*  @brief      Set shake rejection threshold.
*  If the DMP detects a gyro sample larger than @e thresh, taps are rejected.
*  @param[in]  sf      Gyro scale factor.
*  @param[in]  thresh  Gyro threshold in dps.
*  @return     0 if successful.
*/
int dmp_set_shake_reject_thresh(long sf, unsigned short thresh)
{
    unsigned char tmp[4];
    long thresh_scaled = sf / 1000 * thresh;
    tmp[0] = (unsigned char)(((long)thresh_scaled >> 24) & 0xFF);
    tmp[1] = (unsigned char)(((long)thresh_scaled >> 16) & 0xFF);
    tmp[2] = (unsigned char)(((long)thresh_scaled >> 8) & 0xFF);
    tmp[3] = (unsigned char)((long)thresh_scaled & 0xFF);
    return mpu_write_mem(D_1_92, 4, tmp);
}

/**
*  @brief      Set shake rejection time.
*  Sets the length of time that the gyro must be outside of the threshold set
*  by @e gyro_set_shake_reject_thresh before taps are rejected. A mandatory
*  60 ms is added to this parameter.
*  @param[in]  time    Time in milliseconds.
*  @return     0 if successful.
*/
int dmp_set_shake_reject_time(unsigned short time)
{
    unsigned char tmp[2];

    time /= (1000 / DMP_SAMPLE_RATE);
    tmp[0] = time >> 8;
    tmp[1] = time & 0xFF;
    return mpu_write_mem(D_1_90,2,tmp);
}




这是例程上的,不知道可不可以用来检测晃动,还有这个程序的功能是什么

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

使用道具 举报

4

主题

8

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2016-8-2
在线时间
15 小时
 楼主| 发表于 2016-8-8 20:05:46 | 显示全部楼层
回复

使用道具 举报

4

主题

8

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2016-8-2
在线时间
15 小时
 楼主| 发表于 2016-8-8 22:09:15 | 显示全部楼层
看来要沉了
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165536
金钱
165536
注册时间
2010-12-1
在线时间
2117 小时
发表于 2016-8-12 21:56:57 | 显示全部楼层
帮顶
回复

使用道具 举报

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

本版积分规则



关闭

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

正点原子公众号

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

GMT+8, 2025-6-11 15:36

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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