# How to calculate uncertainty of encoder velocity

I am doing a project where I have to calculate the uncertainty (and 95 % confidence interval) for velocity measurements from an encoder.

The encoder uses pulse timing method to calculate angular speed by measuring the time interval for one state change. It has quadrature output and 1024 ppr, hence the speed is estimated every (360)/(4*1024) degrees, which is 0.088 degrees of rotation. I understand that there are better methods to estimate speed, but this one is already implemented, and I have to calculate the expected uncertainty bounds.

One source of uncertainty is code wheel graduation errors. I found the datasheet of the code wheel used as shown below :  The typical value of position error is shown as 7 arc min which is 0.1166 deg. Max value is 20 arc min which is 0.33 deg

The resolution of the encoder is 0.088 degrees which would mean that every state change (1 count) will correspond to 0.088 deg right ? But the error is bigger than this value ? What am I missing here ? The maximum error is over 3 times the resolution..I don't understand that. Could someone please explain..

I think you're using the formula (360)/(4*1024) because of the term quad in quadrature encoder, but a quadrature encoder doesn't have anything to do with four, it's from the the use of the term to mean two signals that are offset by 90 degrees.

Your quadrature encoder will have TWO encoder rings (not four), and the resolution is 1024, not some multiple of it. What you'll wind up with are two channels, typically A and B, with each encoder wheel being 512 counts per revolution, and then the wheels are aligned in quadrature, meaning they're offset by 90 degrees.

If I use a to mean channel A is low, and A to mean it's high, and b and B similarly, then you'll get the following readings:

ab
Ab
AB
aB
ab


They're not in phase, or it'd go ab then AB, and they're not 180 degrees out of phase, or it'd go aB then Ab. Only when they're 90 (or 270!) degrees out of phase do you get that sequencing. In the example above, A is leading B - on one step A toggles, then on the next step B transitions to the same state as A.

If the encoder is moving in reverse, then A will follow B, like:

ab
aB
AB
Ab
ab


And so you can get both position and direction by monitoring the encoder counts. Here's a handy graphic from the Wikipedia entry on quadrature encoders: And so finally, to answer your question, the actual encoder resolution isn't (360)/(4*1024), just 360/1024 = 0.3516 deg. The maximum angle error is very close to (but less than!) this resolution, but I typically would expect anything within +/- the least significant bit to be noise, so it's not a huge deal.

:EDIT:

The terminology in the encoder documentation is very confusing, notably the "bar and window" and "electrical degrees," so I looked for the "bar and window" term and found the following graphic from another encoder manual: Apparently the "bar and window" refers to the dark and light bands on the encoder wheel. In OP's snippet from the manual: 1 Cycle = 360 electrical degrees
= 1 bar and window pair


I can only assume they're calling them "electrical degrees" to refer to the cyclical nature of an encoder output, which should be 0011 0011 0011, etc. Each "cycle" is "360 electrical degrees" in that, after a full "cycle," the encoder is back to the initial state. This meshes with the concept of a "state width" in "electrical degrees," where

State Width: The number of electrical degrees between a transition in the output of channel A and the neighboring transition in the output of channel B. There are 4 states per cycle, each nominally 90°e.

Further, if the snippet defines Count as:

Count (N) = The number of bar and window pairs or counts per revolution of the codewheel

then as I mention above, if the inner ring has 512 "bar and window pairs," and the outer ring has another 512 pairs, then there are 1024 pairs in total.

I personally think the whole concept of "electrical degrees" is whack and I'd probably prefer to call them encoder transitions or state transitions, but that's just a personal preference.

• Hey, thanks for answering. I have some trouble when I refer to the data sheet though..Please take a look at this section : (freeimage.host/i/SLPdle) . It mentions 4 state changes in 1 cycle, and 1 cycle is defined as 360/(CPR) Aug 3, 2022 at 19:15
• @S_holmes - I added more content to the answer, especially to capture a diagram I found online, but the short version is that a "cycle" is not defined as 360/CPR, it's defined as "1 bar and window pair." You've got an outer encoder ring going aa AA aa AA, etc., so each aa AA is what they're calling a "cycle," which has "360 electrical degrees." There's also the inner encoder ring, which also goes bb BB bb BB, etc., but it's offset by "90 electrical degrees" so you get the following four states per "cycle" - ab Ab AB aB. The terminology is really poor in my honest opinion.
– Chuck
Aug 3, 2022 at 20:35
• Thanks again for taking the time...I really really appreciate it. I want to be convinced..but I'm still a bit doubtful about this. I will check with the operator about the number of encoder state changes in 1 revolution and keep you posted! Thanks again.. Aug 3, 2022 at 23:15
• If there is 512 bar and window pairs in one disc, then for each window bar pair, the encoder has to rotate (360/512) degrees right? and when the encoder rotates through 1 window and 1 bar, it produces 1 complete cycle (AA aa). This is 2 states right ? So if I count 1 state, that means the encoder passed through (360/2*512) degrees right ? That is already (360/1024) degrees with one disc alone. Does that mean for 2 discs we get (360/2*1024) degrees per state ? I thought that in this case it will be called a 512 PPR encoder..I will check with the people and report back about the number of states Aug 3, 2022 at 23:52
• Hey! Im sorry I took so long., but I had a talk with our operator, and he said that the velocity is updated every (360/4*1024) degrees Aug 15, 2022 at 15:29