# Making accelerometer sense nonconventional gravity

I am working on a project of finding the bevel angle of a worm drive blade. To find the angle, I have decided to use 2 accelerometers. One of it being my reference and will sit on the footplate, the other one will be on the housing and moves with the bevel pivot.

I want the accelerometer sitting on the footplate to be my reference. Hence, whenever it moves, gravity will be perpendicular to the accelerometer. This is of course impossible to create because gravity is always pointing DOWN!! Is there a math equation or algorithm such that it would take the G values of the footplate accelerometer and create a " nonconventional, pseudo" gravity ?

Please let me know if there is any clarification needed. I am using the MPU6050 accelerometer. • 3 axis accelerometer? Have you experimented with one, they just output a vector which tells you (if stationary) which angle is down? – pjc50 Oct 25 '16 at 15:20
• Yes sir! I am using a 3-axis accelerometer. Yes it does. It gives my three values. For example, if it is lying down, ( x=0, y=0 and z= +1). However, I want to make it a reference. So if it is tilted in some way, I want the other accelerometer to know that gravity has shifted with respect to the reference. how do i do that? – Jason Lee Oct 25 '16 at 15:25
• @JasonLee you'll have to do the adjustment in firmware. I don't know of any accelerometers that allow you to change the samples based on an offset. – CHendrix Oct 25 '16 at 15:32
• It sounds like you want either a subtraction, or the "dot product" of the two vectors read from the two accelerometers. That will give you the angle between them. – pjc50 Oct 25 '16 at 15:35
• this is really a physics question. – kolosy Oct 25 '16 at 15:40

Each accelerometer (when stationary) gives you a 3 vector for the direction of gravity.

Let's assume that both accelerometers are offset-free, and have the same gain on all three axes. If they are not that ideal, then it's fairly easy to obtain an offset and gain for each axis with a calibration step that involves rolling each to a large number of random angles, and deriving offsets and gains such that the magnitude of gravity (sqrt(sum of squared components)) is constant regardless of the accelerometer orientation.

The angle between two 3 vectors is now calculated via their dot (or scalar) product, which gives you the cosine of that angle. See wikipedia dot product for full details.

Are you wanting to measure the "Inclination" angle between the flat surface and the angle of the blade? If so, you can calculate that from one 3-axis Accelerometer, no need for another Accel.

If you have 3 axis - {x,y,z}, you will have a component of the Earths Gravitational Field along each one, generally represented as Gx, Gy and Gz.

The Gtotal is 1G, therefore, in 3 dimensional space we have 1G = SQRT(Gx^2 + Gy^2 + Gz^2). This is what you use to perform a Scalar Calibration. Place the Accelerometer in a variety of positions to determine a Scale Factor and BIAS for each axis.

Once Calibrated, the Inclination can be calculated by atan2(Gxy,Gz), where Gxy = SQRT(Gx^2 + Gy^2).

If the Accel is flat on the table I have assumed Gz is along the axis of the Accel, Gy is pointing up and Gx is perpendicular to both.

Hope this helps.

• You assume the base plate is perfectly level and will stay level. – JRE Oct 25 '16 at 17:07
• I have indeed, it wasn't clear to me that it can move. I've also assumed that there is minimal vibration as this will screw up any angle calcs. I've also assumed that the axis are orhtogonal, i.e. there's no mis-alignments. Sounds like the solution needs two Accels (one for each movable object), the inclination with respect to the horizontal (i.e Earth) can be calculated for each Accel. The difference in Inclination will tell you the angle between each the blade and the footplate. This is assuming I have understood the question of course... – Mike Oct 26 '16 at 9:13