# Accelerometer offset

First off, if this isn't the proper stack for this, I apologize, but since my question isn't based around code, I think this is the proper place.

I am making a system based around a 3 DOF accelerometer to track earthquakes. I take the magnitude of the three axis: mag = sqrt(x^2 + y^2 + z^2). I then take a moving average of 64 points of the data. I get great noise reduction from this method.

My question is on the baseline value of the accelerometer readings. It is my understanding, that since I take the magnitude of the 3 axis, that at any given location, the orientation of the accelerometer shouldn't affect the magnitude?

The problem I have, is that it seems to depend greatly on the orientation, and I can't see why. Here is a great example:

I shook the table that the acc was on, gives a great image of the vibration, but it doesn't return to the original baseline. This same type of behavior happens if I spin it, raise or lower it, ect..

I am using a Invensense MPU-6050 accelerometer. I do have access to other 3 DOF gyro, maybe that could be helpful? I didn't think so since I don't need exact orientation out of it.

Thanks a lot.

EDIT: Based on the suggestions below, I secured the acc to the table, ensuring the orientation didn't change, and this is the result:

Moved back to baseline exactly. So it seems like it's a calibration issue.

• Happy to see that you checked the suggestion and reported back what you learnt. That makes the question more useful for future visitors. Thanks! – Floris May 5 '17 at 19:33

## 1 Answer

Is the orientation of the sensor different after the shake? If not - did you calibrate the sensitivity of the axes? This looks like you have an uncalibrated sensor with changing orientation - so the same acceleration (of gravity) shows up as a slightly different number when pointing along x, y or z.

A well calibrated sensor should give the same reading (at rest) regardless of orientation. If it does not, you could deliberately orient in so $g$ points along x, y and z - then compute the scale factor needed so the three axes read the same thing.

Then when you combine your three signals, use

$$a = \sqrt{(c_x\cdot x)^2 + (c_y\cdot y)^2 + (c_z\cdot z)^2}$$

Where the $c_x$ etc are the calibration factors you found.

• Oh, didn't even think about calibration since I had assumed I didn't need to since I dont need absolute values. Is this something that can be done without manually moving it? Since this system needs to be able to run without much setup. As far as I could tell, the orientation did not change. @Floris – Kyle Hunter May 5 '17 at 18:44
• I dunno. It seems like a rather big change in the baseline value due to shaking to be caused by an x-y-z calibration problem. The baseline appears to change by about 6%, which is a lot. And that's not a 6% change in tilting the accelerometer by 90˚ so that its measuring acceleration along its own z-axis and then along its own x-axis. No, it's a 6% change which would presumably be due to a very slight angular misorientation of perhaps a degree or so as a result of the table or accelerometer settling to a slightly different angle after the shaking event. – Samuel Weir May 5 '17 at 19:19
• @SamuelWeir Check my edited question. I'm guessing that it rotated quite a bit when I shook it last time. Will look into the calibration issue now. – Kyle Hunter May 5 '17 at 19:23