Encoder Guide
Introduction
Encoders are a type of sensor that measures the movement of a mechanical part. For example, a rotary encoder can measure the rotation of a motor, or the position of a dial or knob. A linear encoder could measure the position of a piston in a robot, or it could be used in a digital calliper to precisely measure the width of the object it's gripping.
In order to interpret the data sent out by the encoder, you need to connect it to an encoder interface. The interface will convert the signals sent from the encoder into a number of "counts" or "cycles" which can be converted into number of rotations based on the encoder's CPR (Counts/Cycles per Rotation). The terminology surrounding this specification for encoders can be confusing because there is no consistently agreed upon term to describe these units. Some retailers may call these "pulses" or they might use any of these terms to describe each edge in the signal. In this document, and the rest of the Phidgets Inc. documentation, we will use the term "Cycle" to refer to a complete quadrature cycle, and the term "Edge" will refer to a single rising or falling edge of a pulse in the quadrature signal.
Encoders are often used in control systems, as a type of feedback to ensure that a moving part is moving exactly as much as planned.
How they work
An encoder has two major components- a read surface (is this the proper term?) and a detector. The read surface is covered with a series of areas that the detector will be able to pick up when it moves across them. (picture of encoder disk, and maybe mechanical) For example, optical encoders use light sensors to read the contrasting sections on the surface, while a mechanical encoder uses brushes to read holes in the surface. The encoder then sends this data out to be processed by the encoder interface. You can learn about the specific details of the wide variety of encoder types in the Types of Encoders section.
Quadrature Encoding
Encoder Interfaces
An encoder interface is a device that converts encoder data into a useful format, such as number of counts and direction of rotation. For example, the 1057_2 reads in a pair of quadrature signals, and uses them to continually update the position of the encoder, automatically taking care of direction changes. These updates are sent to your computer via USB. The encoder interface will also typically provide power and ground to the encoder. Phidgets Inc. encoder interfaces supply +5V, which is a common voltage requirement for many encoders. If you're planning on using an optical encoder with one of our encoder interfaces, you should make sure that it's rated for +5V operation. Mechanical encoders, on the other hand, usually don't use the +5V pin at all- they just use the pull-up voltage on the data lines and switch to ground to generate the signal.
Connector
The encoders available at Phidgets, Inc. have either four or five wires in the connector:
- A Channel - This is one of the output channels the encoder uses to report changes in its position.
- B Channel - This is the other output channel the encoder uses to report changes in its position.
- Index (Optional) - This is an output channel that some encoders have. It sends a pulse every time the encoder makes a full rotation.
- +5V - This wire supplies power to the encoder.
- Ground - This wire supplies a ground to the encoder.
The four-wire encoders still use a 5-wire connector, with the index wire not included. This means you can still use these encoders with encoder interfaces that normally accept 5-wire encoders.
Here's a list of encoder cables available at Phidgets Inc.:
(table: +cable +needs_encoder_input)
Phidgets Product # | Connector Type | Length (cm) |
---|---|---|
3019_0 | Molex | 50 |
3032_0 | E4P | 50 |
- Remember to specify part number for molex connector
Types of encoders
Rotary vs. Linear
A rotary encoder measures rotation and is often used in dials and knobs, or on the shaft of a motor to keep track of its position.
A linear encoder measures distance and is typically used in applications that involve precise linear movement, such as digital callipers, scanners, and various robotic applications.
Absolute vs. Incremental
(picture of absolute and quadrature encoder wheels)
An incremental encoder uses a series of thin lines on the read surface to keep track of its position. The most common kind of incremental encoder is called a quadrature encoder, which uses two sets of these lines, slightly offset. This allows the encoder to detect the position relative to the starting position, even if the encoder changes direction. Incremental encoders provide output in the form of a series of pulses. This topic is explained further in the Output Circuit section.
An absolute encoder uses a pattern of concentric rings on the read surface to keep track of its position. Each ring provides additional accuracy- the innermost ring reveals which half of the encoder the sensors are currently on, the next one shows which quarter of the encoder the sensors are reading, and so on. The advantage to an absolute encoder is that you can immediately tell the position of the encoder as soon as it turns on, since each position on the encoder wheel corresponds to a unique sequence of binary bits. The downside of an absolute encoder is that they are much more expensive than incremental encoders.
Read Method
Mechanical encoders consist of a metal disc or strip with slots cut into it which moves beneath a series of wire brushes. When the brushes are over the slot the circuit remains open, but when the brushes contact the read surface they close the circuit. Because of their physical complexity, mechanical encoders need to be larger than the alternatives to get the same degree of accuracy. They are rarely used for high-speed applications because the faster they move, the more likely it is that the encoder signal will be lost in noises caused by the brushes. Also, the brushes wear down rather quickly in high-speed applications.
Optical encoders work on a similar principle as mechanical encoders except the read surface has a number of visual areas instead of slots. A light source in conjunction with a set of photo detectors perform the same function as the wire brushes in a mechanical encoder.
Magnetic encoders have a series of magnets on the read surface and use Hall Effect sensors to measure the position.
Capacitive encoders work by sensing the capacitance between reader and scale. They are inexpensive and can be made thinner than other types of encoders. The main downside is that they are vulnerable to foreign materials such as dust or dirt.
Output Circuit
Absolute encoders report their position in the form of a series of binary bits (one bit for every ring on the encoder). Some encoders convert this binary data to BCD, or gray code before sending it out.
Incremental encoders have varying methods of output, which affect the resulting waveforms. These methods of output can be classified as either a Single-Ended Signal or a Differential Signal.
Single-Ended Signal
In the case of mechanical encoders, the brushes simply switch to ground. The most basic optical encoders will similarly use phototransistors to switch to ground. This method is called "Open Collector". These devices require pull-up resistors in order to generate the output waveform. They may be included in the encoder, or they may rely on the encoder interface to provide them. Phidget Inc.'s encoder interfaces come with fairly weak pull-up resistors built in. If your encoder requires an external pull-up resistance greater than the Phidgets Inc. interface provides, you won't be able to use the encoder with Phidgets. If your encoder needs a lower pull-up resistance (and therefore, a stronger pull-up resistor), it may still work, but at a lower response rate. If you want to make the pull-up resistor stronger, you can add pull-up resistors on the cable. (show picture/diagram)
A "Line Drive" output circuit is the opposite of an open collector output- each phototransistor is connected to a pull-up resistor, so they need pull-down resistors or a sinking input to generate the output waveform. Phidgets Inc. encoder interfaces will not work with line drive encoders, because the interface does not come with built in pull-down resistors.
Another output circuit design called "Push-pull" combines the two methods above, connecting each phototransistor to both a pull-up and a pull-down resistor. A push-pull encoder will still work with a Phidgets Inc. encoder interface- the built-in pull-up resistors are unnecessary but won't cause any problems. Push-pull encoders are desirable because the output waveform can quickly transition from 0 to 5V. A shorter transition time allows the encoder to track faster movement. Another advantage of push-pull is that the output signal is less susceptible to electromagnetic interference, because the output is always strongly connected to either +5V or ground.
Differential Signal
Differential encoders greatly reduce susceptibility to noise by starting with a push-pull encoder and then adding an additional push-pull driver for each signal line (A, B and I). In each driver pair, one driver is always transmitting the opposite of the other. This redundancy allows each signal to be interpreted relative to its inverse, rather than relative to ground. Since two wires in the same environment will experience very similar interference, the differential encoder interface (do we call this a DAQ?) will be able to tell the difference between a real pulse and noise. (diagram illustrating this difference?) Another advantage of a differential encoder is that it emits less electromagnetic interference. Phidgets Inc.'s encoder interfaces do not support differential encoders, although as long as each signal is still in the form of 0-5V pulses, you could just hook up the non-inverted wire from each pair.
Interference
One of the main concerns for encoders is their vulnerability to interference. The encoder reports how far it has moved or rotated by generating a series of pulses. If interference causes an extra pulse to be detected by the encoder interface, it gradually loses track of the encoder's true position. This is especially true when the cable between the encoder and interface is very long. If your encoder is detecting extra counts, or missing counts, there may be electromagnetic interference in your environment. A good way to test for interference is to keep the encoder stationary and monitor it to see if it registers any counts. If you have an open collector encoder, it will be more susceptible to noise when the A and B lines are at +5V, as opposed to ground.
The heavyweight solution to interference is using a Differential encoder and interface. For a cheaper and more practical solution, you can use a single-ended encoder and connect it to the encoder interface with a section of shielded cable. Shielded encoder cables can easily be made from USB cables. (show picture)
Choosing an encoder
The first thing to consider when choosing an encoder is what degree of accuracy you are going to require. Is the application a simple human interface (knob or something similar) or are you trying to precisely track the movement of a motor? Mechanical, magnetic, and capacitive encoders have the advantage of being extremely cheap. So even though they don't have as high accuracy as optical encoders, for applications that don't require it such as turning a knob on a control panel they are ideal. For any situation where you need modest to high accuracy, you only real choice is an optical encoder.
Products that fall under this category
- 1047 - PhidgetEncoder HighSpeed 4-Input
- 1057 - PhidgetEncoder HighSpeed
- 1052 - PhidgetEncoder
- 3530 - Optical Rotary Encoder ISC3004
Glossary
Connector
- Specify our standard encoder connector
- Steal from the 1047/1057 product manual
- Spec the connectors part numbers involved
- List of cables for encoders
Response Frequency
- If we are considering an encoder, this is one of the specs that dictates the maximum speed the encoder can turn at.
- This is the internal limitation of the electronics in the encoder. For a given encoder, this limits the maximum number of pulses/counts it can interpret per second.
- This spec should probably be destroyed, and replaced with a upper limit on how fast the encoder can turn (in RPM)
- Each encoder will have a limit dictated by the lower of the maximum mechanical rotation rate, or the response rate of the electronics.
- Is the ICS3004 360 PPR spec based on counts or pulses?
- The maximum response of a mechanical encoder depends on the amount of contact bounce. Once the encoder is turning fast enough, individual switch closures are lost in the noise.
Supply Voltage
- We should consider specifying for the encoder interfaces that they provide +5V to the encoder.
- Any encoder that connects to Phidgets should be rated for +5V operation.
- This spec is not important for mechanical encoders, that are just a series of switches. In fact, a mechanical encoder doesn't even use the +5V power supply.
- Optical encoders use the power supply for (among other things) powering LEDs. Usually optical encoders will have a series resistor on the LED to limit the current to an optimal value. If you are using an optical encoder not sold by Phidgets, please check the datasheet to ensure the LED current is limited internally - otherwise, you might have to put a series resistor on the +5V line.
Number of Pulses
- Consider renaming, or standardizing
- Counts is the lower resolution spec
- Pulses is the higher resolution spec.
- Do a survey, and figure out what is most prominent.
- We'd also have to standardize in our code samples and API documentation.
- 1065_0 returns the lower resolution value.
- Consider giving both as specs, so customers who have the wrong model (by our standard) can see the difference and infer what we mean.
Output Circuit
- In the case of a mechanical encoder, the output circuit is just switches to ground.
- In the case of optical encoders, there are a lot of different options.
- Very simple optical encoders will use phototransistors as a 'switch' to ground.
- Also called open collector.
- These encoders may have pullup resistors built into the encoder, or they may rely on the interface to provide them.
- Phidgets encoder interfaces have reasonably weak pullup resistors built into them.
- If your encoder specifies an external pullup of greater resistance than the Phidget has integrated, you won't be able to use the encoder with Phidgets.
- If your encoder needs a lower resistance (a stronger pullup), it may still work, but at a lower response rate. If you want to make the pullup stronger, you can add pullup resistors on the cable. (Show picture / diagram of this)
- Open collector is an example of a single ended drive - as opposed to differential.
- Push Pull optical encoders have more complex electronics, and they can actively drive the A/B lines high or low. The Phidget still has pullup resistors - which are not necessary, but in practice they don't cause any problems.
- Another way of saying this is that Push Pull optical encoders can respond much more quickly than the photo transistor based optical encoders - because they are not relying on pullup resistors, which have to be weak by definition. The push pull electronics can very quickly drive the cable to 0 or 1.
- Push pull is an example of a single ended drive - as opposed to differential.
- Differential output optical encoders
- Differential outputs use two push-pull drivers per signal line (A, B, I). In each driver pair, one driver is always transmitting the opposite of the other. The benefit of differential is it will emit less electromagnetic interference, and is less susceptible to electromagnetic interference on the cable introducing extra counts.
- Phidgets do not support differential optical encoders. US Digital makes an adapter board (find part number), which will convert differential signals to single ended, so differential encoders can be used with Phidgets.
- Making your encoder more immune to electromagnetic interference.
- If you are finding that your encoder is showing extra counts, or losing counts during operation, there may be electromagnetic interference in your environment, coupling into the cable.
- A good test is to leave the encoder not moving. If your encoder is open collector, it will be more susceptible to interference when the A/B lines are at +5V (as opposed to ground). If any counts appear as the encoder is still, interference is likely to blame.
- The heavyweight solution is to use a differential encoder.
- A more practical solution is to make a shielded cable.
- USB cables are easily repurposed as shielded cables.
- Show picture of USB Cable chopped up, soldered onto encoder jacks.
MAX RPM
- Merge this with the maximum RPM based on electrical limitations,
- We could indicate whether this is a mechanical or electrical limitation.
Maximum Count Rate
- For encoder interfaces
- This is the maximum count/pulse rate that the interface can receive without losing pulses.
- Have to standardize if we are talking about high or low res spec.
Internal Output Pullup Resistance
- Discussed above
- Customer can put resistors on cable in parallel if they want to lower resistance. - Put resistors on A/B channels, to +5V.
Software Update Rate (typical)
- This is how often the number of counts / pulses that have been recognized is streamed up to the PC.
- Customers often think that when they call a function, we poll the device, but actually the data is being streamed at a constant rate, and they are retrieving the latest values received by our libraries.
Encoder Input Low Voltage
- The encoder must output (on A/B/I) a voltage below this specified value to be absolutely sure the interface will interpret the signal as a 'Zero'.
- If you are unsure, you can use a multimeter to measure the voltage on A/B/I. This does not guarantee that this voltage spec will be achieved as the encoder is being operated at high speed. If you are unsure, and you have an oscilloscope, you can monitor the voltage on A/B/I during operation. Alternatively, you can operate the encoder at greater speed than you will see in your application and verify it does not lose counts.
Encoder Input High Voltage
- The encoder must output (on A/B/I) a voltage above this specified value to be absolutely sure the interface will interpret the signal as a 'One'.
- See comments above.
List of encoders
- Sourced from Digikey
- Customers should look for encoders that advertise 'Quadrature'
- Encoders often advertise 'detents' - which are perceptible clicks as the encoder is rotated. Encoders with detents are usually meant for operation by people as control knobs.
- Encoders for manual (people) operation will often have a built in pushbutton switch on the shaft. This functionality is seperate from the encoder. Encoder interfaces available from Phidgets will often have support for digital inputs - this switch can be wired in to a digital input.
Mechanical encoders
- Mechnical encoders are usually very cheap, and meant for manual (people) operation.
- Mechanical encoders will have a shorter lifespan, measured in the number of rotations.