ST意法半导体
直播中

朱虹博

7年用户 230经验值
私信 关注
[问答]

LIS3DSH怎么知道它已经完成了一个完整的360度转弯?

大家好,我正在使用LIS3DSH加速度计,它是覆盆子pi上的accel2点击板。我能够根据二进制读数得到x,y和z轴的角度,并且我还能够根据数据表中的公式确定加速度计的滚动和俯仰。我的问题是,我怎么能让它知道它已经完成了一个完整的360度转弯?截至目前,它知道当我将加速度计调到90度时,它会向我显示x和z平面相对于z轴的角度。一旦阈值超过90度,它就会重置为零并再次进行数学运算。我无法根据我在下面附带的数据表中找到的图形来实现它,以及我的代码片段,它根据加速度计输出的读数计算角度。您可以查看我的整个'.c'代码,我已经附上了。我怎么做这个?

#lis3dsh

以上来自于谷歌翻译


以下为原文




Hi all, I'm working with the LIS3DSH accelerometer which is the accel2 click board on the raspberry pi. I was able to get the angles of x, y, and z-axis based on the binary reading and I was also able to determine the roll and pitch of the accelerometer based on the equation I found in the datasheet. The question I have is, how am I let it suppose to know that it has done a full 360-degree turn? As of now, it knows that when I turn the accelerometer tune 90 degrees, it shows me the angles of x and z plane with respect to the z-axis. As soon as the threshold gets more than 90 degrees, it resets to zero and does the math again. I am not able to implement it based on the figure I found in the datasheet which I have attached below, along with a snippet of my code which calculates the angles based on the readings outputted by the accelerometer. You can have a look at my whole '.c' code as well, which I have attached. How am I to do this?

#lis3dsh

回帖(2)

甘蔼宾

2019-3-20 10:37:16
单轴只会为您提供有关您所在的四象限世界的一半的信息。在图表中,X的负值将告诉您是否位于前2个象限之一(象限1(0-90) )或象限2(90-180)),如果是正的,则是底部两个中的一个(象限3(180-270)和象限4(270-360))。要区分世界的左半部分和右半部分,需要另一个正交的轴(Y或Z取决于设备的方向)。
这是我如何解决问题:
创建一个2位(4态)状态机,使用两个轴跟踪象限 - 使用每个的四个正负组合。然后将当前读数与之前的读数进行比较,并根据极性变化从一个状态(象限)更改为下一个状态 - 与读取正交轴编码器的方式大致相同。务必处理两个方向的过渡。
你可以将它扩展到所有三对或轴(X,Y),(X,Z)和(Y,Z),以分别跟踪俯仰,偏航和滚转的旋转。

以上来自于谷歌翻译


以下为原文




A single axis willl only give you information on which half of the 4-quadrant world you are in.  In your diagram,  a negative value of X will tell you if you are in one of the top 2 quadrants (quadrant 1 (0-90) or quadrant 2 (90-180)) or, if positive, one of the bottom two (quadrant 3 (180-270) and quadrant 4(270-360)).  To distinguish between the left and right halves of the world, you need another axis in quadrature (Y or Z depending on the orientation of the device).
Here's how I would approach the problem:  
Create a 2-bit (4-state) state machine that tracks the quadrants using two axis -  using the four combinations of positive and negative for each. Then compare the current readings with the previous and change from one state (quadrant) to the next based on the polarity changes - much the same way you would read a quadrature shaft encoder.  Be sure to handle transitions in both directions.
You could probably extend this to all three pairs or axes (X,Y), (X,Z), and (Y,Z) to separately track rotations in pitch, yaw, and roll.
举报

朱虹博

2019-3-20 10:52:32
rick.001
,,感谢您的快速回复。你解释的方法是正确的。我能够得到正确的值。再次感谢:)
 注意:原始帖子包含大量线程对话,只能迁移到第9级

以上来自于谷歌翻译


以下为原文





rick.001
‌, Thanks for the quick reply. Your explained approach was correct. I was able to get the correct values. Thanks again:)
Note: the original post contained a large number of threaded conversations and was only able to be migrated to the 9th level
举报

更多回帖

发帖
×
20
完善资料,
赚取积分