Accelerometer + Tilt compensation

I am looking for a method of compensating for tilt in an accelerometer- based application... lots of google searches show how to calculate tilt with an accelerometer ,but that is not quite what I am looking for.

I need to measure 3-axis acceleration of a moving vessel with my device.. the problem is the device may not be mounted truly flat. For example, if it's tilted slightly on the X-axis, the X-axis will always read a slight gravity component at DC, and the Z-axis will have a little bit removed.

The problem is this: If the vessel moves perfectly along the "flat x- axis", since my device is slightly tilted on the X-axis, this acceleration will result in a change in the Z-axis.

So I am wondering if there is a way I can "rotate the device" to true

0 degrees using post-processing/math. If I could do this, then that forward motion along the TRUE X-axis would result in a reading that only changed the X-axis, not the Z-along with it. I can get samples at DC, so I could easily calculate what the starting tilt is. So if at DC, the X-axis reads -0.1g and the Z-axis 0.98g for example, I don't think it's as simple as adding/subtracting those offsets all the time since that doesn't take into account the component of one into the other..

Thanks.

Reply to
jdhar
Loading thread data ...

If you are using atan2 (

formatting link
) to calculate the angle between two axis, do this at calibration time and then subtract this value from the angle you measure.

If you want to compensate all 3 axis, an nice solution might be using quaternions (

formatting link
). Quaternions are especially useful, if you want to track movements. A quarternion can be used to repesent orientation and rotations:

formatting link

E.g. the scripting language of Second Live uses quarternions, for controlling the orientation and movement of scripted objects in 3D.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

You have six degrees of freedom that you need to be concerned with: translation along each unit vector and also rotation around each. Inertial measuring units typically do this with the second derivative of translation and the first of rotation, i.e., accelerometers and rate gyros. For an unconstrained system, you have to have all six.

In a constrained system (e.g., it's not moving), you can infer orientation by measuring the three-axis acceleration, modulo a correct estimate for the local gravity vector and the bias and scale factors of your instruments. Well that and earth rate, non-aligned gravity and earth's rotational frames of reference, the shape of the geoid, etc.

Search on "strapdown inertial navigation" ...

... but you still need gyros.

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

So I get I can calculate the angle at calibration time... however, subtracting this from the angle I measure won't achieve what I need (I don't think at least). Once in motion, all I have are 3 forces in the X,Y,Z directions... I need a way to translate that initial angle to modify those 3 vectors, right?

These look like an interesting tool... I will have to study it more, but thanks for the tip!

snipped-for-privacy@frank-buss.dehttp://www.frank-buss.de,http://www.it4-systems.de

Reply to
jdhar

jdhar wrote in news:e5d24354-7c95-49a4-95d9- snipped-for-privacy@r15g2000prd.googlegroups.com:

Start with asking what you are trying to measure. If you don't need the DC, then high pass filtering is your easiest solution.

Since gravity is just like any acceleration, once you start thinking about your problem, you'll see there are some ill-posed aspects. If you can find a situation where you can be assured that the platform has no acceleration other than gravity, you should be able to correct, but if you're talking about a ship, it will be rolling and heaving, so the problem is difficult. Consider moving up to a 6-degree of freedom system, that has three accelerometers and three gyros, if you can't just high-pass filter to remove the low frequency.

--
Scott
Reverse name to reply
Reply to
Scott Seidman

Got it. And for my own understanding, a "rate gyro" is simply something that measures the rate of change on an angular basis, correct?

Right, so this is what I could do when the system is at rest... I don't think I need to worry about all of those other factors since this doesn't have to be that precise.

Did a quick search... I'm assuming you are referring to the concept as opposed to the Book title. Basically, that is what I'm trying to build (something fixed to the frame of the vessel)... I didn't think I would need a gyro for this application however, and I'm still not quite clear why I do. There is no way just knowing the acceleration vectors to compensate for an initial tilt?

To maybe clarify my application, I don't need this INS (if you will) to calculate where I am going exactly. What I need is to measure and datalog the forces that are being applied in all 3 axis... that's it. I just need to remove the cross-coupling from one axis into the other due to mounting tilt. So if the vessel moves truly forward, it should register acceleration on X only, not X and Z (for eg.). Other than that, that's all I need.. I don't need to use that information to calculate where I am in reference to a start point.

