Jump to content
I2Cdevlib Forums

Recommended Posts

Hi,


 


I'm using MPU6050 breakout board with I2CDevLib (mpu6050 teapot example).


 


What I would like to achieve is that interrupt is triggered when there is actually some motion on sensor 


(if I move it with hand for example).


 


Based on MPU6050 documentation I set INT_ENABLE (with setIntEnabled function) to B00000010.


This should mean that interrupt should be triggered based on the selected motion threshold only.


 


Well, the problem is that no matter how I set threshold I still get continues interrupts at ~100Hz rate (100 int/sec) 


(measured by oscilloscope on MPU int line)


 


As mpuIntStatus I get 00000011 or 00000010. Which means that interrupt was triggered by "motion detection" (MOT_INT). 


 


This are my current threshold settings:


Actually they are as they were in teapot example.



DEBUG_PRINTLN(F("Setting motion detection threshold to 2..."));
setMotionDetectionThreshold(2);

DEBUG_PRINTLN(F("Setting zero-motion detection threshold to 156..."));
setZeroMotionDetectionThreshold(156);

DEBUG_PRINTLN(F("Setting motion detection duration to 80..."));
setMotionDetectionDuration(80);

DEBUG_PRINTLN(F("Setting zero-motion detection duration to 0..."));
setZeroMotionDetectionDuration(0);

I'm wondering:


- what could I overlooked? Are there some additional register settings I need to make?


- What is triggering motion interrupt? 


- Do I maybe have faulty MPU - received values are looking fine/are quite stable though (if +/- 1 deg in considered stable)


 


I would be glad if someone could give me some suggestion where to look further. I already spent few days figuring this out.


 


Thx,


Gregor


Link to comment
Share on other sites

Ferrocen,

 

Thank you for the suggestion. I checked X-IMU, but can not find how it could help in my case?

 

Actually I'm implementing something else:

Sensor would be inside hexagonal dice. Each side of dice would have it's own led diodes around the corners (so it is easily seen when landed). In the dice would be mpu6050 (or similar), stripped down arduino nano running at 8Mhz, 3.3V and led (or more of them) for each dice side. 

 

When dice would land, Arduino (with help of MPU6050) would turn on leds around the dice side on which it landed.

 

I have quite a few challenges here:

 

No way to shut off electronics - no switches

Circuit is placed inside the dice. There is a way to change batteries with unscrewing some "sides", but it is too complicated to do it each time dice is used.

There are 3 AAA batteries inside. They should last at lease few weeks when in sleep mode. 

 

when dice is not in use, Arduino and MPU should go to sleep mode. 

Arduino would go to sleep mode if it won't receive interrupt from MPU for some time.

MPU would go to cycle mode when there is no movement.

 

Arduino would wake up when next interrupt would be received from MPU. 

MPU would wake up on first movement above threshold. 

 

This is where I'm facing two problems:

- MPU is sending moving interrupts even if it is standing still on my table.

- If I enable cycle mode I get "DMP Initialization failed (code 1)"

 

sampling rate of MPU can be low as possible (if that would effect battery life)

For this particular project it would be enough if MPU would measure it's position 1times/second - dice land and after a sec yaw, pitch and roll is read and appropriate LEDs are turned on.

 

I was experimenting with this and found out that if I set sampling to slowest possible B11111111, MPU readings become strange - like it is not detecting that circuit was moved. 

From my examples I guess lowering sampling rate is not a good idea. What do you think?

 

calibration can be done only once (when circuit is assembled). 

I don't need great accuracy to find out on which side dice has landed.

But it needs to be stable and with out drifting. 

 

How I see calibration process:

1. Assembled circuit is placed on perfectly flat surface.

2. dedicated pins are shorten on Arduino which triggers calibration procedure. 

3. calibration procedure reads current MPU position and set it as offset - so current position (ypr) would be 0,0,0

 

 

The biggest problem at the moment is how to enable cycle mode and properly configure interrupts (there could also be possibility that my MPU is broken).

I would need a way to find out what is triggering motion interrupt. 

 

Any suggestion?

Link to comment
Share on other sites

  • 4 months later...

Hi gregac,

 

I realize this is late, but I've just joined the wonderful world of I2C + mpu6050.

 

I think (taking a closer look at the registers of the mpu6050) that you need to set the INT_ENABLE register to 0b01000000. This will set the MOT_EN bit for motion detection enabled interrupt. Perhaps you mistakenly had the bits backwards?

 

Regards,

Kevin

Link to comment
Share on other sites

  • 11 months later...

hello,

 

I have a similar project, 

I'm able to ready data of acce and gyro, everything woks well except interrupt function. 

 

Did you solve the sleep/wake-up problema to save battery ?

if yes, can you explain how you did it please

 

thanks

 

Spilz

Link to comment
Share on other sites

  • 1 month later...

Gregac,

 

thanks for your reply, I didn't see it hearlier (no notification received).

 

I see what kind of switch it is, but I don't find it on sale, do you have a reference ?

It works only in one position ?

 

Actually I'm looking for other sensor, like ADXL345 (3 acc) and L3GD20H (3 gyro) which have interrupt working.

 

Regards,

Spilz

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...

"Why this is so important to me?
I would like to use interrupt from MPU to wake-up arduino on movement - to save battery, when device is not in use. 
... Circuit should be awake only when someone is holding/throwing it."

Hi maybe it's too late to answer this... but for record, I solved this problem using the LowPower.h library and the SW420 sensor; not MPU6050.
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...