A Rotary Encoder Detection Circuit and Detection Method
By detecting the signal of mechanical contacts when they are not in contact and filtering the burr signal using a monostable circuit, the signal instability problem caused by contact wear by mechanical rotary encoder is solved, and a more stable signal output and a longer service life are achieved.
Patent Information
- Application Number
- CN202510519445.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-04-24
AI Technical Summary
The mechanical rotary encoder has unstable output pulse due to mechanical contact wear and environmental factors, which affects counting and judgment, and has a short service life.
A monostable circuit is used to detect the signal of mechanical contacts when they are not in contact, and the glitch signal caused by poor contact is filtered through the monostable circuit. The signal is processed using the retriggerable monostable circuit and the subsequent circuit to detect the rotation direction and quantity.
It extends the service life of the rotary encoder, improves signal stability and software judgment efficiency, reduces costs and has good compatibility.
Smart Images

Figure CN120043565B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of rotary encoder detection, and particularly relates to a rotary encoder detection circuit and a detection method. Background Art
[0002] Rotary encoders are currently widely used due to their convenient operation and sensitive response. Commonly used rotary encoders are divided into mechanical and photoelectric types. The photoelectric type has a high cost and is used in high-speed and high-precision applications. The mechanical type has a low cost and is generally used in consumer products, panel inputs, etc. Inside the mechanical type, there are two sets of contacts. One set is the static contacts fixed on the base, and the other set is the moving contacts that rotate with the central axis. When the rotary encoder rotates, it drives the moving contacts to slide across the static contacts, generating a pulse signal output. Relying on these two sets of mechanical contacts, mechanical quantities such as rotational angular displacement and angular velocity are converted into electrical signals and output as digital quantities in pulse form. Commonly used mechanical rotary encoders have single-channel and dual-channel outputs. The single-channel output only outputs a string of pulses. The dual-channel outputs are respectively called A and B, and the two outputs are orthogonal with a phase difference of 90 degrees. When rotating in different directions, the phase sequence will also be different. The receiving device processes these two signals to obtain the rotation direction and rotation amount. The technical parameter is the number of pulses per revolution. Mechanical rotary encoders are convenient to use, but after being used for a long time, mechanical contacts will wear during frequent contact processes, resulting in poor contact and unstable output pulses, generating a lot of interference jitter, affecting normal counting judgment, and thus having to be replaced in advance. In addition, the reasons for the poor contact of the rotary encoder are divided into mechanical reasons, environmental reasons, and usage reasons. The mechanical reason is that mechanical wear occurs during use, resulting in wear of the contact points. The environmental reason is that the use environment has temperature and humidity changes, dust, etc., resulting in accelerated oxidation and wear of the contacts. The usage reason is improper usage method, resulting in arcing between the contacts and further accelerating the wear of the contacts. Summary of the Invention
[0003] The purpose of the present invention is to provide a rotary encoder detection circuit and a detection method for the deficiencies of the prior art.
[0004] A rotary encoder detection circuit disclosed by the present invention includes a rotary encoder circuit, a monostable circuit, and a post-stage circuit. The rotary encoder circuit has two sets of signal outputs. Each set of signals includes a signal when the contact is in the contact area and a signal when the contact is in the non-contact area. Each set of signals is respectively shaped by one of the monostable circuits. The post-stage circuit processes the output signal of the monostable circuit when the contact is in the non-contact area to detect the rotation direction and rotation amount of the rotary encoder.
[0005] Further, when the contact in the rotary encoder circuit is in the contact area, a trigger signal is generated to trigger the monostable circuit. The monostable circuit enters the unstable state. During the process of the monostable circuit transitioning from the unstable state to the stable state, unstable glitch signals generated due to poor contact of the contact are filtered, and the monostable circuit outputs an inverted trigger signal. When the contact in the rotary encoder circuit is in the non-contact area, the monostable circuit does not receive the trigger signal. After the monostable circuit completely exits the unstable state, it flips and outputs a signal indicating that the contact in the rotary encoder is in the non-contact state. The subsequent circuit processes the output signals of the two groups of monostable circuits in the non-contact state to detect the rotation direction and rotation amount of the rotary encoder.
[0006] Further, the monostable circuit is a re-triggerable monostable circuit. When the contact in the rotary encoder circuit is in an unstable contact state, the monostable circuit can be triggered again during the unstable state to reset the time of the unstable state.
[0007] Further, the monostable circuit includes a circuit composed of a transistor and a buffer, a 555 circuit, a gate circuit, or a circuit using a monostable multivibrator chip.
[0008] Further, the subsequent circuit includes a single-chip microcomputer or a logic device.
[0009] A detection method based on a rotary encoder detection circuit disclosed by the present invention includes:
[0010] Rotate the rotary encoder so that the rotary encoder circuit outputs two groups of signals, where each group of signals includes a contact area signal and a non-contact area signal.
[0011] If the output signal is a contact area signal, trigger the monostable circuit to work, and the monostable circuit shapes and inverts the output signal of the rotary encoder circuit. If the output signal is a non-contact area signal, the monostable circuit flips and outputs a signal.
[0012] The subsequent circuit processes the output signals of the two groups of monostable circuits in the non-contact area to determine the rotation direction and rotation amount of the rotary encoder.
[0013] Further, the subsequent circuit processes the output signals of the two groups of monostable circuits in the non-contact area. The output signal of one group of monostable circuits is used as a reference signal to determine the rotation direction and rotation amount of the rotary encoder, including:
[0014] When the output signals of the two groups of monostable circuits are both contact area signals, enter the ready-to-detect state.
[0015] When the reference signal becomes a non-contact area signal, it enters the start detection state. After waiting for the output signals of the two monostable circuits to stabilize, it detects the state of the output signal of the other monostable circuit.
[0016] If the output signal of the other monostable circuit is a non-contact area signal, it is detected that it rotates once in the first direction; if the output signal of the other monostable circuit changes from a contact area signal to a non-contact area signal, it is detected that it rotates in the reverse direction once in the first direction.
[0017] After completing one cycle of detection, when the output signals of the two monostable circuits are both non-contact area signals, it returns to the initial state and starts the next detection cycle.
[0018] The beneficial effects brought by the technical solution of the present invention are as follows: The rotation encoder detection circuit and detection method proposed in this application abandon the traditional detection of the electrical signals generated when mechanical contacts are in contact, and instead detect the signals when mechanical contacts are non-contact. In the non-contact area, since there are no electrodes, it is impossible to generate pulses, the signal is more stable, and debouncing is easier. In the contact area, the generated glitches are usually relatively frequent and irregular, so they are abandoned and not used, which greatly extends the service life of the rotation encoder; it has good compatibility and can almost directly replace the original rotation encoder circuit; it filters the glitches generated by the rotation encoder and improves the efficiency of software judgment; it has low cost, and the circuit is simple, stable and reliable. Brief Description of the Drawings
[0019] Figure 1 It is a structural block diagram of the rotation encoder detection circuit proposed in this application.
[0020] Figure 2 It is a circuit diagram of the first specific embodiment of the rotation encoder detection circuit proposed in this application.
[0021] Figure 3 It is an improvement effect diagram of the output waveform of the first specific embodiment of the rotation encoder detection circuit proposed in this application.
[0022] Figure 4 It is an actual output waveform diagram of the first specific embodiment of the rotation encoder detection circuit proposed in this application.
[0023] Figure 5 It is a schematic diagram of the right-handed output waveform of the first specific embodiment of the rotation encoder detection circuit proposed in this application.
[0024] Figure 6 It is a schematic diagram of the left-handed output waveform of the first specific embodiment of the rotation encoder detection circuit proposed in this application.
[0025] Figure 7 It is a circuit diagram of the second specific embodiment of the rotation encoder detection circuit proposed in this application.
[0026] Figure 8 This is a flowchart of a method for determining the rotation direction and rotation amount of a rotary encoder in an embodiment of the present application. Detailed implementation manners
[0027] To make the objectives and technical solutions of the embodiments of the present application clearer, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the described embodiments of the present application without creative efforts shall fall within the scope of protection of the present application.
[0028] In an embodiment of the present application, please refer to Figure 1 , which is a structural block diagram of a rotary encoder detection circuit proposed by the present application. The present invention discloses a rotary encoder detection circuit, including a rotary encoder circuit 11, a monostable circuit 12, and a subsequent-stage circuit 13. The signal output by the rotary encoder circuit 11 is shaped by the monostable circuit 12 for the signal output by the rotary encoder circuit 11, where the signal includes a signal when the contact is in the contact area and a signal when the contact is in the non-contact area. The subsequent-stage circuit 13 processes the signal output by the monostable circuit when the contact is in the non-contact area to detect the rotation direction and rotation amount of the rotary encoder. The subsequent-stage circuit includes a single-chip microcomputer, logic devices, etc.
[0029] Please refer to Figure 2 , which is a circuit diagram of the first specific embodiment of the rotary encoder detection circuit proposed by the present application.
[0030] In this embodiment, the rotary encoder circuit includes a rotary encoder (Encoder), a first resistor R1, a third resistor R3, and a sixth resistor R6. The rotary encoder has two groups of signals A and B output. The a pin of the rotary encoder is the output of the A-group signal. The A-group signal output is connected to the monostable circuit in series with the third resistor R3. The b pin of the rotary encoder is the output of the B-group signal. The B-group signal output is connected to the monostable circuit in series with the sixth resistor R6. The c pin (common pin for pulse output) of the rotary encoder is connected to the power supply in series with the first resistor R1.
[0031] The monostable circuit is a retriggerable monostable circuit. A retriggerable monostable can be triggered again during the astable state to reset the duration of the astable state. The monostable circuit is composed of a transistor and a buffer. The monostable circuit connected to the output of Group A signals includes: a first capacitor C1, a second capacitor C2, a second resistor R2, a fourth resistor R4, a first transistor Q1, and a first buffer U1A. The first terminal of the first capacitor C1 is connected to the first terminal of the fourth resistor R4. The second terminal of the fourth resistor R4 is connected to the second terminal of the first capacitor C1 and the source electrode of the first transistor Q1. The source electrode of the first transistor Q1 is connected to the first terminal of the second capacitor C2. The gate electrode of the first transistor Q1 is connected to the first terminal of the fourth resistor R4. The drain electrode of the first transistor Q1 is connected to the first terminal of the second resistor R2, the second terminal of the second capacitor C2, and the input terminal of the first buffer U1A. The negative pin of the first buffer U1A is connected to the first terminal of the second capacitor C2. The positive pin of the buffer U1A is connected to the power supply. The output terminal of the first buffer U1A is connected to the subsequent circuit. The second terminal of the second resistor R2 is connected to the power supply. The second terminal of the fourth resistor R4 is grounded. The first terminal of the first capacitor C1 is connected to the third resistor R3.
[0032] The monostable circuit connected to the output of Group B signals is the same as the monostable circuit connected to the output of Group A signals, and includes: a third capacitor C3, a fourth capacitor C4, a fifth resistor R5, a seventh resistor R7, a second transistor Q2, and a second buffer U1B. The first terminal of the third capacitor C3 is connected to the first terminal of the seventh resistor R7. The second terminal of the seventh resistor R7 is connected to the second terminal of the third capacitor C3 and the source electrode of the second transistor Q2. The source electrode of the second transistor Q2 is connected to the first terminal of the fourth capacitor C4. The gate electrode of the second transistor Q2 is connected to the first terminal of the seventh resistor R7. The drain electrode of the second transistor Q2 is connected to the first terminal of the fifth resistor R5, the second terminal of the fourth capacitor C4, and the input terminal of the second buffer U1B. The negative pin of the second buffer U1B is connected to the first terminal of the fourth capacitor C4. The positive pin of the second buffer U1B is connected to the power supply. The output terminal of the second buffer U1B is connected to the subsequent circuit. The second terminal of the fifth resistor R5 is connected to the power supply. The second terminal of the seventh resistor R7 is grounded. The first terminal of the third capacitor C3 is connected to the sixth resistor R6.
[0033] As an example, the first buffer U1A and the second buffer U1B are Schmitt trigger buffers. The power supply is a +3.3V power supply.
[0034] When the contact in the rotary encoder is in the on state, the monostable circuit is triggered, and the monostable circuit enters the astable state. Since it takes a certain amount of time for the astable circuit to enter the stable state, during this time, frequent triggering will only reset the duration of the astable state and will not affect the output of the monostable circuit, thereby filtering out the unstable spikes caused by poor contact during the angular displacement of the contact.
[0035] When the contact in the rotary encoder is in the open state, the monostable circuit will flip after a period of time because it does not receive a trigger signal or glitch, indicating that the contact in the rotary encoder is in the non-contact area.
[0036] Taking the output of Group A signals as an example, the first resistor R1, the third resistor R3, the first transistor Q1, and the static contact and moving contact of the rotary encoder together form a contact detection circuit for the rotary encoder, and the first buffer U1A outputs signal A. Due to the amplification effect of the first transistor Q1, the current of the signals output by Group A of the rotary encoder is amplified, so the requirement for the current of the signals output by the rotary encoder is low, and the resistance values of the first resistor R1 and the third resistor R3 can be relatively large.
[0037] When the contact of the rotary encoder is in the contact area, a trigger pulse is generated to trigger the monostable circuit. The trigger pulse makes the first transistor Q1 saturated through the second resistor R2, quickly discharges the second capacitor C2, and the first buffer U1A outputs a low-level signal, and the circuit enters the non-steady state.
[0038] When the contact of the rotary encoder is in a poor contact state in the contact area, a level will be generated. The difference is that the level signals usually generated in the contact area are relatively stable, while the level signals generated in the poor contact state are relatively unstable and will generate continuous, short-duration and numerous glitch signals. Since it takes a certain amount of time for the second capacitor C2 to charge through the second resistor R2, the short-term on and off of the first transistor Q1 will not affect the output of signal A of the monostable circuit, thereby filtering out the unstable glitches caused by poor contact during the angular displacement of the contact.
[0039] It takes a period of time for the monostable circuit in the non-steady state to enter the steady state, and the monostable circuit is a re-triggerable monostable circuit. During this time, that is, the glitches generated by the contact of the rotary encoder circuit are irregular and the time of the next glitch generation cannot be predicted. Frequent triggering of the sub-monostable circuit by the contact in the rotary encoder circuit will only reset the duration of the non-steady state and will not affect the output of signal A of the monostable circuit. Therefore, using a re-triggerable monostable circuit can simplify the design without having to estimate the timing of the next trigger, thereby filtering out the unstable glitches caused by poor contact during the angular displacement of the contact.
[0040] When the contact is in the non-contact area state, the trigger pulse disappears, and the charge on the second capacitor C2 is filled by the current passing through the second resistor R2. When the voltage on the second capacitor C2 accumulates to a certain level, the first buffer U1A is driven to output a high-level signal. At this time, the high-level signal is the processed non-contact area signal. Since there is no pulse, the generated signal is more stable and easier to debounce, and the data that needs to be processed is less than the processed contact area signal.
[0041] See also Figure 3 , is a diagram showing the output waveform improvement effect of the first specific embodiment of the rotary encoder detection circuit proposed in this application. Figure 3 The yellow waveform in the middle is a signal after the rotary encoder outputs a set of signals and before the monostable circuit processes it. When it is at a high level, it means that the rotary encoder contacts are connected, that is, in the contact area. When it is at a low level, it means that the rotary encoder contacts are disconnected, that is, in the non-contact area. It can be seen from the figure that the waveform of the contact area signal output when the rotary encoder contacts are in the contact area contains many burrs. Figure 3 The green waveform in the middle is the signal output after the monostable circuit processes the output of the group of signals. Since the monostable circuit inverts the signal, when the contact is in the contact area, the processed contact area signal output is low level, and when the contact is in the non-contact area, the processed non-contact area signal output is high level. When the contact switches between the non-contact area and the contact area, there is an unstable contact state, see Figure 3 When the yellow waveform is at a high level and the green waveform is at a low level, the green waveform has one more section than the yellow waveform. The unstable contact signal is processed by a monostable circuit to filter out the unstable burrs caused by poor contact during the angular displacement of the contact point, and the processed low-level signal is output, which is beneficial for the subsequent circuit to avoid false detection when detecting the processed non-contact area signal. Figure 3 After the middle contact moves from the contact area to the non-contact area until it is completely out of the contact unstable state, the processed non-contact area signal jumps to a high level.
[0042] The principle of obtaining the signal by processing the output signal of group B through a monostable circuit is the same as that of group A output, and will not be repeated here.
[0043] As an example, see Figure 4 , is an actual output waveform diagram of the first specific embodiment of the rotary encoder detection circuit proposed in the present application, including the monostable circuit connected in group A and the monostable circuit connected in group B jointly completing the output after processing the two-way signal of the rotary encoder, wherein the yellow waveform represents the waveform of the signal output by group A, and the green waveform represents the waveform of the signal output by group B. The phase difference between the two-way signals output by the rotary encoder detection circuit is used to determine whether the rotary encoder is turning left or right; Figure 4The processed signal waveform output by the rotation encoder detection circuit proposed in this embodiment can be obtained to be stable without burrs. After the rotation encoder is used for a period of time, the improved output waveform effect is almost the same as that of a brand-new rotation encoder output waveform.
[0044] As an example, please refer to Figure 5 and Figure 6 , Figure 5 which is a schematic diagram of the right-handed output waveform of the first specific embodiment of the rotation encoder detection circuit proposed in this application, Figure 6 and which is a schematic diagram of the left-handed output waveform of the first specific embodiment of the rotation encoder detection circuit proposed in this application. Since there is a phase difference between the output of group A and the output of group B, the signal A of the output of group A and the signal B of the output of group B will have a time difference when the high level appears. Further, the rotation direction is different, and the phase is different. Among them, Figure 5 and Figure 6 the state 1 in represents the state where the contacts are in full contact. At this time, both signal A and signal B are low levels; the state 2 represents the transition state from the contact area to the non-contact area. When signal B is high level and signal A is low level, it indicates that the rotation encoder rotates to the right. When signal B is high level and signal A is high level, it indicates that the rotation encoder rotates to the left; the state 0 represents the initial state. At this time, both signal A and signal B are high levels. Since the state 2 and the state 0 are the same when rotating to the left, there is no state 2 in Figure 6 , and directly enters the state 0 after the detection is completed.
[0045] Please refer to Figure 7 , Figure 7 which is the circuit diagram of the second specific embodiment of the rotation encoder detection circuit proposed in this application. In this specific embodiment, different from the circuit in Figure 2 , a monostable circuit is constructed using a monostable multivibrator chip.
[0046] The rotation encoder circuit includes: a rotation encoder, a twelfth resistor R12, and a thirteenth resistor R13. The A-group output of the rotation encoder is connected to the first terminal of the thirteenth resistor R13, the B-group output is connected to the first terminal of the twelfth resistor R12, and the second terminal of the thirteenth resistor R13 and the second terminal of the twelfth resistor R12 are connected and grounded. The c pin of the rotation encoder is connected to the power supply VCC.
[0047] The monostable circuit connected to the output of Group A includes: the eleventh resistor R11, the eleventh capacitor C11, and the first monostable multivibrator chip U2A. The first terminal of the eleventh resistor R11 is connected to the node between the power supply VCC and the c pin of the rotary encoder. The second terminal of the eleventh resistor R11 is connected to the pin 1CX / RX of the first monostable multivibrator chip U2A and the first terminal of the eleventh capacitor C11. The pin 1CX of the first monostable multivibrator chip U2A is connected to the second terminal of the eleventh capacitor C11. The pin 1A of the first monostable multivibrator chip U2A is grounded. The pin 1B of the first monostable multivibrator chip U2A is connected to the output of Group A. The pin is connected to the power supply VCC. The pin VCC of the first monostable multivibrator chip U2A is connected to the power supply VCC. The pin is connected to the subsequent circuit. The pin GND of the first monostable multivibrator chip U2A is grounded.
[0048] The monostable circuit connected to the output of Group B includes: the fourteenth resistor R14, the twelfth capacitor C12, and the second monostable multivibrator chip U2B. The first terminal of the fourteenth resistor R14 is connected to the power supply VCC. The second terminal of the fourteenth resistor R14 is connected to the pin 2CX / RX of the second monostable multivibrator chip U2B and the first terminal of the twelfth capacitor C12. The second terminal of the twelfth capacitor C12 is connected to the pin 2CX of the second monostable multivibrator chip U2B. The pin 2A of the second monostable multivibrator chip U2B is grounded. The pin 2B of the second monostable multivibrator chip U2B is connected to the output of Group B. The pin is connected to the power supply VCC. The pin VCC of the second monostable multivibrator chip U2B is connected to the power supply VCC. The pin is connected to the subsequent circuit. The pin GND of the second monostable multivibrator chip U2B is grounded.
[0049] Taking the output of Group A as an example, when the contact of the rotary encoder is in a non-contact state, the input of 1B of the first monostable multivibrator chip U2A is at a low level, and the monostable chip is in a stable state. When the contact of the rotary encoder is in the contact area, a high-level signal is generated. According to the working principle of the first monostable multivibrator chip U2A, when the input is high, the charge on the eleventh capacitor C11 is quickly discharged, and the first monostable multivibrator chip U2A enters the quasi-stable state to shape the pulse signal. At this time, the pin Output a low - level signal, and the circuit enters an unstable state. When the contact is in the non - contact area state, the 1B input of the first monostable multivibrator chip U2A turns into a low - level signal. The power supply continuously charges the eleventh capacitor C11 through the eleventh resistor R11. When the voltage on the eleventh capacitor C11 reaches the threshold value, the circuit flips, and the first monostable multivibrator chip U2A enters the stable state. At this time, on the pin of the first monostable multivibrator chip U2A Output a high - level signal.
[0050] The principle of processing the signal output by the B - group through the monostable circuit is the same as that of the A - group output, which will not be elaborated here.
[0051] As an example, the monostable circuit also includes a re - triggerable monostable circuit composed of a 555 circuit or a gate circuit, which can also achieve the same effect. Using the monostable circuit to shape the signal generated by the rotary encoder requires a lower output current for the driving signal of the rotary encoder, and further reduces the possibility of "sparking" caused by current passing through during the use of the rotary encoder, avoiding further shortening of the service life of the rotary encoder due to usage reasons.
[0052] This application also provides a detection method for a rotary encoder detection circuit, including the following steps:
[0053] Rotate the rotary encoder so that the rotary encoder circuit outputs two groups of output signals, where each group of signals includes a contact - area signal and a non - contact - area signal;
[0054] If the output signal is a contact - area signal, trigger the monostable circuit to work, and the monostable circuit shapes and inverts the output signal of the rotary encoder circuit; if the output signal is a non - contact - area signal, the monostable circuit flips the output signal;
[0055] The subsequent circuit processes the output signals of the monostable circuits in two non - contact areas. The output signal of one group of monostable circuits is used as a reference signal to judge the rotation direction and rotation amount of the rotary encoder. Specifically:
[0056] When the output signals of both groups of monostable circuits are non - contact - area signals, it is the initial state;
[0057] When the output signals of both groups of monostable circuits are contact - area signals, enter the ready - to - detect state;
[0058] When the reference signal becomes a non - contact - area signal, enter the start - detection state. After waiting for the output signals of both groups of monostable circuits to stabilize, detect the state of the output signal of the other group of monostable circuits;
[0059] If the output signal of another group of monostable circuits is a non-contact area signal, it is detected that the rotation encoder rotates once in the first direction; if the output signal of another group of monostable circuits changes from a contact area signal to a contact area signal, it is detected that the rotation encoder rotates once in the reverse direction of the first direction;
[0060] After completing one cycle of detection, when the output signals of both groups of monostable circuits are non-contact area signals, it returns to the initial state and starts the next detection cycle.
[0061] Please refer to Figure 8 , which is a flowchart of a method for determining the rotation direction and rotation amount of a rotary encoder in an embodiment of the present application. Different rotary encoders may have different waveforms. In this embodiment, the encoder PEC16-4115F is used. The output signals of the two groups of monostable circuits are signal A and signal B, and the reference signal is signal B. Taking the example that when the contact is in the non-contact area, signals A and B are at high level, and when the contact is in the contact area, signals A and B are at low level. State 0 is the state where both contacts are in the non-contact state (initial state), state 1 is the state where both contacts are in the contact state, and state 2 is the transition state from contact to non-contact. After the contact corresponding to signal B enters the non-contact area from the contact area, the detection starts. The method for determining the rotation direction and rotation amount of the rotary encoder includes steps S1 to S8:
[0062] Step S1: In the initial state 0, both signal A and signal B are at high level;
[0063] Step S2: Enter state 1, both signal A and signal B are at low level;
[0064] Step S3: Wait for signal B to change from low to high level;
[0065] Step S4: Wait for signals B and A to stabilize;
[0066] Step S5: Detect the state of signal A and determine whether signal A is at high level. If so, enter step S6; if not, enter step S7;
[0067] Step S6: The level of signal A does not change, it is detected that the rotary encoder rotates once to the left, and return to step S1;
[0068] Step S7: There is a process in which the level of signal A changes from low to high, it is detected that the rotary encoder rotates once to the right, and enter state 2;
[0069] Step S8: Wait for signal A to become high level again, and return to step S1.
[0070] When the rotary encoder is rotated, the potential levels of the A signal and the B signal change, and the sequences of the potential combinations of the A signal and the B signal are different during left-handed and right-handed rotations. The rotation direction of the rotary encoder is detected based on the potential difference. The rotary encoder will return to the initial state during both left-handed and right-handed rotations. When the left-handed rotation determination ends, both A and B are at high level, which is the same as the initial state. When the right-handed rotation determination ends, the A signal is at low level and the B signal is at high level. It can be understood that there is an action of the A signal changing from low level to high level. At this time, it is necessary to wait for the A signal to become high level before returning to the initial state, while there is no such action during left-handed rotation.
[0071] The rotary encoder detection circuit and detection method proposed in this application use a rotary encoder circuit, a monostable circuit, and a subsequent circuit to detect the trigger signal of the rotary encoder. It abandons the traditional method of detecting the electrical signal generated when mechanical contacts touch and instead detects the signal when the mechanical contacts are non-contact. In the non-contact area, since there are no electrodes, it is impossible to generate pulses, the signal is more stable, and debouncing is easier. In the contact area, the generated glitches are usually frequent and irregular, so they are abandoned and not used. By using the rotary encoder detection circuit and detection method proposed in this application, the service life of the rotary encoder is greatly extended; it has good compatibility and can almost directly replace the original rotary encoder circuit; it filters the glitches generated by the rotary encoder and improves the efficiency of software judgment; it has low cost, and the circuit is simple, stable, and reliable.
[0072] As described above, although the present invention has been shown and described with reference to specific preferred embodiments, it should not be construed as a limitation of the present invention itself. Various changes can be made in its form and details without departing from the spirit and scope of the present invention defined by the appended claims.
Claims
1. A rotation encoder detection circuit, characterized in that It includes a rotary encoder circuit, a monostable circuit and a subsequent stage circuit. The rotary encoder circuit has two groups of signal outputs. Each group of signals includes a signal when the contact is in the contact area and a signal when the contact is in the non-contact area. Each group of signals is shaped by one of the monostable circuits respectively. When the contact in the rotary encoder circuit is in the contact area, a trigger signal is generated to trigger the monostable circuit, and the monostable circuit enters the non-steady state. During the process that the monostable circuit enters the steady state from the non-steady state, unstable glitch signals generated due to poor contact of the contact are filtered, and the monostable circuit outputs an inverted trigger signal. When the contact in the rotary encoder circuit is in the non-contact area, the monostable circuit does not receive the trigger signal. After the monostable circuit completely gets out of the non-steady state, it flips and outputs a signal indicating that the contact in the rotary encoder is in the non-contact state. The subsequent stage circuit processes the output signals of the two groups of monostable circuits in the non-contact state to detect the rotation direction and rotation amount of the rotary encoder. The monostable circuit is a re-triggerable monostable circuit. When the contact in the rotary encoder circuit is in an unstable contact state, the monostable circuit can be triggered again during the non-steady state to reset the time of the non-steady state.
2. The rotation encoder detection circuit according to claim 1, wherein The monostable circuit includes a circuit composed of a transistor and a buffer, a 555 circuit, a gate circuit or a circuit using a monostable multivibrator chip.
3. The rotation encoder detection circuit according to claim 1, characterized in that, The subsequent stage circuit includes a single-chip microcomputer or a logic device.
4. A detection method based on the rotary encoder detection circuit according to any one of claims 1-3, characterized in that: Rotate the rotary encoder so that the rotary encoder circuit outputs two groups of signals, and each group of signals includes a signal when the contact is in the contact area and a signal when the contact is in the non-contact area; If the output signal is a signal in the contact area, trigger the monostable circuit to work, and the monostable circuit shapes and inverts the output signal of the rotary encoder circuit; if the output signal is a signal in the non-contact area, the monostable circuit flips and outputs a signal; The subsequent stage circuit processes the output signals of the two groups of monostable circuits in the non-contact area to judge the rotation direction and rotation amount of the rotary encoder.
5. The detection method of the rotation encoder detection circuit according to claim 4, characterized in that, The subsequent stage circuit processes the output signals of the two groups of monostable circuits in the non-contact area. The output signal of one of the monostable circuits is used as a reference signal to judge the rotation direction and rotation amount of the rotary encoder, including: The initial state is when the output signals of both groups of monostable circuits are signals in the non-contact area; When the output signals of both groups of monostable circuits are signals in the contact area, enter the ready-to-detect state; When the reference signal becomes a signal in the non-contact area, enter the start-detect state. After waiting for the output signals of both groups of monostable circuits to be stable, detect the state of the output signal of the other group of monostable circuits; If the output signal of the other group of monostable circuits is a signal in the non-contact area, it is detected that the first direction rotates once; if the output signal of the other group of monostable circuits changes from a signal in the contact area to a signal in the non-contact area, it is detected that the first direction rotates in the reverse direction once; After completing a cycle of detection, when the output signals of both groups of monostable circuits are signals in the non-contact area, return to the initial state and start the next detection cycle.
Citation Information
Patent Citations
Keyboard, detection method and detection circuit of rotary encoder, and display device
CN114544153A
Rotary encoder
JP2011089836A