Reply to
jdhar

e

Thanks Scott... I don't need DC, I'm concerned only with the delta in acceleration over time. I'm not sure if highpass will do exactly what I need however. If I simply just highpass filter all 3 axes, it won't help the fact that moving in one TRUE axis (say movement in true X) will couple into 2 axes on the accelerometer due to mounting tilt, right?

u

It seems like 6-degree is where it's going, but I need to fully understand why first. The vessel is a boat, but this is for a sports- performance based application, so it's not a big ship that is in waves or anything. So in short, I could find a situation where there is "virtually" no acceleration other than gravity. The problem is I can't guarantee the situation where the sensor will be mounted such that gravity is only applied on the Z-axis.

Reply to
jdhar

If the sensor is moving in one direction, parallel to ground, you'll measure the same like when it is not moving. For simplifying, now one axis is in the direction of movement and one vertical. If it accelerates, it should be possible to calculate the accleration, if you first calculate atan2 of the vertical and the axis in the movement direction, then substract the calibration angle and then calculate the movement strength with sin or cos of the resulting angle, but I didn't proved it mathematically and physically, maybe I'm wrong.

For 3 axis the same should be possible with quaternions when using calibration quaternions. With this concept it should be possible to calibrate roll, pitch and yaw, if you do two calibration measurements: one not moving and one accelerating in a known direction.

Maybe some search with Google will get some papers, because I don't think you are the first person with such a problem.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

Okay, think I understand what you're aiming for. Conceptually, mount the sensor block (the three accelerometers) in the center of a cube, find the apparent acceleration for each sensor at each of the six orientations, and work backwards from the local gravity vector to find the misalignments that would be necessary to yield the observed results. Could be done with three orthogonal faces but flipping it upside down helps to identify other error sources.

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

I think I understand what you are trying to say here.. I understand what needs to be done conceptually, in my head, the problem is with how to actually do the math. I think I may have figured it out though, and please correct me if I'm wrong.

If we stick with the 2-D case of having only X and Y, if I orient the sensor incorrectly such that it's rotated by 10 degrees (since there is no Z-axis, we'll assume it's perfectly flat), then what I should do with any (X,Y) vector that I read out is effectively rotate the vector back by 10 degrees. And I think I can use a rotation matrix

formatting link
It seems to scale to the 3- D case too, but I haven't tried that yet. The Quaternions also seem to do the same thing in the 3-D case, with just a more compact representation and less calculations (which is a good thing!).

So in the 2-D case, I obviously can't use local gravity to figure out the tilt angle since if it's perfectly flat, there will be no gravity component in the X or the Y. But in the 3-D case, the magnitude of (X,Y,Z) should yield close to 1g, and using these (and atan2), I should be able to figure out the 3 rotation angles (I hope), and apply the rotation matrix above.

Noth> jdhar wrote:

s
e

tems.de

Reply to
jdhar

Some math for the 2D case. First a sketch:

formatting link

Assume you have the angle "a" misalignment. Then the vector c is the calibration vector (normalize this to length 1 and normalize all other measurements with the same factor). You can calculate a=atan2(c_x, c_y). If a force in the direction of the x-axis is applied, e.g. the vector v, you'll measure m=c+v_rotated. v_rotated is v rotated by "a" and m=(c_x+v_x*cos(a)-v_y*sin(a), c_y+v_x*sin(a)+v_y*cos(a)). You can solve this for v_x and v_y: v_x = (m_x-c_x)*cos(a)+(m_y-c_y)*sin(a) v_y = (m_y-c_y)*cos(a)+(c_x-m_x)*sin(a) This should work for arbitrary vectors v, not just parallel to the x-axis.

I hope there is no bug in my math, but looks like I have showed that you have to substract the calibration vector first, and then rotate the result back.

Doing the math for the 3D case with quaternions is left as an exercise to the reader :-)

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

Why can't you just remove the offset as some calibration step? Once you do this it shouldn't effec the accelleration at all... after all it is independent of position.

