Ted's Home Page Get Firefox! Get Thunderbird! Monday, December 30, 2024, 5:09 pm GMT
    Home :: Contact :: Blog :: Updates (Tue, Feb 12) :: Search :: Highlight Linux :: Apache HTTPD :: PHP :: VIM :: OCS
          email me email me
 
[Ted and a baby giraffe]
 
Contact Me
Résumé/CV
More Information
 
Faculty Job Search
Industry Job Search
Research/Graduate
Work
My Teaching Sites
 
General Posts
(including
LaTeX
templates)
 
Utilities
 
Public hg repos
Public git repos
 
Links
The Blog
 
Guestbook
 
 
 
 
   
 
 
  email me
email me
email me
email me


Comments on Quadrature Encoders :: Good and BAD

So, as usual, with the upcoming FIRST season, I've gotten questions about quadrature encoders. And as usual, like everyone who has either just learned about quadrature encoders or simply has known about them for a long time but never used them, the people who come to me with these questions are extremely excited about these things. Some of them seem to even approach me as if I've never heard of them or had to use them. I know plenty about quadrature encoders, and I know that sometimes the best idea is not to use them.

Contents

Some Background

So I wanted to leave a few words here about quadrature encoders. I especially want to stress that they are not always necessary, especially when used as feedback for drive actuators, and if you absolutely need them, don't take for granted that you can build your own pretty easily.

An example of a commercially built quadrature encoder is given here:

Grayhill Series 25L Mechanical Quadrature Encoder

Shaft Encoders: Detection of Amplitude of Speed of Rotation without Detection of Rotation Direction

A shaft encoder is used to convert rotations of some output shaft into information buried on top of a signal that can be read and processed by a computer. That computer then has some idea of the position of the output shaft.

For example, imagine a spinning disk with slits cut in it at regular intervals. Let's say that the cuts in the disk have an equal arc length as the space between them. As the shaft spins, so does the disk. Now imagine a beam of light positioned perpendicular to the disk. The beam shines through the disk. On the other side of the disk is a sensor that generates a high signal (call it a 1) whenever light hits it. When no light hits it, it generates a low signal (call it a 0). So as the disk spins it either blocks the light or lets it pass. And thus, if the shaft is spinning at a constant speed, the light sensor generates a periodic square wave (...01010101...).

If you can assume that the shaft only spins in one direction, waiting for the next transition (from 0 to 1 or from 1 to 0), it's pretty easily to estimate how far the shaft has rotated. If your shaft is turning a drive wheel, you can thus determine how far you've driven. Of course, you still don't know anything about direction. You could be rotating backwards, forwards, or be changing direction constantly. You simply don't know. In other words, simple encoders detect speed of rotation. If direction of rotation is assumed to be known, then angular position can also be found. Otherwise, simple encoders provide no information about the direction of rotation.

Quadrature Encoders: Direction of Rotation and Increased Resolution

So came things like the quadrature encoder. There are lots of things that I can say about quadrature encoders. I'll leave that for a whitepaper I'll put together later. But let's continue the above example to try to illustrate the idea.

Imagine that your first disk is somewhere near the middle of the shaft. Imagine that the light source and light sensor simply straddle that disk. Now imagine you put a second disk away from the middle of the shaft. Again, put a second sensor stradling the disk. Make sure the second disk is aligned perfectly with the first disk. That is, when looking down the shaft, the disks line up. However, put the second sensor half a cut-out-arc length away from the other sensor. In other words, if the cutouts in the disk span 30 degrees of the circular disk, the sensors are placed 15 degrees apart.

So now rotate the shaft as before at a constant rotational speed. Call the first sensor A and the second sensor B. We then get this waveform out:

A: 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 ...
B: 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 ...

This can be depicted graphically as:

So the two waveforms are identical, but the B waveform is shifted a little to the left.

Now, notice that moving either left-to-right or right-to-left, only one bit (either A or B) changes at a time. Only one bit.

But notice something else. Notice that if you know what state you were previously in, you can decipher what direction you moved. If A did not change, but B changed to match A, then you KNOW that you must be moving from RIGHT-TO-LEFT. Likewise, if B did not change, but A changed to match B, you know you must be moving from LEFT-TO-RIGHT. More specifically, if "A lags B," a LEFT-TO-RIGHT movement is implied. If "B lags A," then a RIGHT-TO-LEFT movement is implied.

