This post was last edited by DDZZ669 on 2021-2-14 23:30 Encoder is a sensor used to measure mechanical rotation or displacement. It can measure information such as the displacement position or speed of mechanical parts during rotation or linear motion, and convert it into a series of electrical signals. # 1 Encoder classification## 1.1 Classification by monitoring principle### 1.1.1 Photoelectric encoder Photoelectric encoder is a sensor that converts the mechanical geometric displacement on the output shaft into pulses or digital quantities through photoelectric conversion. This is the most widely used sensor at present. The photoelectric encoder is composed of a light source, an optical code disk and a photosensitive element. The grating disk is a circular plate with a certain diameter and a number of rectangular holes opened in equal parts. Since the photoelectric code disk is coaxial with the motor, when the motor rotates, the grating disk rotates at the same speed as the motor. The detection device composed of electronic components such as light-emitting diodes detects and outputs a number of pulse signals. The current motor speed can be reflected by calculating the number of pulses output by the photoelectric encoder per second. In addition, in order to determine the direction of rotation, the code disk can also provide two pulse signals with a phase difference of 90°.
### 1.1.2 Hall Encoder Hall encoder is a sensor that converts the mechanical geometric displacement on the output shaft into pulses or digital quantities through magnetoelectric conversion. The Hall encoder is composed of a Hall code disk (magnetic ring) and a Hall element. The Hall code disk is a circular plate with different magnetic poles arranged equally on a certain diameter. The Hall code disk is coaxial with the motor. When the motor rotates, the Hall element detects and outputs a number of pulse signals. In order to determine the direction of rotation, it generally outputs two groups of square wave signals with a certain phase difference.
## 1.2 Classification by output signal### 1.2.1 Incremental encoder Incremental encoder converts the displacement information of the device into a continuous pulse signal when it moves. The number of pulses indicates the size of the displacement. Its characteristics are as follows: - The signal is output only when the device moves. - Generally, two groups of signals, channel A and channel B, are output, and there is a 90° phase difference (1/4 cycle). Collecting these two groups of signals at the same time can calculate the movement speed and direction of the device. As shown in the figure below, the period of the signals of channel A and channel B is the same, and the phase difference is 1/4 cycle. Combining the signal values of the two phases: - When both phase B and phase A read high level (1 1) first, then B reads high level and A reads low level (1 0), it is clockwise rotation - When both phase B and phase A read low level (0 0) first, then B reads high level and A reads low level (1 0), it is counterclockwise rotation - In addition to channel A and channel B, an additional channel Z signal is set to indicate the specific reference position of the encoder. As shown in the figure below, the Z axis signal will output a pulse only after the sensor rotates one circle. When the Z axis is output, the absolute position of the code disk can be calculated by clearing the count of the AB channel. - Incremental encoders only output the position change and movement direction of the device, and will not output the absolute position of the device.
### 1.2.2 Absolute encoders The overall structure of absolute encoders is similar to that of incremental encoders. They are both composed of a code disk, a detection device, and an amplifying and shaping circuit, but the specific code disk structure and the meaning of the output signal are different. It converts the displacement information of the device during movement into a digital quantity and directly outputs it through binary coding (special code disk). Its characteristics are as follows: - Its code disk uses a number of light-transmitting and light-proof grooves to form a set of binary codes. These binary codes are uniquely corresponding to each different angle of the encoder shaft. - The **code disk of the absolute encoder has many circles of grooves, which are called code channels**. The number and length of the internal grooves of each (circle) code channel are different. Together, they form a set of binary codes, and one (circle) code channel corresponds to one bit of the binary number (usually the outermost code channel of the code disk represents the lowest bit, and the innermost code channel represents the highest bit). - The number of code channels determines the number of bits in the binary code. If an absolute encoder has N code channels, the total number of binary numbers it outputs is 2 to the power of N. - **Reading these binary codes can tell the absolute position of the device**, so it is called an absolute encoder. - The encoding method generally uses natural binary, Gray code or BCD code. - The natural binary code disk is easy to understand, but when there is an error in the manufacturing process of the code disk, **in the critical area of the two groups of signals, the values of all code channels may not change at the same time, or because there is a slight time difference in the detection of all sensors, the wrong value is read**. For example, from 000 to 111, theoretically it should read 111, but if the three code channels from the inside to the outside are not completely aligned, it may read 001 or other abnormal values. - Gray code (two adjacent binary numbers are only 1 bit different) code disk can avoid abnormal data reading of binary code disk, because **two adjacent signal groups of Gray code disk will only have 1 bit change**. Even if there is an error in the manufacturing process that causes the signal reading to deviate, at most only 1 deviation (deviation of adjacent signals) will be generated.
# 2 Encoder parameters## 2.1 Resolution refers to the smallest unit that the encoder can distinguish. - For incremental encoders, the resolution is expressed as the number of pulses generated by one revolution of the encoder shaft, that is, pulse per revolution (Pulse Per Revolution or PPR). The number of light-transmitting slots on the code disk is actually equal to the resolution, also called the number of lines, and the more common ones are 5-6000 lines. - For absolute encoders, the number of bits used in the internal code disk is its resolution, and the unit is bit (bit), which is specifically divided into single-turn resolution and multi-turn resolution. ## 2.2 Accuracy First of all, it is clear that accuracy and resolution are two different concepts. Accuracy refers to the maximum error between each encoder reading and the actual position of the shaft, usually expressed in degrees, arc minutes or arc seconds. For example, some absolute encoder parameter tables will write ±20′′, which means that there is an error of plus or minus 20 arc seconds between the reading output by the encoder and the actual position of the shaft. The accuracy is determined by various factors such as the processing accuracy of the code disc engraving line, the concentricity of the rotating shaft, the temperature characteristics of the material, the response time of the circuit, etc. ## 2.3 The maximum response frequency refers to the number of pulses output by the encoder per second, in Hz. The calculation formula is: `Maximum response frequency = resolution * shaft speed/60` For example, the resolution of the encoder of a motor is 100 (that is, there are 100 grids in one circle of the photoelectric code disc), and the shaft speed is 120 revolutions per minute (that is, 2 revolutions per second), then the response frequency is 100×120/60=200Hz, that is, at this speed, the encoder outputs 200 pulses per second (the motor drives the encoder to rotate 2 circles). ## 2.4 Signal output form-For incremental encoders, the signal of each channel is output independently, and the output circuit form usually includes open collector output, push-pull output, differential output, etc. - For absolute encoders, since they directly output dozens of binary digits, in order to ensure the transmission rate and signal quality, they generally use **serial output** or bus output, such as synchronous serial interface (SSI), RS485, CANopen or EtherCAT, etc. Some of them are **parallel output**, and the output circuit form is the same as that of incremental encoders. # 3 Code disk speed measurement principle## 3.1 Encoder frequency multiplication What does encoder frequency multiplication mean? For example, a grating encoder has N grids in one circle. In theory, the motor drives the encoder to rotate one circle and can only output N signals. Through frequency multiplication technology, it can achieve one circle, but can output N×n signals, where n is the frequency multiplication number. The pulse waveform output by the incremental encoder is generally a square wave with a duty cycle of 50%, and the phase difference between channels A and B is 90°. - If only channel A is used for counting, and only the rising edge of channel A is captured, the count value of one revolution = the number of grids of the encoder disk, which is 1 times the frequency (no frequency doubling) - If only channel A is used for counting, and both the rising and falling edges of channel A are captured, the count value of one revolution of the encoder doubles, achieving 2 times the frequency - If both channel A and channel B are used for counting, and both the rising and falling edges are captured, 4 times the frequency is achieved
Assume that the resolution of an incremental encoder is 600PPR, and the minimum angle that can be resolved is 0.6°, after quadrupling it, the resolution is increased to 600×4=2400PPR, and the minimum angle that the encoder can resolve is 0.15°. ## 3.2 M method speed measurement is also called **frequency measurement method**. This method counts the number of encoder pulses during a fixed time (in seconds) and calculates the speed value. **M method is suitable for measuring high speed**. Assumptions: - The total number of encoder pulses in a single turn is C (constant) - The statistical time is T0 (fixed value, unit second) - The number of encoder pulses counted within this time is M0 (measured value) Then: The calculation formula for **speed n **(turns/second) is:
>How to understand this formula: > >M0/C is the number of encoder pulses in the statistical time, divided by the statistical time T0, that is, how many turns are made in 1s (unit time). For example: the statistical time T0 is 3s, the number of pulses M0 measured in 3s is 60, and the number of encoder pulses C in a single turn is 20, then the speed n=60/(20×3)=1 turn per second. Since C is a constant, the speed n is proportional to M0. This makes: - At high speed, M0 becomes larger during measurement, and better measurement accuracy and stability can be obtained - But at low speed (so low that there are only a few pulses in each T0), the calculated speed error will be relatively large and very unstable. As shown in the figure below, the square wave is the pulse output by a channel of the encoder. When the speed is high, the count value in each statistical time T0 is large, and a more accurate speed measurement value can be obtained. When the speed is low, the count value in each statistical time T0 is small. Since the starting position of the statistical time does not necessarily correspond to the rising edge of the encoder pulse, **when the starting position of the statistical time is different**, there will be a pulse error (when only the rising edge is counted, there will be a maximum of 1 pulse error, and when the rising and falling edges are counted, there will be a maximum of 2 pulse errors).
Increasing the number of pulses measured per unit time by frequency doubling can improve the accuracy of M method at low speed measurement (for example, originally only 4 pulses M0 were captured, but after 4 times the frequency, M0 at the same motor state becomes 16), but it cannot fundamentally change the measurement problem at low speed. ## 3.3 T method speed measurement is also called period measurement method. This method is to establish a high-frequency pulse of known frequency and count it. **T method is suitable for measuring low speed**. Assumptions: - The total number of pulses in a single turn of the encoder is C (constant) - The frequency of the high-frequency pulse is F0 (fixed value, unit Hz) - The interval time between two adjacent encoder pulses is Te, and the count value in between is M1 (measured value) Then: the calculation formula for the speed n is:
> How to understand this formula: > > 1/Te, that is, how many encoder pulses there are in 1s, divided by the number of pulses in one turn C, that is, how many turns are made in 1s> > F0/M1, that is, the number of high-frequency pulses in 1s divided by the number of high-frequency pulses between two encoder pulses, that is, how many encoder pulses there are in 1s, divided by the number of pulses in one turn C, that is, how many turns are made in 1s For example: the period of the high-frequency pulse is 1ms, that is, the frequency F0 is 1000Hz, and the number of high-frequency pulses M1 generated between the two encoder pulses is 50 (that is, the interval Te between the two encoder pulses =0.05s), the number of pulses C in one circle of the encoder is 20, then the speed n=1000/(50×20)=1 circle per second. Since C and F0 are constants, the speed n is inversely proportional to M1. This makes: - At high speed, the encoder pulse interval Te is very small, so the high-frequency pulse count value M1 in the measurement cycle also becomes very small, resulting in a larger measurement error - At low speed, Te is large enough, and M1 in the measurement cycle is also large enough, so the T method and the M method are just the opposite, and are more suitable for measuring low speeds. As shown in the figure below, the black square wave is the pulse output by a channel of the encoder, and the yellow square wave is the high-frequency measurement pulse. When the speed is low, the high-frequency measurement pulse number M1 is large, and a more accurate speed measurement value can be obtained. When the speed is high, the time interval between the two encoder pulses becomes shorter, resulting in a small high-frequency measurement pulse number M1. Since the rising edge position of the high-frequency pulse does not necessarily correspond to the rising edge of the encoder pulse, **when the rising edge positions of the two waves are different**, there will be a pulse error**.
## 3.4 M/T method for speed measurement This method combines the advantages of both the M method and the T method, measuring both the encoder pulse number and the high-frequency pulse number within a certain period of time. In a relatively fixed period of time, assume that: - The encoder pulse number generates M0 (measured value) - Count a high-frequency pulse with a known frequency of F0 (fixed value, unit Hz), the count value is M1 (measured value), and the speed value is calculated - The total number of pulses in a single circle of the encoder is C (constant) Then the calculation formula for the speed n is:
For example: In a relatively fixed period of time, the encoder pulse number M0 is 3; the period of the high-frequency pulse is 1ms, that is, the frequency F0 is 1000Hz, and the number of high-frequency pulses M1 generated is 150; the number of pulses C of one circle of the encoder is 20, then the speed n=1000×3/(150×20)=1 circle per second. Since F0 and C in the M/T method formula are constants, the speed n is only affected by M0 and M1. - At high speed, M0 increases and M1 decreases, which is equivalent to the M method - At low speed, M1 increases and M0 decreases, which is equivalent to the T method.
3 T method speed measurement is also called period measurement method. This method is to create a high frequency pulse of known frequency and count it. **T method is suitable for measuring low speed**. Assumptions: - The total number of pulses in a single turn of the encoder is C (constant) - The frequency of the high-frequency pulse is F0 (fixed value, unit Hz) - The interval time between two adjacent encoder pulses is Te, and the count value in between is M1 (measured value) Then: the calculation formula for the speed n is:
> How to understand this formula: > > 1/Te, that is, how many encoder pulses there are in 1s, divided by the number of pulses in one turn C, that is, how many turns are made in 1s> > F0/M1, that is, the number of high-frequency pulses in 1s divided by the number of high-frequency pulses between two encoder pulses, that is, how many encoder pulses there are in 1s, divided by the number of pulses in one turn C, that is, how many turns are made in 1s For example: the period of the high-frequency pulse is 1ms, that is, the frequency F0 is 1000Hz, and the number of high-frequency pulses M1 generated between the two encoder pulses is 50 (that is, the interval Te between the two encoder pulses =0.05s), the number of pulses C in one circle of the encoder is 20, then the speed n=1000/(50×20)=1 circle per second. Since C and F0 are constants, the speed n is inversely proportional to M1. This makes: - At high speed, the encoder pulse interval Te is very small, so the high-frequency pulse count value M1 in the measurement cycle also becomes very small, resulting in a larger measurement error - At low speed, Te is large enough, and M1 in the measurement cycle is also large enough, so the T method and the M method are just the opposite, and are more suitable for measuring low speeds. As shown in the figure below, the black square wave is the pulse output by a channel of the encoder, and the yellow square wave is the high-frequency measurement pulse. When the speed is low, the high-frequency measurement pulse number M1 is large, and a more accurate speed measurement value can be obtained. When the speed is high, the time interval between the two encoder pulses becomes shorter, resulting in a small high-frequency measurement pulse number M1. Since the rising edge position of the high-frequency pulse does not necessarily correspond to the rising edge of the encoder pulse, **when the rising edge positions of the two waves are different**, there will be a pulse error**.
## 3.4 M/T method for speed measurement This method combines the advantages of both the M method and the T method, measuring both the encoder pulse number and the high-frequency pulse number within a certain period of time. In a relatively fixed period of time, assume that: - The encoder pulse number generates M0 (measured value) - Count a high-frequency pulse with a known frequency of F0 (fixed value, unit Hz), the count value is M1 (measured value), and the speed value is calculated - The total number of pulses in a single circle of the encoder is C (constant) Then the calculation formula for the speed n is:
For example: In a relatively fixed period of time, the encoder pulse number M0 is 3; the period of the high-frequency pulse is 1ms, that is, the frequency F0 is 1000Hz, and the number of high-frequency pulses M1 generated is 150; the number of pulses C of one circle of the encoder is 20, then the speed n=1000×3/(150×20)=1 circle per second. Since F0 and C in the M/T method formula are constants, the speed n is only affected by M0 and M1. - At high speed, M0 increases and M1 decreases, which is equivalent to the M method - At low speed, M1 increases and M0 decreases, which is equivalent to the T method.
3 T method speed measurement is also called period measurement method. This method is to create a high frequency pulse of known frequency and count it. **T method is suitable for measuring low speed**. Assumptions: - The total number of pulses in a single turn of the encoder is C (constant) - The frequency of the high-frequency pulse is F0 (fixed value, unit Hz) - The interval time between two adjacent encoder pulses is Te, and the count value in between is M1 (measured value) Then: the calculation formula for the speed n is:
> How to understand this formula: > > 1/Te, that is, how many encoder pulses there are in 1s, divided by the number of pulses in one turn C, that is, how many turns are made in 1s> > F0/M1, that is, the number of high-frequency pulses in 1s divided by the number of high-frequency pulses between two encoder pulses, that is, how many encoder pulses there are in 1s, divided by the number of pulses in one turn C, that is, how many turns are made in 1s For example: the period of the high-frequency pulse is 1ms, that is, the frequency F0 is 1000Hz, and the number of high-frequency pulses M1 generated between the two encoder pulses is 50 (that is, the interval Te between the two encoder pulses =0.05s), the number of pulses C in one circle of the encoder is 20, then the speed n=1000/(50×20)=1 circle per second. Since C and F0 are constants, the speed n is inversely proportional to M1. This makes: - At high speed, the encoder pulse interval Te is very small, so the high-frequency pulse count value M1 in the measurement cycle also becomes very small, resulting in a larger measurement error - At low speed, Te is large enough, and M1 in the measurement cycle is also large enough, so the T method and the M method are just the opposite, and are more suitable for measuring low speeds. As shown in the figure below, the black square wave is the pulse output by a channel of the encoder, and the yellow square wave is the high-frequency measurement pulse. When the speed is low, the high-frequency measurement pulse number M1 is large, and a more accurate speed measurement value can be obtained. When the speed is high, the time interval between the two encoder pulses becomes shorter, resulting in a small high-frequency measurement pulse number M1. Since the rising edge position of the high-frequency pulse does not necessarily correspond to the rising edge of the encoder pulse, **when the rising edge positions of the two waves are different**, there will be a pulse error**.
## 3.4 M/T method for speed measurement This method combines the advantages of both the M method and the T method, measuring both the encoder pulse number and the high-frequency pulse number within a certain period of time. In a relatively fixed period of time, assume that: - The encoder pulse number generates M0 (measured value) - Count a high-frequency pulse with a known frequency of F0 (fixed value, unit Hz), the count value is M1 (measured value), and the speed value is calculated - The total number of pulses in a single circle of the encoder is C (constant) Then the calculation formula for the speed n is:
For example: In a relatively fixed period of time, the encoder pulse number M0 is 3; the period of the high-frequency pulse is 1ms, that is, the frequency F0 is 1000Hz, and the number of high-frequency pulses M1 generated is 150; the number of pulses C of one circle of the encoder is 20, then the speed n=1000×3/(150×20)=1 circle per second. Since F0 and C in the M/T method formula are constants, the speed n is only affected by M0 and M1. - At high speed, M0 increases and M1 decreases, which is equivalent to the M method - At low speed, M1 increases and M0 decreases, which is equivalent to the T method.