An encoder is an electromechanical device that can be used to measure mechanical motion or target position. Most encoders use optical sensors to provide electrical signals in the form of pulse trains that can be sequentially converted into motion, direction or position information.
The encoder can be divided into rotary encoder or linear encoder according to the motion mode; according to the readout mode, the encoder can be divided into contact type and non-contact type; according to the working principle, the encoder can be divided into incremental type and absolute type. class. The rotary encoder can convert the rotational position or the amount of rotation into an analog (such as an analog quadrature signal) or a digital (such as USB, 32-bit parallel signal or digital quadrature signal, etc.) electronic signal, usually mounted on a rotating object. , such as a motor shaft.
A rotary encoder is a device that converts the angular position or motion of a shaft or shaft into an analog or digital code. There are two types of rotary encoders:
incremental encoders : incremental rotary encoders only output pulses when the motor is rotating. To determine the position of the axis using an incremental encoder, you must know the starting position and use an external circuit to calculate the number of output pulses.
Absolute encoder : The absolute rotary encoder outputs a digital code corresponding to the angle of rotation. There is no need to calculate pulses to understand the position of the motor shaft. You only need to read the digital output of the encoder.
A linear encoder is a sensor, sensor or read head associated with the scale of the coded position. The sensor reads the scale and converts the position to an analog or digital signal and converts it to a digital reading. Movement depends on the position over time.
A rotary encoder can be used to measure the rotational motion of the shaft. Figure 1 below shows the basic components of a rotary encoder, including a light-emitting diode (LED), a code wheel, and a light sensor on the back of the code wheel. The code wheel is arranged on the rotating shaft, and the opaque and light-transmissive fan-shaped area is arranged on a certain coding form. When the code wheel is rotated, the opaque sectors are able to block light, while the light-transmissive sectors allow light to pass through. This produces a square wave pulse that can be compiled into corresponding position or motion information.
The encoder is usually divided into 100 to 6000 sectors per revolution. This shows that a 100 sector encoder can provide 3.6 degrees of accuracy, while a 6000 sector encoder can provide 0.06 degrees of accuracy.
Encoder_0.png

Figure 1 Basic components of a photoelectric encoder The
above is the basic knowledge of the encoder. Let’s talk about some of the things related to orthogonal coding . Not much to say, first on the map. The quadrature output of the incremental encoder is shown in Figure 2.
Encoder_1.png

Figure 2 Quadrature Output
Quadrature Encoding of an Incremental Encoder is an incremental signal (incremental signals are described below). When the incremental encoder is rotated, two square wave outputs A and B are generated; these signals together form the quadrature output of the incremental encoder. For most encoders, these square waves A and B are out of phase by 90 degrees. By observing the changing state of the A and B outputs, the direction of the encoder is determined. There are two channels: channel A and channel B.
When channel A’s reader passes the bright area on the encoder disk, it generates a square wave pulse on channel A. The area on the encoder wheel or reader is slightly offset, so the reader of channel B will detect the 90° pattern, by reading the number of pulses and which channel is before the other (called the “preamble”), the encoder interface can Determine how far the encoder has rotated and in which direction. Some encoders also have a third channel called the index channel that sends a pulse every time a rotation is completed. This allows the encoder to know its actual position rather than its relative position, such as an absolute encoder, without incurring too much extra cost. You can check the encoder’s data table to see if it has an index channel. As shown in Figure 3, it is a typical encoder square wave output. In the figure, A leads to B for clockwise rotation and B for A to rotate clockwise.
Encoder_2.png

Figure 3 Typical encoder square wave output
However, to determine the encoder’s travel distance or its rotational speed, more information is needed. To calculate this information, it is important to understand the resolution of the encoder. Think of the resolution as the granularity of the encoder, or simply, how many blocks the encoder can divide into blocks per revolution.
Pulse number per revolution (PPR)
The term PPR (or the number of pulses per revolution) represents the resolution of the encoder. The PPR describes the number of high pulses that occur on the square wave output A or B per revolution of the encoder. Once the resolution is known, it can be used to calculate how many geometric angles each pulse and period correspond to. As shown in Figure 4.
Encoder_3.png

Figure 4 Encoder resolution
coding type The
encoder has three basic coding types: X1, X2 and X4.
X1 Encoding
As shown in Figure 5, the number of additions and subtractions of the count value in an orthogonal period and its corresponding X1 coding type is shown. When channel A leads channel B, the increment occurs on the rising edge of channel A. When channel B leads channel A, the decrement occurs on the falling edge of channel A.
Encoder_4.png

Figure 5 X1 coded
X2 coded
X2 code is similar to the above procedure except that the counter increments or decreases on each edge of the A channel, depending on which channel is used to guide which channel. The value of the counter is increased by 2 or 2 per cycle, as shown in Figure 6.
Encoder_5.png

Figure 6 X2 coded
X4 coded
X4 code mode, the counter also increases or decreases on each edge of channels A and B. Whether the number of counters is increasing or decreasing depends on which channel leads which channel. The number of counters is increased by 4 or decreased by 4 in each cycle, as shown in Figure 7.
Encoder_6.png

Figure 7 X4 code
per revolution count (CPR)
CPR most often represents a count per revolution and refers to the number of orthogonal decoding states that exist between the two outputs of A and B. When the two outputs A and B are switched between high and low, two bits of information appear, indicating four different states. The term orthogonal decoding describes a method of counting each state change using both outputs A and B. The result is 4 times the count of each pulse or cycle. Therefore, the CPR of the encoder is the PPR of the encoder multiplied by four. It should also be noted that some encoder manufacturers use the acronym CPR to indicate the number of cycles per revolution (number of cycles per revolution). The number of cycles per revolution represents the complete electrical cycle or time of any encoder output, and this value is equal to the number of pulses per revolution. Since the same abbreviation of CPR is used for each revolution count and number of revolutions per revolution, the definition of resolution must be carefully understood. Figure 8 is a waveform diagram of a common product.
Encoder_7.png

Figure 8 Common product waveform diagram
formula:
1. The relationship between encoder CPR frequency and motor speed (RPM) is given by:
f = (cycle / revolution) * (rev / sec) / 1000 = kHz
rpm = per Minute revolutions
CPR = number of revolutions per revolution
2. Distance conversion:
(PPR) / (2 * pi * shaft radius) = number
of pulses per inch ( number of pulses per inch ^ – 1 = number of inches per pulse