2233 views|0 replies

9702

Posts

24

Resources
The OP
 

Problems with lsm303agr measuring magnetic field [Copy link]

 

LSM303AGR can measure magnetic fields up to ±50 gauss. The Earth's magnetic field strength is around 0.6 gauss.

In this way, the LSM303AGR can theoretically be used to measure the magnetic field of a magnet, such as using it to make a game joystick.

Because it will be affected by the external magnetic field, the influence of the earth's magnetic field is usually around 1%.

External influences should be solved by adding another sensor for compensation

In the actual test, I used csharp to write a simple host computer program to display the X, Y, and Z curves.

The problem I encountered is that when the magnetic field of the magnet reaches a certain level, the sign bit of the data will change when the output data is greater than 32767 or less than -32768.

For example, from -32760 to +32750, in order to prevent the MCU from sending data and the host computer from decoding data errors, I changed the Z axis to a continuously accumulated data in the program.

During the test, the data of the Z axis is normal, but the X and Y axes still have problems like the one in the figure below, where the data jumps from the top to the bottom, or from the bottom to the top.

Below is the original data and the chart generated by EXCEL

EXCEL File

测试数据.xlsx (74.07 KB, downloads: 0)

The test tool uses ST's BlueCoin development board

The code uses DataLog under STSW-BCNKT01_V2.1.0 and makes a simple modification to the format of data output to USB.

This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list