How do to sense 1 or 0.5 Degrees

I have a requirement to measure the angle of a shaft, every 1 degree , ideally every 0.5 degrees (shaft rotation speed is not a requirement, the shaft will be positioned by hand).

I have done some reading and understand how resolution and accuracy are different, but I am trying to understand which encoder to buy, that will meet my requirements.

My main issue, trying to get my head around, is how I will be able to measure 0.5 or 1 degrees with resolutions (CPRs) that do not divide into 360 degrees.

For example, if I purchase an encoder with a resolutions of 1024 counts per revolution (CPR). How can I measure 1 degree, if the smallest measurement I can make is 0.3515625 degrees.

0.3515625 does not divide into 1, or 0.5 degrees.

I understand the theory, that I could find a 360 CPR or 720 CPR encoder, but actually finding one is proving difficult. I do not want to spend more than £100 ideally.

I also understand that I can use quadrature code to increase the resolution of say a 180 CPR encoder to 720 CPR, but I do not want to sacrifice accuracy. I've read that using quadrature code might reduce the accuracy because it essentially magnifies any errors in the system.

It sounds like a simple arithmetic scaling problem.
If the input for 0-359 is 0-1023, then a translation is simply
deg = input * 360 / 1024
in C
int deg = input * 360L / 1024;

Trying to understand...

For example, say the encoder has rotated 3 counts:

3 x (360/1024) = 1.0546875 degrees.

This doesn't solve my problem of trying to measure 1 degree. Sorry if I do not understand.

No, it's integer math. Also commutative operations are performed left to right, so it's
(3 x 360)/1024.

3 x 360 = 1080
1080 / 1024 = 1.

So, 1 degree.

1080 / 1024 = 1.0546875

So it is 1 degree with 0.0546875 error.

This gets worse as you go on. For example if I want to measure 5 degrees I can chose the 14th of 15th count on the encoder:

14th = 4.921875 (0.078125 error)
15th = 5.2734375 (0.2734375 error)

I do not think scaling will help will it? Because the physical CPR on the shaft need to be integer divisors of 360 to measure every 1 degree of rotation?

Dude, the errors are not cumulative. That is just wrong.

There is no magic software function that can read the position of a hardware encoder in between states. So if you were hoping for that, forget about it right now.

No measurements are perfect. There is always an error. The question here is, what error is acceptable to you? If you have to measure a position to within one degree and you have a sensor that can measure it to within 0.35 degrees, most people would say that you've achieved your requirement.

Clearly you don't think so, so what's the real requirement?

3 Likes

It sounds like you want to position the shaft every 1 or 0.5 degree. That is a completely different requirement than measuring.

If so, state the required positioning accuracy.

1 Like

I do not really know what I was hoping for haha! I was just asking the question to try and understand the situation I was in.

I am not adding the error each time, I am just taking the count on the encoder wheel that is closest to the degree I want to measure, and calculating the error of the potential scaled value (I think!).

For example, measuring 359 degrees:

deg (359) = 1021 * 360 / 1024 = 358.9453125

1021th count = 358.9453125 (0.0546875 error)

My current understanding, thanks to your help, is that my eventual code will either need to display the decimals after the integer so a user can determine when the shaft is closest to 1 degree, or my code will need to determine when a degree is registered (threshold).

E.g. for a transition between 4 and 5 degrees:

8th = 2.8125
9th = 3.1640625 (3 degrees)
10th = 3.515625 (3.5 degrees)
11th = 3.8671875 (4 degrees)
12th = 4.21875
13th = 4.5703125 (4.5 degrees)
14th = 4.921875 (5 degrees)
15th = 5.2734375

From this thread, I do not really understand my requirement. Instead of saying I want to measure the shaft angle each degree, I should state how accurate I want the measurements to be. This is a good learning experience.

I guess I also want to understand how to make the scaling in the code decide when a degree should be displayed.

Ah, I think you've hit the point. Because I am turning the shaft by hand, I wanted to measure the shaft angle and display it, so my thoughts were on the sensor detecting each degree.

But really, I manually want to position the shaft every degree. Although I am not using a motor, I am still positioning it and not measuring it. Sorry aarg and cedarlakeinstruments.

Great, but please state the required positioning accuracy. You can buy 4096 cpr shaft encoders, for better than +/- 0.05 degree position error

1 Like

I guess I need to sit down and think about that requirement now.

From what you and cedarlakeinstruments are saying, a 1024 encoder would have a positional accuracy of 0.3515625 degrees?

If you want to position the encoder on exact positions, those positions have to match the encoder sensor positions. So to do this you have to either

  1. Use a 360 position encoder
  2. Use an encoder that has '360*n' positions where n is an integer
1 Like

IDK you did the math. Positional accuracy would be 360/1024 degrees...

adding to what I posted above... if the truncation error if the number of position is not a a multiple of 360, becomes less and less as the number of positions increases...

As a thought experiment, if it has a million positions, obviously it will be easy to resolve 360. Even though, 1000000 is not a multiple of 360.

1 Like

With a 1024 cpr encoder, the step size is 0.35 degrees.

The nearest full degree is often less than one full encoder step away, so the actual positioning error depends on the shaft angle.

1 Like

I assume a human is going to be twisting the 'knob' on this..? If so, how accurate can a person set a knob?

Seem like it's not easy to set a regular knob to one place in 360 very easily... maybe if the knob is the size of a steering wheel...

Maybe your requirements are a bit more strict than need be?

:smiley_cat:

1 Like

Suggestion: attach one of these to the shaft: https://www.aliexpress.com/i/2251832706337001.html
Capture

2 Likes

Thank you all.

I need to have a long hard look at myself, sorry, this problem, and see what I actually want out from it.

Years ago for industrial applications I used BEI Motion Encoders. When selecting an encoder the more PPR (Pulses Per Revolution) the greater the resolution you had. For example one revolution is 360 degrees. If I have 3600 PPR I get 360 / 3600 = 0.1 degree resolution. High end quality encoders come with a price. Also a good quadrature encoder affords direction of rotation. You can increment a count and decrement a count to get back to where you started from. :slight_smile: Just a matter of defining in detail your application and price point(s).

Ron

1 Like

Thanks Ron :slight_smile: