社区导航

 
查看: 781|回复: 8

[工业类传感器] LSM6DSM器件静置在水平上原始数据XYZ三轴跳变

[复制链接]

80

TA的帖子

0

TA的资源

一粒金砂(中级)

Rank: 2

发表于 2017-11-30 10:52:13 | 显示全部楼层 |阅读模式
LSM6DSM这颗传感器放置在水平面上静置不动,串口读出的数据却是跳变的。原始数据如附件。其中xl->data_raw数据是直接从寄存器中读出来的分别是0X28 0X2A 0X2C这上第八位寄存器读出
xl->x,y,z数据是经过计算得出的。这是原始数据出来计算公式#define FROM_FS_2g_TO_mg( lsb )      (int32_t)( ( lsb * 61 )  / 1000)
我用的是2g的量程。
问题是为什么静置的时候XYZ三轴数据会波动如此之大,理论上应该是静止不变的。陀螺仪的数据倒是不变是正常的。


回复

使用道具 举报

80

TA的帖子

0

TA的资源

一粒金砂(中级)

Rank: 2

 楼主| 发表于 2017-11-30 10:54:21 | 显示全部楼层
附件是log

session.log

250.88 KB, 下载次数: 4

点评

你的的数据波动是挺大的我用手里的BlueCoin开发板测了一下LSM6DSM结果如下 如果你还有其它LIS6DSM传感器板子可以再试另一个看下,排除传感器硬件问题 排除传感器问题后可以再看一下代码,是不是哪个地方没有配置好  详情 回复 发表于 2017-11-30 11:49


回复

使用道具 举报

5209

TA的帖子

9

TA的资源

版主

Rank: 6Rank: 6

发表于 2017-11-30 11:49:59 | 显示全部楼层

