I2Cdevlib Forums

How to get both positive & negative G values on acceleromter?

Recommended Posts

To detect vibration I'm sampling the MPU6050 various times and averaging it with previous samples and the algo works very well, it's the following:

```

Force =  sqrt((currentX - lastX) * (currentX - lastX) +
(currentY - lastY) * (currentY - lastY) +
(currentZ - lastZ) * (currentZ - lastZ) );```

However, the problem is the result is always a positive number, and since I've been studying accelerometers I've noticed they often give negative values too. So I'd like to be able to get these negative values.

In the accelerometers initial state x, y can be negative depending on the axis, and y is never negative. I know x, y & z values can be changed by applying the DMP/quaternions/etc. Do I need to apply something like ypr or euler to get the proper G force? How do I get the full negative & positive values of G?

Share on other sites

Aren't the negatives just indicating the direction? Whereas the pythagorean theorem is giving you a magnitude of the force. So if you move up with a force of 5 newtons or down with a force of 5 newtons, it's on the same axis so the magnitude of the force on that axis could be the same, but the direction would be different.

Of course, take this all with a grain of salt. I honestly don't remember from trig class, if you have three different axis' is it still square root or should it be cube root?

Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.