极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 121149|回复: 91

关于mpu6050调试

  [复制链接]
发表于 2012-5-4 16:41:01 | 显示全部楼层 |阅读模式
入手一个mpu6050的六轴。在测试时发现加速z轴读数很高,其它5轴都差不多。但是读数都很不稳定。我是放在桌子上的。
这些读数要怎么换算成角度和加速度谢谢各位?
回复

使用道具 举报

发表于 2012-5-20 10:51:10 | 显示全部楼层
GeMarK 发表于 2012-5-20 03:59
其实我一直有一个疑问,通过加速度传感器,是否可以计算出位移量?利用积分?积分运算放大器?
是不是还有 ...

加速度传感器和陀螺仪,一般用作姿态识别。位移方面现在貌似有问题。

位移如果是飞行器基本都是通过GPS,气压计等进行计算。

如果是小车之类的,基本就是通过码盘,计算轮子转了多少圈,然后通过电子罗盘,记录位移方向。
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2012-5-4 16:42:18 | 显示全部楼层
忘了说。那个arduino的调试程序看的我头大
回复 支持 反对

使用道具 举报

发表于 2012-5-4 17:24:37 | 显示全部楼层
lucsong 发表于 2012-5-4 16:42
忘了说。那个arduino的调试程序看的我头大

能不能把数据和模块图片贴出来,我的MPU6050也出现一堆问题,不能成功!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-5-4 20:42:17 | 显示全部楼层
这个事串口显示的数据。陀螺仪式平放在桌面上的。
加速度aZ数值好大。不知道为什么?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2012-5-4 20:48:46 | 显示全部楼层
怎么大家都入手mpu6560了,我慢了一步啊
是不是寄存器没配置好啊
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-5-4 21:05:02 | 显示全部楼层
这个是用arduino自带的测试程序读出的数值。
那个程序在下是才疏学浅到现在还是没有看明白。
回复 支持 反对

使用道具 举报

发表于 2012-5-4 21:21:01 | 显示全部楼层
lucsong 发表于 2012-5-4 21:05
这个是用arduino自带的测试程序读出的数值。
那个程序在下是才疏学浅到现在还是没有看明白。

arduino自带的?贴出来看看
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-5-4 21:22:34 | 显示全部楼层
  1. // I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
  2. // 10/7/2011 by Jeff Rowberg <[email][email protected][/email]>
  3. // Updates should (hopefully) always be available at [url]https://github.com/jrowberg/i2cdevlib[/url]
  4. //
  5. // Changelog:
  6. //     2011-10-07 - initial release

  7. /* ============================================
  8. I2Cdev device library code is placed under the MIT license
  9. Copyright (c) 2011 Jeff Rowberg

  10. Permission is hereby granted, free of charge, to any person obtaining a copy
  11. of this software and associated documentation files (the "Software"), to deal
  12. in the Software without restriction, including without limitation the rights
  13. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. copies of the Software, and to permit persons to whom the Software is
  15. furnished to do so, subject to the following conditions:

  16. The above copyright notice and this permission notice shall be included in
  17. all copies or substantial portions of the Software.

  18. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. THE SOFTWARE.
  25. ===============================================
  26. */

  27. // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
  28. // is used in I2Cdev.h
  29. #include "Wire.h"

  30. // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
  31. // for both classes must be in the include path of your project
  32. #include "I2Cdev.h"
  33. #include "MPU6050.h"

  34. // class default I2C address is 0x68
  35. // specific I2C addresses may be passed as a parameter here
  36. // AD0 low = 0x68 (default for InvenSense evaluation board)
  37. // AD0 high = 0x69
  38. MPU6050 accelgyro;

  39. int16_t ax, ay, az;
  40. int16_t gx, gy, gz;

  41. #define LED_PIN 13
  42. bool blinkState = false;

  43. void setup() {
  44.   // join I2C bus (I2Cdev library doesn't do this automatically)
  45.   Wire.begin();

  46.   // initialize serial communication
  47.   // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
  48.   // it's really up to you depending on your project)
  49.   Serial.begin(38400);

  50.   // initialize device
  51.   Serial.println("Initializing I2C devices...");
  52.   accelgyro.initialize();

  53.   // verify connection
  54.   Serial.println("Testing device connections...");
  55.   Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

  56.   // configure Arduino LED for
  57.   pinMode(LED_PIN, OUTPUT);
  58. }

  59. void loop() {
  60.   // read raw accel/gyro measurements from device
  61.   accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

  62.   // these methods (and a few others) are also available
  63.   //accelgyro.getAcceleration(&ax, &ay, &az);
  64.   //accelgyro.getRotation(&gx, &gy, &gz);

  65.   // display tab-separated accel/gyro x/y/z values
  66.   Serial.print("a/g:\t");
  67.   Serial.print(ax);
  68.   Serial.print("\t");
  69.   Serial.print(ay);
  70.   Serial.print("\t");
  71.   Serial.print(az);
  72.   Serial.print("\t");
  73.   Serial.print(gx);
  74.   Serial.print("\t");
  75.   Serial.print(gy);
  76.   Serial.print("\t");
  77.   Serial.println(gz);

  78.   // blink LED to indicate activity
  79.   blinkState = !blinkState;
  80.   digitalWrite(LED_PIN, blinkState);
  81. }
