Git Product home page Git Product logo

adxl345_we's People

Contributors

aaronjamt avatar wollewald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

adxl345_we's Issues

setFifoParameters overwrites FIFO_MODE

When using setFifoParameters after setFifoMode, the mode is overwritten to bypass.

Suggested fix:

void setFifoParameters(adxl345_triggerInt intNumber, uint8_t samples)
{
	regVal = readRegister8(ADXL345_FIFO_CTL);
	regVal &= 0b11000000;
	regVal |= (samples - 1);
	if (intNumber == ADXL345_TRIGGER_INT_2)
	{
		regVal |= 0x20;
	}
	writeRegister(ADXL345_FIFO_CTL, regVal);
}

THRESH_TAP actual values and sensitivity

Trying to tune-up tap sensitivity using setGeneralTapParameters().
Defaults provided in example works (but are very sensitive). Going higher on numbers (3...16) did not provided me with result i need and i investigated datasheet:
The THRESH_TAP register is eight bits and holds the threshold value for tap interrupts. The data format is unsigned, therefore, the magnitude of the tap event is compared with the value in THRESH_TAP for normal tap detection. The scale factor is 62.5 mg/LSB (that is, 0xFF = 16 g)
OK, so we have 1-byte value for THRESH_TAP - max 255/0xFF.
Looking into library:
regVal = static_cast<uint16_t>(round(threshold / 0.0625));
Here we cast value into 2-byte integer (?), so max value can be 4096. Where is second byte going?

Tried to set threshold value to ~4000 in setGeneralTapParameters() - and yes, sensitivity is now extremely low.
But it's usable in very non-linear way. Maybe one byte is dropped?
In this way - isn't better to do cast into uint8_t then, as documentation requires (and change scale)?
Or there is something more going on?

"Tap mode" is not generating interrupts

Trying common ADXL345 module on Wemos D1, using I2C.
Readings work, all fine.
Trying ADXL345_single_tap.ino - and it does not generate interrupts on any bumps.
I started with basic example, then lowered sensitivity to 1.3g, increased duration, etc - by reading data i see that overloads up to 8g are registered, but INT2 (and INT1, too) do not change it's values.
I attached logic analyzer with trigger on INT1/INT2 pins and it confirms that values do not change.
I tested with another ADXL345 module - the same, interrupt pin value does not change on bumps.

Unrelated minor issues - to get example compiled under platformio + wemos D1 - need to move "tapISR" function to top of code (above setup()) and add ICACHE_RAM_ATTR in front of it.

in init() shouldn't reset the ADXL345_DATA_FORMAT after setRange

Well done and thanks for your well-organized code.

bool ADXL345_WE::init(){
	......
	setRange(ADXL345_RANGE_2G); // in this func, will set the low two bits of ADXL345_DATA_FORMAT
	writeRegister(ADXL345_DATA_FORMAT, 0); // but here, ADXL345_DATA_FORMAT will be reset.
	setFullRes(true);
      ......

Because the ADXL345_RANGE_2G is defined as 0b00, so it doesn't matter here.
But if try to set ADXL345_RANGE_16G, it won't work as expected.

calibrate

How can I calibrate the ADXL345. It seems that the numbers do not want to settle to zero even if the module is taped to a desk

Raw-z never changes

I ran ADXL345_angles_orientation and Raw-z is always 511.0 and it never changes. Raw-x and Raw-y changes if I rotate the sensor.

With Sparkfun library I see all x, y, z to be changing. There z is between 520-1030.

setInterruptPolarity does not write the value to be set

void ADXL345_WE::setInterruptPolarity(uint8_t pol){
    regVal = readRegister8(ADXL345_DATA_FORMAT);
    if(pol == ADXL345_ACT_HIGH){
        regVal &= ~(0b00100000);
    }
    else if(pol == ADXL345_ACT_LOW){
        regVal |= 0b00100000;
    }
};

should be like this:

void ADXL345_WE::setInterruptPolarity(uint8_t pol){
    regVal = readRegister8(ADXL345_DATA_FORMAT);
    if(pol == ADXL345_ACT_HIGH){
        regVal &= ~(0b00100000);
    }
    else if(pol == ADXL345_ACT_LOW){
        regVal |= 0b00100000;
    }
    writeRegister(ADXL345_DATA_FORMAT, regVal);
};

ranges of values

Thanks for the library!

What would be great for the docs to mention the min and max values.
I guess for ADXL345_RANGE_8G it would be -8G/+8G (for example).

The range of the raw values are not quite so obvious.
From the code it looks like 16bit values.

rawVal.x = (static_cast<int16_t>((rawData[1] << 8) | rawData[0])) * 1.0;
corrRawVal.x = rawVal.x * 1.0 - (offsetVal.x / rangeFactor);
gVal.x = corrVal.x * MILLI_G_PER_LSB * rangeFactor * corrFact.x / 1000.0;

So by default it should be which could be calculated backwards per range factor.

rx = (gx * 1000.0 / (MILLI_G_PER_LSB * rangeFactor * corrFactx) + offsetValx) / rangeFactor

Does that make sense?

checkInterrupt after MCU sleep

Hey Wolfgang, thank you for sharing this lib! I'm currently playing with it and struggle with the checkInterrupt call on an ESP32 after put to deep sleep:

   log_d("Setting up ADXL345...");

  if (!myAcc.init()) 
  {
    log_d("ADXL345 not connected!");
  }

  if(myAcc.checkInterrupt(myAcc.readAndClearInterrupts(), ADXL345_ACTIVITY))
  {
    log_d("ADXL345 - Motion registered at: %s", myAcc.getActTapStatusAsString());
  }
  else
  {
    log_d("ADXL345 - No Motion registered");
  }

  myAcc.setCorrFactors(-230.0, 225.0, -227.0, 238.0, -280.0, 227.0);

  myAcc.setDataRate(ADXL345_DATA_RATE_100);
  myAcc.setRange(ADXL345_RANGE_2G);

  myAcc.setActivityParameters(ADXL345_AC_MODE, ADXL345_XYZ, 0.0675);

  myAcc.setInterrupt(ADXL345_ACTIVITY, INT_PIN_1);

  myAcc.readAndClearInterrupts();

The strange thing is: When I put if(myAcc.checkInterrupt(myAcc.readAndClearInterrupts(), ADXL345_ACTIVITY)) into my main loop without going to sleep - then moving the box will successfully get the trigger data from the ADXL345 - but when i put it into my setup routine and query the ADXL345 after a wakeup it never seems to get anything from myAcc.checkInterrupt.

The ADXL345 is always powered on and should register movement and save it until the esp wakes up again and pulls the state and resets that interrupt. Am I doing it totally wrong or am I missing something here?

Arduino IDE 2.0.0-rc3 - Error 13 while installing using the library manage

Hello,
I'm trying to install this library using the Arduino IDE v2.0.0-rc3 using the in-built library manager but the installation failed with the following error message:

Downloading [email protected]
Installing [email protected]
Failed to install library: ADXL345_WE:2.1.2.
Error: 13 INTERNAL: Library install failed: moving extracted archive to destination dir: rename C:\Users\Admin\Documents\Arduino\libraries\package-469848640\ADXL345_WE-2.1.2 C:\Users\Admin\Documents\Arduino\libraries\ADXL345_WE: Access is denied.

I tried launching the IDE with admin rights but still getting the same issue.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.