Basically you have two coordinate systems. Think of two axes, one for the sensor and one for the vessel. They should be fixed.

So any change in position or acceleration of one will have the same effect on the other.

Therefor you only need to rotate one to the other. Assuming the axis is orthogonal then there shouldn't be any problem as long as you get your rotations right.

Basically rotate y axis to y, z to z, then x to x, or vice versa but don't mix x to y and so forth.

Look up on the web for 3D rotating and probably euler angles, etc...

Reply to
Jon Slaughter

Frank, firstly, thank you so much for the assistance. I appreciate being able to think this through :)

What I was thinking is this... I take my readings, (X1, Y1), which are uncorrected and are rotated by a certain angle. Can't I just multiply it by the 2-D rotation matrix to get new values? IE:

[X2, Y2] = [cos -sin ; sin cos][X1 Y1] (where the sin/cos angles are the rotation angle)

I tried this out in Matlab, and it seems to work. It looks almost similar to your equations, it's just you subtract the calibration components (c_x and c_y). Is just multiplying it by the rotation matrix incorrect?? The rotation matrix is in essence defined by the calibration since I need to figure out the angle from the X and Y components.

...or they might both be equal to eachother :)

snipped-for-privacy@frank-buss.dehttp://www.frank-buss.de,http://www.it4-systems.de

Reply to
jdhar

What method do you recommend... this is the tricky part in effect. It's not as simple as reading the (X,Y) values at steady-state, and then subtracting them to obtain a zero-offset calibrated value. I still have to deal with the fact that the sensor is rotated, and a motion in one direction will affect the other (due to rotation).

Correct.

Correct.

I personally don't think this would work.. again, think about it this way... lets say the sensor is mountd perfectly. Then a movemente in direction X will yield a non-zero X reading (call it X1), and Y will yield zero. However, if the sensor is rotated even the slightest amount, a movement in THAT SAME X-direction will now yield non-zero X AND Y (call them X2 and Y2). Now I need some way to transform (X2,Y2) to match (X1,Y1). The X2 component needs the Y2 component to determine the proper translation to X1... so I can't just "rotate y axis to y and x to x"... unless I am misunderstanding you. In short, I need to treat the pair as a vector, and not individual axes.

Moreover, this isn't something I can calibrate it; it has to be applied to each sample that I read.

Reply to
jdhar

You must calibrate it out in some way. You must somehow measure the axis then use that.

You don't realize that rotating the axis will fix it up properly.

Take 2D for example.

The transformation equations are

r = x*cos(t) - y*sin(t) s = x*sin(t) + y*cos(t)

suppose they are depenent on time(t is angle of rotation between axis)

then

r' = x'*cos(t) - y'*sin(t) s' = x'*sin(t) + y'*cos(t)

r'' = x''*cos(t) - y''*sin(t) s'' = x''*sin(t) + y''*cos(t)

So your derivatives transform exactly the same way.

e.g., normally in vector notation it is

Y = R*X Y' = R*X' Y'' = R*X''

This means that if you have the inverse matrix R, call it S

then

S*Y = X S*Y' = X' S*Y'' = X''

e.g., you can "unrotate" to get back the original system.

It works and I think your making it more complicated than it is.

The only real issue is that in 3D it's a bit harder since you have 3 angles of rotation that you have to deal with.

In fact, in 3D graphics they almost always use a 4D rotation matrix because it's much easier to do. The problem is that to get an arbitrary rotation in

3D you have to rotate 3 orthogonal directions. This causes problems because the order maters. (R = A*B*C != B*C*A)

Another option is quaternions which also handle the rotations in a relatively simple way.

BUT!!! You have to somehow figure out how "off it is.

This shouldn't be too hard though. Measure the vehicle's position when it is in the perfered axis along one axis only!! (that is important)

To get one of the angles: (example in 2D)

  1. Measure the acceleration along the x axis of the vessel. You will get an r and s value for the acceleration of the accelerometers.

  1. Use the equations given above to solve for the angle

r'' = x''*cos(t) - y''*sin(t) s'' = x''*sin(t) + y''*cos(t)

