# Best sensor for measuring rotation angle?

I've come into an existing design that uses a 2D accelerometer chip to measure a board's rotation angle around a shaft. The board is attached to a motor that drives a gearbox that rotates the shaft, so the motor and board rotate with the shaft. Deriving the angle and calibration of this device is quite complex, is there a simple part out there that say has a high level serial interface that can just tell me the rotation angle? Desired accuracy would be < 1 degree. It's for a solar tracking application so angles are between -85 and 85 degrees, speed of rotation is quite slow.

Thanks if anyone can help, Fred

• No time for a full answer, but try a search on "rotary encoder". – The Photon Nov 6 '11 at 18:36
• Please provide more information, like how does the board rotate? Is it on a spindle? How far round does it rotate? What sort of speeds of rotation? etc. – Majenko Nov 6 '11 at 19:14
• I'd actually like to know absolute angle, e.g. bar is at 5 degrees from horizontal. – fred basset Nov 6 '11 at 19:15
• It SOUNDS as if there is major information missing here. An accelerometer is usually used where something more conventional is hard or impossible to use. This suggests that your pplication is not straight forward and that we need more details in order to help you. || How is the board rotated? Is it on a shaft whose rotation is easily accessed or on a "platform" or stage which is moved in complex ways to cause the rotation or ...? – Russell McMahon Nov 6 '11 at 20:45
• You are getting wild answers because you haven't really explained the problem. Until you give us more information, we can't tell whether the first two answers are more misleading than useful. In any case they are irresponsible because they make serious assumptions about your setup but don't mention these restrictions. – Olin Lathrop Nov 6 '11 at 21:04

1. Rotary encoder
2. Optical Encoder
3. Discrete hall effects at predefined positions (viable if you only need zonal info - BLDC)
4. Linear hall effect sensors either 2off at quadrature & use atan2( via cordic), or 3off at 120deg displacement and use park&clark.
5. resolver

I would say for your requirement two optical encoders slightly displaced from one another to increase the angular resolution

The simplest way to measure rotation angle and angular velocity is to use Stepper motor. Either it is unipolar or bipolar stepper motor (Bi-polar stepper motor is little difficult from unipolar s/m).

The simplest method:

The Unipolar stepper motor has five wires (Mostly used in 5" Floppy Drive) one for ground and other 4 wires are used to send pulse to the motor for its rotation. If you rotate its shaft by hand in clock wise or anti clock wise direction it generates a pulse on its four (Coil ends) wires with some voltage and current respectively.

The stepper motor which I discussed has 7.5 degrees single step rotation angle. That means when you rotate its shaft to 360 degrees motor generates pulses on its each wires 12 times.

In this way you can easily calculate rotation angle. This is the easiest way and it is also tried by my self.

If you don’t know the basics or working of stepper motor.

Here is a good link for you: http://en.wikipedia.org/wiki/Stepper_motor (wikipedia)

• You are using a stepper motor as a rotary encoder, so just a rotary encoder should be your first recommendation. Then if you want you can mention how a stepper motor can usually be used as a rotary encoder. – Olin Lathrop Nov 6 '11 at 20:58
• This may be a tricky task. use suitable gear with stepper motor and the shaft rotating the board. This require some mathematics. – Farid-ur-Rahman Nov 7 '11 at 4:00
• +1 for this info, I know this was posted long time ago but I wish that I can get a clear answer about the resolution that I will get from the motor that you are using – Ahmed Al-sabsab Jun 29 '18 at 21:02

Effectively your board is isolated from an easy accessible mechanical stationary reference point - which explains why somebody has chosen to use an accelerometer.

From your description - the angle varies in two dimensions in a vertical plane as part of a solar tracker.

So, if you don't mind the mechanical aspect, a "weighted pivoted arm" that always hangs downwards, with a rotation sensor mounted in the plane of rotation, will give you an easy and relatively low cost means of measurement.

The rotary encoder used can be almost any sort -

As simple and cheap as a potentiometer with a weight clamped to the arm,
Or a gray-coded disk
Or a magnet fixed to the arm pivoting relative to a GMR or AMR sensor.
Or an optical sensor
Or ... .

Due to the relatively low number of cycles a good quality potentiometer could be a good choice, At one whole return cycle per day, 10 years ~= 4000 cycles - low by most pot standards.

`

• Are you sure that Pot will be a good choice? 10k maybe? – Ahmed Al-sabsab Jun 29 '18 at 21:04
• @AhmedAl-sabsab I don't know how your unstated requirement compares with the poorly specified original so I can not, of course, be sure. But you should be ablke to determine if what I described will work in your application. | The value of the pot resistance depends on the design of the circuit it interfaces with. In a system with say 12V "excitation" the pot draws around 1mA. That may be entirely acceptable, depending on design requirements. If your requirement varies substantially from this question you should ask a new question. – Russell McMahon Jul 3 '18 at 12:32
• Thanks @russell my requirements is to major the angle of the rotating object so Pot will not work. The best solution for my case is an absolute rotary encoder – Ahmed Al-sabsab Jul 30 '18 at 21:04
• @AhmedAl-sabsab As I still know very little about your requirement I can't tell if you are correct. A pot can measure the angle of a rotating object and effectively IS an absolute rotary encoder BUT would often not be as suitable as a contactless encoder. If you want to find what others suggest then posting a new question with as much detail as possible is recommended. – Russell McMahon Aug 1 '18 at 11:25

I would say your best bet in terms of your accuracy specification would be to stay with an accelerometer.

You would however be better off by using an accelerometer with a digital interface such as I2C or SPI ( http://www.sparkfun.com/products/9723 ). There are RS232 serial modules available as well ( http://www.sparkfun.com/products/10537 ).

These devices will provide you with digital values with wich you can calculate the angle. As for accuracy, these devices typically come with selectable sensitivy ranges. For the BOSCH BMA180 to which I linked above the settings are as follows: ±1g, 1.5g, 2g, 3g, 4g, 8g and 16g.

Angle calculation is quite easy and is explained in detail here: http://www.instructables.com/id/Accelerometer-Gyro-Tutorial/#step1

$$R = \sqrt{R_x^2 + R_y^2 + R_z^2}$$

With Rx, Ry and Rz the G values the device outputs. From there you can calculate the angles Axr, Ayr and Azr:

$$A_{xr} = arccos(\frac{R_x}{R})$$ $$A_{yr} = arccos(\frac{R_y}{R})$$ $$A_{zr} = arccos(\frac{R_z}{R})$$

• You should mention that this method only works for finding angle with respect to the down direction. You are basically using the gravity vector as the reference. This tells you nothing about rotation around a vertical axis. Also saying that you are better off with a digital versus analog output accellerometer is not supported by anything the OP has said so far. Each have their advantages, but the OP hasn't said enough to know which advantages matter more. – Olin Lathrop Nov 6 '11 at 21:01
• -1 for myself for hasty answers. You are right. OP should be much more specific. – Konsalik Nov 6 '11 at 21:37
• A good chip to use is the LSM303 as it includes both an accelerometer and a magnetometer and therefore both tilt and direction can be obtained. – geometrikal Nov 8 '11 at 8:15
• -1, sorry but with the current info (which will hopefully be updated) it sounds like a rotary encoder on the primary shaft (so getting the benefit of the gearing for multiplying precision) would give a better result than a MEMS sensor. – John U Dec 11 '13 at 11:18

Use an absolute rotary encoder. If this isn't good for you, explain why.