Finding angle in cell phone using accelerometer

In summary: I'm not sure what the "sine of" is but it's probably a mathematical function. If you want to find the orientation of a 3D object, you need at least two vectors. The gravity vector gives you one. An xyz accelerometer can give you the other. If the phone is not rotating, both accelerometers are going to be pointing in the same direction. So really, you have one vector you can work with, and that's the gravity vector. That means that if you tilt the phone vertically in x/y/z (like the difference between you holding the phone to your face and the phone lying on the desk). But if you put the phone on your desk, and then keeping it flat,
  • #1
deck123
3
0
I am using a cellphone with 2 accelerometers in it. So, in all I have 2*3 readings from accelerometer ( 3--> x,y, z axis). I am trying to find the orientation (up and down) and the tilt/angle of the cell phone. The cell phone won't be kept in the horizontal surface, instead it would be rotated in 360 degrees.
Any help would be appreciated.
 
Engineering news on Phys.org
  • #2
If the phone is not rotating, both accelerometers are going to be pointing in the same direction. So really, you have one vector you can work with, and that's the gravity vector. That means that if you tilt the phone vertically in x/y/z (like the difference between you holding the phone to your face and the phone lying on the desk). But if you put the phone on your desk, and then keeping it flat, spin it 180 degrees, you can measure the acceleration of the spin, but once that stops there's no way to know for certain which way you're pointed. You can try to be fancy and say, "well I was accelerating in this direction, for this long, so I was probably going this speed for this long, so I am probably here" But this means that any error will just keep adding and adding with no way to know for sure where you're pointing.

I think this is what you're asking.
 
  • #3
If I understand your problem correctly you want your phone to know its 3D orientation. You need at least two vectors to do that. The xyz accelerometer produces a gravity vector that goes straight down. An xyz magnetometer can provide a second vector that is horizontally towards magnetic north and vertically downward in the northen hemisphere. The cross-product of these two vectors will be horizontal the magnetic east-west directions and the cross-product between the east-west vector and the gravity vector will be horizontal in the magnetic north-south directions. Formulas exist for converting magnetic to geographical north although I don't know them offhand. An xyz accelerometer by itself produces just the gravity vector, which could allow you to use your cell phone as an electronic bi-directional level (lateral and axial to the orientation of the accelerometer).
 
Last edited:
  • #4
InTuoVultu said:
If the phone is not rotating, both accelerometers are going to be pointing in the same direction. So really, you have one vector you can work with, and that's the gravity vector. That means that if you tilt the phone vertically in x/y/z (like the difference between you holding the phone to your face and the phone lying on the desk). But if you put the phone on your desk, and then keeping it flat, spin it 180 degrees, you can measure the acceleration of the spin, but once that stops there's no way to know for certain which way you're pointed. You can try to be fancy and say, "well I was accelerating in this direction, for this long, so I was probably going this speed for this long, so I am probably here" But this means that any error will just keep adding and adding with no way to know for sure where you're pointing.

I think this is what you're asking.

Thanks for the reply.
Actually measuring acceleration in not my main issue. I am using accelerometer for my convenience. I need to find the orientation in the 3d sphere of the phone, i.e. angles in the 3d space. I need the angle information to convert xyz values of accelerometer data to a particular direction from the orientation the cellphone is currently placed.
 
  • #5
If you want 3D orientation you need two vectors. Gravity gives you one. A magnetometer can give you the other.
 
  • #6
MurrayMD said:
If you want 3D orientation you need two vectors. Gravity gives you one. A magnetometer can give you the other.

THanks for the reply.. I looked around and couldn't find the formula that u mentioned in the previous post. Can you give me a link to it.
 
  • #7
Wikipedia's article on magnetic declination has a link to the National Geophysical Data Center (NGDC) where there's an online geomagnetic declination calculator and other useful links: http://www.ngdc.noaa.gov/geomagmodels/Declination.jsp

Geomagnetic north changes over both both time and location (due to factors like hematite and magnetite in the Earth's crust) so maps can become outdated quickly. If you just want to find your way out of the woods or get a Boy Scout badge the maps will work fine but if you're drilling for oil and want to hit your target within 5 feet at five miles down you might be inclined more towards the calculator!

At least I think that's what you were asking. A cross-product (e.g. a x b) is a geometric operation between two vectors "a" and "b" whose magnitude is the product of a,b and the sine of the angle between them, i.e. ab sin(theta) and whose direction is perpendicular to the plane defined by the first two vectors. (It's in the Wikipedia as well; just Google "cross-product wiki") The direction can be one of two (opposite to each other) and follows the "right hand rule" where if you were to physically grab the cross-product vector with your right hand with your thumb out and pointing in the same direction, the vector closest to your knuckles would be the "a" vector and the vector closest to your fingertips would be the "b" vector. If you reverse the order of the multiplication to "b x a" the cross-product will be in the opposite direction.

The reason for the cross-products is to take your two available vectors, magnetic north and gravity and build them into a 3D Cartesian coordinate system whose three principal axes are 90 degrees apart. The magnetic declension will give you the angle from magnetic north you need to rotate your coordinate system to align it to geographical north.
 
Last edited by a moderator:

FAQ: Finding angle in cell phone using accelerometer

1. How does an accelerometer work in a cell phone?

An accelerometer is a sensor that measures the rate of change of acceleration of an object. In a cell phone, it detects the movement of the device and sends this information to the phone's processor. The processor then uses algorithms to calculate the angle at which the phone is tilted.

2. What is the purpose of finding the angle in a cell phone using an accelerometer?

The purpose is to determine the orientation of the cell phone, which is used for various features such as auto-rotation of the screen, motion-controlled gaming, and step tracking in fitness apps. It also helps to keep the screen from rotating when the device is held at a certain angle.

3. How accurate is the angle measurement from an accelerometer in a cell phone?

The accuracy of the angle measurement depends on the quality of the accelerometer and the algorithms used by the phone's processor. In most cases, it is accurate within a few degrees, which is sufficient for the intended purposes.

4. Can the angle measurement from an accelerometer be affected by external factors?

Yes, external factors such as temperature, electromagnetic interference, and mechanical shocks can affect the accuracy of the angle measurement. However, modern cell phones have advanced sensors and algorithms that are designed to minimize these effects.

5. Is it possible to calibrate the accelerometer in a cell phone to improve the accuracy of the angle measurement?

Yes, some cell phones have a built-in calibration feature that allows users to manually adjust the accelerometer's sensitivity and improve the accuracy of the angle measurement. This is especially useful in situations where the phone is used in extreme conditions or when it is not functioning properly.

Back
Top