DMP参考数据手册

上传人:飞****9 文档编号:131871377 上传时间:2020-05-10 格式:DOC 页数:7 大小:446.50KB
返回 下载 相关 举报
DMP参考数据手册_第1页
第1页 / 共7页
DMP参考数据手册_第2页
第2页 / 共7页
DMP参考数据手册_第3页
第3页 / 共7页
DMP参考数据手册_第4页
第4页 / 共7页
DMP参考数据手册_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《DMP参考数据手册》由会员分享,可在线阅读,更多相关《DMP参考数据手册(7页珍藏版)》请在金锄头文库上搜索。

1、参考数据手册:PS-MPU-6000A使用带有DMP的最新库函数(https:/ DMP库函数的dmpGetYawPitchRoll,可以得到pitch(俯仰),yaw(偏航),roll(滚转)角度。角速度: void getRotation(int16_t* x, int16_t* y, int16_t* z); int16_t getRotationX(); int16_t getRotationY(); int16_t getRotationZ();16位,配置时四个量程可选:250,500,1000,2000 度/s。在dmp的例程中初始化:setFullScaleGyroRange(

2、MPU6050_GYRO_FS_2000);说明是选用最高量程2000/s,则换算系数=216/4000=16.4 LSB/(度/s)2012-11-13 15:57 上传下载附件 (157.65 KB) 加速度库函数: void getAcceleration(int16_t* x, int16_t* y, int16_t* z); int16_t getAccelerationX(); int16_t getAccelerationY(); int16_t getAccelerationZ();16位,配置时四个量程可选:2,4,8,16 g。在dmp的例程中没有找到初始化部分,估计是采用

3、了缺省配置。通过观察输出值,采用的是最小量程2g,则换算系数=216/4=16384 LSB/g2012-11-13 15:57 上传下载附件 (189.39 KB) 下面是程序,中断方式,需要把MPU的中断接到arduino数字2脚上。ARDUINO 代码复制打印1. / Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation2. / is used in I2Cdev.h3. #include Wire.h4. 5. / I2Cdev and MPU6050 must be installe

4、d as libraries, or else the .cpp/.h files6. / for both classes must be in the include path of your project7. #include I2Cdev.h8. 9. #include MPU6050_6Axis_MotionApps20.h10. MPU6050 mpu(0x68);11. 12. / MPU control/status vars13. bool dmpReady = false;/ set true if DMP init was successful14. uint8_t m

5、puIntStatus; / holds actual interrupt status byte from MPU15. uint8_t devStatus; / return status after each device operation (0 = success, !0 = error)16. uint16_t packetSize; / expected DMP packet size (default is 42 bytes)17. uint16_t fifoCount; / count of all bytes currently in FIFO18. uint8_t fif

6、oBuffer64; / FIFO storage buffer19. 20. / orientation/motion vars21. Quaternion q; / w, x, y, z quaternion container22. VectorFloat gravity; / x, y, z gravity vector23. float ypr3; / yaw, pitch, roll yaw/pitch/roll container and gravity vector24. 25. 26. / =27. / = INTERRUPT DETECTION ROUTINE =28. /

7、 =29. 30. volatile bool mpuInterrupt = false; / indicates whether MPU interrupt pin has gone high31. void dmpDataReady() 32. mpuInterrupt = true;33. 34. 35. 36. 37. / =38. / = INITIAL SETUP =39. / =40. 41. void setup() 42. Serial.begin(115200); / opens serial port, sets data rate to 9600 bps43. 44.

8、/ join I2C bus (I2Cdev library doesnt do this automatically)45. Wire.begin();46. 47. / initialize device48. Serial.println(Initializing I2C devices.);49. mpu.initialize();50. 51. / verify connection52. Serial.println(Testing device connections.);53. Serial.println(mpu.testConnection() ? MPU6050 conn

9、ection successful : MPU6050 connection failed);54. 55. delay(2);56. 57. / load and configure the DMP58. Serial.println(Initializing DMP.);59. devStatus = mpu.dmpInitialize();60. 61. / make sure it worked (returns 0 if so)62. if (devStatus = 0) 63. / turn on the DMP, now that its ready64. Serial.prin

10、tln(Enabling DMP.);65. mpu.setDMPEnabled(true);66. 67. / enable Arduino interrupt detection68. Serial.println(Enabling interrupt detection (Arduino external interrupt 0).);69. attachInterrupt(0, dmpDataReady, RISING);70. mpuIntStatus = mpu.getIntStatus();71. 72. / set our DMP Ready flag so the main

11、loop() function knows its okay to use it73. Serial.println(DMP ready! Waiting for first interrupt.);74. dmpReady = true;75. 76. / get expected DMP packet size for later comparison77. packetSize = mpu.dmpGetFIFOPacketSize();78. 79. else 80. / ERROR!81. / 1 = initial memory load failed82. / 2 = DMP co

12、nfiguration updates failed83. / (if its going to break, usually the code will be 1)84. Serial.print(DMP Initialization failed (code );85. Serial.print(devStatus);86. Serial.println();87. 88. 89. 90. void loop()91. 92. float alpha,omiga;93. 94. / if programming failed, dont try to do anything95. if (

13、!dmpReady) 96. return;97. 98. / wait for MPU interrupt or extra packet(s) available99. if (!mpuInterrupt & fifoCount packetSize) 100. return;101. 102. / reset interrupt flag and get INT_STATUS byte103. mpuInterrupt = false;104. mpuIntStatus = mpu.getIntStatus();105. 106. / get current FIFO count107. fifoC

展开阅读全文
相关资源
相关搜索

当前位置:首页 > IT计算机/网络 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号