Anti-interference method of Hall sensor and electronic equipment
By setting the operating range of the Hall sensor and shielding the signal when the external magnetic field interferes, the problem of Hall sensor outputting an incorrect signal under magnetic field interference is solved to ensure the normal operation of the electronic equipment.
Patent Information
- Application Number
- CN202510611874.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-08-05
AI Technical Summary
Hall sensors are sensitive to external magnetic field interference, resulting in an error signal output and the switches of electronic devices cannot be controlled normally.
By obtaining the application type of the active switch, setting the operating range of the Hall sensor, and masking the signal when judging that the output signal is out of range, avoiding incorrect output.
Effectively avoid the Hall sensor outputting error signals under external magnetic field interference to ensure the normal operation of electronic equipment.
Smart Images

Figure CN120428149A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Hall sensors, and in particular to an anti-interference method and electronic equipment for a Hall sensor. Background Art
[0002] The Hall sensor is a switching device that operates based on the Hall effect principle. Its main function is to detect changes in magnetic field strength, thereby turning electronic devices on or off by changing the direction of current flow. This makes the Hall sensor sensitive to external magnetic field signal interference. When there is a large amount of external magnetic field signal interference, the Hall sensor is prone to output error signals due to the interference of the external magnetic field and cannot control the switching of electronic devices normally. Summary of the Invention
[0003] In view of the above-mentioned deficiencies in the prior art, an object of the present invention is to provide an anti-interference method and electronic device for a Hall sensor, so as to solve the problem that the Hall sensor may output erroneous data under magnetic field interference.
[0004] The technical solutions of the present invention are as follows:
[0005] An anti-interference method for a Hall effect sensor is applied to an electronic device, wherein the electronic device includes a movable switch provided with a magnet and at least one Hall effect sensor disposed around the movable switch. The anti-interference method for the Hall effect sensor includes the following steps:
[0006] Obtaining an application type of the active switch and setting an operating range of the Hall sensor according to the application type, wherein the operating range is an electrical signal threshold corresponding to a magnetic flux value obtained by the Hall sensor;
[0007] acquiring an electrical signal output according to magnetic flux conversion between the Hall sensor and the magnet when the active switch is in use;
[0008] When it is determined that the electrical signal output by the Hall sensor exceeds a set operating range, the output signal of the Hall sensor is shielded.
[0009] Optionally, the application type of the active switch is a sliding switch, the Hall sensor includes a first Hall sensor and a second Hall sensor respectively arranged on both sides of the magnet, and the step of setting the operating range of the Hall sensor according to the application type specifically includes:
[0010] Establishing a first blank coordinate system, wherein an x-axis of the first blank coordinate system corresponds to a first distance node between the magnet and the first Hall sensor and the second Hall sensor, and a y-axis of the first blank coordinate system corresponds to a first voltage value output by the first Hall sensor and the second Hall sensor according to magnetic flux between the magnet and the first Hall sensor;
[0011] obtaining a first test voltage value output by the first Hall sensor and the second Hall sensor according to the magnetic flux between the first Hall sensor and the magnet when the sliding switch is debugged;
[0012] A corresponding first voltage operation reference line is generated on the first blank coordinate system according to the first distance node and the first test voltage value, and an operation range is set according to the first voltage operation reference line.
[0013] Optionally, the step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes:
[0014] obtaining a first operating voltage value when the sliding switch is in use;
[0015] The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes:
[0016] When the first operating voltage value does not fall within the first voltage operating reference line, it is determined that the first operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
[0017] Optionally, the application type of the active switch is a rotary switch, and the Hall sensor includes a third Hall sensor and a fourth Hall sensor respectively provided on both sides of the rotary switch. The step of setting the operating range of the Hall sensor according to the application type specifically includes:
[0018] Establishing a second blank coordinate system, wherein an x-axis of the second blank coordinate system corresponds to a rotation angle of the rotary switch, and a y-axis of the second blank coordinate system corresponds to a second voltage value output by the third Hall sensor and the fourth Hall sensor according to magnetic flux between the third Hall sensor and the magnet;
[0019] obtaining a second test voltage value output by the third Hall sensor and the fourth Hall sensor according to the magnetic flux between the third Hall sensor and the magnet when the rotary switch is debugged;
[0020] A corresponding second voltage operation reference line is generated on the second blank coordinate system according to the rotation angle of the rotary switch and the second test voltage value, and an operation range is set according to the second voltage operation reference line.
[0021] Optionally, the step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes:
[0022] obtaining a second operating voltage value when the rotary switch is in use;
[0023] The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes:
[0024] When the second operating voltage value does not fall within the second voltage operating reference line, it is determined that the second operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
[0025] Optionally, the application type of the movable switch is a rotating ring provided on a cylinder that can move up and down, the magnet is provided in the rotating ring, the Hall sensor includes a fifth Hall sensor and a sixth Hall sensor provided on a side wall of the cylinder, the fifth Hall sensor and the sixth Hall sensor are provided opposite to each other, and the step of setting the operating range of the Hall sensor according to the application type specifically includes:
[0026] Establishing a third blank coordinate system, wherein an x-axis of the third blank coordinate system corresponds to the rotation angle of the rotating ring, and a y-axis of the third blank coordinate system corresponds to a third voltage value output by the fifth Hall sensor and the sixth Hall sensor according to magnetic flux between the fifth Hall sensor and the magnet;
[0027] obtaining a third test voltage value output by the fifth Hall sensor and the sixth Hall sensor according to the magnetic flux between the fifth Hall sensor and the magnet when the rotating ring is debugged;
[0028] A corresponding third voltage operation reference line is generated on the third blank coordinate system according to the rotation angle of the rotating ring and the third test voltage value, and an operation range is set according to the third voltage operation reference line.
[0029] Optionally, the step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes:
[0030] obtaining a third operating voltage value of the rotating ring when in use;
[0031] The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes:
[0032] When the third operating voltage value does not fall within the third voltage operating reference line, it is determined that the third operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
[0033] Optionally, the application type of the movable switch is a rotating ring that is arranged on a cylinder and can move up and down, the magnet is arranged in the rotating ring, the Hall sensor includes a seventh Hall sensor and an eighth Hall sensor arranged on the side wall of the cylinder, and a ninth Hall sensor arranged below the seventh Hall sensor and the eighth Hall sensor, the seventh Hall sensor and the eighth Hall sensor are arranged opposite to each other, and the step of setting the operating range of the Hall sensor according to the application type specifically includes:
[0034] establishing a fourth blank coordinate system, wherein an x-axis of the fourth blank coordinate system corresponds to the rotation angle of the rotating ring, and a y-axis of the fourth blank coordinate system corresponds to fourth voltage values output by the seventh Hall sensor, the eighth Hall sensor, and the ninth Hall sensor according to magnetic flux between the sensor and the magnet;
[0035] obtaining a fourth test voltage value output by the seventh Hall sensor, the eighth Hall sensor, and the ninth Hall sensor according to the magnetic flux between the seventh Hall sensor and the magnet when the rotating ring is debugged;
[0036] A corresponding fourth voltage operation reference line is generated on the fourth blank coordinate system according to the rotation angle of the rotating ring and the fourth test voltage value, and an operation range is set according to the fourth voltage operation reference line.
[0037] Optionally, the step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes:
[0038] obtaining a fourth operating voltage value of the rotating ring when in use;
[0039] The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes:
[0040] When the fourth operating voltage value does not fall within the fourth voltage operating reference line, it is determined that the fourth operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
[0041] The present invention also proposes an electronic device, comprising a processor, an active switch provided with a magnet, and at least one Hall sensor arranged around the active switch, wherein the processor stores an anti-interference program for the Hall sensor, and the processor is used to implement the anti-interference method for the Hall sensor as described above when executing the anti-interference program for the Hall sensor.
[0042] The technical solution of the present invention can obtain the application type of the active switch and set the operating range of the Hall sensor based on the application type. The operating range is the electrical signal threshold corresponding to the magnetic flux value obtained by the Hall sensor. The electrical signal output based on the magnetic flux between the Hall sensor and the magnet when the active switch is in use is then obtained. If it is determined that the electrical signal output by the Hall sensor exceeds the set operating range, the output signal of the Hall sensor is shielded. In this way, by determining the relationship between the voltage value output by the Hall sensor when the active switch is in use and the set operating range, this solution can determine whether the Hall sensor is interfered with by an external magnetic field. If the Hall sensor is interfered with by an external magnetic field, the output signal of the Hall sensor is shielded, thereby preventing the Hall sensor from outputting an erroneous signal. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary personnel in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.
[0044] Figure 1 This is a flow chart of the method steps of an embodiment of the anti-interference method of the Hall sensor of the present invention.
[0045] Figure 2 It is a structural diagram of the arrangement of the first Hall sensor, the second Hall sensor and the slide switch of the present invention.
[0046] Figure 3 This is a flow chart of the method steps of another embodiment of the anti-interference method of the Hall sensor of the present invention.
[0047] Figure 4 It is a two-dimensional quadrant diagram of the distance-voltage value of the first Hall sensor and the second Hall sensor of the present invention.
[0048] Figure 5 It is a structural diagram of the third Hall sensor, the fourth Hall sensor and the rotary switch of the present invention.
[0049] Figure 6 This is a flow chart of the method steps of another embodiment of the anti-interference method of the Hall sensor of the present invention.
[0050] Figure 7 It is a two-dimensional quadrant diagram of the angle-voltage value of the third Hall sensor and the fourth Hall sensor of the present invention.
[0051] Figure 8 It is a structural diagram of the arrangement of the fifth Hall sensor, the sixth Hall sensor and the rotating ring of the present invention.
[0052] Figure 9 This is a flow chart of the method steps of another embodiment of the anti-interference method of the Hall sensor of the present invention.
[0053] Figure 10 It is a two-dimensional quadrant diagram of the angle-voltage value of the fifth Hall sensor and the sixth Hall sensor of the present invention.
[0054] Figure 11 It is a structural diagram of the seventh Hall sensor, the eighth Hall sensor, the ninth Hall sensor and the rotating ring of the present invention.
[0055] Figure 12 A flow chart of the method steps of another embodiment of the anti-interference method for a Hall sensor of the present invention.
[0056] Figure 13 It is a two-dimensional quadrant diagram of the angle-voltage values of the seventh Hall sensor, the eighth Hall sensor, and the ninth Hall sensor of the present invention. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0058] In the embodiments and patent claims, unless otherwise specified herein, the words "a," "an," "the," and "the" may include plural forms. If the embodiments of the present invention include descriptions of "first," "second," etc., such descriptions are for descriptive purposes only and should not be understood as indicating or implying their relative importance or implicitly specifying the number of the technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include at least one of such features.
[0059] It should be further understood that the term "comprising" as used in the description of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when an element is said to be "connected" or "coupled" to another element, it can be directly connected or coupled to the other element, or there can be intermediate elements. In addition, "connected" or "coupled" as used herein can include wireless connections or wireless couplings. The term "and / or" as used herein includes all or any units and all combinations of one or more associated listed items.
[0060] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with their meanings in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0061] In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the fact that ordinary technicians in this field can implement them. When the combination of technical solutions is mutually contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0062] The Hall sensor is a switching device that operates based on the Hall effect principle. Its main function is to detect changes in magnetic field strength, thereby turning electronic devices on or off by changing the direction of current flow. This makes the Hall sensor sensitive to external magnetic field signal interference. When there is a large amount of external magnetic field signal interference, the Hall sensor is prone to output error signals due to the interference of the external magnetic field and cannot control the switching of electronic devices normally.
[0063] To solve the above problem, the present invention proposes an anti-interference method for a Hall sensor, which is applied to an electronic device. The electronic device includes a movable switch provided with a magnet and at least one Hall sensor arranged around the movable switch.
[0064] Reference Figure 1 In one embodiment, the anti-interference method of the Hall sensor includes the following steps:
[0065] S100, obtaining an application type of the active switch, and setting an operating range of the Hall sensor according to the application type, wherein the operating range is an electrical signal threshold corresponding to a magnetic flux value obtained by the Hall sensor;
[0066] S200, obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet 20 when the movable switch is in use;
[0067] S300: When it is determined that the electrical signal output by the Hall sensor exceeds a set operating range, shield the output signal of the Hall sensor.
[0068] In this embodiment, the active switch refers to a switch device with a movable part that can change its state (on or off) by manual operation. This type of switch usually realizes its function based on a mechanical structure, relying on the movement, rotation or pressing of the movable part to control the on and off of the circuit or the operation of other systems. The application type of the active switch represents different types of active switches, such as a sliding switch 11 or a rotary switch 12. Different types of switches have different specific structures. Therefore, when the Hall sensor detects different active switches, the magnetic flux is also different, thereby outputting different electrical signals, which can be specifically voltage signals. The subsequent processing device can convert the voltage signal into a voltage value. In this embodiment, the operating range of the Hall sensor can be set according to the different application types of the active switch; it can be understood that the Hall sensor is a magnetic sensor based on the Hall effect, which is used to detect the presence and intensity of the magnetic field and output a corresponding electrical signal; therefore, the operating range of the Hall sensor is set, which can specifically be the voltage value threshold corresponding to the magnetic flux value obtained by the Hall sensor. When the electronic device is operating normally, the active switch is also in use. By obtaining the voltage value obtained by converting the electrical signal output by the Hall sensor based on the magnetic flux between the Hall sensor and the magnet 20 when the active switch is in use, and then comparing it with the voltage value threshold represented by the set operating range, it can be determined whether the Hall sensor is in normal operation. If the voltage value obtained by converting the electrical signal output by the Hall sensor when the active switch is in use is the same as the voltage value threshold of the set operating range, the Hall sensor is determined to be in normal operation and not interfered with by the external magnetic field; or if there is a difference between the voltage value obtained by converting the electrical signal output by the Hall sensor when the active switch is in use and the voltage value threshold of the set operating range, but the difference is small, it is determined that the Hall sensor is slightly interfered with by the external magnetic field and will not affect normal operation. Only when there is a difference between the voltage value obtained by converting the electrical signal output by the Hall sensor when the active switch is in use and the voltage value threshold of the set operating range, and the difference is large, is it determined that the Hall sensor is interfered with by the external magnetic field. In this case, the output signal of the Hall sensor can be shielded, thereby preventing the Hall sensor from outputting an erroneous signal. The setting standard of the difference value for determining whether the Hall sensor is interfered with by the external magnetic field can be set according to actual conditions and user needs.
[0069] The technical solution of the present invention can obtain the application type of the active switch and set the operating range of the Hall sensor based on the application type. The operating range is the electrical signal threshold corresponding to the magnetic flux value obtained by the Hall sensor. The electrical signal output based on the magnetic flux between the Hall sensor and the magnet 20 when the active switch is in use is then obtained. If it is determined that the electrical signal output by the Hall sensor exceeds the set operating range, the output signal of the Hall sensor is shielded. In this way, by determining the relationship between the voltage value output by the Hall sensor when the active switch is in use and the set operating range, this solution can determine whether the Hall sensor is interfered with by an external magnetic field. If the Hall sensor is interfered with by an external magnetic field, the output signal of the Hall sensor is shielded, thereby preventing the Hall sensor from outputting an erroneous signal.
[0070] Reference Figure 2 and Figure 3 In one embodiment, the application type of the active switch is a slide switch 11, and the Hall sensor includes a first Hall sensor H1 and a second Hall sensor H2 respectively disposed on both sides of the magnet 20. The step of setting the operating range of the Hall sensor according to the application type specifically includes:
[0071] S111. Establish a first blank coordinate system, where the x-axis of the first blank coordinate system corresponds to a first distance node between the magnet 20 and the first Hall sensor H1 and the second Hall sensor H2, and the y-axis of the first blank coordinate system corresponds to a first voltage value output by the first Hall sensor H1 and the second Hall sensor H2 according to the magnetic flux between the magnet 20 and the first Hall sensor H1 and the second Hall sensor H2.
[0072] S112, obtaining a first test voltage value output by the first Hall sensor H1 and the second Hall sensor H2 according to the magnetic flux between the first Hall sensor H1 and the magnet 20 when the sliding switch 11 is debugged;
[0073] S113 . Generate a corresponding first voltage operation reference line on the first blank coordinate system according to the first distance node and the first test voltage value, and set an operation range according to the first voltage operation reference line.
[0074] In this embodiment, when the active switch is a sliding switch 11, a first Hall sensor H1 and a second Hall sensor H2 can be provided, and are respectively provided on both sides of the magnet 20 for detection. For details, please refer to Figure 2The operating range of the Hall sensor can be specifically set by first establishing a first blank coordinate system, where the x-axis corresponds to the first distance node between the magnet 20 and the first Hall sensor H1 and the second Hall sensor H2, and the y-axis corresponds to the first voltage value output by the first Hall sensor H1 and the second Hall sensor H2 according to the magnetic flux between the magnet 20; then the sliding switch 11 is controlled to slide to debug the first Hall sensor H1 and the second Hall sensor H2, and the first test voltage value output by the first Hall sensor H1 and the second Hall sensor H2 according to the magnetic flux between the magnet 20 is obtained; in this way, a corresponding first voltage operating reference line can be generated on the first blank coordinate system according to the first distance node and the first test voltage value, and the operating range can be set according to the first voltage operating reference line. Specifically, the corresponding threshold value of the first voltage value is set through the first voltage operating reference line. The threshold value can be the same as the voltage value of the first voltage, or the threshold value can be increased or decreased according to the actual situation and user needs. In this embodiment, the Hall sensor is taken as an example to operate at 3.5V. The Hall sensor actually converts the magnetic flux parameter into a voltage value, which is then compared by an external processor. The following is the corresponding experimental data:
[0075]
[0076] The unit of distance is cm, and the unit of voltage is v. The corresponding two-dimensional quadrant diagram can be obtained from each electrical signal in the above diagram. Figure 4 .
[0077] It should be noted that, in this embodiment, only the case where the first Hall sensor H1 and the second Hall sensor H2 are respectively arranged on both sides of the magnet 20, and the distances between the magnet 20 and the first Hall sensor H1 and the second Hall sensor H2 are the same is described. In actual applications, the setting positions of the first Hall sensor H1 and the second Hall sensor H2 may be changed. For example, the first Hall sensor H1 may be arranged on one side and the second Hall sensor H2 may be arranged below the magnet 20, or the distances between the magnet 20 and the first Hall sensor H1 and the second Hall sensor H2 may be different. In this case, the corresponding acquired data and the drawn curve should also be inconsistent with those in this embodiment.
[0078] Reference Figure 2 and Figure 3 In one embodiment, the step of obtaining the electrical signal output according to the magnetic flux between the Hall sensor and the magnet 20 when the active switch is in use specifically includes:
[0079] S210, obtaining a first operating voltage value of the sliding switch 11 when in use;
[0080] The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes:
[0081] S310: When the first operating voltage value does not fall within the first voltage operating reference line, determine that the first operating voltage value exceeds the operating range, and shield the output signal of the Hall sensor.
[0082] In this embodiment, after setting the operating range of the Hall sensors, the first operating voltage values output by the first Hall sensor H1 and the second Hall sensor H2 when the slide switch 11 is in normal use during operation of the electronic device can be obtained. The first operating voltage values are then compared with a voltage threshold corresponding to the operating range of the slide switch 11. When the first operating voltage value falls within the first voltage operating reference line, it is determined that the first operating voltage value does not exceed the operating range, and the first Hall sensor H1 and the second Hall sensor H2 are operating normally. When the first operating voltage value does not fall within the first voltage operating reference line, it is determined that the first operating voltage value exceeds the operating range, and the output signals of the first Hall sensor H1 and the second Hall sensor H2 are shielded to prevent the first Hall sensor H1 and the second Hall sensor H2 from outputting erroneous signals. The first operating voltage value not falling within the first voltage operating reference line can mean that the first operating voltage value is greater than or less than the voltage threshold corresponding to the first voltage operating reference line, or that the difference between the first operating voltage value and the voltage threshold is less than a preset value. The preset value can be set according to actual conditions and user needs.
[0083] Reference Figure 5 and Figure 6 In one embodiment, the application type of the active switch is a rotary switch 12, and the Hall sensor includes a third Hall sensor H3 and a fourth Hall sensor H4 respectively disposed on both sides of the rotary switch 12. The step of setting the operating range of the Hall sensor according to the application type specifically includes:
[0084] S121. Establish a second blank coordinate system, where the x-axis of the second blank coordinate system corresponds to the rotation angle of the rotary switch 12, and the y-axis of the second blank coordinate system corresponds to the second voltage value output by the third Hall sensor H3 and the fourth Hall sensor H4 according to the magnetic flux between the third Hall sensor H3 and the fourth Hall sensor H4 and the magnet 20.
[0085] S122, obtaining a second test voltage value output by the third Hall sensor H3 and the fourth Hall sensor H4 according to the magnetic flux between the third Hall sensor H3 and the magnet 20 when the rotary switch 12 is debugged;
[0086] S123 , generating a corresponding second voltage operation reference line on the second blank coordinate system according to the rotation angle of the rotary switch 12 and the second test voltage value, and setting an operation range according to the second voltage operation reference line.
[0087] In this embodiment, when the active switch is a rotary switch 12, a third Hall sensor H3 and a fourth Hall sensor H4 can be provided, and are respectively provided on both sides of the rotary switch 12 for detection. For details, please refer to Figure 5 The operating range of the Hall sensor can be specifically set by first establishing a second blank coordinate system, where the x-axis corresponds to the rotation angle of the rotary switch 12, and the y-axis corresponds to the second voltage value output by the third Hall sensor H3 and the fourth Hall sensor H4 based on the magnetic flux between them and the magnet 20; then controlling the rotation of the rotary switch 12 to debug the first Hall sensor H1 and the second Hall sensor H2, and obtaining the second test voltage value output by the third Hall sensor H3 and the fourth Hall sensor H4 based on the magnetic flux between them and the magnet 20 when the rotary switch 12 is debugged; thus, a corresponding second voltage operating reference line can be generated on the second blank coordinate system based on the rotation angle of the rotary switch 12 and the second test voltage value, and the operating range can be set based on the second voltage operating reference line. Specifically, a corresponding threshold value of the second voltage value is set through the second voltage operating reference line. The threshold value can be the same as the voltage value of the second voltage, or it can be increased or decreased based on actual conditions and user needs. In this embodiment, the Hall sensor operating at 3.5V is used as an example for explanation. The Hall sensor actually converts the magnetic flux parameter into a voltage value, which is then compared by an external processor. The following is the corresponding experimental data:
[0088]
[0089] The unit of voltage value is mV. The corresponding two-dimensional quadrant diagram can be obtained from each electrical signal in the above diagram. Figure 7 .
[0090] It should be noted that, in this embodiment, the setting of the sliding switch 11 is the same as that in the above embodiment, and only represents the corresponding curve obtained by the setting position of the magnet 20 and the third Hall sensor H3 and the fourth Hall sensor H4 in this embodiment. In other embodiments, the setting position of the third Hall sensor H3 and the fourth Hall sensor H4 may be different from the setting position in this embodiment, and the obtained magnetic flux value and the generated curve are also different.
[0091] Reference Figure 5 and Figure 6 In one embodiment, the step of obtaining the electrical signal output according to the magnetic flux between the Hall sensor and the magnet 20 when the active switch is in use specifically includes:
[0092] S220, obtaining a second operating voltage value when the rotary switch 12 is in use;
[0093] The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes:
[0094] S320: When the second operating voltage value does not fall within the second voltage operating reference line, determine that the second operating voltage value exceeds the operating range, and shield the output signal of the Hall sensor.
[0095] In this embodiment, after setting the operating range of the Hall sensors, the second operating voltage values output by the third Hall sensor H3 and the fourth Hall sensor H4 when the rotary switch 12 is in normal use during operation of the electronic device can be obtained. The second operating voltage values are then compared with a voltage threshold corresponding to the operating range of the rotary switch 12. When the second operating voltage value falls within the second voltage operating reference line, it is determined that the second operating voltage value does not exceed the operating range, and the third Hall sensor H3 and the fourth Hall sensor H4 are operating normally. When the second operating voltage value does not fall within the second voltage operating reference line, it is determined that the second operating voltage value exceeds the operating range, and the output signals of the third Hall sensor H3 and the fourth Hall sensor H4 are shielded to prevent the third Hall sensor H3 and the fourth Hall sensor H4 from outputting erroneous signals. The second operating voltage value not falling within the second voltage operating reference line can mean that the second operating voltage value is greater than or less than the voltage threshold corresponding to the second voltage operating reference line, or that the difference between the second operating voltage value and the voltage threshold is less than a preset value. The preset value can be set according to actual conditions and user needs.
[0096] Reference Figure 8 and Figure 9 In one embodiment, the application type of the active switch is a rotating ring 13 that is disposed on a cylinder 30 and can move up and down, the magnet 20 is disposed within the rotating ring 13, and the Hall sensor includes a fifth Hall sensor H5 and a sixth Hall sensor H6 disposed on a side wall of the cylinder 30, the fifth Hall sensor H5 and the sixth Hall sensor H6 being disposed opposite each other. The step of setting the operating range of the Hall sensor according to the application type specifically includes:
[0097] S131. Establish a third blank coordinate system, where the x-axis of the third blank coordinate system corresponds to the rotation angle of the rotating ring 13, and the y-axis of the third blank coordinate system corresponds to the third voltage value output by the fifth Hall sensor H5 and the sixth Hall sensor H6 according to the magnetic flux between the fifth Hall sensor H5 and the sixth Hall sensor H6 and the magnet 20;
[0098] S132, obtaining a third test voltage value output by the fifth Hall sensor H5 and the sixth Hall sensor H6 according to the magnetic flux between the fifth Hall sensor H5 and the magnet 20 when the rotating ring 13 is being debugged;
[0099] S133 , generating a corresponding third voltage operation reference line on the third blank coordinate system according to the rotation angle of the rotating ring 13 and the third test voltage value, and setting an operation range according to the third voltage operation reference line.
[0100] In this embodiment, when the movable switch is a rotating ring 13, a fifth Hall sensor H5 and a sixth Hall sensor H6 can be provided, and the fifth Hall sensor H5 and the sixth Hall sensor H6 are provided opposite to each other on the side wall of the cylinder 30. For details, please refer to Figure 8 Setting the operating range of the Hall sensor can be done by first establishing a third blank coordinate system, where the x-axis corresponds to the rotation angle of the rotating ring 13, and the y-axis corresponds to the third voltage value output by the fifth Hall sensor H5 and the sixth Hall sensor H6 based on the magnetic flux between them and the magnet 20. The rotating ring 13 is then controlled to rotate to debug the fifth Hall sensor H5 and the sixth Hall sensor H6, and the third test voltage value output by the fifth Hall sensor H5 and the sixth Hall sensor H6 based on the magnetic flux between them and the magnet 20 is obtained when the rotating ring 13 is debugged. In this way, a corresponding third voltage operating reference line can be generated on the third blank coordinate system based on the rotation angle of the rotating ring 13 and the third test voltage value, and the operating range can be set based on the third voltage operating reference line. Specifically, a corresponding threshold value of the third voltage value is set using the third voltage operating reference line. The threshold value can be the same as the voltage value of the third voltage, or it can be increased or decreased based on actual conditions and user needs. In this embodiment, the Hall sensor operating at 3.5V is used as an example for explanation. The Hall sensor actually converts the magnetic flux parameter into a voltage value, which is then compared by an external processor. The following is the corresponding experimental data:
[0101] Angle 1 Angular 2 Angular 3 Angular 4 Angular 5 Angular 6 Fifth Hall sensor voltage value (unplugged) 3213 2914 2451 1687 1423 1440 The sixth Hall sensor voltage value (not removed) 1150 1193 1240 1313 1350 1380 Fifth Hall sensor voltage value (unplugged) 2913 2614 2151 1387 1123 1140 The sixth Hall sensor voltage value (unplugged) 850 893 940 1013 1050 1080 Angular 7 Angular 8 Angular 9 Angle 10 Angular 11 Angle 12 Fifth Hall sensor voltage value (unplugged) 1439 1445 1432 1423 1414 1404 The sixth Hall sensor voltage value (not removed) 1404 1414 1423 1432 1445 1439 Fifth Hall sensor voltage value (unplugged) 1139 1145 1132 1123 1114 1104 The sixth Hall sensor voltage value (unplugged) 1104 1114 1123 1132 1145 1139 Angular 13 Angle 14 Angle 15 Angle 16 Angle 17 Angle 18 Fifth Hall sensor voltage value (unplugged) 1380 1350 1313 1240 1193 1150 The sixth Hall sensor voltage value (not removed) 1440 1423 1687 2451 2914 3213 Fifth Hall sensor voltage value (unplugged) 1080 1050 1013 940 893 850 The sixth Hall sensor voltage value (unplugged) 1140 1123 1387 2151 2614 2913
[0102] The unit of the voltage value is mV, and the angles corresponding to angles 1 to 18 can refer to the angles in the above embodiment; the corresponding two-dimensional quadrant diagram can be obtained from each electrical signal in the above diagram. Figure 10 .
[0103] It should be noted that in this embodiment, when the rotating ring 13 is not moved downward (undialed) and when it is moved downward (dialed) during commissioning rotation, the fifth Hall sensor H5 and the sixth Hall sensor H6 generate a total of four reference curves in the third blank coordinate system. The reference curves are the reference ranges. Furthermore, the upward and downward movement of the rotating ring can be used to switch the function of the device. For example, when the rotating ring is in the undialed state, it is used to adjust the data of function A, and when the rotating ring is in the dialed state, it is used to adjust the data of function B.
[0104] Reference Figure 8 and Figure 9 In one embodiment, the step of obtaining the electrical signal output according to the magnetic flux between the Hall sensor and the magnet 20 when the active switch is in use specifically includes:
[0105] S230, obtaining a third operating voltage value of the rotating ring 13 when in use;
[0106] The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes:
[0107] S230: When the third operating voltage value does not fall within the third voltage operating reference line, determine that the third operating voltage value exceeds the operating range, and shield the output signal of the Hall sensor.
[0108] In this embodiment, after setting the operating range of the Hall sensors, the third operating voltage value output by the fifth Hall sensor H5 and the sixth Hall sensor H6 when the rotating ring 13 is in normal use during operation of the electronic device can be obtained. The third operating voltage value is then compared with the voltage threshold corresponding to the operating range of the rotary switch 12. When the third operating voltage value falls within the third voltage operating reference line, it is determined that the third operating voltage value does not exceed the operating range, and the fifth Hall sensor H5 and the sixth Hall sensor H6 are operating normally. When the third operating voltage value does not fall within the third voltage operating reference line, it is determined that the third operating voltage value does not exceed the operating range, and the output signals of the fifth Hall sensor H5 and the sixth Hall sensor H6 are shielded to prevent the fifth Hall sensor H5 and the sixth Hall sensor H6 from outputting erroneous signals. The third operating voltage value not falling within the third voltage operating reference line can mean that the third operating voltage value is greater than or less than the voltage threshold corresponding to the third voltage operating reference line, or it can mean that the difference between the third operating voltage value and the voltage threshold is less than a preset value. The preset value can be set according to actual conditions and user needs.
[0109] Further, refer to Figure 11 and Figure 12In one embodiment, the application type of the active switch is a rotating ring 13 that is disposed on a cylinder 30 and can move up and down, the magnet 20 is disposed within the rotating ring 13, the Hall sensors include a seventh Hall sensor H7 and an eighth Hall sensor H8 disposed on a side wall of the cylinder 30, and a ninth Hall sensor H9 disposed below the seventh Hall sensor H7 and the eighth Hall sensor H8, the seventh Hall sensor H7 and the eighth Hall sensor H8 being disposed opposite each other, and the step of setting the operating range of the Hall sensors according to the application type specifically includes:
[0110] S141. Establish a fourth blank coordinate system, where the x-axis of the fourth blank coordinate system corresponds to the rotation angle of the rotating ring 13, and the y-axis of the fourth blank coordinate system corresponds to fourth voltage values output by the seventh Hall sensor H7, the eighth Hall sensor H8, and the ninth Hall sensor H9 according to magnetic flux between the sensor and the magnet 20.
[0111] S142, obtaining a fourth test voltage value output by the seventh Hall sensor H7, the eighth Hall sensor H8, and the ninth Hall sensor H9 according to the magnetic flux between the seventh Hall sensor H7, the eighth Hall sensor H8, and the ninth Hall sensor H9 and the magnet 20 when the rotating ring 13 is being debugged;
[0112] S143 , generating a corresponding fourth voltage operation reference line on the fourth blank coordinate system according to the rotation angle of the rotating ring 13 and the fourth test voltage value, and setting an operation range according to the fourth voltage operation reference line.
[0113] In this embodiment, the type of the active switch is still the rotating ring 13. On the basis of the above embodiment, a Hall sensor is added to make the test more accurate. The specific structure can be referred to Figure 11 The specific principle of setting the operating range of the Hall sensor can refer to the description of the rotating ring 13 in the above embodiment, and will not be repeated here. The following is the corresponding experimental data when setting the seventh Hall sensor H7, the eighth Hall sensor H8 and the ninth Hall sensor H9:
[0114] Angle 1 Angular 2 Angular 3 Angular 4 Angular 5 Angular 6 The voltage value of the seventh Hall sensor (not removed) 3213 2914 24511 1687 1423 1440 The eighth Hall sensor voltage value (not removed) 1150 1193 1240 1313 1350 1380 The ninth Hall sensor voltage value (not removed) 150 193 240 313 350 380 Seventh Hall sensor voltage value (unplugged) 2913 2614 21511 1387 1123 1140 The eighth Hall sensor voltage value (unplugged) 850 893 940 1013 1050 1080 The ninth Hall sensor voltage value (unplugged) 650 693 740 813 850 880 Angular 7 Angular 8 Angular 9 Angle 10 Angular 11 Angle 12 The voltage value of the seventh Hall sensor (not removed) 1439 1445 1432 1423 1414 1404 The eighth Hall sensor voltage value (not removed) 1404 1414 1423 1432 1445 1439 The ninth Hall sensor voltage value (not removed) 404 414 423 432 445 439 Seventh Hall sensor voltage value (unplugged) 1139 1145 1132 1123 1114 1104 The eighth Hall sensor voltage value (unplugged) 1104 1114 1123 1132 1145 1139 The ninth Hall sensor voltage value (unplugged) 904 914 923 932 945 939 Angular 13 Angle 14 Angle 15 Angle 16 Angle 17 Angle 18 The voltage value of the seventh Hall sensor (not removed) 1380 11350 1313 1240 1193 1150 The eighth Hall sensor voltage value (not removed) 1440 1423 1687 2451 2914 3213 The ninth Hall sensor voltage value (not removed) 440 423 687 1451 1914 2213 Seventh Hall sensor voltage value (unplugged) 1080 1050 1013 940 893 850 The eighth Hall sensor voltage value (unplugged) 1140 1123 1387 2151 2614 2913 The ninth Hall sensor voltage value (unplugged) 940 923 1187 1951 2414 2713
[0115] The unit of the voltage value is mV, and the angles corresponding to angles 1 to 18 can refer to the angles in the above embodiment; the corresponding two-dimensional quadrant diagram can be obtained from each electrical signal in the above diagram. Figure 13 .
[0116] It should be noted that, in this embodiment, when the rotating ring 13 that has not moved downward (not dialed) and the rotating ring 13 that has moved downward (dialed) are performing debugging rotation, the seventh Hall sensor H7, the eighth Hall sensor H8 and the ninth Hall sensor H9 generate a total of 6 reference curves in the fourth blank coordinate system, and the reference curve is the reference range.
[0117] Reference Figure 11 and Figure 12 In one embodiment, the step of obtaining the electrical signal output according to the magnetic flux between the Hall sensor and the magnet 20 when the active switch is in use specifically includes:
[0118] S240, obtaining a fourth operating voltage value of the rotating ring 13 when in use;
[0119] The step of shielding the output signal of the Hall sensor when it is determined that the voltage value output by the Hall sensor exceeds a set operating range specifically includes:
[0120] S340: When the fourth operating voltage value does not fall within the fourth voltage operating reference line, determine that the fourth operating voltage value exceeds the operating range, and shield the output signal of the Hall sensor.
[0121] In this embodiment, the specific working principle and judgment principle can also refer to the description of the rotating ring 13 in the above embodiment, and will not be repeated here.
[0122] The present invention also provides an electronic device.
[0123] In one embodiment, the electronic device includes a processor, an active switch provided with a magnet 20, and at least one Hall sensor arranged around the active switch, wherein the processor stores an anti-interference program for the Hall sensor, and the processor is used to implement the anti-interference method for the Hall sensor as described above when executing the anti-interference program for the Hall sensor. In this embodiment, the processor can be a digital signal processor (DSP), a programmable logic device (PLD), a field programmable gate array (FPGA), a microprocessor, an MCU, or other electronic components. The specific settings and working principles of the active switch provided with the magnet 20 and the Hall sensor can refer to the contents in the above embodiments. The electronic device can be a flashlight, a headlamp, or other equipment.
[0124] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A Hall sensor anti-interference method, applied to an electronic device, wherein the electronic device includes a movable switch provided with a magnet and at least one Hall sensor arranged around the movable switch, characterized in that: The anti-interference method of the Hall sensor comprises the following steps: Obtaining an application type of the active switch and setting an operating range of the Hall sensor according to the application type, wherein the operating range is an electrical signal threshold corresponding to a magnetic flux value obtained by the Hall sensor; acquiring an electrical signal output according to magnetic flux conversion between the Hall sensor and the magnet when the active switch is in use; When it is determined that the electrical signal output by the Hall sensor exceeds a set operating range, the output signal of the Hall sensor is shielded.
2. The anti-interference method for a Hall sensor according to claim 1, wherein: The application type of the movable switch is a sliding switch, the Hall sensor includes a first Hall sensor and a second Hall sensor respectively arranged on both sides of the magnet, and the step of setting the operating range of the Hall sensor according to the application type specifically includes: Establishing a first blank coordinate system, wherein an x-axis of the first blank coordinate system corresponds to a first distance node between the magnet and the first Hall sensor and the second Hall sensor, and a y-axis of the first blank coordinate system corresponds to a first voltage value output by the first Hall sensor and the second Hall sensor according to magnetic flux between the magnet and the first Hall sensor; obtaining a first test voltage value output by the first Hall sensor and the second Hall sensor according to the magnetic flux between the first Hall sensor and the magnet when the sliding switch is debugged; A corresponding first voltage operation reference line is generated on the first blank coordinate system according to the first distance node and the first test voltage value, and an operation range is set according to the first voltage operation reference line.
3. The anti-interference method for a Hall sensor according to claim 2, wherein: The step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes: obtaining a first operating voltage value when the sliding switch is in use; The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes: When the first operating voltage value does not fall within the first voltage operating reference line, it is determined that the first operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
4. The anti-interference method for a Hall sensor according to claim 1, wherein: The application type of the active switch is a rotary switch, the Hall sensor includes a third Hall sensor and a fourth Hall sensor respectively arranged on both sides of the rotary switch, and the step of setting the operating range of the Hall sensor according to the application type specifically includes: Establishing a second blank coordinate system, wherein an x-axis of the second blank coordinate system corresponds to a rotation angle of the rotary switch, and a y-axis of the second blank coordinate system corresponds to a second voltage value output by the third Hall sensor and the fourth Hall sensor according to magnetic flux between the third Hall sensor and the magnet; obtaining a second test voltage value output by the third Hall sensor and the fourth Hall sensor according to the magnetic flux between the third Hall sensor and the magnet when the rotary switch is debugged; A corresponding second voltage operation reference line is generated on the second blank coordinate system according to the rotation angle of the rotary switch and the second test voltage value, and an operation range is set according to the second voltage operation reference line.
5. The anti-interference method for a Hall sensor according to claim 4, wherein: The step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes: obtaining a second operating voltage value when the rotary switch is in use; The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes: When the second operating voltage value does not fall within the second voltage operating reference line, it is determined that the second operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
6. The anti-interference method for a Hall sensor according to claim 1, wherein: The application type of the movable switch is a rotating ring that is arranged on a cylinder and can move up and down, the magnet is arranged in the rotating ring, the Hall sensor includes a fifth Hall sensor and a sixth Hall sensor that are arranged on the side wall of the cylinder, and the fifth Hall sensor and the sixth Hall sensor are arranged opposite to each other. The step of setting the operating range of the Hall sensor according to the application type specifically includes: Establishing a third blank coordinate system, wherein an x-axis of the third blank coordinate system corresponds to the rotation angle of the rotating ring, and a y-axis of the third blank coordinate system corresponds to a third voltage value output by the fifth Hall sensor and the sixth Hall sensor according to magnetic flux between the fifth Hall sensor and the magnet; obtaining a third test voltage value output by the fifth Hall sensor and the sixth Hall sensor according to the magnetic flux between the fifth Hall sensor and the magnet when the rotating ring is debugged; A corresponding third voltage operation reference line is generated on the third blank coordinate system according to the rotation angle of the rotating ring and the third test voltage value, and an operation range is set according to the third voltage operation reference line.
7. The anti-interference method for a Hall sensor according to claim 6, wherein: The step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes: obtaining a third operating voltage value of the rotating ring when in use; The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes: When the third operating voltage value does not fall within the third voltage operating reference line, it is determined that the third operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
8. The anti-interference method for a Hall sensor according to claim 1, wherein: The application type of the movable switch is a rotating ring that is arranged on a cylinder and can move up and down, the magnet is arranged in the rotating ring, the Hall sensor includes a seventh Hall sensor and an eighth Hall sensor arranged on the side wall of the cylinder, and a ninth Hall sensor arranged below the seventh Hall sensor and the eighth Hall sensor, the seventh Hall sensor and the eighth Hall sensor are arranged opposite to each other, and the step of setting the operating range of the Hall sensor according to the application type specifically includes: establishing a fourth blank coordinate system, wherein an x-axis of the fourth blank coordinate system corresponds to the rotation angle of the rotating ring, and a y-axis of the fourth blank coordinate system corresponds to fourth voltage values output by the seventh Hall sensor, the eighth Hall sensor, and the ninth Hall sensor according to magnetic flux between the sensor and the magnet; obtaining a fourth test voltage value output by the seventh Hall sensor, the eighth Hall sensor, and the ninth Hall sensor according to the magnetic flux between the seventh Hall sensor and the magnet when the rotating ring is debugged; A corresponding fourth voltage operation reference line is generated on the fourth blank coordinate system according to the rotation angle of the rotating ring and the fourth test voltage value, and an operation range is set according to the fourth voltage operation reference line.
9. The anti-interference method for a Hall sensor according to claim 8, wherein: The step of obtaining an electrical signal output according to the magnetic flux between the Hall sensor and the magnet when the active switch is in use specifically includes: obtaining a fourth operating voltage value of the rotating ring when in use; The step of shielding the output signal of the Hall sensor when it is determined that the electrical signal output by the Hall sensor exceeds a set operating range specifically includes: When the fourth operating voltage value does not fall within the fourth voltage operating reference line, it is determined that the fourth operating voltage value exceeds the operating range, and the output signal of the Hall sensor is shielded.
10. An electronic device, characterized in that: The invention comprises a processor, an active switch provided with a magnet, and at least one Hall sensor arranged around the active switch, wherein the processor stores an anti-interference program for the Hall sensor, and the processor is used to implement the anti-interference method for the Hall sensor according to any one of claims 1 to 9 when executing the anti-interference program for the Hall sensor.