Calibration of a 3-Axis Accelerometer for fixing effect of gravity

Click For Summary

Discussion Overview

The discussion revolves around the calibration of a 3-axis accelerometer to account for the effects of gravity when the device is tilted. Participants explore mathematical approaches and formulas to correct acceleration readings influenced by tilt angles in a practical application involving mapping a train track.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes the challenge of measuring acceleration due to gravity when the accelerometer is tilted, leading to incorrect readings in the x and y directions.
  • Proposed formulas for recalibrating acceleration values are presented, but a participant critiques the approach, noting issues with unit consistency in the calculations.
  • Another participant suggests using a rotation matrix to correct the acceleration values based on tilt angles, but reports difficulties in achieving plausible results.
  • A participant points out that the matrix used in the calculations is singular and has no inverse, indicating a potential flaw in the approach to combining rotations.
  • Discussion includes references to linear algebra concepts and the need for proper understanding of rotation matrices and their application in this context.
  • One participant introduces the use of arctangent to determine angles from tilt ratios, emphasizing the importance of quadrant considerations in trigonometric calculations.

Areas of Agreement / Disagreement

Participants express differing views on the correctness of the proposed formulas and methods for calibration, indicating that the discussion remains unresolved with multiple competing approaches and interpretations of the problem.

Contextual Notes

There are unresolved issues regarding the assumptions made in the calculations, particularly concerning the application of rotation matrices and the handling of singular matrices. The discussion reflects a complex interplay of mathematical concepts that may not be fully addressed.

electrophile
Messages
5
Reaction score
0
Hi all,

I've been trying to develop this excel macro for mapping out a train track and locating kinks.
It's been going well so far except that when the accelerometer is not exactly level with the ground, the acceleration due to gravity (9.8 m/s^2) is not only effective in the z-direction, but in the x and y as well since the whole co-ordinate system of the accelerometer is tilted.

Now, I have the x-tilt and the y-tilt angles and am trying to fix this problem.
Please have a look at the excel sheets I have attached. Starting from row 13 in B, C and D, I have the acceleration values in g (with 1g = 9.8m/s^w) and the tilt angles are in columns G and H.

I've thought about this for a while and came up with the following formulas for acceleration.

new_x_acceleration = old_x_acceleration + sin(x_tilt)
new_y_acceleration = old_y_acceleration + sin(y_tilt)
new_z_acceleration = sqrt (1 - (new_x_acceleration)^2 - (new_y_acceleration)^2)

These seem right but when I apply these formulas (run the calibrator macro i programmed replaces the originals) the values seem very implausible. They are on the order of 10^-16 or less.

Any thoughts on what I'm doing wrong?
 

Attachments

Physics news on Phys.org
anyone?...
 
The reason no one has helped is because it a difficult problem to be sure we got it right.
electrophile said:
new_x_acceleration = old_x_acceleration + sin(x_tilt)
new_y_acceleration = old_y_acceleration + sin(y_tilt)
new_z_acceleration = sqrt (1 - (new_x_acceleration)^2 - (new_y_acceleration)^2)

Your right angle trig is royally messed up.

Problem repeat and simplification:
Given:
x,y,z vector in rotated vector
x,y angle from true x and y
Find: x,y,z in true vertical

VM (g) in column G is total acceleration or rho.
new_z=sqrt(VM^2-new_x^2-new_y^2)

It is going to take a lot of thought to figure out new_x and new_y. I can tell you yours are wrong because you are adding an acceleration and a unitless ratio. You can multiply mismatched units together, but you can't add them.
 
Thank you for your response.
Yes, I realized the solution couldn't be that simple.

I think the solution can be given using a rotation matrix. However, this is not my area of expertise. I was wondering if anyone here could suggest a possible solution.

So far, what I'm thinking is, I should find the rotation matrix according to the x and y tilts. Take the inverse of it and multiply it by the matrix of xyz accelerations I have to find the original axis value (before the rotation). I've tried this but it's still not working out as I'm getting values that are even farther from 0 for x and y acceleration.
 
