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

In summary: Cylindrical 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}What you are doing is 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
  • #1
electrophile
5
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

  • Test 22 Aligned physforums.zip
    144.7 KB · Views: 267
Physics news on Phys.org
  • #2
anyone?...
 
  • #3
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.
 
  • #4
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.
 
  • #5
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.
 
  • #6
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

  • Sub pitchroll2.doc
    28.5 KB · Views: 279
  • Test 22 physforums rotmat nonmacro xls.xls
    88.5 KB · Views: 344
Last edited:
  • #7
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:
[tex]\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}[/tex]
It certainly looks like you used it in your algorithm.
That looks a lot like the conversion matrix for going from Cartesian [tex]\hat{x}, \hat{y}, \hat{z}[/tex] to cylindrical [tex]\hat{s}, \hat{\phi}, \hat{z}[/tex] which is as follows:
[tex]\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}[/tex]
The conversion matrix for going from Cartesian [tex]\hat{x}, \hat{y}, \hat{z}[/tex] to cylindrical [tex]\hat{r}, \hat{\theta}, \hat{\phi}[/tex] is as follows:
[tex]\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}[/tex]
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.
 
  • #8
[tex]\theta=arctan(\frac{y_{tilt}}{x_{tilt}})[/tex]
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:

What is a 3-axis accelerometer?

A 3-axis accelerometer is a sensor that measures acceleration in three dimensions: X, Y, and Z. It is commonly used in devices such as smartphones and fitness trackers to detect movement and orientation.

Why is calibration necessary for a 3-axis accelerometer?

Calibration is necessary to ensure accurate measurements from the 3-axis accelerometer. Over time, the sensor can become misaligned or affected by external factors, such as temperature changes, which can lead to inaccurate readings. Calibration corrects these errors and ensures reliable data.

How is a 3-axis accelerometer calibrated?

A 3-axis accelerometer is typically calibrated by placing it in a known orientation and recording the readings. This process is repeated for different orientations, and the readings are compared to the expected values. Adjustments can then be made to the sensor to correct any discrepancies.

What is the fixing effect of gravity in the calibration process?

The fixing effect of gravity refers to the process of removing the influence of gravity on the accelerometer readings during calibration. Since gravity is a constant force, it can skew the readings of the sensor, but by fixing its effect, we can isolate the true acceleration values.

How often should a 3-axis accelerometer be calibrated?

The frequency of calibration depends on the specific device and its intended use. In general, it is recommended to calibrate the sensor at least once a year or whenever there are significant changes in temperature or usage environment. It is also important to recalibrate if the device is dropped or experiences any physical damage.

Similar threads

Replies
4
Views
4K
  • Mechanics
Replies
4
Views
3K
Replies
14
Views
1K
Replies
10
Views
21K
Replies
4
Views
2K
Replies
4
Views
4K
Replies
1
Views
8K
  • Classical Physics
Replies
10
Views
4K
  • Special and General Relativity
Replies
4
Views
4K
Back
Top