LSM303DLHC не работает DRDY вывод
- Войдите на сайт для отправки комментариев
Чт, 26/11/2020 - 03:36
Всем привет!
Уже не знаю что делать. Все перепробовал, свой код, чужие библиотеки, замена самого сенсора. Не работает вывод DRDY (постоянно висит лог.1 на выходе), а так же бит в статус регистре получения новых данных повисла 1 (SR_REG_M, бит 0).
Кто нибудь работал с этим сенсором, в чем может быть проблема?
Для примера взял эту библиотеку:
https://github.com/pololu/lsm303-arduino
Тестовый код:
/*
The sensor outputs provided by the library are the raw 16-bit values
obtained by concatenating the 8-bit high and low accelerometer and
magnetometer data registers. They can be converted to units of g and
gauss using the conversion factors specified in the datasheet for your
particular device and full scale setting (gain).
Example: An LSM303D gives a magnetometer X axis reading of 1982 with
its default full scale setting of +/- 4 gauss. The M_GN specification
in the LSM303D datasheet (page 10) states a conversion factor of 0.160
mgauss/LSB (least significant bit) at this FS setting, so the raw
reading of -1982 corresponds to 1982 * 0.160 = 317.1 mgauss =
0.3171 gauss.
In the LSM303DLHC, LSM303DLM, and LSM303DLH, the acceleration data
registers actually contain a left-aligned 12-bit number, so the lowest
4 bits are always 0, and the values should be shifted right by 4 bits
(divided by 16) to be consistent with the conversion factors specified
in the datasheets.
Example: An LSM303DLH gives an accelerometer Z axis reading of -16144
with its default full scale setting of +/- 2 g. Dropping the lowest 4
bits gives a 12-bit raw value of -1009. The LA_So specification in the
LSM303DLH datasheet (page 11) states a conversion factor of 1 mg/digit
at this FS setting, so the value of -1009 corresponds to -1009 * 1 =
1009 mg = 1.009 g.
*/
#include <Wire.h>
#include "LSM303.h"
#define SDA_LSM 32
#define SCL_LSM 33
#define DRDY_LSM 35
#define CLK_LSM 400000
LSM303 compass;
char report[80];
void setup()
{
pinMode(DRDY_LSM, INPUT);
Serial.begin(921600);
Wire.begin(SDA_LSM, SCL_LSM, CLK_LSM);
compass.init();
compass.enableDefault();
// Отключить акселерометр.
compass.writeReg(LSM303::CTRL_REG1_A, 0x00);
// Измерение температуры выключено. Обновление данных MAG 0.75Hz.
compass.writeReg(LSM303::CRA_REG_M, 0x00);
}
void loop()
{
compass.read();
snprintf(report, sizeof(report), "A: %6d %6d %6d M: %6d %6d %6d",
compass.a.x, compass.a.y, compass.a.z,
compass.m.x, compass.m.y, compass.m.z);
Serial.print(report);
Serial.print(" SR_REG_M: ");
Serial.println(compass.readReg(LSM303::SR_REG_M));
delay(50);
}
Видно что новые данные на MAG сенсоре обновляются как положено, 0,75 Hz,
но статус байт не изменен (всегда = 3, LOCK и DRDY = 1).

Спасите))) Как отслеживать новые данные на MAG сенсоре???