How far off? Let's what else you have come up with. We may say that the "off" numbers are in fact correct. Or we might realize what the correct solution is because you can so close.
 
Hey,

Okay, they are very far off. I have attached the excel sheet containing the rotation matrices and the final calibrated answers.

P1:R3 (yellow cells) contain the Rz matrix since (x-tilt is the rotation about the z-axis). T1:V3 (green cells) contain the Rx matrix (y-tilt is the rotation about the x-axis). X1:Z3 (red cells) contain the multiplication of the two (Rx * Ry). X4:Z6 (blue) contain the inverse of this multiplication and AD1:AD3 (purple) contain the final calibrated answers (inverse*xyz).

These values are calculated for the row 13 values. I have written a VBA code for this calculation [Sub pitchroll2()]

Please get back to me with your thoughts on this.
 

Attachments

Last edited:
electrophile said:
P1:R3 (yellow cells) contain the Rz matrix since (x-tilt is the rotation about the z-axis). T1:V3 (green cells) contain the Rx matrix (y-tilt is the rotation about the x-axis). X1:Z3 (red cells) contain the multiplication of the two (Rx * Ry). X4:Z6 (blue) contain the inverse of this multiplication and AD1:AD3 (purple) contain the final calibrated answers (inverse*xyz).

You need a course in linear algebra or matrix algebra. That matrix in red is a singular matrix, it has no inverse. But that is a correct multiplication of matrices.
X-tilt is rotation about the y-axis. Rotation about the z-axis is yaw. x-axis goes right and y-axis goes up on the plane of the paper with the z-axis coming out of the paper. If you wish to draw the three axis on the paper, you must maintain this relationship. The two common ways to do are y right, z up, x down and left; and x right, y up, z down and left.

I didn't poke your algorithm real hard but it looks like you are calculating roll and pitch and then multiplying them together. The problem with this is that that playing with roll and pitch in this manner works best when there is only roll or only pitch.
The rotation matrix for 2 dimensions is as follows:
\begin{pmatrix}\bar{A_y}\\\bar{A_x}\end{pmatrix}=\begin{pmatrix}\cos\phi&\sin\phi\\-\sin\phi&\cos\phi\end{pmatrix}\begin{pmatrix}A_y\\A_x\end{pmatrix}
It certainly looks like you used it in your algorithm.
That looks a lot like the conversion matrix for going from Cartesian \hat{x}, \hat{y}, \hat{z} to cylindrical \hat{s}, \hat{\phi}, \hat{z} which is as follows:
\begin{pmatrix}\hat{s}\\\hat{\phi}\\\hat{z}\end{pmatrix}=\begin{pmatrix}\cos\phi&\sin\phi&0\\-\sin\phi&\cos\phi&0\\0&0&1\end{pmatrix}\begin{pmatrix}\hat{x}\\\hat{y}\\\hat{z}\end{pmatrix}
The conversion matrix for going from Cartesian \hat{x}, \hat{y}, \hat{z} to cylindrical \hat{r}, \hat{\theta}, \hat{\phi} is as follows:
\begin{pmatrix}\hat{r}\\\hat{\theta}\\\hat{\phi}\end{pmatrix}=\begin{pmatrix}\sin\theta\cos\phi&\sin\theta\sin\phi&\cos\theta\\\cos\theta\cos\phi&\cos\theta\sin\phi&-\sin\theta\\-\sin\phi&\cos\phi&0\end{pmatrix}\begin{pmatrix}\hat{x}\\\hat{y}\\\hat{z}\end{pmatrix}
Theta is the angle from the z axis to the vector. Phi is the angle from the x-axis to the projection of the vector onto the xy-plane. The trick to using this as a conversion matrix for this case is figuring out what theta and phi is, neither of which you posses, but you can find them.
 
\theta=arctan(\frac{y_{tilt}}{x_{tilt}})
I can do this because the two angles produce a unitless ratio which is what arc trig functions take as arguments.
Make sure that the angle is in the right quadrant as arctangent is rather ambiguous.
 
Last edited:

Similar threads

  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 10 ·
Replies
10
Views
22K
Replies
4
Views
4K