y'' = 0 since we only moved the vessel in the x direction.

so

r'' = x''*cos(t) s'' = x''*sin(t)

or

tan(t) = s''/r''

So you have the angle t when then allows you to "undo" the rotation by the accelerometer.(just rotate the opposite way)

Its very simple to do for 2D because there is only one angle of rotation. In

3D there are 3 so you have to solve a system of linear equations. It's no big deal though but just make sure that the get the order of rotations correct.

(normally one rotates about different axis. Y = A*B*C*X. So X = c*b*a*Y.)

Unless I'm totally misunderstanding your problem. Simple question: Suppose you could orient your accelerometer perfectly and in any way you want, could you then eliminate the problem?

Reply to
Jon Slaughter

pose

uld

I need to read your post 10 times before I comment on it... but I'll answer this quickly. If I could orient the accelerometer such that it is perfectly flat (ie: perpendicular to gravity), meaning X and Y read

0 and Z reads 1 at steady-state... AND... if I could orient it such that movement of the vessel in a perfectly straight line only results in an acceleration on the X-axis, then yes, the problem that I am describing would not be there.

I actually thought of another issue that I don't think I can solve easily. I don't know if there is a way I can figure out the YAW angle. IE: If the sensor is perfectly flat such that X=3DY=3D0 and Z=3D1, the sensor can still be rotated around the Z-axis (YAW) and there would be no way of me knowing, correct? In that case, I wouldn't know the angle to de-rotate the readings by....

So all of this discussion would not apply to a Yaw offset I think....

Reply to
jdhar

No, I don't think this works. Your readings are the sum of the acceleration in one direction and the earth gravitation, which gives a vector, which is not in the direction of the accleration. But when subtracting the earth gravitation, you can rotate it. If you rotate it before, I think you'll get the wrong result.

As Ken wrote: A good idea would be to write a simulation program. You could try it in Second Life, which has already a physical engine and a simple scripting language, or you could use PyOpenGL or similiar systems for prototyping. I don't like Python, but you can try a Google search with your favorite language, in combination with OpenGL, and chances are good that you'll get a result, e.g.

formatting link
for JavaScript.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

The sensor needs not to be mounted perfectly flat. You can't detect rotating about the z-axis, regardless of the orientation of the sensor. This is the reason why I'm currently evaluating this sensor, in addition with a 3-axis accelerometer:

formatting link

This is much cheaper than currently available 3-axis gyros and has the additional advantage to give absolute orientation measurements (if the earth magnetic field can be measured and is not distorted too much by external magnets) and you can move it as slowly as you want (some gyros have lower limits on how slow you can rotate it for good detection).

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

I need to read your post 10 times before I comment on it... but I'll answer this quickly. If I could orient the accelerometer such that it is perfectly flat (ie: perpendicular to gravity), meaning X and Y read

0 and Z reads 1 at steady-state... AND... if I could orient it such that movement of the vessel in a perfectly straight line only results in an acceleration on the X-axis, then yes, the problem that I am describing would not be there.
--
The its a "simple" calibration issue. i.e., you just have to "fixup" your 
data from the accelerometer before using them in computation. This involves 
 Click to see the full signature
Reply to
Jon Slaughter

I've done something like this with an ocean bottom tilt sensor.

Two accelerometers were used, one on the main PCB and another on a small PCB mounted at right angles. The boards were then potted into a sensor head so they couldn't move. We built a special "tilt calibration" jig that had fluid spirit levels on it, the idea being that you put the sensor head on the jig which could be locked into place at the different axes. Once in place you would read the DC offset value from the accelerometer on the desired axis and then program an EEPOT (programmable EEPROM variable resistor) that nulled out that DC offset directly on the front end circuit from the accelerometer. Do that on all three axis and your sensor head is now "calibrated" relative to a known level plane. You wouldn't need to null it out in circuitry either, just need to record the cal values so you can subtract it later in software.

Very simple and very effective.

I can't find the original schematics though, sorry. Perhaps it's in a Patent we did for this device, I'll try and look it up...

Regards Dave.

Reply to
David L. Jones

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.