An encoder is a device that encodes signals (such as bitstreams) or data and converts them into a signal format that can be used for communication, transmission, and storage. Photoelectric encoders can be classified into incremental encoders and absolute encoders based on their signal principle. A rotary encoder is a photoelectric rotary measuring device that directly converts the measured angular displacement into a digital signal (high-speed pulse signal). Therefore, the output pulse signal of the rotary encoder can be directly input to a PLC, and the PLC's high-speed counter can count the pulse signal to obtain the measurement result.
Encoder wiring principle:
We typically use incremental encoders, which allow the output pulse signal of a rotary encoder to be directly input to a PLC. The PLC's high-speed counter counts these pulse signals to obtain the measurement results. Different models of rotary encoders output different numbers of pulse phases. Some rotary encoders output three-phase pulses (A, B, Z), while others only output two phases (A and B), and the simplest only outputs phase A.
The encoder has 5 leads: 3 pulse output lines, 1 COM terminal line, and 1 power supply line (OC gate output type). The encoder can be powered by an external power supply or directly from the PLC's DC 24V power supply. The power supply "-" terminal should be connected to the encoder's COM terminal, and the "+" terminal should be connected to the encoder's power supply terminal. The encoder's COM terminal is connected to the PLC's COM input terminal. The A, B, and Z phase pulse output lines are directly connected to the PLC's input terminals. A and B are pulses 90 degrees out of phase, and the Z phase signal produces only one pulse per revolution of the encoder, typically used as a zero-point indicator. When connecting, pay attention to the PLC's input response time. The rotary encoder also has a shielded wire; this shielded wire should be grounded to improve interference immunity.
Encoder-----------PLC
A-----------------X0
B-----------------X1
Z------------------X2
+24V------------+24V
COM--------------24V-----------COM
When the incremental encoder shaft rotates, it outputs corresponding pulses. The starting point for counting can be arbitrarily set, enabling infinite accumulation and measurement over multiple revolutions. Each revolution of the encoder shaft outputs a fixed number of pulses, determined by the number of lines in the encoder grating. To improve resolution, the A and B signals, with a 90-degree phase difference, can be multiplied, or a higher-resolution encoder can be used.
Namiki motor photoelectric encoder wiring:
The photoelectric encoder for this motor has four wires: two power lines connected to 5V and ground respectively, and two data lines. Its output signal is a square wave. The specific output process is as follows:
For every revolution of the motor, one pulse is output from each of the two symmetrical signal lines. The two data lines provide output, improving the accuracy of motor position control. For only a rough count, a single data pulse line is sufficient.
How to wire an absolute photoelectric encoder to a microcontroller?
Absolute photoelectric encoders have many types of interfaces. The most common one now is the serial synchronous interface, which is a clock data interface that conforms to the RS422 level standard. Its clock lines usually have a set of + and -, and the data lines have a set of + and -. If connecting to a microcontroller, it is best to use a microcontroller with SPI functionality. The clock output and data input of the microcontroller's SPI are converted into differential signals by a 422 level converter chip and then connected to the encoder. Of course, you can also use a regular microcontroller's I/O port to simulate SPI timing, but doing so is quite complicated in terms of programming and is best avoided.
NPN open-circuit output, also known as OC output.
You need to connect an external resistor to both terminals A and B. The voltage across the resistors is determined by your circuit.
The microcontroller is connected to 5V and the PLC is connected to 24V, making it very convenient to use.
Detecting signals A and B involves (1) detecting the number of pulses; and (2) determining which of A and B comes first. If the rising edge of phase A comes first (a high level appears), it indicates that the encoder is rotating in the forward direction; conversely, if phase B comes first, it indicates that the encoder is rotating in the reverse direction.
As for 45°, it depends on how many pulses the encoder produces per revolution; you can allocate them yourself.
Wiring diagram of PLC and rotary encoder
A rotary encoder is a photoelectric rotary measuring device that directly converts the measured angular displacement into a digital signal (high-speed pulse signal). Therefore, the output pulse signal of the rotary encoder can be directly input to a PLC, where a high-speed counter counts the pulses to obtain the measurement result.
Connection diagram between rotary encoder and PLC
The figure shows a connection diagram between a rotary encoder that outputs two-phase pulses and an FX2N series PLC.
The encoder has four leads: two are pulse output lines, one is a COM terminal line, and one is a power supply line.
The encoder can be powered by an external power supply or directly by the PLC's DC 24V power supply. The power supply "-" terminal should be connected to the encoder's COM terminal, and the "+" terminal should be connected to the encoder's power supply terminal.
The encoder's COM terminal is connected to the PLC's COM input terminal, and the A and B phase pulse output lines are directly connected to the PLC's input terminals. When connecting, pay attention to the PLC's input response time. Some rotary encoders also have a shielded wire; this shielded wire must be grounded during use.
Different models of rotary encoders have different numbers of output pulse phases. Some rotary encoders output three-phase pulses (A, B, and Z), while others only output two-phase pulses (A and B). The simplest ones only output phase A.