A method and device for detecting the rolling direction of a roller based on double magnetic sensitive sensors
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-30
- Publication Date
- 2026-08-11
AI Technical Summary
[0006]鉴于现有技术的上述缺点、不足,本申请提供一种基于双磁敏传感器的滚轮滚动方向检测方法及装置、计算机可读存储介质,其解决了现有技术中基于单一传感器或单通道信号难以准确判别滚动方向、在存在机械振动及余波干扰时易出现误触发或漏检测的技术问题
[0024] The roller rolling direction detection method and apparatus based on dual magnetic sensors, and the computer-readable storage medium provided in this application embodiment, by setting dual magnetic sensors at a preset interval at adjacent positions on the roller and synchronously sampling the dual magnetic sensors to obtain the channel signals of the two magnetic sensors respectively, and determining the rolling direction of the roller based on the channel signals of the two magnetic sensors, can accurately determine the rolling direction of the roller by utilizing the temporal differences and changes between the two channel signals. At the same time, by performing collaborative analysis of the channel signals of the two magnetic sensors, the dependence on a single channel signal is reduced, and the detection stability under signal fluctuation or interference conditions is improved, thereby reducing the occurrence of false triggering and missed detection. In addition, this method performs non-contact detection of the roller with embedded magnetic elements based on magnetic sensors, avoiding the wear problems caused by mechanical contact while realizing the rolling direction detection, improving the reliability and applicability of the device, and thus enabling stable and reliable roller rolling direction detection in human-computer interaction devices.
Smart Images