你的的数据波动是挺大的我用手里的BlueCoin开发板测了一下LSM6DSM结果如下
如果你还有其它LIS6DSM传感器板子可以再试另一个看下,排除传感器硬件问题
排除传感器问题后可以再看一下代码,是不是哪个地方没有配置好,
http://www.st.com/content/st_com ... e/stsw-bcnkt01.html
这个官方例程里有LIS6DSM的代码,你可以参考一下
另外传感器数据变化大还和你的测试环境振动有关,可以尽量将传感器放在比较稳定的桌面或者平台上
  1. Acc_X: -26, Acc_Y: -11, Acc_Z :-1033
  2. Acc_X: -26, Acc_Y: -15, Acc_Z :-1033
  3. Acc_X: -26, Acc_Y: -15, Acc_Z :-1052
  4. Acc_X: -19, Acc_Y: -3, Acc_Z :-1021
  5. Acc_X: -34, Acc_Y: -15, Acc_Z :-1048
  6. Acc_X: -19, Acc_Y: -7, Acc_Z :-1044
  7. Acc_X: -26, Acc_Y: -7, Acc_Z :-1044
  8. Acc_X: -22, Acc_Y: -11, Acc_Z :-1033
  9. Acc_X: -30, Acc_Y: -7, Acc_Z :-1036
  10. Acc_X: -19, Acc_Y: -11, Acc_Z :-1036
  11. Acc_X: -22, Acc_Y: -11, Acc_Z :-1040
  12. Acc_X: -22, Acc_Y: -11, Acc_Z :-1036
  13. Acc_X: -22, Acc_Y: -7, Acc_Z :-1029
  14. Acc_X: -26, Acc_Y: -7, Acc_Z :-1036
  15. Acc_X: -19, Acc_Y: -3, Acc_Z :-1033
  16. Acc_X: -22, Acc_Y: -3, Acc_Z :-1033
  17. Acc_X: -26, Acc_Y: -7, Acc_Z :-1029
  18. Acc_X: -11, Acc_Y: -15, Acc_Z :-1029
  19. Acc_X: -22, Acc_Y: -11, Acc_Z :-1036
  20. Acc_X: -22, Acc_Y: -7, Acc_Z :-1033
  21. Acc_X: -22, Acc_Y: -11, Acc_Z :-1036
  22. Acc_X: -30, Acc_Y: -3, Acc_Z :-1033
  23. Acc_X: -19, Acc_Y: -7, Acc_Z :-1036
  24. Acc_X: -30, Acc_Y: -15, Acc_Z :-1036
  25. Acc_X: -15, Acc_Y: -15, Acc_Z :-1036
  26. Acc_X: -15, Acc_Y: -15, Acc_Z :-1040
  27. Acc_X: -19, Acc_Y: -7, Acc_Z :-1036
  28. Acc_X: -22, Acc_Y: -15, Acc_Z :-1025
  29. Acc_X: -22, Acc_Y: -15, Acc_Z :-1033
  30. Acc_X: -19, Acc_Y: -7, Acc_Z :-1036
  31. Acc_X: -26, Acc_Y: -11, Acc_Z :-1033
  32. Acc_X: -22, Acc_Y: -15, Acc_Z :-1040
  33. Acc_X: -15, Acc_Y: -7, Acc_Z :-1040
  34. Acc_X: -26, Acc_Y: -11, Acc_Z :-1036
  35. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  36. Acc_X: -22, Acc_Y: 0, Acc_Z :-1040
  37. Acc_X: -22, Acc_Y: -7, Acc_Z :-1033
  38. Acc_X: -19, Acc_Y: -7, Acc_Z :-1033
  39. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  40. Acc_X: -22, Acc_Y: -15, Acc_Z :-1036
  41. Acc_X: -15, Acc_Y: -15, Acc_Z :-1036
  42. Acc_X: -22, Acc_Y: -7, Acc_Z :-1040
  43. Acc_X: -19, Acc_Y: -7, Acc_Z :-1033
  44. Acc_X: -19, Acc_Y: -11, Acc_Z :-1033
  45. Acc_X: -22, Acc_Y: -7, Acc_Z :-1033
  46. Acc_X: -15, Acc_Y: -11, Acc_Z :-1040
  47. Acc_X: -15, Acc_Y: -11, Acc_Z :-1048
  48. Acc_X: -19, Acc_Y: -11, Acc_Z :-1040
  49. Acc_X: -22, Acc_Y: -7, Acc_Z :-1044
  50. Acc_X: -19, Acc_Y: -7, Acc_Z :-1036
  51. Acc_X: -15, Acc_Y: 0, Acc_Z :-1036
  52. Acc_X: -22, Acc_Y: -7, Acc_Z :-1025
  53. Acc_X: -15, Acc_Y: -7, Acc_Z :-1040
  54. Acc_X: -26, Acc_Y: -19, Acc_Z :-1036
  55. Acc_X: -22, Acc_Y: -11, Acc_Z :-1036
  56. Acc_X: -15, Acc_Y: -15, Acc_Z :-1040
  57. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  58. Acc_X: -22, Acc_Y: -11, Acc_Z :-1029
  59. Acc_X: -22, Acc_Y: -7, Acc_Z :-1029
  60. Acc_X: -22, Acc_Y: -11, Acc_Z :-1040
  61. Acc_X: -22, Acc_Y: -3, Acc_Z :-1040
  62. Acc_X: -22, Acc_Y: -3, Acc_Z :-1036
  63. Acc_X: -22, Acc_Y: -3, Acc_Z :-1036
  64. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  65. Acc_X: -19, Acc_Y: -7, Acc_Z :-1040
  66. Acc_X: -15, Acc_Y: -11, Acc_Z :-1040
  67. Acc_X: -15, Acc_Y: -15, Acc_Z :-1036
  68. Acc_X: -19, Acc_Y: -11, Acc_Z :-1033
  69. Acc_X: -15, Acc_Y: -11, Acc_Z :-1021
  70. Acc_X: -19, Acc_Y: -15, Acc_Z :-1040
  71. Acc_X: -15, Acc_Y: -7, Acc_Z :-1033
  72. Acc_X: -19, Acc_Y: -7, Acc_Z :-1033
  73. Acc_X: -19, Acc_Y: -7, Acc_Z :-1033
  74. Acc_X: -19, Acc_Y: -11, Acc_Z :-1036
  75. Acc_X: -15, Acc_Y: -3, Acc_Z :-1044
  76. Acc_X: -19, Acc_Y: -19, Acc_Z :-1052
  77. Acc_X: -15, Acc_Y: -11, Acc_Z :-1036
  78. Acc_X: -11, Acc_Y: -7, Acc_Z :-1029
  79. Acc_X: -19, Acc_Y: -11, Acc_Z :-1036
  80. Acc_X: -15, Acc_Y: -11, Acc_Z :-1033
  81. Acc_X: -11, Acc_Y: -15, Acc_Z :-1036
  82. Acc_X: -22, Acc_Y: -11, Acc_Z :-1036
  83. Acc_X: -19, Acc_Y: -19, Acc_Z :-1036
  84. Acc_X: -19, Acc_Y: -3, Acc_Z :-1036
  85. Acc_X: -11, Acc_Y: -11, Acc_Z :-1040
  86. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  87. Acc_X: -19, Acc_Y: -3, Acc_Z :-1033
  88. Acc_X: -15, Acc_Y: -3, Acc_Z :-1036
  89. Acc_X: -19, Acc_Y: -7, Acc_Z :-1029
  90. Acc_X: -15, Acc_Y: -7, Acc_Z :-1044
  91. Acc_X: -15, Acc_Y: -11, Acc_Z :-1036
  92. Acc_X: -15, Acc_Y: -11, Acc_Z :-1033
  93. Acc_X: -15, Acc_Y: -7, Acc_Z :-1044
  94. Acc_X: -15, Acc_Y: -11, Acc_Z :-1040
  95. Acc_X: -19, Acc_Y: -11, Acc_Z :-1033
  96. Acc_X: -15, Acc_Y: -15, Acc_Z :-1029
  97. Acc_X: -19, Acc_Y: -15, Acc_Z :-1036
  98. Acc_X: -22, Acc_Y: -3, Acc_Z :-1044
  99. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  100. Acc_X: -19, Acc_Y: -11, Acc_Z :-1036
  101. Acc_X: -15, Acc_Y: -7, Acc_Z :-1040
  102. Acc_X: -19, Acc_Y: -3, Acc_Z :-1033
  103. Acc_X: -15, Acc_Y: -11, Acc_Z :-1036
  104. Acc_X: -15, Acc_Y: -11, Acc_Z :-1040
  105. Acc_X: -15, Acc_Y: -19, Acc_Z :-1040
  106. Acc_X: -15, Acc_Y: 0, Acc_Z :-1033
  107. Acc_X: -19, Acc_Y: -11, Acc_Z :-1040
  108. Acc_X: -15, Acc_Y: -3, Acc_Z :-1036
  109. Acc_X: -15, Acc_Y: -15, Acc_Z :-1033
  110. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  111. Acc_X: -15, Acc_Y: -7, Acc_Z :-1033
  112. Acc_X: -19, Acc_Y: -7, Acc_Z :-1036
  113. Acc_X: -19, Acc_Y: -3, Acc_Z :-1040
  114. Acc_X: -15, Acc_Y: -15, Acc_Z :-1036
  115. Acc_X: -11, Acc_Y: -11, Acc_Z :-1040
  116. Acc_X: -11, Acc_Y: -11, Acc_Z :-1036
  117. Acc_X: -11, Acc_Y: -11, Acc_Z :-1029
  118. Acc_X: -7, Acc_Y: -15, Acc_Z :-1036
  119. Acc_X: -19, Acc_Y: -11, Acc_Z :-1040
  120. Acc_X: -15, Acc_Y: -7, Acc_Z :-1040
  121. Acc_X: -15, Acc_Y: -19, Acc_Z :-1029
  122. Acc_X: -11, Acc_Y: -15, Acc_Z :-1033
  123. Acc_X: -11, Acc_Y: -7, Acc_Z :-1029
  124. Acc_X: -7, Acc_Y: -11, Acc_Z :-1040
  125. Acc_X: -11, Acc_Y: -11, Acc_Z :-1036
  126. Acc_X: -15, Acc_Y: -7, Acc_Z :-1040
  127. Acc_X: -15, Acc_Y: -11, Acc_Z :-1036
  128. Acc_X: -15, Acc_Y: -11, Acc_Z :-1036
  129. Acc_X: -11, Acc_Y: -11, Acc_Z :-1036
  130. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  131. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  132. Acc_X: -7, Acc_Y: -19, Acc_Z :-1040
  133. Acc_X: -7, Acc_Y: -7, Acc_Z :-1033
  134. Acc_X: -11, Acc_Y: -11, Acc_Z :-1040
  135. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  136. Acc_X: -7, Acc_Y: -7, Acc_Z :-1029
  137. Acc_X: -11, Acc_Y: -7, Acc_Z :-1033
  138. Acc_X: -19, Acc_Y: -11, Acc_Z :-1033
  139. Acc_X: -11, Acc_Y: -15, Acc_Z :-1044
  140. Acc_X: -7, Acc_Y: -7, Acc_Z :-1033
  141. Acc_X: -11, Acc_Y: -7, Acc_Z :-1036
  142. Acc_X: -7, Acc_Y: -11, Acc_Z :-1036
  143. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  144. Acc_X: -11, Acc_Y: -19, Acc_Z :-1040
  145. Acc_X: -3, Acc_Y: -15, Acc_Z :-1033
  146. Acc_X: -11, Acc_Y: -19, Acc_Z :-1036
  147. Acc_X: -11, Acc_Y: -7, Acc_Z :-1025
  148. Acc_X: -11, Acc_Y: -7, Acc_Z :-1040
  149. Acc_X: 8, Acc_Y: -7, Acc_Z :-1033
  150. Acc_X: -11, Acc_Y: -15, Acc_Z :-1029
  151. Acc_X: -11, Acc_Y: -11, Acc_Z :-1021
  152. Acc_X: -15, Acc_Y: -7, Acc_Z :-1029
  153. Acc_X: -11, Acc_Y: -15, Acc_Z :-1040
  154. Acc_X: -3, Acc_Y: -11, Acc_Z :-1033
  155. Acc_X: -15, Acc_Y: -15, Acc_Z :-1040
  156. Acc_X: -15, Acc_Y: -15, Acc_Z :-1040
  157. Acc_X: -11, Acc_Y: -15, Acc_Z :-1033
  158. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  159. Acc_X: -7, Acc_Y: -11, Acc_Z :-1029
  160. Acc_X: -15, Acc_Y: -11, Acc_Z :-1040
  161. Acc_X: -11, Acc_Y: -11, Acc_Z :-1040
  162. Acc_X: -11, Acc_Y: -7, Acc_Z :-1040
  163. Acc_X: -15, Acc_Y: -3, Acc_Z :-1040
  164. Acc_X: -7, Acc_Y: -11, Acc_Z :-1033
  165. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  166. Acc_X: -11, Acc_Y: -11, Acc_Z :-1040
  167. Acc_X: -15, Acc_Y: -11, Acc_Z :-1040
  168. Acc_X: -11, Acc_Y: -7, Acc_Z :-1036
  169. Acc_X: -15, Acc_Y: -11, Acc_Z :-1040
  170. Acc_X: -7, Acc_Y: -15, Acc_Z :-1036
  171. Acc_X: -7, Acc_Y: -11, Acc_Z :-1036
  172. Acc_X: -7, Acc_Y: -15, Acc_Z :-1029
  173. Acc_X: -7, Acc_Y: -11, Acc_Z :-1033
  174. Acc_X: -7, Acc_Y: -7, Acc_Z :-1040
  175. Acc_X: -11, Acc_Y: -11, Acc_Z :-1048
  176. Acc_X: -7, Acc_Y: -7, Acc_Z :-1033
  177. Acc_X: -11, Acc_Y: -11, Acc_Z :-1033
  178. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  179. Acc_X: -3, Acc_Y: -15, Acc_Z :-1036
  180. Acc_X: -7, Acc_Y: -15, Acc_Z :-1036
  181. Acc_X: -7, Acc_Y: -3, Acc_Z :-1040
  182. Acc_X: -15, Acc_Y: -15, Acc_Z :-1040
  183. Acc_X: -15, Acc_Y: -7, Acc_Z :-1036
  184. Acc_X: -11, Acc_Y: -15, Acc_Z :-1033
  185. Acc_X: -11, Acc_Y: -7, Acc_Z :-1040
  186. Acc_X: -7, Acc_Y: -15, Acc_Z :-1033
  187. Acc_X: -3, Acc_Y: -15, Acc_Z :-1033
  188. Acc_X: -11, Acc_Y: -15, Acc_Z :-1040
  189. Acc_X: -11, Acc_Y: -7, Acc_Z :-1036
  190. Acc_X: -7, Acc_Y: -11, Acc_Z :-1036
  191. Acc_X: -11, Acc_Y: -3, Acc_Z :-1036
  192. Acc_X: -7, Acc_Y: -7, Acc_Z :-1036
  193. Acc_X: -11, Acc_Y: -7, Acc_Z :-1033
  194. Acc_X: -11, Acc_Y: -11, Acc_Z :-1036
  195. Acc_X: -11, Acc_Y: -7, Acc_Z :-1036
  196. Acc_X: -7, Acc_Y: -3, Acc_Z :-1036
  197. Acc_X: -3, Acc_Y: -7, Acc_Z :-1036
  198. Acc_X: -11, Acc_Y: -11, Acc_Z :-1036
  199. Acc_X: -11, Acc_Y: -15, Acc_Z :-1036
  200. Acc_X: -11, Acc_Y: -7, Acc_Z :-1036
  201. Acc_X: -7, Acc_Y: -7, Acc_Z :-1033
  202. Acc_X: -7, Acc_Y: -15, Acc_Z :-1036
  203. Acc_X: -3, Acc_Y: -15, Acc_Z :-1036
  204. Acc_X: -3, Acc_Y: -11, Acc_Z :-1040
  205. Acc_X: -7, Acc_Y: -7, Acc_Z :-1036
  206. Acc_X: -19, Acc_Y: -11, Acc_Z :-1033
  207. Acc_X: -3, Acc_Y: -7, Acc_Z :-1033
  208. Acc_X: -7, Acc_Y: -7, Acc_Z :-1036
  209. Acc_X: 0, Acc_Y: -11, Acc_Z :-1036
  210. Acc_X: -3, Acc_Y: -11, Acc_Z :-1036
  211. Acc_X: -7, Acc_Y: -11, Acc_Z :-1040
  212. Acc_X: -7, Acc_Y: -7, Acc_Z :-1040
  213. Acc_X: -11, Acc_Y: -7, Acc_Z :-1029
  214. Acc_X: -3, Acc_Y: -7, Acc_Z :-1040
  215. Acc_X: -3, Acc_Y: -11, Acc_Z :-1040
  216. Acc_X: -7, Acc_Y: -15, Acc_Z :-1036
  217. Acc_X: -3, Acc_Y: -11, Acc_Z :-1036
  218. Acc_X: -7, Acc_Y: -11, Acc_Z :-1036
  219. Acc_X: -11, Acc_Y: -3, Acc_Z :-1036
  220. Acc_X: 12, Acc_Y: -7, Acc_Z :-1033