It's a beautiful way of deciphering both DIRECTION of rotation AND angular position. And on top of this, because transitions from A occur in between transitions of B and vice-versa, the quadrature encoder provides a major increase in resolution over using only the A or B signal alone (by a multiple of 4).

Good Applications of Quadrature Encoders

Now, if your motor is coupled to an arm by some flexible member, like a spring, then the arm can move relative to the motor. It's not a rigid connection, thus knowing something about the motor's movement does not give you a whole lot of information about the actual arm movement. Thus, coupling the arm's rotational axis with a quadrature encoder allows us to find how the position of the arm moves with respect to the motor. We can use this feedback to move the motor so that it ends up also moving the arm where we want the arm to move.

[ Additionally, the use of the quadrature encoder may actually provide a significant increase in resolution with only a small increase in complexity. Quadrature encoders serve a dual purpose: they provide direction information and increased resolution. ]

BAD Applications of Quadrature Encoders

Now, let's say we're talking about drill motor. Let's say we're talking about a drill motor that has been severely geared down so that many rotations of the motor cause few rotations of the output. Now let's say the output is a wheel. That wheel rotates freely and ends up moving a robot forward and backward.

There is nearly no way to back drive that motor from the wheel. It requires a great deal of force to rotate that wheel even when the motor is not being driven. If the motor is rigged for dynamic braking, and the leads are shorted together, it is even harder to rotate that wheel. Finally, if the motor is being driven in a particular direction, it will be nearly impossible to rotate that wheel manually in any direction but the direction corresponding to the motor's rotation.

And yet people feel like it's necessary to take the time to put a quadrature encoder on their drive shaft. IF the system rotates at all, it will only be due to rotation of the motor. If that robot is ever driven backwards, it will be due to slipping on the ground and not due to rotation of the wheel. However, note that using a quadrature encoder does provide significant gains in resolution (by a multiple of four).

Rules for When and How to Use Quadrature Encoders

There is a simple set of criteria for the for determining when and how to use quadrature encoders. Weigh all options and keep these four simple statements in mind.
  1. So I contend that it is SILLY to use quadrature shaft encoders on drive shafts for detecting direction of rotation. If there's any direction, it will be in the direction of the DRIVEN rotation, which is also known a priori.

  2. And I also think it's silly to attempt to buy your own quadrature encoders and find some crazy way to couple them to a drive shaft when you can just build your own. If you're careful, you can build your own for a measily $10 from RadioShack.

  3. If you're going to gear down your motor anyway, PUT THE ENCODER CLOSER TO THE MOTOR. It GREATLY INCREASES YOUR RESOLUTION.

  4. EVEN IF DIRECTION INFORMATION IS NOT USEFUL TO YOU, QUADRATURE ENCODERS HAVE A RESOLUTION THAT IS FOUR TIMES GREATER THAN THE RESOLUTION OF AN INDIVIDUAL WHEEL OF THE SAME NUMBER OF COUNTS. This ALONE is enough reason to use a quadrature encoder. Just don't worry so much about figuring out direction information.

Example Application

The four rules enumerated above are demonstrated in an example available on the web. In the following link, instructions are given on how to build a quadrature encoder into a hobby servomotor that has been converted to a DC gearhead motor.

It is important to note that:

  1. The encoder wheel is made extremely trivial (only two counts per revolution) because it is painted onto a gear very close to the driven motor end of the gear train.

  2. Placing two encoders 90 degrees apart on one encoder wheel is an effective way to build a quadrature encoder.

  3. The use of the quadrature encoder here is NOT meant to provide a convenient way to detect direction.

  4. The use of the quadrature encoder IS meant to increase the encoder resolution from 52 counts per output revolution to 208 counts per output revolution.


 


appalling appalling
appalling appalling
email me email me
 
1711797 hits
(171 today)
 
Terms of Use
Ted Pavlic <ted@tedpavlic.com>   appalling appalling appalling appalling email me email me GPG Public Key: D/L, View, Ubuntu, MIT, PGP (verified) (ID: E1E66F7C) This Page Last Updated on Tuesday, February 12, 2019, 6:17 pm GMT