Figure CN122545843A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of human-computer interaction input device technology, and in particular to a method and device for detecting the rolling direction of a roller based on dual magnetic sensors, and a computer-readable storage medium. Background Technology
[0002] In the field of human-computer interaction devices, such as remote controls, mice, and presentation pens, scroll wheels are common input components widely used to achieve functions such as menu selection, page scrolling, and parameter adjustment. As devices evolve towards miniaturization, low power consumption, and high reliability, higher demands are placed on the accuracy, response speed, and environmental adaptability of scroll wheel direction detection solutions. Currently, the detection of scroll wheel motion status typically employs technologies such as mechanical encoders, photoelectric encoders, Hall effect sensors, and capacitive touchscreens.
[0003] In existing technologies, mechanical encoders generate orthogonal pulse signals through contact to determine direction. However, this approach relies on mechanical contact structures, which are prone to wear and tear after long-term use, leading to signal jitter or even failure. Furthermore, their large size hinders the design of thinner and lighter devices. While photoelectric encoders offer high detection accuracy, they rely on light sources and photoelectric receivers, resulting in high overall power consumption and requiring high environmental cleanliness, making them unsuitable for battery-powered portable devices. Hall sensor-based solutions acquire rolling information by detecting changes in the magnetic field, achieving non-contact detection. However, using a single Hall sensor or a single-channel signal makes it difficult to effectively distinguish the rolling direction, typically requiring additional mechanical structures for assistance, increasing system complexity. Capacitive touch solutions primarily detect finger swipes for input, but their ability to detect the physical rotation of the scroll wheel is limited, and they are susceptible to environmental humidity and user operation, resulting in poor stability.
[0004] In summary, most existing roller detection solutions rely on a single sensor or single-channel signal for judgment, which is highly dependent on the integrity and stability of the signal. In practical applications, when there are complex working conditions such as mechanical vibration, residual wave interference, or switching between different rolling modes, problems such as false triggering, missed detection, and inaccurate direction determination are prone to occur. Summary of the Invention
[0005] (a) Technical problems to be solved
[0006] In view of the above-mentioned shortcomings and deficiencies of the prior art, this application provides a method and device for detecting the rolling direction of a roller based on dual magnetic sensors, as well as a computer-readable storage medium, which solves the technical problems in the prior art that it is difficult to accurately determine the rolling direction based on a single sensor or single-channel signal, and that false triggering or missed detection is easy to occur when there is mechanical vibration and residual interference.
[0007] (II) Technical Solution
[0008] To achieve the above objectives, the main technical solutions adopted in this application include:
[0009] In a first aspect, embodiments of this application provide a method for detecting the rolling direction of a roller based on dual magnetic sensors, applied to a human-computer interaction device including a roller with embedded magnetic elements and dual magnetic sensors arranged at a preset distance at adjacent positions of the roller. The method includes: synchronously and periodically sampling the dual magnetic sensors to obtain the channel signals of the two magnetic sensors respectively, and determining the rolling direction of the roller based on the channel signals of the two magnetic sensors.
[0010] Optionally, in some embodiments of this application, when it is determined that the roller is in damping mode, the method for determining the rolling direction of the roller includes: calculating the offset of the channel signals relative to the baseline value for each of the two magnetic sensors; entering a detection state when the offset of either channel signal first reaches a preset trigger threshold; continuously tracking the offset of the two channel signals in the detection state, and determining the rolling direction of the roller based on the two channel signals during the detection process when the offset of either channel signal decreases or increases by a preset amplitude.
[0011] Optionally, in some embodiments of this application, when the magnetic sensor is a linear Hall sensor, the method further includes: upon entering the detection state, recording the maximum offset of each channel signal and storing the corresponding timestamp and initializing the peak recording variable, and starting a sampling time counter to record the number of sampling cycles since entering the detection state; the peak recording variable is used to track and store the maximum offset of each channel signal during the detection process.
[0012] Optionally, in some embodiments of this application, when the magnetic sensor is a switch Hall sensor, the method further includes: upon entering the detection state, recording the timestamps corresponding to the offsets of each channel signal being 0 and 1 respectively, and starting a sampling time counter to record the number of sampling cycles since entering the detection state.
[0013] Optionally, in some embodiments of this application, the rolling direction of the roller is determined based on two channel signals during the detection process, specifically including: taking the timestamp when the offset of each channel signal first exceeds a preset peak threshold as the peak timestamp of the channel signal, and marking the peak timestamp as valid; If valid spike timestamps are recorded for both channel signals, the difference between the two valid spike timestamps is compared. If the valid spike timestamp of the first channel signal is earlier than that of the second channel signal, and the difference is greater than a preset tolerance value, then the scrolling direction is determined to be the direction corresponding to the first channel signal. If the valid spike timestamp of the second channel signal is earlier than that of the first channel signal, and the difference is greater than a preset tolerance value, then the scrolling direction is determined to be the direction corresponding to the second channel signal. If only the valid spike timestamp of the first channel signal is recorded, then the scrolling direction is determined to be the direction corresponding to the first channel signal. If only the valid spike timestamp of the second channel signal is recorded, then the scrolling direction is determined to be the direction corresponding to the second channel signal. If neither valid spike timestamp is recorded, then the scrolling direction is determined to be the direction corresponding to the channel signal with the larger offset.
[0014] Optionally, in some embodiments of this application, the rolling direction of the roller is determined based on two channel signals during the detection process. Specifically, this includes: upon entering the detection state, recording the timestamps corresponding to the offsets of each channel signal being 0 and 1; taking the timestamp corresponding to the first change of the offset of each channel signal from 0 to 1 as the first timestamp of that channel, and marking the first timestamp as valid; when both channel signals have recorded valid first timestamps, comparing the difference between the two valid first timestamps; if the valid first timestamp of the first channel signal is earlier than the valid first timestamp of the second channel signal, then determining the rolling direction as the direction corresponding to the first channel signal; if the valid first timestamp of the second channel signal is earlier than the valid first timestamp of the first channel signal, then determining the rolling direction as the direction corresponding to the second channel signal; if only the valid first timestamp of the first channel signal is recorded, then determining the rolling direction as the direction corresponding to the first channel signal; if only the valid first timestamp of the second channel signal is recorded, then determining the rolling direction as the direction corresponding to the second channel signal.
[0015] Optionally, in some embodiments of this application, after determining the rolling direction of the roller, the method further includes: setting a stabilization gate flag and determining that an idle state has been entered; in the idle state with the stabilization gate flag present, filtering the two channel signals until the difference between the two channel signals and their baseline offsets is within a stable range and the stability condition is met for N consecutive sampling periods.
[0016] Optionally, in some embodiments of this application, the stability condition is met for N consecutive sampling periods, including: the channel signals of the two magnetic sensors are within a preset stability range for N sampling periods.
[0017] Optionally, in some embodiments of this application, when it is determined that the roller is in free mode, the method for determining the rolling direction of the roller includes: decoding the channel signals of the two magnetic sensors using the orthogonal decoding principle, parsing them into binary status codes, and determining the stepping direction based on the binary status codes; and determining the rolling direction of the roller based on the stepping direction.
[0018] Optionally, in some embodiments of this application, determining the step direction based on the binary status code includes: performing a hysteresis comparison on each channel signal, converting it into a binary status code, and determining whether the channel signal is in a high or low state based on the corresponding adaptive midpoint and hysteresis amount; wherein, the adaptive midpoint corresponding to the channel signal of each magnetic sensor is calculated from the historical minimum and maximum values of the channel signal of the magnetic sensor; combining the binary status codes of two channel signals into a 2-bit status code group, and determining the step direction through a preset state transition table, wherein the step direction includes forward, reverse, or invalid.
[0019] Optionally, in some embodiments of this application, determining the rolling direction of the roller includes: when the stepping direction is opposite to the current trend direction, using a reversal buffer to count the stepping direction, and when the count recorded by the reversal buffer reaches a preset threshold, directly adding the count of the reversal buffer to the count of the position counter, and setting the count in the trend duration step counter according to the count of the reversal buffer, and flipping the current trend direction; the current trend direction is a stepping direction that appears frequently in a preset historical stepping sequence; when the stepping direction is consistent with the current trend direction, using both the position counter and the trend duration step counter to count the stepping direction, and clearing the count in the reversal buffer; using the count of the position counter as the cumulative position change, and when the cumulative position change reaches a preset step threshold, determining the stepping direction corresponding to the position counter as the rolling direction.
[0020] Optionally, in some embodiments of this application, the roller is determined to be in a damped mode upon receiving a signal indicating that the roller is in a damped mode; or, the roller is determined to be in a free mode upon receiving a signal indicating that the roller is in a free mode.
[0021] On the other hand, this application also provides a roller rolling direction detection device based on dual magnetic sensors, a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the roller rolling direction detection method based on dual magnetic sensors described in the above embodiments.
[0022] In another aspect, embodiments of this application also provide a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the roller rolling direction detection method based on dual magnetic sensors as described in the above embodiments.
[0023] (III) Beneficial Effects
[0024] The roller rolling direction detection method and apparatus based on dual magnetic sensors, and the computer-readable storage medium provided in this application embodiment, by setting dual magnetic sensors at a preset interval at adjacent positions on the roller and synchronously sampling the dual magnetic sensors to obtain the channel signals of the two magnetic sensors respectively, and determining the rolling direction of the roller based on the channel signals of the two magnetic sensors, can accurately determine the rolling direction of the roller by utilizing the temporal differences and changes between the two channel signals. At the same time, by performing collaborative analysis of the channel signals of the two magnetic sensors, the dependence on a single channel signal is reduced, and the detection stability under signal fluctuation or interference conditions is improved, thereby reducing the occurrence of false triggering and missed detection. In addition, this method performs non-contact detection of the roller with embedded magnetic elements based on magnetic sensors, avoiding the wear problems caused by mechanical contact while realizing the rolling direction detection, improving the reliability and applicability of the device, and thus enabling stable and reliable roller rolling direction detection in human-computer interaction devices. Attached Figure Description
[0025] Figure 1 This is a flowchart illustrating a roller rolling direction detection method based on dual magnetic sensors according to an embodiment of this application.
[0026] Figure 2 This is a perspective view of a human-computer interaction device according to an embodiment of this application;
[0027] Figure 3 This is another perspective view of a human-computer interaction device according to an embodiment of this application;
[0028] Figure 4 This is an exploded view of a human-computer interaction device according to an embodiment of this application after the first housing has been removed;
[0029] Figure 5This is an enlarged schematic diagram of a damping switching structure in a human-computer interaction device according to an embodiment of the present application; wherein the damping switching structure is located in a first position, and in the first position, the second magnetic element of the damping switching structure corresponds to the first magnetic element on the roller body;
[0030] Figure 6 This is another enlarged schematic diagram of a damping switching structure in a human-computer interaction device according to an embodiment of the present application; wherein the damping switching structure is located in a second position, and in the second position, the second magnetic element of the damping switching structure is misaligned with the first magnetic element on the roller body;
[0031] Figure 7 This is a flowchart illustrating the process of determining the rolling direction of a roller when the roller is in damped mode, according to an embodiment of this application.
[0032] Figure 8 This is an actual sampling waveform diagram when the magnetic sensor according to one embodiment of this application is a linear Hall sensor;
[0033] Figure 9 This is a flowchart illustrating the process of determining the rolling direction of a roller in free mode according to an embodiment of this application.
[0034] Figure 10 This is a schematic diagram of a roller signal waveform based on a dual magnetic sensor in free mode according to an embodiment of this application. Detailed Implementation
[0035] To better explain and facilitate understanding of this application, the following detailed description of the application is provided in conjunction with the accompanying drawings and specific embodiments.
[0036] In related technologies, solutions for detecting the rolling direction of rollers can be mainly categorized as follows:
[0037] The first type is the direction detection scheme based on mechanical encoders. This scheme mechanically couples a rotary encoder to the roller shaft, uses contact switches or quadrature code disks to generate pulse signals, and determines the rolling direction based on the pulse phase relationship. Although this scheme is technically mature and has a clear discrimination logic, it relies on a mechanical contact structure, which is prone to wear and poor contact during long-term use. In addition, it is susceptible to signal jitter under the influence of dust, moisture, and other environmental factors, thus affecting the stability and reliability of rolling direction detection.
[0038] The second type is the direction detection scheme based on photoelectric encoders. This scheme uses a combination of a grating disk and phototransistors to generate periodic light signals during the rotation of the roller, and achieves direction recognition based on the phase difference of the light signals. This scheme has high resolution and detection accuracy, but because it requires the configuration of a light source and photoelectric receiving devices, the overall structure is complex, the power consumption is high, and the requirements for assembly precision and the cleanliness of the operating environment are high, making it unsuitable for low-power wireless remote control portable devices.
[0039] The third type is the direction detection scheme based on a single magnetic sensor. This scheme uses a single Hall sensor to detect changes in the magnetic field of an embedded magnetic element to determine the rolling state. However, this scheme can usually only acquire a single-channel signal, making it difficult to directly reflect the rolling direction information. In practical applications, it often requires the introduction of complex mechanical structures or reasoning logic for auxiliary judgment, which increases the system complexity and reduces the reliability of direction judgment.
[0040] Furthermore, when the above-mentioned solutions are applied to different working modes (such as damped segmented rollers and undamped free-rotating rollers), the signal characteristics generated by the rollers in different modes are significantly different. Existing technologies usually rely on a single signal channel or fixed structure for processing, making it difficult to achieve stable and consistent direction detection in the same human-machine interaction device. They are easily affected by mechanical vibration and signal fluctuations, resulting in unstable direction determination.
[0041] Therefore, the roller rolling direction detection method based on dual magnetic sensors provided in this application embodiment sets dual magnetic sensors at a preset interval at adjacent positions of the roller and performs synchronous periodic sampling on the dual magnetic sensors to obtain the channel signals of the two magnetic sensors respectively. The rolling direction of the roller is determined based on the channel signals of the two magnetic sensors. By utilizing the time difference characteristics of the signals obtained by the dual-channel synchronous sampling, the rolling direction of the roller can be directly determined. At the same time, through the synergistic effect of the channel signals of the dual magnetic sensors, the uncertainty in direction recognition of a single sensor is avoided, and the stability and reliability of direction detection are improved, thereby realizing accurate detection of the rolling direction of rollers with embedded magnetic elements in human-computer interaction devices.
[0042] To better understand the above technical solutions, exemplary embodiments of this application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application can be understood more clearly and thoroughly, and that the scope of this application can be fully conveyed to those skilled in the art.
[0043] Figure 1This is a schematic flowchart illustrating a roller rolling direction detection method based on dual magnetic sensors according to an embodiment of this application. This roller rolling direction detection method based on dual magnetic sensors is applied to a human-machine interface device including a roller with embedded magnetic elements and dual magnetic sensors arranged at preset intervals adjacent to the roller.
[0044] In some embodiments of this application, the human-computer interaction device is used to realize remote interactive control of the controlled device, and it can be widely used in different types of human-computer interaction terminals. For example, in a vehicle control system, the human-computer interaction device can be used to control functions such as multimedia playback, volume adjustment, and interface menu switching; in a smart TV or set-top box control scenario, it can be used to realize operations such as program browsing, playback progress adjustment, and application selection; in a smart home control system, it can be used to adjust parameters or switch modes of devices such as lights and air conditioners. As can be seen from the above application scenarios, the human-computer interaction device can adapt to various control needs and realize a unified interaction entry point for different devices.
[0045] Next, see the appendix. Figure 2-6 This application provides a detailed description of the human-computer interaction device. Specific embodiments and accompanying drawings are also provided. Figure 2-6 The structure shown is further explained in detail, including its components, working principle, and the interrelationships between them, so that those skilled in the art can more clearly and completely understand the technical solution and its implementation in this application. (Refer to...) Figure 2-6 The human-computer interaction device includes a dual-mode magnetic induction roller assembly and a housing frame 1. The dual-mode magnetic induction roller assembly includes a roller body 2 and a damping switching structure 3. Specifically, the housing frame 1 is the mounting base for the entire dual-mode magnetic induction roller assembly, with an internal accommodating chamber and a semi-open roller mounting cavity 11 on its outer side (the front end in this embodiment). The roller body 2 is rotatably mounted within the roller mounting cavity 11 for the user to operate by flicking it with their fingers. Figures 2 to 4As shown, the roller body 2 includes a cylindrical segment 22 and a prism segment 23. The outer surface of the cylindrical segment 22 may be provided with an anti-slip texture or a rubber coating to improve the feel of turning. Multiple first magnetic elements 21 are spaced apart along the circumference of the prism segment 23. Furthermore, it should be noted that the cylindrical segment 22 and the prism segment 23 can be integrally formed or separate. Preferably, the prism segment 23 has a regular polygonal prism structure, and multiple first magnetic elements 21 are embedded on the side surface of the regular polygonal prism. Specifically, one first magnetic element 21 can be provided on each side surface of the regular polygonal prism; or, multiple first magnetic elements 21 can be spaced apart along the circumference of the regular polygonal prism on some of its side surfaces. A damping switching structure 3 is movably disposed within the accommodating cavity and located on the side near the roller mounting cavity 11. A second magnetic element 31 is provided on the damping switching structure 3. In this embodiment, both the first magnetic element 21 and the second magnetic element 31 are permanent magnets.
[0046] The roller assembly in this embodiment can switch between "damped mode" and "free mode". The specific principle is as follows: the damping switching structure 3 can be positioned relative to the housing frame 1 at a first position (e.g., ...). Figure 5 (as shown) and second position (as shown) Figure 6 The device moves between the two positions (as shown). When the user moves the damping switching structure 3 to the first position, the position of the second magnetic element 31 is exactly opposite to the trajectory of the first magnetic element 21 as it rotates with the roller body 2. At this time, if the roller body 2 is turned, a magnetic attraction will be generated between the second magnetic element 31 and the first magnetic element 21 passing through its directly opposite position. This periodic magnetic attraction overcomes the free rotation of the roller, thus producing a clear segmented damping feel.
[0047] When the user moves the damping switching structure 3 to the second position, the second magnetic element 31 moves accordingly, thus misaligning with the movement trajectory of the first magnetic element 21, and the magnetic force between them is greatly weakened or disappears. At this time, the segment damping is released, and the roller body 2 can rotate smoothly and freely without magnetic interference.
[0048] To convert the mechanical motion of the roller into electrical signals recognizable by electronic devices, this embodiment also includes a sensor substrate 4 (such as a PCB board). The sensor substrate 4 is fixedly mounted on the cavity wall of the roller mounting cavity 11. On one hand, a first magnetic sensor 5 and a second magnetic sensor 6 are disposed on the sensor substrate 4. These two magnetic sensors are arranged at intervals along the circumference of the roller body 2 and are positioned directly opposite the movement trajectory of the first magnetic element 21. When the roller body 2 rotates, the first magnetic element 21 sequentially passes over the first magnetic sensor 5 and the second magnetic sensor 6, causing a periodic change in the magnetic field strength. The circuit on the sensor substrate 4 can accurately calculate the rolling direction and rotational speed of the roller body 2 by acquiring the channel signals output by these two magnetic sensors.
[0049] Based on the above-mentioned structure and working principle of human-computer interaction devices, to more clearly explain the implementation process of the roller rolling direction detection method based on dual magnetic sensors, the following section combines... Figure 1 The method for detecting the rolling direction of a roller based on dual magnetic sensors in the embodiments of this application will be described in detail. The method includes:
[0050] The dual magnetic sensors are synchronously sampled periodically to obtain the channel signals of the two magnetic sensors respectively, and the rolling direction of the roller is determined based on the channel signals of the two magnetic sensors.
[0051] Specifically, in this embodiment, the synchronous periodic sampling of the dual magnetic sensors refers to synchronously triggering sampling of the first and second magnetic sensors, which are positioned adjacent to the roller and have a preset distance between them, within a preset sampling period. This allows the acquisition of the channel signals corresponding to the two magnetic sensors at the same sampling moment. Because the roller has an embedded magnetic element, as the roller rotates, this magnetic element passes sequentially relative to the two magnetic sensors in space, causing changes in the time sequence of the two channel signals.
[0052] For example, when the roller rolls forward, the embedded magnetic element first approaches the first magnetic sensor, causing the first channel signal to show an initial change in amplitude or characteristic. Then, as the roller continues to rotate, the magnetic element approaches the second magnetic sensor, causing the second channel signal to subsequently change accordingly. Under synchronous periodic sampling conditions, the leading change relationship between the first channel signal and the second channel signal can be clearly obtained.
[0053] Accordingly, when the roller rolls in the opposite direction, the magnetic element first passes through the second magnetic sensor, causing a change in the second channel signal. Subsequently, the first channel signal corresponding to the first magnetic sensor changes. By comparing and analyzing the channel signals of the two magnetic sensors, the rolling direction of the roller can be determined based on the order of their changes.
[0054] Therefore, this application acquires dual-channel signals through synchronous periodic sampling of dual magnetic sensors, and utilizes the time difference characteristics generated when the magnetic element passes through different spatial positions to achieve stable determination of the rolling direction of the roller, thereby improving the accuracy and reliability of roller direction detection.
[0055] Optionally, in some embodiments of the application, see [link to application]. Figure 7 When it is determined that the roller is in damped mode, the method for determining the rolling direction of the roller includes:
[0056] For the channel signals of the two magnetic sensors, calculate the offset of the channel signal relative to the baseline value for each;
[0057] When the offset of any channel signal first reaches the preset trigger threshold, the detection state is entered.
[0058] During the detection process, the offset of the two channel signals is continuously tracked, and the rolling direction of the roller is determined based on the two channel signals when the offset of either channel signal decreases or increases by a preset amplitude.
[0059] For example, when the roller is determined to be in damped mode, the roller will exhibit a distinct segmented motion during rotation. Each segment transition typically corresponds to a local positional change of the magnetic element relative to the magnetic sensor, resulting in periodic fluctuations in the channel signals of the two magnetic sensors. To address this characteristic, this application first calculates the offset of the channel signals of the two magnetic sensors relative to a baseline value, where the baseline value can be the average magnetic field value or the initial stable value when the roller is stationary. This eliminates the influence of ambient magnetic fields or device bias on the signal, ensuring that the offset accurately reflects the magnetic field changes caused by the roller's movement.
[0060] For example, when the roller is stationary, the channel signals of both the first and second magnetic sensors remain stable, with the offset approaching zero. As the user begins to slowly roll the roller, the magnetic element gradually approaches a particular magnetic sensor, causing the offset of the corresponding channel of that sensor to gradually increase. When the offset of any channel signal first reaches a preset trigger threshold, it is determined that the roller has entered a valid rolling state and enters the detection state. This triggering mechanism avoids false triggers caused by slight vibrations or environmental noise, improving the reliability of the detection.
[0061] After entering the detection state, the offset of the two channel signals is continuously tracked. For example, during a complete segmented scrolling process, the offset of the first magnetic sensor may rise rapidly and reach a peak, while the second magnetic sensor will show a corresponding change later. The trend of offset changes is continuously monitored. When the offset of either channel signal decreases relative to its peak value, or when it increases by a factor greater than or equal to a preset amplitude during scrolling, it indicates that the magnetic element has completed the transfer from one sensing area to another. Based on this, a comprehensive judgment is made by combining the sequence and amplitude changes of the two channel signals during the detection process to determine the scrolling direction of the roller.
[0062] In some embodiments of this application, when the magnetic sensor is a linear Hall sensor, the method further includes:
[0063] Upon entering the detection state, the maximum offset of each channel signal is recorded and the corresponding timestamp is stored, and the peak recording variable is initialized. The sampling time counter is started to record the number of sampling cycles since entering the detection state. The peak recording variable is used to track and store the maximum offset of each channel signal during the detection process.
[0064] It should be noted that when the magnetic sensor is a linear Hall sensor, since its output is an analog signal that continuously changes with the magnetic field strength, the channel signal exhibits a continuous rise, reaching a peak, and then gradually declining during the rotation of the roller. In this case, to more accurately characterize the key features of the roller's movement, this application records the maximum offset of each channel signal in real time upon entering the detection state, synchronously stores the corresponding timestamp, initializes the peak value recording variable, and starts a sampling time counter to record the number of sampling cycles since entering the detection state. For example, when the roller begins a segmented roll, the first channel signal corresponding to the first magnetic sensor may continuously rise as the magnetic element gradually approaches, reaching its maximum offset at a certain moment. This maximum offset is then taken as the peak value of the first channel signal, and the timestamp corresponding to this peak value is recorded. Subsequently, as the roller continues to rotate, the channel signal gradually decreases. Similarly, the second channel signal of the second magnetic sensor will also reach its maximum offset at a later stage, and its peak value and timestamp will be recorded respectively. In this way, the continuously changing analog signal can be converted into key feature points with clear time stamps.
[0065] Meanwhile, the peak recording variable, initialized upon entering the detection state, is used to continuously update the maximum offset of each channel signal throughout the detection process, thereby avoiding misjudgments caused by instantaneous noise or local fluctuations. For example, in cases of rapid roller reversal or mechanical rebound, multiple local peaks may appear in the channel signal. The peak recording variable can continuously retain the global maximum value, ensuring that the most representative signal feature is ultimately used for direction determination.
[0066] In addition, the sampling time counter is used to record the number of sampling cycles since entering the detection state, so that each peak not only contains amplitude information, but also has a clear time position relationship. The order of the roller's movement can be determined based on the timestamp difference, thereby helping to determine the rolling direction.
[0067] This application embodiment records the maximum offset and timestamp at the initial detection stage and combines the peak recording variable to globally track the channel signal, enabling the continuous analog signal output by the linear Hall sensor to be effectively structured into a stable set of feature points, thereby improving the reliability of direction determination. At the same time, by introducing a sampling time counter, the peak information is given a time dimension, which can effectively solve the problem of difficulty in distinguishing the order of events in the case of rapid rolling or signal overlap. In addition, this mechanism can suppress the influence of local noise or instantaneous interference on peak recognition, thereby improving the stability, anti-interference ability and overall accuracy of roller rolling direction detection.
[0068] Specifically, when the magnetic sensor is a linear Hall sensor, the rolling direction of the roller is determined based on the two channel signals during the detection process in this embodiment of the application, specifically including:
[0069] The timestamp when the offset of each channel signal first exceeds a preset peak threshold is recorded as the peak timestamp of that channel signal and marked as valid. For example, when a user drives the scroll wheel to perform a segmented scroll, the magnetic element gradually approaches the first magnetic sensor, causing the offset of the first channel signal to gradually increase. When its offset first exceeds the preset peak threshold, the timestamp corresponding to that moment is recorded as the peak timestamp of the first channel signal and marked as a valid peak event. Subsequently, the magnetic element continues to move and approaches the second magnetic sensor, causing the offset of the second channel signal to exceed the same peak threshold for the first time at a later time. Similarly, its peak timestamp is recorded and marked as a valid event.
[0070] When both channel signals record valid spike timestamps, the difference between the two valid spike timestamps is compared. If the valid spike timestamp of the first channel signal is earlier than the valid spike timestamp of the second channel signal, and the difference is greater than a preset tolerance value, then the rolling direction is determined to be the direction corresponding to the first channel signal. If the valid spike timestamp of the second channel signal is earlier than the spike timestamp of the first channel signal, and the difference is greater than a preset tolerance value, then the rolling direction is determined to be the direction corresponding to the second channel signal. For example, if the spike timestamp of the first channel signal appears in the 10th sampling period, while the spike timestamp of the second channel signal appears in the 15th sampling period, it indicates that the magnetic element acts on the first magnetic sensor first, and then on the second magnetic sensor. When this time difference is greater than a preset tolerance value, the rolling direction of the roller can be determined to be the direction corresponding to the first magnetic sensor. Conversely, if the second channel signal reaches the spike threshold first, then the rolling direction is determined to be the direction corresponding to the second magnetic sensor. By comparing the peak timestamps of the two channel signals and introducing a preset tolerance value for constraint, the slight time deviation caused by sampling period differences, signal jitter or instantaneous interference can be eliminated at the inference level. This ensures that direction determination is only performed when the time difference reaches a threshold with actual physical significance, thereby avoiding the misinterpretation of noise as valid direction information.
[0071] If only the valid spike timestamp of the first channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the first channel signal; if only the valid spike timestamp of the second channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the second channel signal. In some special cases, such as when the user performs a very short-distance slight scrolling or a rapid change of direction, only one channel signal may reach the preset spike threshold and form a valid spike timestamp, while the other channel signal may fail to reach the threshold. In this case, the scrolling direction will be directly determined to be the direction indicated by the corresponding channel signal based solely on the recorded valid spike timestamps, thus avoiding the problem of inability to determine the direction due to incomplete signals.
[0072] If no valid peak timestamps are recorded for either of the two channel signals, the rolling direction is determined to be the direction corresponding to the channel signal with the larger offset. When neither channel signal reaches the preset peak threshold, it indicates that no obvious peak characteristics are formed during the rolling process. In this case, based on the offset information stored in the peak recording variable, the maximum offsets of the two channel signals are compared, and the direction corresponding to the channel signal with the larger offset is taken as the final rolling direction, thus ensuring that direction determination can still be completed under weak signal or low-amplitude rolling conditions.
[0073] Optionally, in some other embodiments of this application, when the magnetic sensor is a switch Hall sensor, the method further includes:
[0074] When entering the detection state, record the timestamps corresponding to the offset of each channel signal being 0 and 1 respectively, and start the sampling time counter to record the number of sampling cycles since entering the detection state.
[0075] In this embodiment, when the magnetic sensor is a switch Hall sensor, its output channel signal is a typical digital switching signal, usually representing whether the magnetic field strength has reached the trigger condition with two states: "0" and "1". In this case, since the signal itself does not have continuous amplitude change characteristics, this application records the timestamps corresponding to the change from "0" to "1" and from "1" to "0" for each channel signal when entering the detection state, and simultaneously starts a sampling time counter to record the number of sampling cycles since entering the detection state, thereby converting the discrete switch signal into an event sequence with time sequence characteristics.
[0076] For example, when the roller is in damped mode and begins to roll, the first channel signal of the first magnetic sensor may first change from "0" to "1", and the timestamp T1 corresponding to this change is recorded. Subsequently, as the roller continues to rotate, the second channel signal of the second magnetic sensor may change from "0" to "1" at a later time, and its timestamp T2 is recorded. By comparing T1 and T2, the sequential triggering relationship of the two channel signals can be determined, thereby determining the rolling direction of the roller.
[0077] Furthermore, after the roller completes a single segment of rolling, the magnetic element may leave the sensor's operating area, causing the channel signal to return from "1" to "0". At this time, the corresponding falling edge timestamp is also recorded. By simultaneously recording the time information of the rising and falling edges, the entire process of magnetic field change during one rolling cycle can be completely depicted, thereby improving the completeness of direction determination.
[0078] Meanwhile, a sampling time counter is used to record the number of sampling cycles after entering the detection state, so that each "0→1" or "1→0" transition event can be mapped to a unified time reference. For example, when the first channel signal undergoes a "0→1" transition in the 8th sampling cycle, and the second channel signal undergoes the same transition in the 12th sampling cycle, the order of the roller movement can be determined based on the difference in sampling cycles, thereby realizing the determination of the rolling direction.
[0079] In detail, when the magnetic sensor is a switched Hall sensor, the rolling direction of the roller is determined based on the two channel signals during the detection process in this embodiment of the application, specifically including:
[0080] When entering the detection state, record the timestamps corresponding to the offsets of 0 and 1 for each channel signal;
[0081] The timestamp corresponding to the first change of the offset of each channel signal from 0 to 1 is taken as the first timestamp of that channel, and the first timestamp is marked as valid.
[0082] If both channel signals have recorded a valid first timestamp, compare the difference between the two valid first timestamps. If the valid first timestamp of the first channel signal is earlier than the valid first timestamp of the second channel signal, then the scrolling direction is determined to be the direction corresponding to the first channel signal; if the valid first timestamp of the second channel signal is earlier than the valid first timestamp of the first channel signal, then the scrolling direction is determined to be the direction corresponding to the second channel signal.
[0083] For example, during one rotation of the roller, as the embedded magnetic element gradually approaches the first magnetic sensor (in the case of a Hall effect sensor), the first channel signal may first change from "0" to "1". This change moment is recorded as the first timestamp of the first channel signal and marked as valid. Subsequently, the magnetic element continues to rotate and approaches the second magnetic sensor (in the case of a Hall effect sensor), causing the second channel signal to change from "0" to "1" at a later time. This second timestamp is also recorded and marked as valid. If both channel signals have valid first timestamps, by comparing the order of the two timestamps—for example, if the first timetamp of the first channel signal is earlier than the second channel signal—it indicates that the magnetic element acted on the first magnetic sensor first, thus determining the roller's rolling direction to be the direction corresponding to the first channel signal; otherwise, it is determined to be the direction corresponding to the second channel signal.
[0084] If only the valid first timestamp of the first channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the first channel signal; if only the valid first timestamp of the second channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the second channel signal.
[0085] In some situations, such as when the scroll wheel is slightly scrolling or operating rapidly, only one channel signal may transition from "0" to "1" and form a valid first timestamp, while the other channel signal may not transition. In this case, the scrolling direction can be determined directly based on the channel corresponding to the recorded valid first timestamp, thus avoiding the problem of being unable to determine the direction due to incomplete information.
[0086] In this embodiment, by using the state transition time of the switch Hall sensor as the key determination criterion, the discrete signal, which is originally difficult to analyze in terms of amplitude, is essentially transformed into an event sequence with a temporal relationship. This allows the determination of the rolling direction to be inferred based on a clear temporal order. At the same time, by selecting only the "first change from 0 to 1" transition as the effective feature point, interference caused by repeated triggering or signal jitter can be avoided, improving the uniqueness and stability of the determination result. In addition, the direction determination can still be completed when only a single channel is triggered, without relying on the ideal dual-channel simultaneous triggering condition, thereby enhancing the adaptability in weak signal or fast operation scenarios and improving the overall reliability of the roller rolling direction detection.
[0087] In this embodiment of the application, after determining the rolling direction of the roller, the method further includes:
[0088] Set the stabilization gate indicator and confirm that the system is in an idle state;
[0089] When the stabilization gate flag is present in the idle state, the two channel signals are filtered until the difference between the two channel signals and their baseline offset is within a stable range and the stabilization condition is met for N consecutive sampling periods.
[0090] Specifically, after the roller completes one segment of rolling, due to the elasticity and inertia of the mechanical structure, the embedded magnetic element may experience short-term reciprocating micro-motions near the sensor, thus forming damped oscillations or residual signals in the channel signals of the two magnetic sensors. Although the amplitude of such signals gradually decreases, they may still trigger threshold judgments multiple times in a short period of time. If left untreated, they can easily be misidentified as new rolling events. For example, after a rolling direction determination is completed, the first and second channel signals may still have slight fluctuations, with their offsets changing repeatedly within the positive and negative range relative to the baseline value. At this time, the detection process is restricted by a stabilization gating flag. In the idle state, new triggering conditions are not responded to temporarily, but the two channel signals are continuously monitored and filtered. Specifically, it is determined whether the difference between the offsets of the two channel signals relative to their respective baselines has entered a preset stable range (e.g., close to zero or less than a certain small threshold), and further, this stable state is required to remain valid for N consecutive sampling periods. Only when all the above conditions are met is the roller and its corresponding magnetic field state considered to have returned to stability, thereby clearing the stabilization gating flag and allowing the next round of effective detection.
[0091] This method effectively distinguishes between "real rolling signals" and "aftershock signals." From a reasoning perspective, only when the channel signal returns to the baseline and remains stable can it be said that the current physical motion has ended, and only then does restarting detection have a clear physical meaning; otherwise, it is still in the decay phase of the previous rolling, and the signal changes generated during this period should not be regarded as new input events.
[0092] The stability condition is met for N consecutive sampling periods, including that the channel signals of the two magnetic sensors remain within a preset stable range for all N sampling periods. For example, after one roller roll, due to mechanical rebound or inertia, the channel signals of the two magnetic sensors may experience small oscillations for a short period, with their offsets fluctuating around the baseline value. Assuming a sampling period of 1ms and N=10 consecutive periods required for stability determination, it is necessary to continuously monitor whether the two channel signals remain within the preset stable range for 10 consecutive ms. If the offsets of the first and second channel signals do not exceed the stable range within these 10 consecutive sampling periods, the roller and magnetic field state are considered to have stabilized; otherwise, if the offset of either channel signal exceeds the stable range in any sampling period, the count is reset, and the system waits for a new set of N consecutive stable periods.
[0093] By employing the above method, a time-dimensional constraint is effectively introduced into the "steady state," requiring not only that the signal amplitude be close to the baseline but also that the state remain unchanged over a continuous period of time. This avoids misjudging short-term, accidental stability as true stability. For example, when the signal has not fully attenuated, it may momentarily fall into the stable range. However, since fluctuations will still occur in subsequent sampling periods, the condition of N consecutive periods cannot be met, and therefore, a stability determination will not be triggered.
[0094] In a specific embodiment of this application, when the magnetic sensor is a linear Hall sensor, combined with Figure 8 The actual sampling waveforms can further illustrate the specific implementation process of the roller rolling direction detection method based on dual magnetic sensors. Figure 8 The red line represents the first channel signal (LinerA) corresponding to the first magnetic sensor, and the orange line represents the second channel signal (LinerB) corresponding to the second magnetic sensor. Both are stable near their respective baseline values, with the baseline value of the first channel signal being approximately 64 and the baseline value of the second channel signal being approximately 70.
[0095] Within a time window between approximately the 2700th and 2900th sampling points, three consecutive discrete pulse groups can be observed, each pulse group corresponding to the roller passing through a damped stop. Within this time window, the peak value of the orange line (second channel signal) is significantly higher than that of the red line (first channel signal), and the orange line rises significantly and reaches its peak value first relative to the red line. Specifically, the second channel signal rapidly rises from a baseline value of approximately 70 to approximately 280–300, corresponding to an offset of approximately 210–230; while the first channel signal rises from a baseline value of approximately 64 to approximately 170–180, corresponding to an offset of approximately 106–116. According to the determination logic in this embodiment, the timestamp when the offset of each channel signal first exceeds a preset peak threshold (e.g., 95) is taken as the peak timestamp of that channel signal. In this pulse group, the second channel signal first exceeds the peak threshold and records the peak timestamp, while the first channel signal exceeds the threshold at a later time. Therefore, if both channel signals record valid spike timestamps, the spike timestamp of the second channel signal is earlier than that of the first channel signal, thus determining that the roller's rolling direction is the direction corresponding to the second channel signal, i.e., forward rolling.
[0096] Furthermore, within a time window between approximately the 2950th and 3100th sampling points, two additional pulse groups can be observed. Within this region, the peak value of the red line (first channel signal) is significantly higher than that of the orange line (second channel signal), and the red line reaches its peak value first. Specifically, the first channel signal rapidly rises from a baseline value of approximately 64 to approximately 280–290, corresponding to an offset of approximately 216–226, while the second channel signal only rises to approximately 130–160, corresponding to an offset of approximately 60–90. At this point, the first channel signal first exceeds the preset peak threshold and records the peak timestamp, while the second channel signal reaches the corresponding change only afterward. Therefore, based on the order of the peak timestamps, the scrolling direction can be determined to be the direction corresponding to the first channel signal, i.e., reverse scrolling.
[0097] Taking the first pulse group within a time window between approximately the 2700th and 2900th sampling points as an example, the various processing stages are described in relation to the waveforms. For instance, before the pulse occurs, both channel signals are stable near the baseline value. When the signal begins to rise and exceeds a preset trigger threshold (e.g., rising approximately 25 units relative to the baseline), the detection state is entered. Subsequently, as the signal continues to rise and exceeds a preset peak threshold (e.g., 95), the peak timestamp of the corresponding channel signal is recorded. After the signal reaches its peak value, when its offset decreases to meet a preset direction determination condition (e.g., an adaptive decrease threshold based on the peak value), the rolling direction determination is completed sequentially by combining the peak timestamps of the two channel signals. At the end of the pulse phase, the two channel signals gradually fall back to near the baseline and enter the stabilization gating process.
[0098] During the stabilization gating phase, the signals from both channels are filtered to ensure that their offsets return to a preset stable range (e.g., within ±20 of the baseline) and this stabilization condition is met for several consecutive sampling periods. Only after meeting these conditions does the system exit the idle state and prepare to respond to the next roller rotation, thus avoiding false triggering caused by mechanical rebound or residual signals.
[0099] Therefore, it can be seen that by introducing a complete processing flow of "baseline value - offset - trigger threshold - spike threshold - timestamp comparison - stabilization gating" into the dual magnetic sensor channel signal, the embodiments of this application can achieve... Figure 8 The method shown can stably extract rolling direction information from multiple sets of discrete pulses, which can not only distinguish between forward and reverse rolling, but also effectively suppress signal jitter and residual interference, thereby improving the accuracy and stability of roller rolling direction detection.
[0100] See Figure 9 In some embodiments of this application, when it is determined that the roller is in free mode, the method for determining the rolling direction of the roller includes:
[0101] The channel signals of the two magnetic sensors are decoded using the orthogonal decoding principle and parsed into binary status codes. The stepping direction is then determined based on the binary status codes.
[0102] Based on the stepping direction, the rolling direction of the roller is determined.
[0103] In this embodiment, when the roller is determined to be in free mode, it rotates continuously under inertia. The embedded magnetic element periodically passes through the dual magnetic sensors, causing the two channel signals to exhibit a continuous change characteristic with a phase difference. Based on this characteristic, this application binarizes the channel signals of the two magnetic sensors according to the orthogonal decoding principle and determines the stepping direction by combining the state transition relationship, thereby realizing the determination of the roller's rolling direction.
[0104] Furthermore, in the embodiments of this application, determining the step direction based on the binary status code includes: performing hysteresis comparison on each channel signal, converting it into a binary status code, and determining whether the channel signal is in a high or low state based on the corresponding adaptive midpoint and hysteresis amount; wherein, the adaptive midpoint corresponding to the channel signal of each magnetic sensor is calculated from the historical minimum and maximum values of the channel signal of the magnetic sensor.
[0105] The binary status codes of the two channel signals are combined into a 2-bit status code group. The step direction is determined by a preset status transition table. The step direction includes forward, reverse, or invalid.
[0106] Specifically, the channel signals of each magnetic sensor are first subjected to hysteresis comparison processing to convert the continuously changing analog signals into stable binary status codes. In this process, to adapt to different environments and individual device differences, this application introduces an adaptive midpoint as a comparison benchmark. The adaptive midpoint is calculated from the historical minimum and maximum values of the corresponding channel signal over a period of time; for example, the average of the two can be used as the midpoint. Simultaneously, a hysteresis amount is set based on the midpoint, thus forming an upper threshold and a lower threshold. When the channel signal rises from below the lower threshold and exceeds the upper threshold, it is determined to be a high state (denoted as "1"); when the channel signal falls from above the upper threshold and falls below the lower threshold, it is determined to be a low state (denoted as "0"). This hysteresis comparison method effectively avoids frequent reversals when the signal fluctuates near the threshold, thereby obtaining a stable binary status output.
[0107] For example, during a free rotation, if the channel signal of the first magnetic sensor varies within a historical range of a minimum of 60 and a maximum of 200, its adaptive midpoint can be set to 130. A hysteresis of ±10 is then set to this range, resulting in an upper threshold of 140 and a lower threshold of 120. When the first channel signal rises from below 120 to above 140, the state switches from "0" to "1"; when it falls from above 140 to below 120, the state switches from "1" to "0". The channel signal of the second magnetic sensor also undergoes independent adaptive midpoint and hysteresis determination, thus obtaining the binary states of the two channels respectively.
[0108] Furthermore, the binary states of the first and second channels are combined to form a 2-bit status code group, such as "00", "01", "11", "10", etc. Since the two magnetic sensors have a preset spatial distance, these status codes will change cyclically in a certain order during the continuous rotation of the roller. By parsing the status code changes at adjacent moments using a pre-set state transition table, the current step direction can be determined. For example, when the status code changes in the order of "00→01→11→10", it is determined as a forward step; when the status code changes in the order of "00→10→11→01", it is determined as a reverse step; and any jump that does not conform to the above pattern (such as "00→11") is determined as an invalid step to avoid interference from abnormal signals.
[0109] After obtaining the stepping direction, the rolling direction of the roller is further determined based on the stepping direction. For example, when multiple positive steps are detected consecutively, it can be determined that the roller is in a positive rolling state; when reverse steps are detected consecutively, it is determined to be in a reverse rolling state.
[0110] This application's embodiments improve adaptability by introducing an adaptive midpoint to the channel signals, enabling the binarization process to dynamically adapt to different magnetic field strengths, device biases, and environmental changes. By setting a hysteresis, a stable state-holding interval is formed when the signal approaches a threshold, theoretically avoiding state jitter caused by noise or minor fluctuations. Furthermore, by combining the two channel signals into a 2-bit state code and determining the step direction based on a state transition table, the direction determination is based on the phase relationship of the state sequence rather than a single amplitude judgment, thereby enhancing anti-interference capabilities. Simultaneously, by filtering illegal state transitions, misjudgments caused by abnormal signals or high-speed jitter can be effectively suppressed. Therefore, this method can achieve stable and continuous determination of the roller's rolling direction in free mode, improving detection accuracy.
[0111] Optionally, in some embodiments of this application, determining the rolling direction of the roller includes:
[0112] When the step direction is opposite to the current trend direction, the reverse buffer is used to count the step direction. When the count recorded by the reverse buffer reaches the preset threshold, the count of the reverse buffer is directly added to the count of the position counter and the count in the trend duration step counter is set according to the count of the reverse buffer. The current trend direction is then reversed.
[0113] The current trend direction is the step direction that appears most frequently in the preset historical step sequence;
[0114] When the step direction is consistent with the current trend direction, the position counter and the trend duration step counter are used to count the step direction, and the count in the reversal buffer is cleared to zero.
[0115] The count of the position counter is used as the cumulative position change. When the cumulative position change reaches a preset step threshold, the stepping direction corresponding to the position counter is determined as the rolling direction.
[0116] Optionally, in some embodiments of this application, after obtaining the step direction through orthogonal decoding, in order to further improve the stability and anti-interference capability of the roller rolling direction determination, a trend direction, a reversal buffer, and a position counter are introduced when determining the roller rolling direction to comprehensively determine the step direction. Specifically, the current trend direction is first defined as the step direction that appears most frequently in a preset historical step sequence. For example, if the detected step direction sequence is "forward, forward, forward, reverse, forward" within several consecutive sampling periods, the current trend direction is determined to be positive because the forward step occurs most frequently.
[0117] In actual operation, when a newly detected step direction matches the current trend direction, it indicates that the roller is in a stable rolling state. For example, if the trend direction is positive and another positive step is detected, the position counter and the trend duration step counter are used to accumulate the count for that step direction, while the count in the reversal buffer is reset to zero. In this way, valid steps consistent with the current trend can be continuously accumulated, thus reflecting the main movement trend of the roller.
[0118] Conversely, when the detected step direction is opposite to the current trend direction—for example, if the current trend is positive and a new reverse step is detected—the scrolling direction is not immediately changed. Instead, the reverse step is temporarily counted in the inversion buffer. For instance, during the inertial rotation of the scroll wheel or slight user jitter, a small number of step signals opposite to the main trend may occur. If these signals are used directly to determine the direction, it can easily lead to frequent direction switching. Therefore, this application uses an inversion buffer to buffer such steps.
[0119] Furthermore, when the count recorded in the reversal buffer reaches a preset threshold, it indicates that the reverse stepping has formed a stable trend, rather than being an accidental disturbance. For example, when multiple reverse steps are detected consecutively, and their number exceeds a preset threshold (such as 3 or 5 steps), the count in the reversal buffer is directly added to the position counter. Simultaneously, the count in the trend duration step counter is set according to the count in the reversal buffer, and the current trend direction is flipped to the direction corresponding to the reverse step. Through this process, a smooth switching of the scroll wheel's rolling direction is achieved.
[0120] Based on this, the position counter is used to record the cumulative position change, that is, to accumulate and count all valid steps. When the cumulative position change reaches a preset step threshold, such as reaching a complete scroll unit or a preset number of steps, the current step direction corresponding to the position counter is determined as the scrolling direction of the scroll wheel, and the corresponding scrolling event is output.
[0121] The above method effectively distinguishes between "short-term disturbances" and "true direction changes." From a reasoning perspective, if only a few steps occur in the opposite direction to the current trend, they are more likely to originate from mechanical vibration, signal jitter, or minor user errors. Therefore, delaying the judgment through a reversal buffer can avoid misjudgment. However, when reverse steps occur continuously and reach a certain number, it indicates that the actual movement direction of the roller has changed. At this point, trend reversal can ensure the accuracy of direction switching.
[0122] This application's embodiments introduce the current trend direction and perform historical statistics on the step direction, enabling the scrolling direction determination to have temporal continuity and integrity. By setting a reversal buffer, steps that are opposite to the trend are buffered, thereby logically filtering out instantaneous interference signals and avoiding frequent direction jitter. By setting a reversal threshold, a delayed confirmation of direction switching is achieved, ensuring that direction reversal is based on continuous and effective steps, thus improving the reliability of the determination. Simultaneously, a position counter uniformly counts the cumulative position changes and combines this with a preset step threshold to output the scrolling direction, making the detection results more stable and consistent. Therefore, this application can achieve smooth and accurate determination of the scrolling direction of the roller in free mode.
[0123] In a specific embodiment of this application, reference is made to Figure 10 The diagram shows the signal waveform of a roller based on dual magnetic sensors in free mode, used to illustrate the roller rolling direction detection process in free mode. In this mode, the roller is in an undamped state and can rotate continuously and freely under inertia, causing the embedded magnetic element to periodically pass through the dual magnetic sensors, thereby forming a periodic signal with a phase difference on the two sensor channels.
[0124] Specifically, the red curve in the figure corresponds to the first magnetic sensor channel signal (LinerA), and the orange curve corresponds to the second magnetic sensor channel signal (LinerB). The two channel signals vary periodically in the ranges of approximately 150 to 340 and approximately 130 to 320, respectively, and exhibit an overall characteristic of approximately square wave or trapezoidal wave. Furthermore, there is a significant phase difference between the two signals, forming a typical orthogonal coded signal pair structure.
[0125] Within a time window between approximately the 5305th and 5500th sampling points, the state changes of the red channel signal lead those of the orange channel signal; that is, the first channel signal undergoes a high-to-low level transition first, followed by the corresponding change in the second channel signal. Based on this phase sequence, it can be determined that the current scroll wheel is in a forward scrolling state, corresponding to a forward step sequence.
[0126] Within a time window between approximately the 5600th and 5800th sampling points, a reversal in the phase relationship of the channel signals can be observed. That is, the orange channel signal changes state before the red channel signal, and then the red channel signal responds and changes, thus forming an inverse orthogonal sequence characteristic, corresponding to the reverse rolling state of the roller.
[0127] During a time window between approximately the 5500th and 5600th sampling points, the frequency of change in the two channel signals decreases and the period lengthens, while local unstable jumps occur. This process corresponds to the transition phase of the roller from deceleration to reversal. During this phase, short-term inconsistent step signals may appear.
[0128] In this embodiment, for the continuously changing analog signal, a hysteresis comparison method is first used to binarize each channel signal, thereby converting it into a stable binary status code. The comparison benchmark for each channel signal is determined using an adaptive midpoint, which is calculated from the historical maximum and minimum values of the corresponding channel signal. For example, for the first channel signal, its maximum value is approximately 340 and its minimum value is approximately 150, so the adaptive midpoint is approximately 245. A hysteresis band (e.g., ±12) is then set based on this, forming stable upper and lower threshold ranges to avoid frequent state reversals caused by signal fluctuations near the threshold. The second channel signal is processed similarly, with its adaptive midpoint approximately 225 and a hysteresis range of 225±12.
[0129] After binarization, the binary states of the two channels are combined to form a 2-bit state code group, and orthogonal decoding is performed according to a preset state transition relationship to deduce the corresponding step direction. Specifically, when the state code changes in the order of "00→01→11→10", it is determined as a forward step; when the state code changes in the order of "00→10→11→01", it is determined as a reverse step; for transitions that do not conform to the state transition rules, they are determined as invalid steps, thereby filtering out abnormal interference signals.
[0130] Furthermore, sporadic reverse step signals caused by roller deceleration or reversal can be observed within a time window between approximately the 5500th and 5600th sampling points. In this embodiment, the aforementioned reverse step does not immediately cause a direction reversal, but is accumulated and counted through a reverse buffer mechanism. Only when the reverse step occurs continuously and reaches a preset threshold is a formal switch in the trend direction triggered, thereby avoiding misjudgment caused by instantaneous disturbances.
[0131] Through the above processing method, this application utilizes the phase difference of the orthogonal signals formed by dual magnetic sensors to achieve stable analysis of the roller rotation direction, and combines adaptive threshold and hysteresis mechanism to improve signal robustness. At the same time, through state transition judgment and reversal buffer strategy, it effectively suppresses the misjudgment problem caused by inertial jitter or reversal process in free mode, thereby achieving high-precision and continuous detection of the roller rolling direction.
[0132] Specifically, in the practical application of this application, when a signal indicating that the roller is in damped mode is received, it is determined that the roller is in damped mode; or, when a signal indicating that the roller is in free mode is received, it is determined that the roller is in free mode.
[0133] See Figure 2-6 In some implementations, a state signal characterizing the roller's operating mode can be generated by the position state of the damping switching structure 3, changes in magnetic field coupling strength, or by an independent state detection unit (such as a Hall sensor, potentiometer, or mechanical contact). When the control circuit receives this state signal, it can determine the current operating mode of the roller, thereby providing different processing logic for subsequent rolling direction detection strategies.
[0134] Specifically, in one application scenario, when the user pushes the damping switching structure 3 to the first position, the movement trajectories of the second magnetic element 31 and the first magnetic element 21 form a periodic magnetic attraction, causing the roller body 2 to exhibit a distinct "step-by-step" or "locking-in" feel during rotation. At this time, the mode detection circuit can generate a mode signal characterizing the "damping mode" by detecting the mechanical positioning signal of the damping switching structure 3 (e.g., microswitch closure, capacitance change, or Hall displacement signal change). Upon receiving this signal, the control unit determines that the roller is currently in damping mode. For example, in the scenario of a vehicle central control knob, after the user switches to damping mode, each scale rotation corresponds to a clear menu item change, which will trigger high-precision step control logic to avoid accidental touches or jumps.
[0135] Correspondingly, when the user moves the damping switching structure 3 to the second position, the magnetic field interaction between the second magnetic element 31 and the first magnetic element 21 is essentially released, allowing the roller body 2 to achieve near-unrestricted free rotation. In this state, the mode detection unit also determines that the damping structure has left its effective range through the position sensor or changes in magnetic field strength, and outputs a status signal characterizing the "free mode." Upon receiving this signal, the control unit determines that the roller is in free mode.
[0136] This embodiment also provides a roller rolling direction detection device based on dual magnetic sensors, including: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the roller rolling direction detection method based on dual magnetic sensors described in the above embodiment.
[0137] In addition, this application embodiment also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the roller rolling direction detection method based on dual magnetic sensors as described in the above embodiments.
[0138] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0139] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make modifications, alterations, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A method for detecting the rolling direction of a roller based on dual magnetic sensors, characterized in that, A human-machine interface device including a roller with embedded magnetic elements and dual magnetic sensors arranged at preset intervals adjacent to the roller, the method comprising: The dual magnetic sensors are synchronously sampled periodically to obtain the channel signals of the two magnetic sensors respectively, and the rolling direction of the roller is determined based on the channel signals of the two magnetic sensors.
2. The method for detecting the rolling direction of a roller based on dual magnetic sensors according to claim 1, characterized in that, When it is determined that the roller is in damped mode, the method for determining the rolling direction of the roller includes: For the channel signals of the two magnetic sensors, calculate the offset of the channel signal relative to the baseline value for each; When the offset of any channel signal first reaches the preset trigger threshold, the detection state is entered. During the detection process, the offset of the two channel signals is continuously tracked, and the rolling direction of the roller is determined based on the two channel signals when the offset of either channel signal decreases or increases by a preset amplitude.
3. The method for detecting the rolling direction of a roller based on dual magnetic sensors according to claim 2, characterized in that, When the magnetic sensor is a linear Hall sensor, the method further includes: Upon entering the detection state, the maximum offset of each channel signal is recorded and the corresponding timestamp is stored, and the peak recording variable is initialized. The sampling time counter is started to record the number of sampling cycles since entering the detection state. The peak recording variable is used to track and store the maximum offset of each channel signal during the detection process.
4. The dual magnetic sensor-based roller rolling direction detection method according to claim 2, wherein When the magnetic sensor is a switched Hall sensor, the method further includes: When entering the detection state, record the timestamps corresponding to the offset of each channel signal being 0 and 1 respectively, and start the sampling time counter to record the number of sampling cycles since entering the detection state.
5. The dual magnetic sensor-based roller roll direction detection method according to claim 3, wherein Based on the signals from two channels during the detection process, the rolling direction of the roller is determined, specifically including: The timestamp when the offset of each channel signal first exceeds the preset spike threshold is taken as the spike timestamp of that channel signal, and the spike timestamp is marked as valid. If both channel signals record valid spike timestamps, compare the difference between the two valid spike timestamps. If the valid spike timestamp of the first channel signal is earlier than the valid spike timestamp of the second channel signal, and the difference is greater than a preset tolerance value, then the scrolling direction is determined to be the direction corresponding to the first channel signal; if the valid spike timestamp of the second channel signal is earlier than the spike timestamp of the first channel signal, and the difference is greater than a preset tolerance value, then the scrolling direction is determined to be the direction corresponding to the second channel signal. If only the valid spike timestamp of the first channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the first channel signal; if only the valid spike timestamp of the second channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the second channel signal. If no valid spike timestamps are recorded for either of the two channel signals, the rolling direction is determined to be the direction corresponding to the channel signal with the larger offset.
6. The dual magnetic sensor-based roller roll direction detection method according to claim 4, wherein Based on the signals from two channels during the detection process, the rolling direction of the roller is determined, specifically including: When entering the detection state, record the timestamps corresponding to the offsets of 0 and 1 for each channel signal; The timestamp corresponding to the first change of the offset of each channel signal from 0 to 1 is taken as the first timestamp of that channel, and the first timestamp is marked as valid. If both channel signals have recorded a valid first timestamp, compare the difference between the two valid first timestamps. If the valid first timestamp of the first channel signal is earlier than the valid first timestamp of the second channel signal, then the scrolling direction is determined to be the direction corresponding to the first channel signal; if the valid first timestamp of the second channel signal is earlier than the valid first timestamp of the first channel signal, then the scrolling direction is determined to be the direction corresponding to the second channel signal. If only the valid first timestamp of the first channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the first channel signal; if only the valid first timestamp of the second channel signal is recorded, the scrolling direction is determined to be the direction corresponding to the second channel signal.
7. The dual magnetic sensor-based roller roll direction detection method according to claim 5 or 6, characterized by, After determining the rolling direction of the roller, the method further includes: Set the stabilization gate indicator and confirm that the system is in an idle state; When the stabilization gate flag is present in the idle state, the two channel signals are filtered until the difference between the two channel signals and their baseline offset is within a stable range and the stabilization condition is met for N consecutive sampling periods. The stability condition is met for N consecutive sampling periods, including: the channel signals of the two magnetic sensors are within the preset stability range for N sampling periods.
8. The method for detecting the rolling direction of a roller based on dual magnetic sensors according to claim 1, characterized in that, When it is determined that the roller is in free mode, the method for determining the rolling direction of the roller includes: The channel signals of the two magnetic sensors are decoded using the orthogonal decoding principle and parsed into binary status codes. The stepping direction is then determined based on the binary status codes. Based on the stepping direction, the rolling direction of the roller is determined.
9. The method for detecting the rolling direction of a roller based on dual magnetic sensors according to claim 8, characterized in that, Determining the step direction based on the binary status code includes: Hysteresis comparison is performed on each channel signal, which is converted into a binary status code, and the channel signal is determined to be in a high or low state based on the corresponding adaptive midpoint and hysteresis amount; wherein, the adaptive midpoint corresponding to the channel signal of each magnetic sensor is calculated from the historical minimum and maximum values of the channel signal of that magnetic sensor. The binary status codes of the two channel signals are combined into a 2-bit status code group. The step direction is determined by a preset status transition table. The step direction includes forward, reverse, or invalid.
10. The dual magnetic sensor-based roller roll direction detection method according to claim 9, wherein, Determining the direction of the roller's roll includes: When the step direction is opposite to the current trend direction, the reverse buffer is used to count the step direction. When the count recorded by the reverse buffer reaches the preset threshold, the count of the reverse buffer is directly added to the count of the position counter and the count in the trend duration step counter is set according to the count of the reverse buffer. The current trend direction is then reversed. The current trend direction is the step direction that appears most frequently in the preset historical step sequence; When the step direction is consistent with the current trend direction, the position counter and the trend duration step counter are used to count the step direction, and the count in the reversal buffer is cleared to zero. The count of the position counter is used as the cumulative position change. When the cumulative position change reaches a preset step threshold, the stepping direction corresponding to the position counter is determined as the rolling direction.
11. A dual magnetic sensor based roller rolling direction detection device, characterized by, include: The system includes a memory and a processor, which are interconnected. The memory stores computer instructions, and the processor executes the computer instructions to perform the roller rolling direction detection method based on dual magnetic sensors as described in any one of claims 1-10.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the roller rolling direction detection method based on dual magnetic sensors as described in any one of claims 1-10.