Jump to content
I2Cdevlib Forums
Sign in to follow this  
blckdmp

Free Fall interrupts

Recommended Posts

Anyone have any luck setting up freefall interrupts for the 6050?  Looks like they've omitted (deleted?) all information about it in the register map and datasheet.  From looking through Jeff's library and seaching the web, I've called the following functions from the MPU6050 library, but am getting pretty iffy free fall detection, more like crappy tap detection at best.  Also, I see definitions for ...FF_COUNT_BIT and ...FF_COUNT_LENGTH values, but have no idea what writing to those registers does.  Any thoughts?

 

Thanks,

Jon

 

 

 

 
accelgyro.setInterruptMode(1); // active low
accelgyro.setInterruptDrive(1); // open drain
accelgyro.setInterruptLatch(1); // latch until read
accelgyro.setInterruptLatchClear(1); // clear on any read
accelgyro.setIntDataReadyEnabled(false); // trigger interrupt on data ready
accelgyro.setIntFreefallEnabled(1);
accelgyro.setFreefallDetectionThreshold(0x10);  //I've tried lots of different values here
accelgyro.setFreefallDetectionDuration(0x05);  // and here!!

The whole code for my basic trial sketch is:



#include <Wire.h>
#include <MPU6050.h>
#include <I2Cdev.h>

int pin = 13;
volatile int state = LOW;
MPU6050 accelgyro;         // Declare the instanced of the MPU6050

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  pinMode(pin, OUTPUT);
  attachInterrupt(1, blink, RISING);

  accelgyro.setInterruptMode(1); // active low
  accelgyro.setInterruptDrive(1); // open drain
  accelgyro.setInterruptLatch(1); // latch until read
  accelgyro.setInterruptLatchClear(1); // clear on any read
  accelgyro.setIntDataReadyEnabled(false); // trigger interrupt on data ready

  
 
 //Free Fall interrupt
 accelgyro.setIntFreefallEnabled(1);
 accelgyro.setFreefallDetectionThreshold(0x10);
 accelgyro.setFreefallDetectionDuration(0x05);

}

void loop()
{

}

void blink()
{
  state = !state;
  digitalWrite(pin, state);
  Serial.println(" Free fall Detected");
}

Share this post


Link to post
Share on other sites

I'm glad to hear that! I haven't actually worked with freefall detection at all, so I wouldn't be able to provide much help myself. I hope you are able to find some help in the older datasheets.

Share this post


Link to post
Share on other sites

Have you been able to work this out? I need a program for school that gives me an interrupt when a person with this sensor attached to his waist falls, and only when it gives an interrupt does it have to read sensor values. I can't however find a solution for this, was hoping you could help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×