Pages: [1]   Go Down
Author Topic: Quadrature Encoder Error Question  (Read 1242 times)
0 Members and 1 Guest are viewing this topic.
NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: September 01, 2012, 01:20:05 am by fiddler » Logged

India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 634
Posts: 34551
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-)
Interesting thing is that you can program it using the Arduino IDE.
http://papilio.cc/

Here is a link to a pretty good summary about quadrature encoders
http://electronics.stackexchange.com/questions/12845/quadrature-decoding

Cheers
Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 638
Posts: 50307
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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).
Logged

Pages: [1]   Go Up
Jump to: