user3554669
user3554669

Reputation: 11

Can I cancel out gravity only with gyro and magnetometer?

On a device I want to detect a range of forces: small forces (Minimum around 0.01g) but also stronger forces like 0.1g - 0.15g.

This device will have different positions in 3d space so in order to detect the small forces I have to know its angle in order to be able to subtract 1g. Because the device can have a random position (angle position).

What I did so far: I used the MPU6050 and used a complementary filter with accel. and gyro. It's something like:

agnleX_k+1 = 0.98*(angle_k + deltaT * gyro_k+1) + 0.02*angle_acc_k+1;

angle_acc is the angle calculated from the accel. sensor. Something like:

arctan(accelX / sqrt(accelX^2 + accelY^2 + accelZ^2 + ))

So I am interested in:

forceX_k+1 = accelX_k+1 - 1g*sin(agnleX_k+1)

The problem is:

If I want to detect a small force coming in very fast, let's say on accelX_k+1 I would want to detect a Change from 0g to 0.01g or more but in a very small time range. The problem is that my calculated angle would then also be influenced by this small and fast change of the accel. sensor although the angle haven't really changed.

I think I would have to do the angle calculation independent of the accel. sensor. Can I do something like a complementary filter with gyro and magnetometer? Would that work the same as my filter described above but just with the mag. sensor instead? Or how would you do that? I was thinking about using MPU9250.

Upvotes: 0

Views: 1027

Answers (2)

M lab
M lab

Reputation: 234

Using DMP library fromJeff Rowberg will do the work for you. it can compensate gravity acceleration internally way faster that Arduino code.

Link to github

Upvotes: 0

tomtzook
tomtzook

Reputation: 549

You stated using MPU6050, which contains both an accelerometer and a gyrosocpe. You could use them independantly - get acceleration from the accelerometer and get angles from the gyroscope, and then use the angles to compensate for rotation. There is no need for the angle to depend on your accelerometer.

Upvotes: 0

Related Questions