完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
大家好,我正在使用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个回答
|
|
|
单轴只会为您提供有关您所在的四象限世界的一半的信息。在图表中,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. |
|
|
|
|
|
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 |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1453 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1502 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3649 浏览 1 评论
3842 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2461 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
727浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
661浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 01:19 , Processed in 0.660873 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2770