ST意法半导体
直播中

徐丽丽

8年用户 183经验值
私信 关注
[问答]

怎么使用带有I2C接口的ST加速计传感器LIS3DH

你好,先生,
我正在使用带有I2C接口的ST加速计传感器LIS3DH(适配器板STEVAL-MKI105V1)。
我现在可以阅读寄存器了
。但是对于没有默认值的寄存器,例如,
OUT_X_L(0x28),
OUT_
X
_H(0x29),
OUT_Y_L
(0x2A),
OUT_Y_H
(0x2B访问),
OUT_Z_L
(0x2c上),
OUT_Z_H
(0x2D),
读取的值全为零。
我的问题:
1.如何获得没有默认值的寄存器的正确加速度计值?在读取寄存器之前需要的任何配置?
2.“AN3308”第4章写入寄存器的启动顺序,但应写入什么值?你能帮忙建议吗?
谢谢,
阿娜李

以上来自于谷歌翻译


以下为原文




Hi Sir,

I am using ST accelerometer Sensor  LIS3DH (adapter board STEVAL-MKI105V1) with I2C interface.

I can now read the registers
. But for the registers which doesn't have default value, for example,
OUT_X_L (0x28),
OUT_
X
_H (0x29),
OUT_Y_L
(0x2A),
OUT_Y_H
(0x2B),
OUT_Z_L
(0x2C),
OUT_Z_H
(0x2D),


the value read are all zero.


My questions:


1. How to get the correct accelerometer value for the registers which doesn't have default value? Any configurations needed before reading the registers?


2. “AN3308� chapter 4 Startup sequence to write the registers, but what values should be written? Could you help to advice?


Thanks,


Arna Lee

回帖(6)

徐丽丽

2019-4-19 15:16:57
你好
Batek.Miroslav
感谢您的评论。
我试着配置
CTRL_REG1
 然后读取OUT_X_ / OUT_Y_ / OUT_Z_,例如OUT_Y
_L,但即使我没有移动它,我也有不同/变化的价值。这是正常的吗?如果有什么不对的话,你能不能查看我的日志?
非常感谢。
---日志---
开始...
 
致电LIS3DH_GetWHO_AM_I
读LIS3DH_WHO_AM_I(0x0F)寄存器:0x33 --- UART2 RX HEX:---
 
7E 20 03 33 20 4E
Cal_Checksum:0x4E
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x20,响应:0x57 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x80 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x80 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x40 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0xC0 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x40 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x40 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0xC0 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x40 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x80 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x00 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0x40 --- UART2 RX HEX:---
 
7E 20 04 33 2A 43
Cal_Checksum:0x43
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x2A,响应:0xC0 ---
 谢谢,
阿娜李
 
 注意:原始帖子包含大量线程对话,只能迁移到第9级

以上来自于谷歌翻译


以下为原文




Hello
Batek.Miroslav
Thank you for the comment.
I tried to configure
CTRL_REG1
then read OUT_X_/OUT_Y_/OUT_Z_, for example, OUT_Y
_L, but I got different/changing value even though I didn't move it. It is normal?Could you be kindly to review my log if anything wrong?
Thanks a lot.
--- Logs ---
START...

call LIS3DH_GetWHO_AM_I
read LIS3DH_WHO_AM_I(0x0F) reg: 0x33--- UART2 RX HEX: ---

7E 20 03 33 20 4E  
Cal_Checksum: 0x4E
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x20, Response: 0x57--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x80--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x80--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0xC0--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0xC0--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x80--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x00--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0x40--- UART2 RX HEX: ---

7E 20 04 33 2A 43  
Cal_Checksum: 0x43
call HAL_I2C_Mem_Read
Read I2C device addr: 0x33, register addr 0x2A, Response: 0xC0---
Thanks,
Arna Lee

Note: the original post contained a large number of threaded conversations and was only able to be migrated to the 9th level
举报

曾玲娟

2019-4-19 15:23:48
绝对正常,传感器本身或环境振动会产生一些小噪音。

以上来自于谷歌翻译


以下为原文




It is absolutly normal, there is always some small noise, caused by the sensor itself or by vibration of the enviroment.
举报

徐丽丽

2019-4-19 15:41:22
你好,先生,
我很困惑。
我把传感器放在桌子上。但看起来XYZ数据变化有点大?
在使用XYZ寄存器/数据之前是否需要配置任何其他寄存器?
**************************************
开始...
致电LIS3DH_GetWHO_AM_I
读取LIS3DH_WHO_AM_I(0x0F)寄存器:0x33
 
--- UART2 RX HEX:---
7E 20 03 33 20 4E
Cal_Checksum:0x4E
调用HAL_I2C_Mem_Read
读I2C器件地址:0x33,寄存器地址0x20,响应:0x57
 
--- UART2 RX HEX:---
7E 24 01 5B
Cal_Checksum:0x5B
X = -128 Y = -1856 Z = -16064
 
--- UART2 RX HEX:---
7E 24 01 5B
Cal_Checksum:0x5B
X = -128 Y = -1664 Z = -16000
 
--- UART2 RX HEX:---
7E 24 01 5B
Cal_Checksum:0x5B
X = -704 Y = -1536 Z = -16192
**************************************
 
谢谢,
ARNA

以上来自于谷歌翻译


以下为原文




Hi Sir,
I am confused.
I just keep the sensor on the desk. But it looks like the XYZ data change a little big?
Any other register needed to be configured before using XYZ register/data?

**************************************

START...

call LIS3DH_GetWHO_AM_I

read LIS3DH_WHO_AM_I(0x0F) reg: 0x33



--- UART2 RX HEX: ---

7E 20 03 33 20 4E

Cal_Checksum: 0x4E

call HAL_I2C_Mem_Read

Read I2C device addr: 0x33, register addr 0x20, Response: 0x57



--- UART2 RX HEX: ---

7E 24 01 5B

Cal_Checksum: 0x5B

X=  -128 Y= -1856 Z=-16064



--- UART2 RX HEX: ---

7E 24 01 5B

Cal_Checksum: 0x5B

X=  -128 Y= -1664 Z=-16000



--- UART2 RX HEX: ---

7E 24 01 5B

Cal_Checksum: 0x5B

X=  -704 Y= -1536 Z=-16192

**************************************



Thanks,

Arna
举报

曾玲娟

2019-4-19 15:50:36
如果你将数据转换成g单位,我会帮助你,你会发现变化很小并且是由噪音引起的。
这取决于您使用的模式,根据模式,输出在16位输出寄存器中调整为8,10,12位。

以上来自于谷歌翻译


以下为原文




I would help if you convert the data into g unit, you would see the change is small and is caused by noise.
It depends which mode you are using, according to the mode the output is 8, 10, 12 bit left adjusted in 16 bit output register.
举报

更多回帖

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