Encoder detection method, encoder detection apparatus, and massage device
By monitoring the encoder's pulse signal level in real time and using interrupt signal detection, the problem of signal interference during encoder operation is solved, improving the accuracy and response speed of signal processing, and ensuring the instant response of the massage device and the user experience.
Patent Information
- Application Number
- CN202210707205.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2042-06-21
AI Technical Summary
Existing encoders are susceptible to interference during operation, leading to signal loss and false responses, which affects the accuracy and response speed of signal processing.
By monitoring the level of the first and second pulse signals of the encoder, and using interrupt signals to detect changes in the level in real time, it is determined whether the preset conditions are met, and a response command is output to instruct the target device to execute the event, thus avoiding signal loss and interference caused by polling.
It improves the accuracy and response speed of signal processing, enhances the response precision of encoders and microcontroller systems, and ensures the instant response of massage equipment and user operating experience.
Smart Images

Figure CN115212092B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of signal processing, in particular to an encoder detection method, an encoder detection device and a massage device. BACKGROUND
[0002] An encoder is a device that organizes or changes signals or data into a signal form that can be used for communication, transmission and storage. Existing encoders are mostly designed based on single-chip microcomputers, which can convert mechanical displacement into electrical signals and can be used to measure the length, angle, position or speed of an object. Encoders are widely used in different aspects, for example, a roller encoder provided on a massage instrument. A user adjusts the vibration frequency of the massage instrument by rotating the roller encoder clockwise.
[0003] Due to the mechanical nature of the encoder, it inherently has interference problems during operation. For example, an encoder converts angular displacement or linear displacement into electrical signals, generating two phase-including pulse signals, defined as pulse signal A and pulse signal B. A single-chip microcomputer at the decoding end can calculate the number of pulses of pulse signal A and pulse signal B to obtain the angular displacement value or linear displacement value, and determine the displacement direction of the angular displacement or linear displacement according to the phase difference between pulse signal A and pulse signal B, so as to send a response instruction to the massage device with the encoder and the single-chip microcomputer, so that the massage device executes a target event in response to the response instruction. SUMMARY
[0004] The present application provides an encoder detection method, an encoder detection device and a massage device, which can at least improve the accuracy of signal processing, avoid the misresponse of the encoder, and improve the detection speed.
[0005] The technical solution is as follows:
[0006] In a first aspect, the present application provides an encoder detection method, which comprises:
[0007] monitoring a first pulse signal and a second pulse signal of the encoder;
[0008] outputting an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and detecting the level state of at least one of the first pulse signal and the second pulse signal according to the interrupt signal;
[0009] judging whether the change of the level state of the first pulse signal and the second pulse signal meets a preset condition according to the detection result;
[0010] If the level state change of the first pulse signal and the second pulse signal meets the preset condition, a response instruction is output to a target device corresponding to the encoder, and the response instruction is used to instruct the target device to execute a target event.
[0011] In a second aspect, the embodiments of the present application provide an encoder detection device, which comprises:
[0012] A monitoring pulse module is configured to monitor a first pulse signal and a second pulse signal of the encoder.
[0013] An interruption detection module is configured to output an interruption signal when a level state of the first pulse signal or the second pulse signal changes, and detect the level state of at least one of the first pulse signal and the second pulse signal according to the interruption signal.
[0014] A result judgment module is configured to judge whether the level state change of the first pulse signal and the second pulse signal meets a preset condition according to a detection result.
[0015] A response execution module is configured to output a response instruction to a target device corresponding to the encoder if the level state change of the first pulse signal and the second pulse signal meets the preset condition, and the response instruction is used to instruct the target device to execute a target event.
[0016] In a third aspect, the embodiments of the present application provide a massage device, which can comprise a processor and a memory, wherein the memory stores a computer program, and the computer program is adapted to be loaded by the processor and execute the method steps described above.
[0017] The technical solutions provided by some embodiments of the present application have at least the following beneficial effects:
[0018] The present application monitors the level states of the first pulse signal and the second pulse signal in real time, outputs an interruption signal when the level state of the first pulse signal and / or the level state of the second pulse signal changes, detects the level state of the first pulse signal and / or the second pulse signal in time based on the interruption signal, determines a response instruction according to the first pulse signal and the second pulse signal, and makes the target device provided with the encoder execute a target event according to the response instruction, so as to avoid the signal loss and signal interference problems caused by the polling method in the related art, to avoid the situation that the system does not respond or responds randomly when the roller encoder rotates, to enhance the accuracy of signal processing, and to improve the response accuracy and reaction speed of the system composed of the encoder and the single-chip microcomputer. When applied to the massage device, the massage feeling of the user during massage can be ensured, and false triggering can be avoided. When the user operates, the massage device can respond in time. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, the accompanying drawings in the following description only represent some embodiments of the present application, and all other drawings obtained by those of ordinary skill in the art based on these drawings without any creative effort are within the protection scope of the present application.
[0020] Figure 1 is a structural schematic diagram of an encoder provided by an embodiment of the present application;
[0021] Figure 2 is a flow schematic diagram of an encoder detection method provided by an embodiment of the present application;
[0022] Figure 3 is a timing schematic diagram of a first pulse signal and a second pulse signal provided by an embodiment of the present application;
[0023] Figure 4 is a flow schematic diagram of an encoder detection method provided by an embodiment of the present application;
[0024] Figure 5 is a flow schematic diagram of an encoder detection method provided by an embodiment of the present application;
[0025] Figure 6 is a structural schematic diagram of an encoder detection device provided by an embodiment of the present application;
[0026] Figure 7 is a structural schematic diagram of a massage device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0027] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without any creative effort are within the protection scope of the present application.
[0028] In the description of the application, it should be understood that the terms "first", "second" and the like are used only for descriptive purposes and are not intended to indicate or imply relative importance. In the description of the application, it should be noted that unless otherwise expressly specified and limited, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to such processes, methods, products or devices. For those skilled in the art, the specific meaning of the above terms in the application can be understood in specific cases. In addition, in the description of the application, unless otherwise specified, "a plurality of" means two or more. The association between the associated objects is described as "and / or", which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. The character " / " generally represents a "or" relationship between the associated objects before and after it.
[0029] The application will be described in detail below in conjunction with specific embodiments.
[0030] In one embodiment, as shown in Figure 1 The structure diagram of an encoder provided by the embodiment of the application is shown, which can be a gear structure, provided with two pins, respectively a first pin A and a second pin B. When the encoder of the gear structure rotates around the center, the pulse signal output by the first pin A is defined as the first pulse signal, and the pulse signal output by the second pin B is defined as the second pulse signal. And when the encoder is stationary, the processing unit indicates that the level state of the first pulse signal output by the first pin A is always high, and indicates that the level state of the second pulse signal output by the second pin B is always high.
[0031] The encoder can be used as a switch, for example, the encoder is arranged on a massage device, for example, the massage device can be but not limited to a fascia gun, a neck massage, a waist massager, a knee massager, a head massager or a physiotherapy instrument, etc., in addition, the encoder can also be applied to electronic devices, for example, a wearable bracelet or a watch, or can also be applied to a physiotherapy instrument, etc. When the processing unit receives the input instruction of the user rotating the encoder in the first direction, it can increase the output of the massage force or the vibration frequency of the massage device, and when the processing unit receives the input instruction of the user rotating the encoder in the second direction, it can reduce the output of the massage force or the vibration frequency of the massage device. In addition, the encoder can also be applied to electronic devices, such as wearable bracelets / watches, oximeters, sphygmomanometers, etc. When the receiving unit receives the input instruction of the user rotating the encoder clockwise, the time of the wearable watch is adjusted. In one application scenario, when using a scroll wheel encoder, the user can easily realize multi-grade adjustment by rotating the scroll wheel
[0032] It can be understood that the present application also includes the events completed by the encoder using the encoder interface mode function of the single-chip microcomputer, for example, the processing unit detects the first pulse signal and the second pulse signal corresponding to the first pin and the second pin of the single-chip microcomputer respectively.
[0033] In one embodiment, as Figure 2 shown, an encoder detection method provided by the embodiment of the present application can be realized by relying on a computer program and can run on an encoder detection device based on the von Neumann system. The computer program can be integrated in an application or can run as an independent tool class application.
[0034] Specifically, the encoder detection method comprises:
[0035] S101, detecting a first pulse signal and a second pulse signal of the encoder.
[0036] The processing unit connected with the encoder detects the level state of the first pulse signal and the second pulse signal output by the encoder. For example, the encoder is arranged on a massage device based on a Linux operating system, and the processing unit detects the level state of the first pulse signal and the second pulse signal through a polling function.
[0037] S102, outputting an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and detecting the level state of at least one of the first pulse signal and the second pulse signal according to the interrupt signal.
[0038] Specifically, a first interrupt signal is output when the level state of the first pulse signal changes, the level state of the second pulse signal is detected according to the first interrupt signal, and a second interrupt signal is output when the level state of the second pulse signal changes, the level state of the first pulse signal is detected according to the second interrupt signal. Or a first interrupt signal is output when the level state of the first pulse signal changes, the level state of the first pulse signal is detected according to the first interrupt signal, and a second interrupt signal is output when the level state of the second pulse signal changes, the level state of the second pulse signal is detected according to the second interrupt signal. Or a first interrupt signal is output when the level state of the first pulse signal changes, the level state of the second pulse signal and the level state of the first pulse signal are detected according to the first interrupt signal, and a second interrupt signal is output when the level state of the second pulse signal changes, the level state of the first pulse signal and the level state of the second pulse signal are detected according to the second interrupt signal.
[0039] In one embodiment, the method for detecting the level state is: in the polling function, the first pin A and the second pin B of the encoder are respectively registered as interrupts corresponding to the general purpose input / output (gpio) in advance, when Figure 1 When the encoder rotates as shown, the interrupt signal is output in time according to the level state of the first pulse signal corresponding to the first pin A and the level state of the second pulse signal corresponding to the first pin A, so as to detect the level state of the first pulse signal and the second pulse signal according to the interrupt function.
[0040] As Figure 3 shown, it is a timing diagram of a first pulse signal and a second pulse signal provided by an embodiment of the present application, including a first pulse signal corresponding to a first pin A and a second pulse signal corresponding to a second pin B. When the encoder is stationary, the first pulse signal and the second pulse signal are always in a high level state, when the encoder rotates clockwise with the center as the axis, the level state of the first pulse signal and the second pulse signal will change alternately, and the phase difference is 90 degrees.
[0041] For example, Figure 3As shown, when the encoder rotates in the first direction, in the time period S0, the first pulse signal switches from high level to low level, and the second pulse signal lags behind the first pulse signal to switch from high level to low level; in the time period S1, the first pulse signal switches from low level to high level, and the second pulse signal lags behind the first pulse signal to switch from low level to high level. In other words, when the encoder rotates in the first direction, the falling edge of the first pulse signal appears in advance of the falling edge of the second pulse signal, and when the encoder rotates in the second direction, the falling edge of the first pulse signal appears behind the falling edge of the second pulse signal. The first direction can be clockwise, and the second direction can be counterclockwise. The present application also includes other cases.
[0042] It can be understood that the above is only an example, and a person skilled in the art can set the judgment conditions corresponding to the first direction rotation and the second direction rotation as needed.
[0043] S103, judging whether the change of the level state of the first pulse signal and the second pulse signal meets the preset condition according to the detection result.
[0044] According to the detection result, it is judged whether the change of the level state of the first pulse signal and the second pulse signal meets the preset condition, so as to judge whether the encoder is a normal input or an input caused by user misoperation or other abnormal working.
[0045] In one embodiment, the preset condition is that, in a preset time period, the level state of the first pulse signal changes N times, and the level state of the second pulse signal also changes N times, and N is a positive even number, for example, N can be 4 times, 6 times or 8 times, etc.
[0046] An interrupt signal is output when the level state of the first pulse signal or the second pulse signal changes, and the level state of the target pulse signal corresponding to the interrupt signal is detected according to the interrupt signal; wherein the target pulse signal is the first pulse signal or the second pulse signal. It can be understood that the values of the preset time and N are set by a person skilled in the art as needed, and the present application does not make any limitation on this.
[0047] The level state of the first pulse signal is detected according to the first interrupt signal output by the first pulse signal, and the level state of the second pulse signal is detected according to the second interrupt signal output by the second pulse signal. For example, when it is detected that the level state of the first pulse signal changes N times in a preset time T, and the level state of the second pulse signal also changes N times, and N is a positive even number, it is judged that the change of the level state of the first pulse signal and the second pulse signal meets the preset condition.
[0048] Based on the preset conditions provided in this embodiment, it is determined whether the encoder is a normal input, and thus whether to respond to the encoder's input to execute the target event. The judgment conditions are simple and the execution efficiency is high.
[0049] In another embodiment, the preset conditions include: the level state of the first pulse signal and the level state of the second pulse signal change continuously M times; when the level state of the target pulse signal changes, the level state of the non-target pulse signal is detected as the target level state; wherein, M is a positive even number, when the target pulse signal is the first pulse signal, the non-target pulse signal is the second pulse signal, and when the target pulse signal is the second pulse signal, the non-target pulse signal is the first pulse signal.
[0050] In this embodiment, the level state of the second pulse signal is detected based on the first interrupt signal output from the first pulse signal, and the level state of the first pulse signal is detected based on the second interrupt signal output from the second pulse signal. For example, M is 4. When the level state of the first pulse signal is detected to change from the first level state to the second level state for the first time, the level state of the second pulse signal is the first level state; when the level state of the second pulse signal is detected to change from the first level state to the second level state for the second time, the level state of the first pulse signal is the second level state; when the level state of the first pulse signal is detected to change from the second level state to the first level state for the third time, the level state of the second pulse signal is the second level state; when the level state of the second pulse signal is detected to change from the second level state to the first level state for the fourth time, the level state of the first pulse signal is the first level state. That is... Figure 3 The timing changes of the first and second pulse signals are shown. The first level state can be a high level state, and the second level state can be a low level state. Of course, when the encoder rotates counterclockwise, the first level state is a low level state, and the second level state is a high level state.
[0051] Based on the preset conditions provided in this embodiment, it is determined whether the encoder is a normal input, and thus whether to respond to the encoder's input execution target event. The judgment conditions are rigorous and the judgment accuracy is high.
[0052] S104. If the changes in the level states of the first pulse signal and the second pulse signal meet the preset conditions, a response command is output to the target device corresponding to the encoder. The response command is used to instruct the target device to execute the target event.
[0053] When the changes in the level states of the first pulse signal and the second pulse signal meet the preset conditions, the processing unit determines that the encoder is a normal input, and then outputs a response command to the target device corresponding to the encoder. The response command is used to instruct the target device to execute the target event.
[0054] For example, the encoder is a detector of a knob of a massage device. When the processing unit determines that the change of the first pulse signal and the second pulse signal meets the preset condition, it is determined that the encoder receives an input instruction of clockwise rotation from the user, and a response instruction is output to the massage device to indicate that the massage increases the massage intensity, for example, the vibration frequency, the massage intensity, or the electric stimulation intensity.
[0055] In one embodiment, the response instruction is determined according to the detection result, wherein the plurality of preset response instructions at least include a response instruction corresponding to rotation of the encoder in a first direction and a response instruction corresponding to rotation of the encoder in a second direction, and each preset response instruction corresponds to a target event performed by a target device.
[0056] For example, the encoder is a detector of a knob of a massage device. The response instruction for rotation in the first direction is used to instruct the massage device to increase the massage intensity or the vibration massage speed, and the response instruction for rotation in the second direction is used to instruct the massage device to decrease the massage intensity or the vibration massage speed. Based on the embodiment, a plurality of different response conditions are set based on the change of the first pulse signal and the second pulse signal corresponding to the encoder, to meet the working requirements of complex use scenarios.
[0057] The present application monitors the level state corresponding to the first pulse signal and the second pulse signal in real time, and outputs an interrupt signal when the level state of the first pulse signal and / or the level state of the second pulse signal changes, so as to timely detect the level state of the first pulse signal and / or the second pulse signal based on the interrupt signal, and further determine a response instruction according to the first pulse signal and the second pulse signal, so that the target device provided with the encoder executes a target event according to the response instruction, avoids the signal loss and signal interference problems caused by the polling mode in the related art, avoids the situation that the system does not respond or responds randomly when the roller encoder is rotated, enhances the accuracy of signal processing, improves the response accuracy and reaction speed of the system composed of the encoder and the single-chip microcomputer, reduces the complexity of operation, and improves the user operation experience.
[0058] In addition, in the complete roller signal processing process of the encoder in the embodiment, the interrupt function can be implemented, and the preemptive processing is guaranteed to not miss the signal and avoid the defect that the roller of the scrolling encoder does not respond.
[0059] In one embodiment, as shown in Figure 4 A kind of encoder detection method provided in the embodiment of the present application, which can be realized by computer program, can be run on the encoder detection device based on von Neumann system. The computer program can be integrated in application, or can be run as independent tool class application.
[0060] Specifically, the encoder detection method includes:
[0061] S201, detect the first pulse signal and the second pulse signal of the encoder.
[0062] See S101 above; it will not be repeated here.
[0063] S202. When the level of the first pulse signal or the second pulse signal changes, an interrupt signal is output, and the level of at least one of the first pulse signal and the second pulse signal is detected based on the interrupt signal.
[0064] See S202 above, which will not be repeated here.
[0065] S203. Based on the detection results, determine whether the first pulse signal and the second pulse signal include interference signals.
[0066] Interference signals can be understood as abnormal pulse signals caused by malfunctions such as abnormal operation. For example, aging of parts or harsh working environment can cause a small segment of pulse signals that do not originate from the user input to appear in the first pulse signal output by the first pin of the encoder.
[0067] In one embodiment, it is detected whether a second interrupt signal is output during the time period between the output of two first interrupt signals; if no second interrupt signal is output during the time period between the output of two first interrupt signals, it is determined that the first pulse signal corresponding to the two first interrupt signals is an interference signal.
[0068] Additionally, it detects whether a first interrupt signal is output during the time interval between the output of two second interrupt signals; if no first interrupt signal is output during the time interval between the output of two second interrupt signals, it determines that the second pulse signal corresponding to the two second interrupt signals is an interference signal.
[0069] For example, when the roller encoder rolls in the first or second direction, such as Figure 3 As shown, the falling edges of the first pulse signal and the second pulse signal alternate, as do the rising edges of the first pulse signal and the second pulse signal. Therefore, the first interrupt signal and the second interrupt signal, which change based on the level state, also alternate. In other words, if no second interrupt signal is output within the time interval between two first interrupt signals, or no first interrupt signal is output within the time interval between two second interrupt signals, it can be determined that an interference signal exists in the first pulse signal or the second pulse signal.
[0070] If it is determined that the first pulse signal and the second pulse signal do not include interference signals, then step S205 is executed directly.
[0071] S204, if it is judged that the first pulse signal and / or the second pulse signal includes an interference signal, filtering the interference signal.
[0072] If it is detected that an interference signal appears in the first pulse signal and / or the second pulse signal, the interference signal is filtered to avoid the interference signal from affecting the processing unit to make a false judgment on the change of the first pulse signal and the second pulse signal.
[0073] For example, it is detected that no second interrupt signal is output in a time period between output of two first interrupt signals, it is judged that the first pulse signal corresponding to the two first interrupt signals is an interference signal, and the interference signal is filtered. It is detected that no first interrupt signal is output in a time period between output of two second interrupt signals, it is judged that the second pulse signal corresponding to the two second interrupt signals is an interference signal, and the interference signal is filtered.
[0074] In the embodiment, the interference signal possibly appearing in the first pulse signal and the second pulse signal is judged and filtered, the judgment accuracy of the change of the first pulse signal and the second pulse signal is improved, and thus the working performance of the encoder is improved.
[0075] S205, according to the detection result, judging whether the change of the level state of the first pulse signal and the second pulse signal satisfies a preset condition.
[0076] Referring to S103, details are not repeated here.
[0077] S206, outputting a response instruction to a target device corresponding to the encoder, the response instruction being used to instruct the target device to execute a target event.
[0078] Referring to S104, details are not repeated here.
[0079] The application monitors the level state corresponding to the first pulse signal and the second pulse signal in real time, outputs an interrupt signal when the level state of the first pulse signal and / or the level state of the second pulse signal changes, detects the level state of the first pulse signal and / or the level state of the second pulse signal in time based on the interrupt signal, determines a response instruction according to the first pulse signal and the second pulse signal, and makes the target device provided with the encoder execute a target event according to the response instruction, so as to avoid the signal loss and signal interference problem caused by the polling manner in the related art, to avoid the situation that the system does not respond or responds randomly when the roller encoder rotates, to enhance the accuracy of signal processing, and to improve the response accuracy and reaction speed of the system composed of the encoder and the single-chip microcomputer. When applied to a massage device, the massage feeling of a user during massage can be ensured, and false triggering can be avoided. When the user operates, the massage device can respond in time.
[0080] In one embodiment, asFigure 5 As shown in the figure, the encoder detection method provided by the embodiment of the present application can be implemented by relying on a computer program and can run on an encoder detection device based on the Von Neumann system. The computer program can be integrated in an application or can run as an independent tool application.
[0081] Specifically, the encoder detection method comprises the following steps.
[0082] S301, start.
[0083] The processing unit detects a start instruction. For example, a user inputs the start instruction through an input device of the target device, and the input device is a touch screen or a certain physical button of the target device.
[0084] S302, initialize the parameters of the polling function.
[0085] The processing unit executes the tasks in the preset work queue through the polling function. The work queue can be understood as a form of sequentially calling and executing the preset tasks, and the work queue does not need to be executed immediately by the interrupt function and is allowed to be rescheduled or even sleep. The work queue needs to be created in advance, and the parameters of the polling function need to be initialized each time it is started. The specific steps are set by the related technical personnel as needed.
[0086] S303, whether the scroll wheel rotates.
[0087] The scroll wheel is a scroll wheel encoder, and the processing unit judges whether the scroll wheel encoder rotates based on the change of the first pulse signal and the second pulse signal on the first pin and the second pin of the scroll wheel encoder.
[0088] S304, if the scroll wheel rotates, execute the interrupt function.
[0089] When the level state of the first pulse signal or the second pulse signal changes, the interrupt function is output, and the level state of the first pulse signal or the second pulse signal is judged according to the interrupt function. For example, when the level state of the first pulse signal is detected to change, the first interrupt signal is output according to the interrupt function, and the level state of the first pulse signal is detected, or when the level state of the first pulse signal is detected to change, the first interrupt signal is output according to the interrupt function, and the level state of the second pulse signal is detected. The tasks executed according to the interrupt function are described above Figures 2-4 , which will not be described here again.
[0090] If the preset condition of the interrupt function on the first pulse signal and the second pulse signal is met, a work task of transmitting a response instruction of executing a target event to application layer software of the target device is executed. For example, when it is judged that the first pulse signal and the second pulse signal meet the preset condition and it is judged that the scroll wheel encoder rotates in the first direction, four bytes of response instruction are used to represent the above information, and the processing unit executes a work task of transmitting the response instruction to the application layer software according to the work queue, so that the target device executes a target event corresponding to the response instruction, for example, a target event of increasing the massage intensity or vibration massage speed of the massage device.
[0091] When the preset condition of the interrupt function on the first pulse signal and the second pulse signal is not met, the work queue corresponding to the polling function is continued to be executed according to the polling function.
[0092] S305, if the scroll wheel does not rotate, the polling function is executed.
[0093] If the rotation of the scroll wheel is not detected, the interrupt function is not triggered, and the work queue corresponding to the polling function is continued to be executed according to the polling function. For example, the target device as a massage device outputs a prompt voice to guide the user to operate the massage device.
[0094] S306, end.
[0095] When the end instruction input by the user or the preset end condition is detected, the polling function is stopped. For example, the preset end condition is that the trigger of the interrupt function is not detected within a preset time.
[0096] The present application monitors the level state corresponding to the first pulse signal and the second pulse signal in real time through the interrupt function and the polling function, so as to output the interrupt signal in time, and judges whether to execute the task of transmitting the response instruction to the application layer of the target device according to the interrupt function, avoids the signal loss and signal interference problem caused by the polling method in the related art to avoid the situation that the scroll wheel encoder rotates but the system does not respond or responds randomly, enhances the accuracy of signal processing, and improves the response accuracy and reaction speed of the system composed of the encoder and the single-chip microcomputer. When applied to a massage device, the massage feeling of the user during massage can be ensured, and false triggering can be avoided. When the user operates, the massage device can respond in time.
[0097] The following is an embodiment of the device of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the device embodiment of the present application, please refer to the method embodiment of the present application.
[0098] Please refer to Figure 6FIG. 1 shows a structure diagram of an encoder detection device according to an example embodiment of the present application. The encoder detection device can be implemented by software, hardware or a combination of both to become all or part of the device. The encoder detection device comprises a monitoring pulse module 601, an interrupt detection module 602, a result judging module 603 and a response execution module 604.
[0099] The monitoring pulse module 601 is configured to monitor a first pulse signal and a second pulse signal of the encoder.
[0100] The interrupt detection module 602 is configured to output an interrupt signal when a level state of the first pulse signal or the second pulse signal changes, and detect the level state of at least one of the first pulse signal and the second pulse signal according to the interrupt signal.
[0101] The result judging module 603 is configured to judge whether the change of the level state of the first pulse signal and the second pulse signal meets a preset condition according to the detection result.
[0102] The response execution module 604 is configured to output a response instruction to a target device corresponding to the encoder if the change of the level state of the first pulse signal and the second pulse signal meets the preset condition, wherein the response instruction is used to instruct the target device to execute a target event.
[0103] In an example embodiment, the interrupt detection module 602 comprises:
[0104] A first interrupt unit is configured to output a first interrupt signal when the level state of the first pulse signal changes, and detect the level state of the second pulse signal according to the first interrupt signal; and
[0105] A second interrupt unit is configured to output a second interrupt signal when the level state of the second pulse signal changes, and detect the level state of the first pulse signal according to the second interrupt signal.
[0106] In an example embodiment, the interrupt detection module 602 comprises:
[0107] A first detection unit is configured to output an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and detect the level state of a target pulse signal corresponding to the interrupt signal according to the interrupt signal, wherein the target pulse signal is the first pulse signal or the second pulse signal.
[0108] The preset condition comprises:
[0109] The level state of the first pulse signal changes N times within a preset time period, and the level state of the second pulse signal also changes N times, and N is an even positive number.
[0110] In one embodiment, the preset condition comprises:
[0111] The level state of the first pulse signal and the level state of the second pulse signal change alternately M times continuously, and when the level state of the target pulse signal changes, the level state of the non-target pulse signal is detected as the target level state.
[0112] M is an even positive number, the non-target pulse signal is the second pulse signal when the target pulse signal is the first pulse signal, and the non-target pulse signal is the first pulse signal when the target pulse signal is the second pulse signal.
[0113] In one embodiment, M is 4, the level state of the first pulse signal and the level state of the second pulse signal change alternately M times continuously, and when the level state of the target pulse signal changes, the level state of the non-target pulse signal is detected as the target level state, comprising:
[0114] When the level state of the first pulse signal is detected to change from a first level state to a second level state for the first time, the level state of the second pulse signal is the first level state;
[0115] When the level state of the second pulse signal is detected to change from the first level state to the second level state for the second time, the level state of the first pulse signal is the second level state;
[0116] When the level state of the first pulse signal is detected to change from the second level state to the first level state for the third time, the level state of the second pulse signal is the second level state;
[0117] When the level state of the second pulse signal is detected to change from the second level state to the first level state for the fourth time, the level state of the first pulse signal is the first level state.
[0118] In one embodiment, the encoder detection device further comprises:
[0119] An interference judgment module is configured to judge whether the first pulse signal and / or the second pulse signal comprises an interference signal according to the detection result.
[0120] An interference filtering module is configured to filter out the interference signal if the first pulse signal and / or the second pulse signal comprises an interference signal.
[0121] In one embodiment, the interference judgment module is specifically configured to detect whether one second interrupt signal is output within a time period between output of two first interrupt signals;
[0122] If no second interrupt signal is output within the time period between output of the two first interrupt signals, it is determined that the first pulse signals corresponding to the two first interrupt signals are interference signals;
[0123] In addition, the interference judgment module is specifically configured to detect whether one first interrupt signal is output within a time period between output of two second interrupt signals;
[0124] If no first interrupt signal is output within the time period between output of the two second interrupt signals, it is determined that the second pulse signals corresponding to the two second interrupt signals are interference signals.
[0125] In one embodiment, the response execution module 604 comprises:
[0126] An instruction determination unit configured to determine the response instruction from a plurality of preset response instructions according to the detection result;
[0127] The plurality of preset response instructions at least include a response instruction corresponding to rotation of the encoder in a first direction and a response instruction corresponding to rotation of the encoder in a second direction, and a target event executed by a target device corresponding to each of the preset response instructions is different.
[0128] The present application monitors the level state corresponding to the first pulse signal and the second pulse signal in real time, and outputs an interrupt signal when the level state of the first pulse signal and / or the level state of the second pulse signal changes, so as to timely detect the level state of the first pulse signal and / or the second pulse signal based on the interrupt signal, and further determine a response instruction according to the first pulse signal and the second pulse signal, so that the target device provided with the encoder executes a target event according to the response instruction, avoids the signal loss and signal interference problem caused by the polling manner of acquiring the interrupt signal in the related art, and avoids the situation that the system does not respond or responds randomly when the roller encoder is rotated, enhances the accuracy of signal processing, and improves the response accuracy and reaction speed of the system composed of the encoder and the single-chip microcomputer. When applied to a massage device, the massage feeling of the user during massage can be ensured, and false triggering can be avoided. When the user operates, the massage device can respond in time.
[0129] It should be noted that the encoder detection apparatus provided in the above embodiment is only used as an example to illustrate the division of the above functional modules, and in actual application, the above functions can be completed by different functional modules according to the needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the encoder detection apparatus and the encoder detection method provided in the above embodiment belong to the same concept, and the implementation process is embodied in the method embodiment, which will not be described here.
[0130] The serial numbers of the above embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0131] The embodiment of the present application further provides a computer storage medium, which can store a plurality of instructions, and the instructions are suitable for being loaded and executed by a processor to implement the encoder detection method of the above Figures 1-5 embodiment, and the specific implementation process can refer to the specific description of the above Figures 1-5 embodiment, which will not be described here.
[0132] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the encoder detection method of the above Figures 1-5 embodiment, and the specific implementation process can refer to the specific description of the above Figures 1-5 embodiment, which will not be described here.
[0133] Please refer to Figure 7 , the embodiment of the present application provides a structural block diagram of a massage device. The massage device can be, but is not limited to, a fascia gun, a neck massage, a waist massager, a knee massage instrument, a head massage instrument or a physiotherapy instrument, etc. In addition, the massage device can also be a wristband with a massage function, etc. The massage device 700 includes a processor 701 and a memory 704, which can also include a user interface 703, at least one communication bus 702.
[0134] Among them, the communication bus 702 is used to realize the connection communication between the components.
[0135] Among them, the user interface 703 can include a display screen (Display), a camera (Camera), and an optional user interface 703 can also include a standard wired interface, a wireless interface.
[0136] The processor 701 can include one or more processing cores. The processor 701 connects various parts within the server 700 through various interfaces and lines, performs various functions of the server 700 and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 704, and calling data stored in the memory 704. Alternatively, the processor 701 can be implemented in at least one of a hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 701 can integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes operating systems, user interfaces, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 701, but can be realized by a separate chip.
[0137] The memory 704 can include a random access memory (RAM) and a read-only memory (ROM). Alternatively, the memory 704 includes a non-transitory computer-readable storage medium. The memory 704 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 704 can include a program storage area and a data storage area, wherein the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area can store data involved in the above-mentioned various method embodiments, etc. The memory 704 can also be at least one storage device located away from the aforementioned processor 701. As shown, the memory 704 as a computer storage medium can include an operating system, an instruction communication module, a user interface module, and an encoder detection application program. Figure 7
[0138] In Figure 7 The massage device 700 shown, the user interface 703 is mainly used for providing the interface for the user to input, obtaining the data input by the user; and the processor 701 can be used to call the encoder detection application stored in the memory 704, and specifically perform the following operations:
[0139] monitoring the first pulse signal and the second pulse signal of the encoder;
[0140] outputting an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and detecting the level state of at least one of the first pulse signal and the second pulse signal according to the interrupt signal;
[0141] judging whether the change of the level state of the first pulse signal and the second pulse signal meets a preset condition according to the detection result;
[0142] if the change of the level state of the first pulse signal and the second pulse signal meets the preset condition, outputting a response instruction to a target device corresponding to the encoder, the response instruction being used to instruct the target device to execute a target event.
[0143] In one embodiment, the processor 701 performs the outputting of the interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and the detection of the level state of at least one of the first pulse signal and the second pulse signal according to the interrupt signal, specifically performs:
[0144] outputting a first interrupt signal when the level state of the first pulse signal changes, and detecting the level state of the second pulse signal according to the first interrupt signal; and
[0145] outputting a second interrupt signal when the level state of the second pulse signal changes, and detecting the level state of the first pulse signal according to the second interrupt signal.
[0146] In one embodiment, the processor 701 performs the outputting of the interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and the detection of the level state of at least one of the first pulse signal and the second pulse signal according to the interrupt signal, specifically performs:
[0147] outputting an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and detecting the level state of a target pulse signal corresponding to the interrupt signal according to the interrupt signal; wherein the target pulse signal is the first pulse signal or the second pulse signal;
[0148] The preset condition includes:
[0149] The level state of the first pulse signal changes N times within a preset time period, and the level state of the second pulse signal also changes N times, and N is an even positive number.
[0150] In one embodiment, the preset condition comprises:
[0151] The level state of the first pulse signal and the level state of the second pulse signal change alternately M times continuously, and when the level state of the target pulse signal changes, the level state of the non-target pulse signal is detected as the target level state.
[0152] M is an even positive number, the non-target pulse signal is the second pulse signal when the target pulse signal is the first pulse signal, and the non-target pulse signal is the first pulse signal when the target pulse signal is the second pulse signal.
[0153] In one embodiment, M is 4, the level state of the first pulse signal and the level state of the second pulse signal change alternately M times continuously, and when the level state of the target pulse signal changes, the level state of the non-target pulse signal is detected as the target level state, comprising:
[0154] When the level state of the first pulse signal is detected to change from a first level state to a second level state for the first time, the level state of the second pulse signal is the first level state;
[0155] When the level state of the second pulse signal is detected to change from the first level state to the second level state for the second time, the level state of the first pulse signal is the second level state;
[0156] When the level state of the first pulse signal is detected to change from the second level state to the first level state for the third time, the level state of the second pulse signal is the second level state;
[0157] When the level state of the second pulse signal is detected to change from the second level state to the first level state for the fourth time, the level state of the first pulse signal is the first level state.
[0158] In one embodiment, the processor 701 performs the output of the interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and after detecting the level state of at least one of the first pulse signal and the second pulse signal according to the interrupt signal, before judging whether the level state change of the first pulse signal and the second pulse signal meets the preset condition according to the detection result, the processor 701 further performs:
[0159] determining whether the first pulse signal and / or the second pulse signal comprises an interference signal according to the detection result;
[0160] filtering the interference signal if the first pulse signal and / or the second pulse signal comprises the interference signal.
[0161] In one embodiment, the processor 701 performs the determining whether the first pulse signal and / or the second pulse signal comprises an interference signal according to the detection result, specifically:
[0162] detecting whether one second interrupt signal is output within a time period between output of two first interrupt signals;
[0163] determining that the first pulse signal corresponding to the two first interrupt signals is an interference signal if one second interrupt signal is not output within the time period between output of the two first interrupt signals;
[0164] and detecting whether one first interrupt signal is output within a time period between output of two second interrupt signals;
[0165] determining that the second pulse signal corresponding to the two second interrupt signals is an interference signal if one first interrupt signal is not output within the time period between output of the two second interrupt signals.
[0166] In one embodiment, the processor 701 performs the outputting a response instruction to a target device corresponding to the encoder if the level state change of the first pulse signal and the second pulse signal meets the preset condition, specifically:
[0167] determining the response instruction from a plurality of preset response instructions according to the detection result;
[0168] The plurality of preset response instructions at least include a response instruction corresponding to rotation of the encoder in a first direction and a response instruction corresponding to rotation of the encoder in a second direction, and a target event performed by a target device corresponding to each preset response instruction is different.
[0169] The application monitors the level states corresponding to the first pulse signal and the second pulse signal in real time, and outputs an interrupt signal when the level state of the first pulse signal and / or the level state of the second pulse signal changes, so as to detect the level state of the first pulse signal and / or the second pulse signal in time based on the interrupt signal, further determine a response instruction according to the first pulse signal and the second pulse signal, and make the target device provided with the encoder execute a target event according to the response instruction, so as to avoid the signal loss and signal interference problems caused by the polling manner in the related art to obtain the interrupt signal, so as to avoid the situation that the system does not respond or responds randomly when the roller encoder is rotated, enhance the accuracy of signal processing, and improve the response accuracy and reaction speed of the system composed of the encoder and the single-chip microcomputer. When applied to a massage device, the massage device can ensure the massage body feeling of a user during massage, and can avoid false triggering. When the user operates, the massage device can respond in time.
[0170] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware, and the program can be stored in a computer readable storage medium. When the program is executed, the program can include the processes of the above-mentioned embodiment methods. The storage medium can be a magnetic disc, an optical disc, a read-only memory or a random access memory.
[0171] The above only describes the preferred embodiments of the application, and cannot limit the scope of the application. Any equivalent changes made according to the claims of the application are still within the scope of the application.
Claims
1. An encoder detection method, characterized in that, The method includes: Monitor the first pulse signal and the second pulse signal of the encoder; When the level of the first pulse signal or the second pulse signal changes, an interrupt signal is output, and the level of at least one of the first pulse signal and the second pulse signal is detected based on the interrupt signal; Based on the detection results, determine whether the changes in the level states of the first pulse signal and the second pulse signal meet the preset conditions; If the level changes of the first pulse signal and the second pulse signal meet the preset conditions, a response instruction is output to the target device corresponding to the encoder. The response instruction is used to instruct the target device to execute the target event. The step of outputting an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and detecting the level state of at least one of the first pulse signal and the second pulse signal based on the interrupt signal, includes: When the level of the first pulse signal changes, a first interrupt signal is output, and the level of the second pulse signal is detected based on the first interrupt signal; and When the level of the second pulse signal changes, a second interrupt signal is output, and the level of the first pulse signal is detected based on the second interrupt signal; The method for detecting the voltage level is as follows: In the polling function, the general-purpose inputs and outputs corresponding to the first and second pins of the encoder are registered as interrupts. When the level of the first pulse signal or the second pulse signal changes, an interrupt function is output. The level of the first pulse signal or the second pulse signal is determined according to the interrupt function. If the preset conditions of the interrupt function for the first pulse signal and the second pulse signal are not met, the work queue corresponding to the polling function continues to be executed.
2. The encoder detection method according to claim 1, characterized in that, The step of outputting an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and detecting the level state of at least one of the first pulse signal and the second pulse signal based on the interrupt signal, includes: An interrupt signal is output when the level of the first pulse signal or the second pulse signal changes, and the level of the target pulse signal corresponding to the interrupt signal is detected based on the interrupt signal; wherein, the target pulse signal is the first pulse signal or the second pulse signal; The preset conditions include: Within the preset time period, the level of the first pulse signal changes N times, and the level of the second pulse signal also changes N times, where N is a positive even number.
3. The encoder detection method according to claim 1, characterized in that, The preset conditions include: The level states of the first pulse signal and the second pulse signal alternately change M times. When the level state of the target pulse signal changes, the level state of the non-target pulse signal is detected as the target level state. Where M is a positive even number, when the target pulse signal is the first pulse signal, the non-target pulse signal is the second pulse signal, and when the target pulse signal is the second pulse signal, the non-target pulse signal is the first pulse signal.
4. The encoder detection method according to claim 3, characterized in that, M is 4. The level states of the first pulse signal and the second pulse signal change alternately M times. When the level state of the target pulse signal changes, the level state of the non-target pulse signal is detected as the target level state, including: When the level state of the first pulse signal is first detected to change from the first level state to the second level state, the level state of the second pulse signal is the first level state; The second time, the level state of the second pulse signal is detected to change from the first level state to the second level state, and the level state of the first pulse signal is the second level state; When the level state of the first pulse signal is detected to change from the second level state to the first level state for the third time, the level state of the second pulse signal is the second level state; The fourth time, the level state of the second pulse signal is detected to change from the second level state to the first level state, and the level state of the first pulse signal is the first level state.
5. The encoder detection method according to claim 1, characterized in that, The step of outputting an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and after detecting the level state of at least one of the first pulse signal and the second pulse signal based on the interrupt signal, before determining whether the level state change of the first pulse signal and the second pulse signal meets a preset condition based on the detection result, includes: Based on the detection results, it is determined whether the first pulse signal and / or the second pulse signal include interference signals; If the first pulse signal and / or the second pulse signal includes interference signals, the interference signals are filtered out.
6. The encoder detection method according to claim 5, characterized in that, The step of determining whether the first pulse signal and / or the second pulse signal includes interference signals based on the detection results includes: Detect whether a second interrupt signal is output during the time period between the output of two first interrupt signals; If no second interrupt signal is output within the time period between the two first interrupt signals, the first pulse signal corresponding to the two first interrupt signals is determined to be an interference signal. And, detect whether a first interrupt signal is output during the time period between the output of two second interrupt signals; If no first interrupt signal is output within the time interval between the two second interrupt signals, the second pulse signal corresponding to the two second interrupt signals is determined to be an interference signal.
7. The encoder detection method according to claim 1, characterized in that, If the level changes of the first pulse signal and the second pulse signal satisfy the preset condition, a response command is output to the target device corresponding to the encoder, including: Based on the detection results, determine the response command among multiple preset response commands; The plurality of preset response instructions include at least a response instruction corresponding to the encoder rotating in a first direction and a response instruction corresponding to the encoder rotating in a second direction, and the target event executed by the target device corresponding to each preset response instruction is different.
8. An encoder detection device, characterized in that, The device includes: A pulse monitoring module is used to monitor the first pulse signal and the second pulse signal of the encoder. An interrupt detection module is used to output an interrupt signal when the level state of the first pulse signal or the second pulse signal changes, and to detect the level state of at least one of the first pulse signal and the second pulse signal based on the interrupt signal. The result judgment module is used to determine, based on the detection result, whether the changes in the level states of the first pulse signal and the second pulse signal meet preset conditions; and The response execution module is configured to output a response instruction to the target device corresponding to the encoder if the level changes of the first pulse signal and the second pulse signal meet the preset conditions. The response instruction is used to instruct the target device to execute the target event. The interruption detection module includes: A first interrupt unit is configured to output a first interrupt signal when the level of the first pulse signal changes, and to detect the level of the second pulse signal based on the first interrupt signal; and The second interrupt unit is used to output a second interrupt signal when the level state of the second pulse signal changes, and to detect the level state of the first pulse signal based on the second interrupt signal; The method for detecting the voltage level is as follows: In the polling function, the general-purpose inputs and outputs corresponding to the first and second pins of the encoder are registered as interrupts. When the level of the first pulse signal or the second pulse signal changes, an interrupt function is output. The level of the first pulse signal or the second pulse signal is determined according to the interrupt function. If the preset conditions of the interrupt function for the first pulse signal and the second pulse signal are not met, the work queue corresponding to the polling function continues to be executed.
9. A massage device, characterized in that, include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute the method steps as claimed in any one of claims 1 to 7.
Citation Information
Patent Citations
Knob digital code switch device and working state identification method thereof
CN107589933A