Accelerometer Lateral Movement Controlling Mouse

Hello world :P,

I have my 3-axis accelerometer working well controlling the computer the mouse through my Leonardo, moving it based on the calculated pitch an roll. However, I'm wondering how I could control the mouse by moving the accelerometer laterally, in each axis from side to side. For example, moving the accelerometer horizontally to the right results in moving the mouse right on screen. But of course, if you try and translate the acceleration straight into mouse movement, it works alright except that when you stop the movement there will of course be an acceleration in the opposite direction as you slow it down, returning the cursor (roughly) to its original position.

Is it possible to remove this negative acceleration, or kind of calculate the distance moved? It would feel a bit like a proper mouse in that moving it in a direction would cause the cursor to move correspondingly. I think I would also implement a bit of a "dead spot" in the middle of the range of movement to allow the user to return the accelerometer to their preferred resting position. Would it require something like an inertial navigation system to roughly measure distance travelled? Or would you just filter out the "kickback" of slowing down? Or something else?

Thanks.

All the yaw/pitch/roll examples to that, as far as I know.
You need a filter that combines the gyro and the accelerometer.

Kalman Guide : http://forum.arduino.cc/index.php/topic,58048.0.html
i2cdevlib : MPU-6050 6-axis accelerometer/gyroscope | I2C Device Library

Sorry, that's not what I was asking about. I'm not concerned about pitch, roll or yaw (that was just to show you where I was at), only the linear movement of the accelerometer in each axis. Gyros don't come into it. Please read my question before posting.

I read it three times :roll_eyes:
Is it the position sideways ?

Some have tried to calculate the position. It won't be accurate, but I read that it was possible.
I think you should get the acceleration with a fixed data rate, and just add/substract for 3 axis.

For a fixed data rate, the 'dmp' example of the i2cdevlib can be used (for a MPU-6050 sensor).

I think you should get the acceleration with a fixed data rate, and just add/substract for 3 axis.

Could you explain this? I don't understand.

For a fixed data rate, the 'dmp' example of the i2cdevlib can be used (for a MPU-6050 sensor).

Can't seem to find what I was looking for there either.

Maybe I should put it this way: how can I simulate moving a real mouse with an accelerometer? My problem is that I need to remove the negative acceleration when I slow the unit down, or calculate the distance travelled. Just look at your mouse and pretend it's an accelerometer. Move it around and compare it to what happens to your cursor on your screen. How could I do this with an accelerometer? The benefit/point being, of course, that it's in 3 axes and not restricted to being on a table/surface of some sort.

I understand now. The horizontal position in one or two axis.

When you have the acceleration at for example 100Hz, the time between the samples is fixed. That makes it easier to calculate the position. I think just add/substract the acceleration value.

The 'dmp' example does not calculate the position, but it tells the MPU-6050 to generate a stream of data of 100Hz sample rate.

I understand now. The horizontal position in one or two axis.

What part of

it's in 3 axes

didn't you understand?

I think just add/substract the acceleration value.

From/to what? Explain the whole "calculating the position" part. Any formulas or approaches? Just so you know, it's not over I2C, rather analog inputs, but this is of no consequence anyway.

Anyone else got anything to suggest?

The position (location) in 3D space with an analog accelerometer without the damping of a gyro.

Which sensor do you want to use ?
Just the raw accelerator value is very inaccurate, since you have to sample at a high rate to keep track of the motion.

The MPU-6050 that I mentioned is more accurate.
And the gyro and accelerator together with a filter can create useful data, the 'dmp' code is even better.
The 'dmp' calculates also quaternions which can also be used for the position, but I don't know how.

The formula is integrate. That is pure mathematical: Integrate acceleration and you get speed. Integrate speed for position.

You can google for : arduino accelerometer position
Or : arduino accelerometer position integration

I read about it a few months ago, it was more succesful that I thought it would be.
This was not it, but it's a step in the direction : Random Acts of Senseless Blogging: Arduino based Inertial Navigation System - first steps