复制代码

点评

全是负值,是传感器面向桌面吗?加速度合力的算法是R=SQRT(x^2+y^2+z^2)吗?所以如果有负值的算法也是这个公式吗  详情 回复 发表于 2017-11-30 16:33
虾扯蛋


回复

使用道具 举报

80

TA的帖子

0

TA的资源

一粒金砂(中级)

Rank: 2

 楼主| 发表于 2017-11-30 16:33:08 | 显示全部楼层
littleshrimp 发表于 2017-11-30 11:49
你的的数据波动是挺大的我用手里的BlueCoin开发板测了一下LSM6DSM结果如下
如果你还有其它LIS6DSM传感器 ...

全是负值,是传感器面向桌面吗?加速度合力的算法是R=SQRT(x^2+y^2+z^2)吗?所以如果有负值的算法也是这个公式吗

点评

有负值是正常的  详情 回复 发表于 2017-11-30 17:32


回复

使用道具 举报

5209

TA的帖子

9

TA的资源

版主

Rank: 6Rank: 6

发表于 2017-11-30 17:32:07 来自手机 | 显示全部楼层
xieyj 发表于 2017-11-30 16:33
全是负值,是传感器面向桌面吗?加速度合力的算法是R=SQRT(x^2+y^2+z^2)吗?所以如果有负值的算法也是这 ...