复制代码

以上就是
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-5-6 21:51:08 | 显示全部楼层
终于自己搞定了,就是调整mpu6050精度上还要费些时间。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-5-7 22:10:45 | 显示全部楼层
g:        0.07        -0.02        0.09        0.15        -0.26        -0.36
a/g:        0.09        -0.00        0.06        0.41        -0.79        -0.20
a/g:        0.08        -0.02        0.04        0.32        -0.64        -0.04
a/g:        0.08        -0.01        0.05        0.32        0.26        -0.47
a/g:        0.07        -0.01        0.06        0.22        0.14        -0.36
a/g:        0.07        -0.01        0.08        0.41        -0.81        0.02
a/g:        0.07        -0.02        0.05        0.25        -0.56        -0.09
a/g:        0.08        -0.02        0.05        0.52        0.28        -0.10
a/g:        0.08        -0.00        0.06        0.28        0.20        -0.04
a/g:        0.07        -0.01        0.08        0.34        -0.38        -0.50
a/g:        0.05        -0.03        0.10        0.49        -0.47        -0.20
a/g:        0.09        -0.00        0.06        0.48        -0.12        -0.33
a/g:        0.07        -0.01        0.06        0.29        0.22        -0.24
a/g:        0.07        -0.01        0.06        0.26        0.00        -0.35
a/g:        0.07        -0.03        0.07        0.26        -0.04        -0.27
a/g:        0.07        -0.03        0.06        0.37        -0.23        -0.12
a/g:        0.07        -0.02        0.05        0.55        0.05        -0.10
a/g:        0.08        -0.00        0.04        0.26        0.40        -0.33
a/g:        0.08        -0.02        0.06        0.17        0.08        -0.38
a/g:        0.06        -0.02        0.09        0.38        -0.93        -0.09
a/g:        0.08        -0.02        0.04        0.55        -0.58        -0.41
a/g:        0.08        -0.02        0.04        0.43        -0.43        -0.18
a/g:        0.07        -0.01        0.07        0.43        0.32        -0.27
a/g:        0.08        -0.02        0.07        0.19        -0.04        -0.50
a/g:        0.07        -0.02        0.07        0.72        -0.44        -0.12
a/g:        0.08        -0.02        0.06        0.43        -0.03        -0.41
a/g:        0.09        -0.01        0.06        0.46        0.38        -0.29
a/g:        0.08        -0.02        0.06        0.41        0.02        -0.17
a/g:        0.08        -0.03        0.08        0.34        -0.70        -0.15
a/g:        0.08        -0.02        0.05        0.72        -0.10        -0.17
a/g:        0.09        -0.02        0.05        0.41        -0.04        -0.17
a/g:        0.08        -0.02        0.07        0.12        0.23        0.15
a/g:        0.08        -0.03        0.09        0.34        -0.35        -0.38
a/g:        0.07        -0.02        0.08        0.35        -0.26        0.05
a/g:        0.08        -0.03        0.06        0.54        -0.18        -0.36
a/g:        0.08        -0.02        0.05        0.40        -0.01        -0.07
a/g:        0.08        -0.04        0.06        0.28        -0.10        -0.24
a/g:        0.06        -0.00        0.06        0.57        -0.32        -0.18
a/g:        0.08        -0.01        0.05        0.58        0.28        -0.32
新数据终于趋于正常。
回复 支持 反对

使用道具 举报

发表于 2012-5-7 22:37:48 | 显示全部楼层
{:soso_e142:} 不错不错。。。不知道randy的调好了没
回复 支持 反对

使用道具 举报

发表于 2012-5-7 22:52:23 | 显示全部楼层
lucsong 发表于 2012-5-7 22:10
g:        0.07        -0.02        0.09        0.15        -0.26        -0.36
a/g:        0.09        -0.00        0.06        0.41        -0.79        -0.20
a/g:        0.08        -0.02        0.04        0.3 ...

我的可能是板子有问题了,需要重新画板才行,您能否解析一下您测试的结果呢?
回复 支持 反对

使用道具 举报

发表于 2012-5-8 11:24:14 | 显示全部楼层
lucsong 发表于 2012-5-6 21:51
终于自己搞定了,就是调整mpu6050精度上还要费些时间。

你好。能说说你是如何调好的吗?有哪些要特别注意的。不胜感激!
回复 支持 反对

使用道具 举报

发表于 2012-5-8 15:05:21 | 显示全部楼层
放代码看看
回复 支持 反对

使用道具 举报

发表于 2012-5-12 01:04:16 | 显示全部楼层
lucsong 发表于 2012-5-6 21:51
终于自己搞定了,就是调整mpu6050精度上还要费些时间。

怎么搞定的呀,我也是这种情况
回复 支持 反对

使用道具 举报

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

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-29 05:01 , Processed in 0.057999 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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