ST意法半导体
直播中

张玲

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

LSM303DLHC最大磁场范围错误

我不能完全解决这个问题。有人告诉我,如果我疯了。

LSM303DLHC数据表在这里有点难以阅读。我将CRB_REG_M设置为001,+ / - 1.3gauss,它是最敏感的范围。但是它的所有轴都不是同样敏感的,数据表表75:
传感器输入场范围[高斯]:+/- 1.3
增益X,Y和Z [LSB / Gauss]:1100('Z''肯定是一个拼写错误,Z在NEXT字段中描述)
增益Z [LSB / Gauss]:980
输出范围:0xF800 - 0x07FF(-2048 - 2047)


他们说Z实际上不太敏感并且具有更大的范围,这是正确的,地球磁场的Z分量实际上明显大于XY分量的矢量和。


我相当确定我已经正确解码了I2C寄存器。 X和Y是2的符号补码16位整数除以1100.Z除以980.它的矢量和得到~0.480gauss,我的位置的正确磁场,并且当它旋转时总和是相当恒定的。


但是,当旋转设备使Y与地球的磁矢量对齐时,它会突然饱和。超出范围的饱和度没有在​​数据表中描述,但是当它变得“太过消极”时我得到了0xF000。该限制似乎在X或Y上约为-0.439gauss .I2C寄存器上的最负数是-483。


只是用磁铁探索这个,我通过实验发现了以下限制(近似值):
Xrange = + / - 0.736高斯
Yrange = + / - 0.439gauss
Zrange = + / - 2.080高斯(!)


此外,当Z轴接近其极限时,它实际上将是FLIP SIGN,而绝对值保持一致。随着场的增加,该值可能会从+ 1.833gauss变为+ 1.923gauss然后是错误的-2.079。 X和Y都没有这样做。


在所有轴中,值“0xF000”返回“超出范围”,无论是过于正还是负。


请注意,在某些方向上,仅地球磁场可以超过Y轴的+/- 0.439高斯的表观最大范围。这使得这个范围对于这个星球上的任何应用都相当无用。


我无法解释这一点。数据表说了几件事,但都没有解释。
它说数据范围会到-2048,但事实并非如此。那应该是-1.86gauss,所以我不知道为什么这样说。它将读取的最负值是-483。
它说在任何轴上范围都是+/- 1.3高斯,而不是。早期我得到的理论是,这是所有轴最大值的矢量和,即0.750gauss,它大致与X轴最大值相关,但不与Y或Z相关。


我不明白为什么轴也会有不同的范围。地球磁场的Z分量更强,是的,但是由于3D罗盘的性质,设备将被旋转,X,Y或Z可以随时与该矢量对齐,因此工作范围不会大于最小轴。

这很容易“解决” - 只是增加范围。 1.9gauss范围在与地球场的任何角度都没有产生误差。但是,我还需要测试这些的范围数字,我怀疑它们也有这些“不寻常”的范围配置文件。这很不幸,因为我们在进行更大规模时确实失去了解决方案。 “1.3gauss”的比例在Y中仅为+/- 483 LSB,而不是2047,当然也不是16比特的范围。增加范围将进一步降低地球磁场的分辨率,并且可能需要更大的尺度以避免在被第二磁场源(设备附近的磁体)干扰时使输出饱和。

以上来自于谷歌翻译


以下为原文




I can't quite work this out.  Someone tell me if I'm crazy.

LSM303DLHC datasheet is somewhat difficult to read here.  I have CRB_REG_M set to 001, +/-1.3gauss, its most sensitive range.  But all its axes are not equally sensitive, the datasheet Table 75:
Sensor input field range [Gauss] : +/- 1.3
Gain X, Y, and Z[LSB/Gauss] : 1100  (the ''Z'' is surely a typo here, Z is described in the NEXT field)
Gain Z[LSB/Gauss]: 980
Output Range: 0xF800–0x07FF (-2048–2047)


They're saying Z is actually less sensitive and has greater range, which is correct, the Z component of the Earth's magnetic field is actually significantly greater than the vector sum of the XY components.


I am fairly certain I have correctly decoded the I2C registers.  X and Y are signed 2's compliment 16 bit ints, divided by 1100.  Z is divided by 980.  The vector sum of this yields ~0.480gauss, the correct magnetic field for my location, and the sum is fairly constant as it is rotated.


However, when the device is rotated so the Y is aligned with the Earth's magnetic vector, it will suddenly saturate.  Saturation by exceeding range is not described in the datasheet, but I got 0xF000 when it turns ''too negative''.  That limit seems to be about -0.439gauss on the X or Y.  The most negative number on the I2C registers is -483.      


Just exploring this with a magnet, I experimentally discovered the following limits (approximate):
Xrange=+/-0.736 gauss
Yrange=+/-0.439gauss
Zrange=+/-2.080 gauss(!)


Additionally, when the Z-axis approaches its limit, it will actually FLIP SIGN, while the absolute value stays consistent.  As the field increases, the value might go from +1.833gauss to +1.923gauss then an erroneous -2.079.  Neither the X nor Y did this.


In all axes, the value 0xF000 is returned for ''out of range'', whether too positive or negative.


Note that the Y-axis' apparent maximum range of +/-0.439 gauss can be exceeded by the Earth's magnetic field alone, in certain orientations.  This makes this one range fairly useless for any application in this planet.


I can't explain this.  The datasheet said several things, none of which explain it.  
1.  It said the data range would go to -2048, which it doesn't.  That would have been -1.86gauss, so I don't know why this says this.  The most negative value it would read is -483.
2.  It said the range is +/- 1.3 gauss, it's not, on any axis.  Early on I had a theory that this was the vector sum of all the axis maximums, that would be 0.750gauss, which roughly correlates to the X-axis max but not the Y or Z.


I don't understand why the axes would be different ranges, either.  The Z-component of the Earth's magnetic field is stronger, yes, but by the nature of a 3D compass, the device will be rotated and the X,Y, or Z could be aligned with that vector at any time, so the operating range would not be larger than the smallest axis.  

It's easy enough to ''work around''- just increase the range.  The 1.9gauss range did not yield an error at any angle to the Earth's field.  However, I'll need to test the range figures for these as well, I suspect they've also got these ''unusual'' range profiles.  It's unfortunate because we do lose resolution here when going to larger scales.  The ''1.3gauss'' scale was only +/-483 LSBs of range in the Y, not 2047, and certainly not 16 bits of range.  Increasing the range will further decrease the resolution of the Earth's magnetic field, and a far larger scale may be necessary to avoid saturating the output when disturbed by a second magnetic field source, a magnet near the device.

回帖(1)

张玲

2018-9-30 10:45:00
我确实想到了这一点,以为我会为其他人更新帖子。
 
 
问题是这个。在I2C单读模式下,LSM303DLHC accel / mag似乎无法一致读取。您需要对6个输出寄存器进行I2C顺序读取。
 
重复读取对我不起作用。我以为是司机。但是,数据表中有一行表示您需要将I2C寄存器地址的MSB更改为1以自动增加。我没有这样做,我的I2C驱动程序不能用于重复读取,所以我又回到了单读事务。
 
这是针对LSM303DLHC和L3GD20指定的,但奇怪的是,未能将MSB设置为1,导致寄存器无法自动递增加速度计。当寄存器MSB为0时,LSM303DLHC mag和L3GD20似乎自动递增,即使规格表显示它们不会。 ''奇怪的''。

以上来自于谷歌翻译


以下为原文




I did figure this out, thought I'd get around to updating the post for others.


The problem is this.  The LSM303DLHC accel/mag doesn't seem to read consistently in I2C single-read mode.  You NEED to do I2C sequential-reads of the 6 output registers.

Repeat-reads didn't work for me.  I thought it was the driver.  However, there's a line in the datasheet which says you NEED TO CHANGE THE I2C REGISTER ADDRESS'S MSB TO 1 TO AUTO-INCREMENT.  I didn't do that, my I2C driver wasn't working for repeat-reads so I'd fallen back to single-read transactions.

This is specified for both the LSM303DLHC and L3GD20, but oddly enough failing to set the MSB to 1 only resulting in the register failing to auto-increment for the accelerometer.  The LSM303DLHC mag and L3GD20 seem to auto-increment when the register MSB is 0 even though the spec sheet says they won't.  ''weird''.
举报

更多回帖

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