1
完善资料让更多小伙伴认识你,还能领取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 |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2733 浏览 1 评论
3241 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1810 浏览 1 评论
3650 浏览 6 评论
6038 浏览 21 评论
1339浏览 4评论
201浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
443浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
274浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 00:13 , Processed in 1.018449 second(s), Total 48, Slave 42 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号