完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
大家好,
当我尝试从中汇集数据时,我遇到了IIS2DH加速度计的问题。 我的设置是: STM32L442使用SPI接口连接到IIS2DH,并通过USART将数据发送到Tera Term(使用FTDI电缆)。 首先,我有一个小的初始化过程,根据我的需要设置芯片: 启用400Hz,X Y和Z轴,+ -2G刻度,高分辨率,SPI 4线,BDU。 然后我读了所有6个控制寄存器和“我是谁”注册,检查一切是否正常,我在Tera Term上显示结果。正如所料,一切都很好。 但是,当我从输出寄存器(OUT_X_L,OUT_X_H,...)汇集数据时,它仅适用于X和Y轴... 一旦存储了来自多个寄存器的数据,就会有一个小序列从每个轴的高和低寄存器构造16位有符号整数,然后将16位向右移位以仅保留前12位(HR模式)最后我通过USART发送数据(使用atoi()函数将数据转换为字符串)。 但正如我所说,它适用于X和Y轴,但不适用于Z轴。我没有找到与-1g相对应的东西(或12位刻度的-1024),而是读取了近-2g(-2039)。 有时当我碰到传感器时,Z轴稍微移动但不符合正常操作。 有没有人遇到过这类问题? 感谢您的帮助! 马克西姆 以上来自于谷歌翻译 以下为原文 Hello everyone, I have an issue with the IIS2DH accelerometer when I try to pool data from it. My setup is: STM32L442 connected to the IIS2DH using SPI interface and sending data through USART to Tera Term (using a FTDI cable). First I have a small initialization process which sets up the chip following my needs: 400Hz, X Y and Z axis enabled, +-2G scale, high resolution, SPI 4 wires, BDU. Then I read all the 6 control registers and the "who I am" register to check if everything is ok and I display the results on Tera Term. All works nicely, as expected. However, when I pool data from output registers (OUT_X_L, OUT_X_H, ...) it works only for X and Y axis... Once data from the several registers are stored, there is a small sequence which constructs the 16-bit signed integers from the high and low regisiters of each axis, then it shifts the 16 bits to the right to keep only the first 12 bits (HR mode) and finally I send the data through USART (using atoi() function to convert the data into strings). But as I said, it works perfectly for the X and Y axis, but not for the Z axis. Instead of having something corresponding to -1g (or -1024 on a 12 bit scale), I read almost -2g (-2039). Sometimes when I hit the sensor, the Z axis moves a little bit but it does not correspond to normal operating. Has anyone ever encountered this type of problem? Thank you for your help! Maxime |
|
相关推荐
1个回答
|
|
|
你能分享你的代码吗?
如果你的轴与重力对齐,你会在X轴和Y轴上看到1g吗? 以上来自于谷歌翻译 以下为原文 Can you share your code? Do you see 1g in X and Y axis if your align the axis with gravity? |
|
|
|
|
只有小组成员才能发言,加入小组>>
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 04:41 , Processed in 0.657029 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1793