Signal processing method, storage medium, electronic device and rotary encoding switch
By detecting the falling edge of the input signal in the rotary encoding switch and performing correction signal processing, the signal jitter problem caused by contact aging is solved, and the accuracy of judgment is improved.
Patent Information
- Application Number
- CN202311471613.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-07
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2043-11-07
AI Technical Summary
The rotary encoded switch has poor contact due to contact oxidation and damping oil aging, resulting in a large amount of jitter in the output waveform, resulting in an increase in the number of pulses and even incorrect judgment of phase difference.
By acquiring the input signal, detecting the falling edge, the correction signal is set to low, and then different processing is performed according to the high and low level status of the input signal: if it is low, the timer is cleared, if it is high, the timer is accumulated, and Determine whether the timing exceeds the preset time. If exceeded, the correction signal is set to high. The correction signal is used for subsequent judgment to avoid burr jitter.
It effectively avoids signal burr jitter caused by contact aging, improves the accuracy of judgment, and ensures the reliability of the rotary code switch.
Smart Images

Figure CN117639760B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital signal processing, and in particular to a signal processing method, a storage medium, an electronic device and a rotary encoding switch. Background Art
[0002] Rotary encoding switches are now used in more and more scenarios, such as digital volume adjustment, menu operation, etc. During the rotation of the rotary encoding switch, the grounding slider is alternately connected to the two contacts A and B with a phase difference of 90 degrees, thereby generating square wave signals with a phase difference of 90 degrees orthogonal on the two contacts A and B. The positive and negative values of the signal phase difference represent the rotation direction. For example, when the grounding slider is not rotated (that is, no operation instruction is issued), the grounding slider is not in contact with the two contacts A and B, and the signals output by the two contacts A and B are both high level. When the grounding slider is rotated (that is, an operation instruction is issued), the grounding slider contacts the two contacts A and B respectively, and the two contacts A and B output low level signals respectively. In this way, a pulse square wave signal is generated. When the grounding slider rotates from contact A to contact B, the grounding slider contacts contact A first and then contacts B, so the phase of the square wave signal of contact A is earlier than the phase of the square wave signal of contact B, so the phase of the square wave signal of contact A minus the phase of the square wave signal of contact B is positive. On the contrary, when the grounding slider rotates from contact B to contact A, the grounding slider contacts contact B first and then contact A, so the phase of the square wave signal of contact A is later than that of contact B, so the phase of the square wave signal of contact A minus the phase of the square wave signal of contact B is negative. In this way, when the phase of the square wave signal of contact A minus the phase of the square wave signal of contact B is positive, it means that the grounding slider (operation instruction) is rotating from contact A to contact B, and it is assumed that the volume is turned up; correspondingly, when the phase of the square wave signal of contact A minus the phase of the square wave signal of contact B is negative, it means that the grounding slider (operation instruction) is rotating from contact B to contact A, and it is defined as turning down the volume. If multiple such pulses are obtained continuously, it means that multiple gears are adjusted (increased or decreased).
[0003] However, after using the rotary encoder switch for a period of time, due to contact oxidation, damping oil aging and other reasons, it will lead to poor contact, a lot of jitter in the output waveform, resulting in an increase in the number of pulses and even wrong phase difference judgment. The undesirable results are as follows: when you want to adjust it upward, it actually goes down; when you operate to rotate one gear, it is recognized as several gears or even dozens of gears. Summary of the invention
[0004] Based on the above-mentioned defects of the prior art, the present invention provides a signal processing method, a storage medium, an electronic device and a rotary coding switch, which can avoid the signal burr jitter problem caused by contact aging and improve the accuracy of judgment.
[0005] In order to achieve the above-mentioned purpose, the present invention provides a signal processing method, which is applicable to a rotary coding switch, and the signal processing method comprises: obtaining an input signal, detecting a falling edge of the input signal, setting a correction signal to a low level after detecting the falling edge of the input signal, and then performing different processing when the input signal is detected to be high or low: if the input signal is low, the timer is cleared; if the input signal is high, the timer is accumulated, and it is determined whether the timing exceeds a preset time, and if it exceeds the preset time, the correction signal is set to a high level.
[0006] In one embodiment, the input signal includes a first input signal and a second input signal, and the first input signal and the second input signal are processed as described above to form a first corrected signal and a second corrected signal respectively.
[0007] In one embodiment, the signal processing method further includes performing phase judgment based on the first correction signal and the second correction signal: if the second correction signal is at a high level when the first correction signal is at a falling edge, the direction is positive; if the second correction signal is at a low level when the first correction signal is at a falling edge, the direction is negative.
[0008] In one implementation, the falling edge detection of the input signal is implemented by external interruption or fast query of port status.
[0009] The present invention also provides a storage medium on which a computer program is stored. When the computer program is read and executed by a processor, the signal processing method as described above is executed.
[0010] The present invention also provides an electronic device, comprising: a processor, a memory and a communication bus, wherein the processor is connected to the memory via the communication bus for communication so as to execute the signal processing method as described above.
[0011] The present invention further provides a rotary coding switch, comprising a first contact, a second contact and an MCU, wherein the first contact and the second contact are respectively coupled to the MCU, and the MCU executes the signal processing method as described above.
[0012] In one embodiment, the rotary coding switch further includes a first resistor and a second resistor; a first end of the first resistor is connected to a power supply, and a second end of the first resistor is coupled to both the first contact and the MCU; a first end of the second resistor is connected to the power supply, and a second end of the second resistor is coupled to both the second contact and the MCU.
[0013] In one embodiment, the rotary coding switch further includes a first capacitor and a second capacitor; the first end of the first capacitor is connected to the second end of the first resistor, and the second end of the first capacitor is connected to the ground; the first end of the second capacitor is connected to the second end of the second resistor, and the second end of the second capacitor is connected to the ground.
[0014] In one embodiment, the rotary coding switch further includes a third resistor and a fourth resistor; the first end of the third resistor is connected to the second end of the first resistor, and the second end of the third resistor is connected to the first contact; the first end of the fourth resistor is connected to the second end of the second resistor, and the second end of the fourth resistor is connected to the second contact.
[0015] The signal processing method, storage medium, electronic device and rotary coding switch of the present invention set the correction signal to a low level after detecting the falling edge of the input signal (signal on the contact), and then perform different processing when the input signal is detected to be high or low: if the input signal is low, the timer is cleared; if the input signal is high, the timer is accumulated, and it is judged whether the timing exceeds the preset time, and if it exceeds the preset time, the correction signal is set to a high level. The correction signal replaces the input signal for subsequent judgment, and the correction signal has no burr jitter, which improves the accuracy of judgment. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings described herein are only for explanation purposes and are not intended to limit the scope of the present invention in any way. In addition, the shapes and proportional dimensions of the various components in the figures are only schematic, used to help understand the present invention, and are not specifically limited to the shapes and proportional dimensions of the various components of the present invention. Those skilled in the art can select various possible shapes and proportional dimensions to implement the present invention according to the teachings of the present invention.
[0017] Figure 1 A circuit diagram of a rotary coding switch provided in accordance with a fourth embodiment of the present invention.
[0018] Explanation of main figure marks: SW_A first contact, SW_B second contact, VCC power supply, GND ground, R1 first resistor, R2 second resistor, R3 third resistor, R4 fourth resistor, C1 first capacitor, C2 second capacitor, TOMCU_A first input signal, TOMCU_B second input signal. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0020] See also Figure 1 As shown, the first embodiment of the present invention provides a signal processing method, which is applicable to a rotary coding switch, and the signal processing method includes: obtaining an input signal, detecting a falling edge of the input signal, setting a correction signal to a low level after detecting the falling edge of the input signal, and then performing different processing when the input signal is detected to be high or low: if the input signal is low, the timer is cleared; if the input signal is high, the timer is accumulated, and it is determined whether the timing exceeds a preset time, and if it exceeds the preset time, the correction signal is set to a high level.
[0021] According to the above content, further analysis shows that when the grounding slider of the rotary coding switch is not in contact with the contact, the signal on the contact is high level, and when the grounding slider is not in contact with the contact, the signal on the contact is low level. Therefore, the burr signal (jitter signal) generated by the poor contact caused by the aging of the contact occurs in the low level period of the signal, and there is no jitter in the high level period of the signal. Therefore, the present invention detects the (first) falling edge of the signal on the contact (which can be considered as the above-mentioned input signal), that is, when the signal changes from high level to low level, that is, when the grounding slider slides from non-contact to contact with the contact. At this time, it is a normal change of the signal, but in the subsequent period, it should ideally be a low level of a certain length of time, but because of the aging of the contact, the actual signal will have multiple burr jitters, etc., and the high level of each burr jitter is often only a short time, and only when the grounding slider slides from contact to non-contact with the contact, the signal on the contact will have a long time of high level. Therefore, after the first falling edge of the signal on the contact is detected, the present invention sets a correction signal to a low level, starts a timer, and counts the duration of the high level of the signal (input signal) on the contact, and resets it to zero when it is at a low level. Because the high level of the burr jitter is often only a short time and will not exceed the preset time, the correction signal continues to be a low level, which is equivalent to "ignoring" (processing) the burr jitter of the signal on the contact until the duration of the high level of the signal (input signal) on the contact (the count of the timer) exceeds the preset time, which means that the grounding slider slides from contact to no contact with the contact, and the correction signal is set to a high level. This cycle repeats itself, and the generated correction signal has the same phase waveform as the ideal signal on the contact, so it can replace the input signal for subsequent judgment, and the correction signal has no burr jitter, which can ensure that the subsequent judgment is more accurate. In a specific embodiment, a rotary encoding switch rotates one circle, and the duration of the high level of the signal on the contact is 4ms, and the above preset time is 1ms. After testing, good results can be achieved.
[0022] Please refer to Figure 1As shown in the figure, a circuit of a rotary coding switch is shown, which includes two contacts, a first contact SW_A and a second contact SW_B. Therefore, in one embodiment, the input signal includes a first input signal and a second input signal, and the first input signal and the second input signal are respectively processed as described above to form a first correction signal and a second correction signal. Because a rotary coding switch generally requires at least two contacts, each two contacts form a group, to identify and judge the operation instruction, the corresponding signal on each contact must be processed as described above to solve the influence of burr jitter. In other embodiments, the rotary coding switch can have more groups of contacts, of course, each group of contacts can have two or more contacts, which can be set according to actual conditions. No matter how many contacts there are, the above processing can be performed.
[0023] In one embodiment, the signal processing method further includes performing phase judgment according to the first correction signal and the second correction signal: if the second correction signal is at a high level when the first correction signal is at a falling edge, the direction is positive; if the second correction signal is at a low level when the first correction signal is at a falling edge, the direction is reverse. In this way, the judgment of the rotation direction of the rotary encoding switch is completed. Of course, it can also be the other way around. If the second correction signal is at a high level when the first correction signal is at a falling edge, the direction is reverse; if the second correction signal is at a low level when the first correction signal is at a falling edge, the direction is positive. Those skilled in the art can make adjustments according to actual conditions. In addition, if there is one group of "the first correction signal is at a high level when the first correction signal is at a falling edge" or "the second correction signal is at a low level when the first correction signal is at a falling edge", it means that the operation instruction requires adjusting one gear. If there are multiple groups, it means adjusting multiple gears.
[0024] In addition, in one embodiment, the falling edge of the input signal is detected by external interruption or by fast querying the port status, so that the falling edge of the signal can be accurately detected.
[0025] A second embodiment of the present invention provides a storage medium having a computer program stored thereon. When the computer program is read and executed by a processor, the signal processing method as described above is performed.
[0026] A third embodiment of the present invention provides an electronic device, including: a processor, a memory and a communication bus, wherein the processor is connected to the memory for communication via the communication bus to execute the signal processing method as described above.
[0027] See also Figure 1As shown, the fourth embodiment of the present invention provides a rotary coding switch, which includes a first contact SW_A, a second contact SW_B and an MCU (not shown), wherein the first contact SW_A and the second contact SW_B are respectively coupled to the MCU, and the MCU executes the signal processing method as described above.
[0028] The signals on the two contacts can be directly transmitted to the MCU for the aforementioned processing to solve the glitch problem. In this way, the signals on the two contacts can also be considered as two input signals (the first input signal and the second input signal). Figure 1 The circuit shown is transmitted to the MCU through two points TOMCU_A and TOMCU_B. At this time, TOMCU_A and TOMCU_B are the aforementioned first input signal TOMCU_A and the aforementioned second input signal TOMCU_B respectively.
[0029] In one embodiment, the rotary coding switch further includes a first resistor R1 and a second resistor R2; the first end of the first resistor R1 is connected to the power supply VCC, and the second end of the first resistor R1 is coupled to both the first contact SW_A and the MCU; the first end of the second resistor R2 is connected to the power supply VCC, and the second end of the second resistor R2 is coupled to both the second contact SW_B and the MCU. Since the rotary coding switch only has a contact grounding function, the circuit needs to have a level pull-up function, and the first resistor R1 and the second resistor R2 realize the function.
[0030] In one embodiment, the rotary coding switch further includes a first capacitor C1 and a second capacitor C2; the first end of the first capacitor C1 is connected to the second end of the first resistor R1, and the second end of the first capacitor C1 is connected to the ground GND; the first end of the second capacitor C2 is connected to the second end of the second resistor R2, and the second end of the second capacitor C2 is connected to the ground GND. The first capacitor C1 and the second capacitor C2 can slow down the speed at which the signal level rises when the contact point is in poor contact, that is, they can also reduce burr jitter to a certain extent. The capacitance of the first capacitor C1 and the second capacitor C2 generally needs to be determined according to the resistance of the first resistor R1 and the second resistor R2 to determine the appropriate capacitance value, so that the time for the signal level to fully rise from a low level to a high level is controlled at about 0.5ms, which has a better effect.
[0031] In one embodiment, the rotary coding switch further includes a third resistor R3 and a fourth resistor R4; the first end of the third resistor R3 is connected to the second end of the first resistor R1, and the second end of the third resistor R3 is connected to the first contact SW_A; the first end of the fourth resistor R4 is connected to the second end of the second resistor R2, and the second end of the fourth resistor R4 is connected to the second contact SW_B. Since the first capacitor C1 and the second capacitor C2 are used for filtering, the discharge of the capacitor when the rotary coding switch contacts are connected will accelerate the aging of the contacts, so the third resistor R3 and the fourth resistor R4 are set to protect the switch contacts. The resistance of the third resistor R3 and the fourth resistor R4 is generally less than one tenth of the resistance of the first resistor R1 and the second resistor R2, so that the low level of the output signal is preferably lower than one tenth of the power supply voltage.
[0032] The signal processing method, storage medium, electronic device and rotary coding switch of the present invention set the correction signal to a low level after detecting the falling edge of the input signal (signal on the contact), and then perform different processing when the input signal is detected to be high or low: if the input signal is low, the timer is cleared; if the input signal is high, the timer is accumulated, and it is judged whether the timing exceeds the preset time, and if it exceeds the preset time, the correction signal is set to a high level. The correction signal replaces the input signal for subsequent judgment, and the correction signal has no burr jitter, which improves the accuracy of judgment.
[0033] It should be understood that the above description is for illustration and not for limitation. Many embodiments and many applications beyond the examples provided will be apparent to those skilled in the art upon reading the above description. Therefore, the scope of the present teachings should not be determined with reference to the above description, but rather with reference to the foregoing claims and the full scope of equivalents to which such claims are entitled. For the purpose of comprehensiveness, all articles and references, including disclosures of patent applications and publications, are incorporated herein by reference. The omission of any aspect of the subject matter disclosed herein in the foregoing claims is not intended to be a waiver of such subject matter, nor should it be considered that the applicant has not considered such subject matter to be part of the disclosed application subject matter.
Claims
1. A signal processing method, applicable to a rotary coding switch, characterized in that: The signal processing method comprises: obtaining an input signal, detecting a falling edge of the input signal, setting a correction signal to a low level after detecting the falling edge of the input signal, and then performing different processing when the input signal is detected to be high or low: if the input signal is low, clearing the timer; if the input signal is high, accumulating the timer, and judging whether the timing exceeds a preset time, and if it exceeds the preset time, setting the correction signal to a high level; The input signal includes a first input signal and a second input signal, and the first input signal and the second input signal are respectively processed as described above to form a first corrected signal and a second corrected signal respectively; The signal processing method also includes performing phase judgment based on the first correction signal and the second correction signal: if the second correction signal is at a high level when the first correction signal is at a falling edge, the direction is positive; if the second correction signal is at a low level when the first correction signal is at a falling edge, the direction is negative.
2. The signal processing method according to claim 1, characterized in that: The falling edge detection of the input signal is achieved by external interruption or rapid query of port status.
3. A storage medium, characterized in that: A computer program is stored thereon, and when the computer program is read and executed by a processor, the signal processing method according to any one of claims 1 to 2 is executed.
4. An electronic device, characterized in that: include: A processor, a memory and a communication bus, wherein the processor is connected to the memory for communication via the communication bus to execute the signal processing method according to any one of claims 1 to 2.
5. A rotary coding switch, characterized in that: The rotary encoding switch includes a first contact, a second contact and an MCU, the first contact and the second contact are respectively coupled to the MCU, and the MCU executes the signal processing method according to any one of claims 1-2.
6. The rotary coding switch according to claim 5, characterized in that: The rotary encoding switch also includes a first resistor and a second resistor; the first end of the first resistor is connected to a power supply, and the second end of the first resistor is coupled to both the first contact and the MCU; the first end of the second resistor is connected to the power supply, and the second end of the second resistor is coupled to both the second contact and the MCU.
7. The rotary coding switch according to claim 6, characterized in that: The rotary encoding switch also includes a first capacitor and a second capacitor; the first end of the first capacitor is connected to the second end of the first resistor, and the second end of the first capacitor is connected to the ground; the first end of the second capacitor is connected to the second end of the second resistor, and the second end of the second capacitor is connected to the ground.
8. The rotary coding switch according to claim 7, characterized in that: The rotary encoding switch further includes a third resistor and a fourth resistor; a first end of the third resistor is connected to a second end of the first resistor, and a second end of the third resistor is connected to the first contact; a first end of the fourth resistor is connected to a second end of the second resistor, and a second end of the fourth resistor is connected to the second contact.
Citation Information
Patent Citations
Software jitter elimination method and device for rotary encoder and storage medium
CN116380133A