1. Introduction to Coders
Encoders are a type of sensor mainly used to detect speed, position, angle, distance or count of mechanical movement.
In addition to being used in machines, many motor controls, such as servo motors, require encoders to provide feedback for commutation, speed, and position detection to the motor controller.
2. Classification of encoders
The encoder can be divided into analog encoder and digital encoder. The analog encoder can be divided into rotary transformer and Sin/Cos encoder, while the digital encoder can be divided into incremental encoder and absolute encoder.
3. Working principles of commonly used encoders
3.1 Principle of digital encoders
1) Use photoelectric couplers to digitize a segmented disk installed on a mechanical shaft.
The mechanical code is converted into proportional electrical pulse signals.
The light source (usually an LED) emits a narrow beam of light toward the receiver (which may be a photodiode). Both the light source and receiver are strictly installed on stationary parts of the rotating connecting bearing.
The encoder is a shading disc with a transparent opening or window, which is installed on the rotating part of the bearing.
3.2 Principle of photoelectric digital encoders
When the bearing rotates, the encoder allows the beam of light to alternate (pass through the small window in the disc).
The photodiode emits corresponding high or low level signals as the position changes. The output of the photodiode can be converted into position and velocity information through a specialized circuit.
3.2.1 Incremental Encoders Output
The output of the incremental encoder consists of a central axis photoelectric disk with transparent and opaque circular markings, which are read by the photoelectric sender and receiver components to obtain combined square wave signals as A, B, -A, -B.
Each pair of signals has a C phase difference of 90 degrees (one cycle equals 360 degrees).
In addition, there is a zero point calibration signal and the encoder outputs a signal per rotation of the disk.
3.2.2 Connection principles of incremental encoders
1. Single-phase connection
Used for one-way counting and one-way speed measurement.
2. AB two-phase connection
Used for two-way counting and determining direction and speed.
3. Three-phase ABC connection
Used to determine speed with reference position correction.
The AABBCC connection has symmetrical negative signal connection current, which has minimal attenuation and strong anti-interference, and can be emitted over long distances.
How to determine the direction
Since A and B are 90 degrees out of phase, the direction can be determined by detecting whether A or B occurs first.
How to perform zero position calibration
During the transmission of encoder pulses, errors may occur due to reasons such as interference, resulting in transmission errors.
At this time, it is necessary to carry out zero position calibration in a timely manner.
The C encoder emits a pulse with each rotation, which is called the zero pulse or identification pulse, and is used to determine the zero or identification position.
To accurately measure the zero pulse regardless of the direction of rotation, the zero pulse is output as a high-level combination of two channels.
Due to the phase difference between the channels, the zero pulse is only half the duration of the pulse.
3.2.3 Incremental Encoder Multiplier
Due to technological and sampling limitations, it is impossible to achieve a more precise and precise physical division of the encoding disk.
However, higher pulses can be achieved by converting the digital circuit.
Dual Frequency Signal
Obtained by “exclusive or” conversion of phases A and B.
Quadruple Frequency Signal
The counter also increases or decreases on each edge of channels A and B. The direction of the counter is determined by which channel drives the other.
The number on the counter increases or decreases by 4 each cycle.
3.2.4 Features of incremental encoders
The encoder outputs a pulse signal for each preset rotation angle, and the rotation angle is calculated by counting the number of pulse signals.
Therefore, the position data output by the encoder is relative.
Since a fixed pulse signal is used, the initial position of the rotation angle can be set arbitrarily.
Due to the use of relative coding, rotation angle data will be lost and will need to be reset after a power outage.
3.2.5 Problems with Incremental Encoders
1) Incremental encoders have cumulative zero point errors.
2) They have poor anti-interference ability.
3) The receiving device needs to be turned off and the reference position found again after power outages or shutdowns.
The emergence of absolute coders solves these problems.
3.3 Absolute Encoder Principle
An absolute encoder has a light code disk with multiple light channels and lines engraved on it.
Each channel is encoded using 2, 4, 8, 16, and so on lines in sequence.
At each encoder position, the light channels are read and their on/off state is used to obtain a unique binary code, known as the Gray code, ranging from 2^0 to 2^(n-1), where n is the absolute encoder bit number.
The position of the encoder is determined mechanically by the light code disk, so it is not affected by power outages or interference.
3.3.1 Absolute encoder code disk
The light code disk is scanned by a group of photoelectric couplers to obtain the unique code at each position. Each position has its own unique code.
The output codes of absolute encoders are:
1. Natural binary code: 0000 0001 0010 0011 0100
2. Gray code: 0000 0001 0011 0010 0110
Gray Code Features:
Adjacent integers in their numerical representation have only one difference, which can prevent large current spikes from occurring in the digital conversion circuit (such as 3-4, 0011-0100).
Binary-Gray Code Conversion Format:
The highest digits are retained and the second highest digit is obtained by performing an “exclusive or” operation on the highest digits and the second highest digit (in binary).
Reference for decimal and Gray codes.
Decimal | Gray Code |
0 | 0000 |
1 | 0001 |
two | 0011 |
3 | 0010 |
4 | 0110 |
5 | 0111 |
6 | 0101 |
7 | 0100 |
Decimal | Gray Code |
8 | 1100 |
9 | 1101 |
10 | 1111 |
11 | 1110 |
12 | 1010 |
13 | 1011 |
14 | 1001 |
15 | 1000 |
3.3.2 Absolute encoder output formats
1. Parallel output mode
In this mode, there is one cable for each bit of data (bit channel), and the signal level (high or low) on each cable represents 1 or 0.
The physical device is similar to an incremental encoder and has different types such as open collector PNP, NPN, differential drive, push-pull, and effective high or low differential based on the shape of the physical device.
The parallel output is usually in the form of a Gray code, also called a Gray code encoder.
2. Synchronous Serial Interface (SSI) output
In this mode, data is concentrated and transmitted through a group of cables. The data output is ordered by a communication protocol that specifies time.
Serial output uses fewer connection lines and can transmit over longer distances, which greatly improves the protection and reliability of the encoder.
High-bit absolute encoders and multiturn absolute encoders generally use serial output.
3. Asynchronous serial format
In this mode, instructions and data are exchanged through questions and answers, and the interface is duplex. A typical example is the RS485 interface, which requires only two cables.
The data content can be the encoder position value or other content requested by the instruction.
For example, if an address is added for each encoder, multiple encoders can share the transmission and subsequent reception cable. This form is called fieldbus type.
4. Hybrid encoder principle
Incremental encoding and absolute encoding are integrated on the same disk.
The outermost circle of the disk contains high-density incremental bands, while the middle part is the Gray code binary channel of the absolute encoder.
The rotation of the disk is indicated by counting the number of pulses per rotation, and the angle rotated within a week is counted using the Gray code numerical value.
Multi-turn absolute encoder: Based on the single-turn absolute encoder, the principle of clock gear mechanism is used to transmit the rotation of the central disc to another set of discs (or multiple sets of gears and discs) through gear transmission, which adds turn number coding based on single turn coding to expand the measuring range of the encoder.
When parallel light passes through a grating, the intensity of the Moiré fringes produced approximates a cosine function.
By placing four 1/4 Moiré fringes of photosensitive elements in the direction of movement of the Moiré fringe, four sets of sine and cosine output signals can be obtained.
Sine-cosine encoder output shape
Linear Encoder
A linear encoder measures the linear displacement distance of an object and converts the measured distance into a pulsed electrical signal output.
In simple terms, the principle is to stretch the disk of a rotary encoder in a straight line.
Grid Scale Encoder
The working principle of the grating displacement sensor is that when the master grating (i.e., the scale grating) and the auxiliary grating (i.e., the indicator grating) in the grating pair are relatively displaced, interference and diffraction of light produce a regular black–and white–striped (or chiaroscuro) pattern, called Moiré fringe.
The equal black and white (or light and dark) stripes are converted into electrical signals that change from sine wave through photoelectric devices.
After amplification and shaping by modeling circuits, two sine wave or square wave signals with a phase difference of 90 degrees are obtained and sent to the grid digital display for counting and display.
Rotary Transformer
A rotary transformer, also known as a resolver, is a type of micromotor used for control purposes.
It is an indirect measuring device that converts mechanical rotation into an electrical signal that is related to the angle of rotation by a certain mathematical function.
Principle of Rotary Transformer
1. A rotary transformer is a signal component that outputs a voltage that varies with the rotor angle.
When the excitation winding is excited by an alternating voltage of a certain frequency, the voltage amplitude of the output winding is in a sine or cosine function relationship with the rotor angle, or maintains a certain proportional relationship, or has a linear with the rotor angle within a certain range.
2. The distribution of magnetic flux between the stator and rotor of the rotating transformer follows a sinusoidal rule.
Therefore, when the excitation voltage is applied to the stator winding, the rotor winding generates an induced electromotive force through electromagnetic coupling, as shown in the figure above.
The magnitude of the output voltage depends on the angular position of the rotor and therefore varies sinusoidally with the rotor displacement.
According to the transformer principle, assuming that the number of turns in the primary winding is N1 and the number of turns in the secondary winding is N2, k = N1/N2 is the turns ratio. When an AC voltage is applied to the primary winding
Rotary Transformer Application
1. Phase detection mode
The phase angle of the induced voltage is equal to the mechanical rotation angle of the rotor.
Therefore, as long as the phase angle of the rotor output voltage is detected, the rotation angle of the rotor is known.
2. Amplitude detection mode
In practical applications, by continuously modifying the electrical angle of the modulating voltage, the variation of the mechanical angle can be tracked, and the amplitude of the induced voltage can be measured to obtain the displacement of the mechanical angle.
5. Installation precautions for encoders
Mechanical Aspects:
1. Pay attention to the allowable axle load during installation;
2. Make sure that the axis difference of the encoder shaft and the user output shaft is less than 0.20mm and the axis deviation angle is less than 1.5°;
3. During installation, avoid hitting, falling and colliding to avoid damage to the shaft and disc;
4. During prolonged use, regularly check whether the screws securing the encoder are loose (once a quarter).
Electrical aspects:
1) The ground wire should be as thick as possible, generally larger than 1.5 square millimeters;
2) The encoder output wires must not overlap to avoid damage to the output circuit;
3) The encoder signal wires must not be connected to DC power or AC current to avoid damage to the output circuit;
4)Equipment such as motors connected to the encoder must be well grounded and free from static electricity.
6. Installation of the Encoder Shield Cable.
Diagram of the internal structure of a rotary encoder.