Hi guys!
I couldn’t solve it yet and hope to find some help here.
I have an LSM303DLH attached to an Arduino Mega 2560.
The project I would like to realize is quite simple. While there is nothing the Arduino should sleep, optimized also the LSM303DLH should be in Low Power Mode (but for the beginning this is not neccessary). An impact on the sensor of the LSM303DLH should activate the whole system by setting the INT1 of the LSM303DLH to LOW and wake my Arduino which now makes a LED light. I am not interessted in the value of the acceleration.
Until now my interrupt signal is on interrupt all the time, even when I just start the system.
May I can solve this. Because as I understood the datasheet, if I grab the data from the INT1_SRC_A register the interrupt signal should again be HIGH.
My problem at the moment is, I can’t read this register. May you help me please on how to read it.
I am using the pololu library for LSM303 boards:
github.com/pololu/lsm303-arduino
What I changed is this, which was not more than reading the datasheet (and similar datasheets) and copy and paste:
else // DLM, DLH - Code-Line 266
{
// 0b00100100 = 0x24
// 001 Normal Mode - 00 50Hz - 100 sensible axis zyx
writeAccReg(CTRL_REG1_A, 0x24);
// 0b00000000
// 0 Boot - 00 HP-Filter - 0 filtered data selection - 0 HP filter enabled for int2 source - 0 HP filter enabled for int1 source -
// 00 HP Filter Cut off Frequ
writeAccReg(CTRL_REG2_A, 0x00);
// 0b01000100
// 0 Interrupt active HIGH - 1 open drain - 0 latch int2 - 00 Data Signal on INT2 pad - 1 latch int1 - 00 Data signal on INT1 pad
writeAccReg(CTRL_REG3_A, 0x44);
// 0b0000000
// 0 block data update - 0 big/little endian data selection - 00 Full-Scale +-2g - 00 STsign - 0 ST disabled - 0 empty
writeAccReg(CTRL_REG4_A, 0x00);
// 0b00000000
// 000000 empty - 00 Sleep-to-wake disabled
writeAccReg(CTRL_REG5_A, 0x00);
// 0b00110000
// 0 AOI - 0 6D - 1 ZHIE - 1 ZLIE - 0000 for YHIE, YLIE, XHIE, XLIE
writeAccReg(INT1_CFG_A, 0x30);
// 0b00000001
// 1LSB ~ 16mg
writeAccReg(INT1_THS_A, 0x01);
// 0b00000000
// 1LSB ~ 10ms
writeAccReg(INT1_DURATION_A, 0x00);
}
}
This is my Arduino Test-Code:
Fist of all I initialze all needed variables. In the main-loop I look if the Pin 2 of the Arduino is LOW. This pin is connected with INT1 of the LSM303.
If an impact occurs Pin 2 goes Low and reads the data and prints it out. The value itself is yet not important.
I never get a LOW on Pin2
#include <Wire.h>
#include <LSM303.h>
LSM303 impactRec;
char report[80];
void setup()
{
Serial.begin(9600);
Wire.begin();
impactRec.init();
impactRec.enableDefault();
pinMode(2, INPUT);
}
void loop()
{
if(digitalRead(2)==LOW){
Serial.println("Impact occured");
impactRec.read();
snprintf(report, sizeof(report), "A: %6d %6d %6d M: %6d %6d %6d",
impactRec.a.x, impactRec.a.y, impactRec.a.z,
impactRec.m.x, impactRec.m.y, impactRec.m.z);
Serial.println(report);
}
}