有负值是正常的

点评

你读的这个是寄存器是高八位还是第八位?就是说读的是0X28 0X2A 0X2C还是高八位的0x29 0X2B 0X2C寄存器的值?  详情 回复 发表于 2017-12-1 10:41
这个加速度合加速度计算是不是这个公式啊  详情 回复 发表于 2017-11-30 18:16


回复

使用道具 举报

80

TA的帖子

0

TA的资源

一粒金砂(中级)

Rank: 2

 楼主| 发表于 2017-11-30 18:16:48 | 显示全部楼层

这个加速度合加速度计算是不是这个公式啊


回复

使用道具 举报

80

TA的帖子

0

TA的资源

一粒金砂(中级)

Rank: 2

 楼主| 发表于 2017-12-1 10:41:48 | 显示全部楼层

你读的这个是寄存器是高八位还是第八位?就是说读的是0X28 0X2A 0X2C还是高八位的0x29 0X2B 0X2C寄存器的值?


回复

使用道具 举报

80

TA的帖子

0

TA的资源

一粒金砂(中级)

Rank: 2

 楼主| 发表于 2017-12-1 11:20:26 | 显示全部楼层
我已经解决这个问题了,多谢!


回复

使用道具 举报

80

TA的帖子

0

TA的资源

一粒金砂(中级)

Rank: 2

 楼主| 发表于 2017-12-22 14:22:24 | 显示全部楼层
我也来回复这个问题解决办法:我读出的数据其实是第八位,但是这个数据其实是16位的有高八位和第八位。将这两个位相加组成16位才对。acceleration_data = ((int16_t)acceleration_rawx[1]<<8) + (int16_t)acceleration_rawx[0];
留给遇到同样的问题的童鞋们,希望对你们有帮助


回复

使用道具 举报

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

本版积分规则

  • 论坛活动 E手掌握

    扫码关注
    EEWORLD 官方微信

  • EE福利  唾手可得

    扫码关注
    EE福利 唾手可得

小黑屋|手机版|Archiver|电子工程世界 ( 京ICP证 060456

GMT+8, 2018-9-25 09:52 , Processed in 0.346645 second(s), 17 queries , Gzip On, Redis On.

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