Quadrature Encoder Error Question

I have a commercial quadrature encoder (1000ppr) connected to an Arduino board and using the Encoder Library from PJRC
http://www.pjrc.com/teensy/td_libs_Encoder.html

All working good and its counting fine.

However I notice that there are no error detection nor Z (index) reading in the library.
I would like to check for errors be it either a faulty encoder, to much counting or noise.

I have googled, but haven't found anything so far

Anyone knows of any libraries ?

Kim

If you are good in programming please see my post ' Convert C into arduino uno 3' page 2 has a encoder code.

I'm curious. How does one detect sensor errors without having multiple sensors? Do you look for continuity in the speeds?

Is z index reading where the encoder outputs a different pulse less often?

How does one detect sensor errors without having multiple sensors?

Generally you are write, however:-
In this case the two bits have a pattern. For any one pattern there are two valid patterns that happen next, one for clockwise and the other for anti clockwise. This leaves one transition that is not valid. If you see that, it is an error.

However I notice that there are no error detection nor Z (index) reading in the library.

A basic 2 channel quadrature encoder is just a device where one can get rate information (i.e. speed if counting the steps received per fixed time period) or the total accumulated absolute step counted CW or CCW from start of the program. A 'Z' channel is an optional 3rd added channel for some encoders that gives a single pulse, once per revolution of the shaft. This added channel can be used to determine the absolute position of the shaft at any given time or used as a speed indicator pulse if desired. I've never seen a general purpose encoder library that supported a Z channel input, so I think you would be pretty much on your own to include it's capabilities, although it is not a particularly difficult task.

Lefty

Yes, the Z output gives you one pulse per revolution.

So you can use the Z output to read the count and determine if the count is correct.
If you encoder has X count per revolution, then each time Z signal occurs, it should be in multiple of this count.

And I guess you could also measure the length of each signal, A and B, to filter out noise, however a hardware filter may be a better solution.

Also most commercial quadrature encoders has the following 6 outputs, A, A Not, B, B Not, Z, and Z Not.
I'm not sure if the "A" and "A Not" signals are just inverted (but otherwise aligned) of the same signal or if they are in fact a separate measurement/signal, but by comparing both signals you should be able to guard against some errors at least.

BTW, this is for position control.

Kim

Grumpy_Mike:

How does one detect sensor errors without having multiple sensors?

Generally you are write, however:-
In this case the two bits have a pattern. For any one pattern there are two valid patterns that happen next, one for clockwise and the other for anti clockwise. This leaves one transition that is not valid. If you see that, it is an error.

Yes, only one bit of the 2 bits can change at anyone time, ie you cannot have both bits change at the same time.

Also most commercial quadrature encoders has the following 6 outputs, A, A Not, B, B Not, Z, and Z Not.
I'm not sure if the "A" and "A Not" signals are just inverted (but otherwise aligned) of the same signal or if they are in fact a separate measurement/signal, but by comparing both signals you should be able to guard against some errors at least.

Not exactly. Many industrial encoders make you state the output type option you wish to have when you order them. The A and NOT A you describe is a full differential output option (and yes one is just the inversion of the other), best for long cable runs as it has better noise handling ability and double the signal to noise ratio over single ended outputs, however it has no 'error detecting' abilities over any of the other output options. Other optional output types are single ended output at various voltage levels (5v, 12v, 24v are common options) and finally open collector output option. Each option as an advantage for certain installations.

Well, yes, that should of course have been: a common output configuration is A, A Not, B, B Not, Z, and Z Not.

The 2 bit pattern comparison should guard against noise and going to fast for the micro type scenario.
Using the Z input should guard against counting errors.

Should be good enough for me for now.

Will start to work on the library.

Cheers
Kim

After some more thoughts, I have decided to do the Encoders in a FPGA, mainly because I will need interrupts in other parts of the program as well and also think that it will get too slow for what I want to achieve.

Papilio has some boards and I got both the 250K and 500K in my hands :slight_smile:
Interesting thing is that you can program it using the Arduino IDE.

Here is a link to a pretty good summary about quadrature encoders

Cheers

Problem with error detection and such is that it takes TIME. Better to build the encoder and wiring for reliability rather then trying to clean up a dirty signal.You also want a circuit that can function at a higher rate than the operating rate so you don't lose counts because the decode circuitry can't keep up. Make sure the errors can't get in is generally easier than trying to figure out how to catch errors and correct them.

Make sure the errors can't get in is generally easier than trying to figure out how to catch errors and correct them.

Truer words were never spoken (written).