Encoders - Hardware
This section covers encoder hardware. For a software guide to encoders, see Encoders - Software.
Encoders are by far the most common method for measuring rotational motion in FRC®, and for good reason - they are cheap, easy-to-use, and reliable. As they produce digital signals, they are less-prone to noise and interference than analog devices (such as potentiometers).
Types of Encoders
There are three main ways encoders connect physically that are typically used in FRC:
These encoders vary in how they are mounted to the mechanism in question. In addition to these types of encoders, many FRC mechanisms come with quadrature encoders integrated into their design.
There are also three main ways the encoder data is communicated that are typically used in FRC:
Some encoders may support more then one communication method
Shafted encoders have a sealed body with a shaft protruding out of it that must be coupled rotationally to a mechanism. This is often done with a helical beam coupling, or, more cheaply, with a length of flexible tubing (such as surgical tubing or pneumatic tubing), fastened with cable ties and/or adhesive at either end. Many commercial off-the-shelf FRC gearboxes have purpose-built mounting points for shafted encoders.
Examples of shafted encoders:
On-shaft encoders couple to a shaft by fitting around it, forming a friction coupling between the shaft and a rotating hub inside the encoder.
Examples of On-shaft encoders:
Magnetic encoders require no mechanical coupling to the shaft at all; rather, they track the orientation of a magnet fixed to the shaft. While the no-contact nature of magnetic encoders can be handy, they often require precise construction in order to ensure that the magnet is positioned correctly with respect to the encoder.
Examples of magnetic encoders:
The term «quadrature» refers to the method by which the motion is measured/encoded. A quadrature encoder produces two square-wave pulses that are 90-degrees out-of-phase from each other, as seen in the picture below:
Thus, across both channels, there are four total «edges» per period (hence «quad»). The use of two out-of-phase pulses allows the direction of motion to be unambiguously determined from which pulse «leads» the other.
As each square wave pulse is a digital signal, quadrature encoders connect to the digital input ports on the roboRIO.
Examples of quadrature encoders:
AMT103-V available through FIRST Choice
Quadrature Encoder Wiring
Quadrature Encoders, such as the E4T OEM Miniature Optical Encoder, can be wired to two digital input ports as shown above.
Some quadrature encoders have a third index pin which pulses when the encoder completes a revolution.
Quaderature Encoder Resolution
The acronyms «CPR» and «PPR» are both used by varying sources to denote both edges per revolution and cycles per revolution, so the acronym alone is not enough to tell which is of the two is meant when by a given value. When in doubt, consult the technical manual of your specific encoder.
As encoders measure rotation with digital pulses, the accuracy of the measurement is limited by the number of pulses per given amount of rotational movement. This is known as the «resolution» of the encoder, and is traditionally measured in one of two different ways: edges per revolution, or cycles per revolution.
Edges per revolution refers to the total number of transitions from high-to-low or low-to-high across both channels per revolution of the encoder shaft. A full period contains four edges.
Cycles per revolution refers to the total number of complete periods of both channels per revolution of the encoder shaft. A full period is one cycle.
Thus, a resolution stated in edges per revolution has a value four times that of the same resolution stated in cycles per revolution.
In general, the resolution of your encoder in edges-per-revolution should be somewhat finer than your smallest acceptable error in positioning. Thus, if you want to know the mechanism plus-or-minus one degree, you should have an encoder with a resolution somewhat higher than 360 edges per revolution.
Duty Cycle Encoders
Duty cycle encoders connect to a single digital input on the roboRIO. They output a pulse where the length of a pulse is proportional to the absolute position of the encoder.
Examples of duty cycle encoders:
Analog encoders connect to a analog input on the roboRIO. They output a voltage proportional to the absolute position of the encoder.
Examples of analog encoders: