A low-temperature-resistant proximity switch magnetic target detection method based on Hall effect
Patent Information
- Application Number
- CN202611200249.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-10
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2046-08-10
AI Technical Summary
[0007]为了解决现有技术无法有效应对极寒震颤与电磁干扰的问题,第一方面,本发明提供了基于霍尔效应的耐低温接近开关磁性目标检测方法,包括以下步骤:
本发明能够应对极寒环境下的温度漂移、机械震颤及无序电磁干扰,显著提升传感器在恶劣工况下的检测可靠性与安全性。
Smart Images

Figure CN122710211B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of sensor detection. More specifically, this invention relates to a method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect. Background Technology
[0002] Hall effect proximity switches, as a type of non-contact position detection sensor, are widely used in industrial automation, new energy equipment, and outdoor heavy machinery due to their advantages such as fast response speed, long service life, and resistance to dust pollution. Their core working principle utilizes the Hall effect; when a magnetic target approaches or moves away from the sensor, the internal Hall element outputs a corresponding magnetic field voltage signal. The system compares this voltage signal with preset action and release thresholds to output control signals to start / stop the equipment or determine its position.
[0003] In conventional Hall effect proximity switch designs, a fixed voltage threshold combined with a simple software delay filtering algorithm is typically used to prevent false triggering caused by signal jitter. However, as industrial applications extend to extreme environments and complex electromagnetic conditions, this traditional detection and anti-jitter mechanism has revealed significant limitations.
[0004] On the one hand, in extremely cold environments, the internal semiconductor characteristics of proximity switches change significantly, causing temperature drift in the sensitivity of Hall elements. Simultaneously, the external mechanical structure of the sensor and the measured magnetic target undergo contraction and deformation at low temperatures, inducing irregular mechanical micro-vibrations. When the magnetic target is at the critical detection distance, these cold-induced micro-vibrations cause the output magnetic field voltage signal to fluctuate violently around the threshold. Existing fixed threshold mechanisms cannot dynamically compensate for temperature drift, leading to a shift in the baseline detection; while simple delay filtering algorithms cannot distinguish between these periodic physical vibrations and actual physical displacement, easily causing frequent malfunctions or delayed responses in the switch.
[0005] On the other hand, in complex industrial environments, large motors, frequency converters, and high-voltage cables generate strong electromagnetic interference. When these disordered electromagnetic surges couple to sensor signal lines, they form voltage spikes with large amplitudes and no discernible patterns. Existing anti-shake strategies often struggle to accurately distinguish the essential differences between regular mechanical vibrations and disordered electromagnetic surges. Blindly increasing the release threshold or extending the filtering time to suppress electromagnetic interference may reduce false triggers, but it significantly sacrifices the sensor's detection sensitivity and response speed, and may even create detection blind spots when the signal attenuates. If the normal threshold is maintained, the system is highly susceptible to being misled by electromagnetic disturbances, leading to misjudgments of the status.
[0006] In summary, existing Hall effect proximity switch detection mechanisms lack the ability to adaptively compensate for changes in the physical environment and the ability to deeply discern signal characteristics when faced with extreme temperatures and complex electromagnetic environments. They cannot effectively cope with the problems of extreme cold vibrations and electromagnetic interference, which seriously restricts the reliability and safety of equipment operation under harsh conditions. Summary of the Invention
[0007] To address the limitations of existing technologies in effectively handling extreme cold vibrations and electromagnetic interference, this invention provides, in a first aspect, a low-temperature resistant proximity switch magnetic target detection method based on the Hall effect, comprising the following steps: Acquire real-time temperature values and discrete data of Hall magnetic field voltage, compensate the initial release threshold based on the real-time temperature values, and generate a real-time reference release threshold; Based on a set differential threshold, the step span sequence corresponding to the fluctuation and turning point of the discrete Hall magnetic field voltage data within the sliding window is extracted. Based on the step span sequence, a span dispersion penalty term is determined to characterize the dispersion degree of adjacent step spans, and a trust discount weight is calculated based on the real-time temperature value and the span dispersion penalty term. The trust discount weight is negatively correlated with the dispersion degree. Based on the local range of the data within the sliding window and the trust discount weight, the dynamic downward bias is calculated. The real-time reference release threshold is reconstructed using the dynamic downward bias, and an anti-shake release threshold is generated after combining it with clamping constraints. The currently acquired discrete data of Hall magnetic field voltage is compared with the preset action threshold and the anti-shake release threshold. The output control signal controls the proximity switch to act, and the dynamic downward bias is attenuated and discharged according to the preset clock cycle to achieve threshold reset.
[0008] Preferably, the step of compensating the initial release threshold based on the real-time temperature value and generating a real-time reference release threshold includes: The absolute value of the temperature difference is obtained by subtracting the real-time temperature value from the system's pre-stored ambient temperature reference temperature, and the absolute value of the temperature difference is multiplied by the preset extreme cold compensation base to generate a dynamic sensitivity compensation bias. The compensation polarity is determined based on the predetermined low-temperature drift characteristics of the sensor. The initial release threshold is then added to or subtracted from the dynamic sensitivity compensation bias based on the compensation polarity to generate the real-time reference release threshold under the current temperature environment.
[0009] Preferably, the step-size span sequence corresponding to the fluctuation and turning points of the Hall magnetic field voltage discrete data within the sliding window based on a set differential threshold includes: The discrete data of the Hall magnetic field voltage are continuously acquired and updated in the sliding window, and a first-order difference sequence is generated by subtracting adjacent data one by one; For any difference value in a first-order difference sequence, if the previous difference value is greater than a preset positive noise threshold and the current difference value is less than a preset negative noise threshold, or the previous difference value is less than the negative noise threshold and the current difference value is greater than the positive noise threshold, then the index position corresponding to the current difference value is marked as a valid flip point. Extract the step span value by subtracting the index sequence number of the previous adjacent valid flip point from the index sequence number of the current valid flip point, and then iterate through the steps to construct the step span sequence.
[0010] Preferably, determining the span discreteness penalty term based on the step span sequence to characterize the discreteness of adjacent step spans includes: Extract the next adjacent step span value and the previous step span value in the step span sequence; The absolute value of the result obtained by subtracting the previous step span value from the next step span value is defined as the span discrete penalty term.
[0011] Preferably, the step of calculating the trust discount weight based on the real-time temperature value and the span discrete penalty term includes: Subtract the real-time temperature value from the system's pre-stored ambient temperature reference temperature. If the result of the subtraction is less than zero, force it to be zero to cut off the high-temperature logic exception. Multiply the non-negative subtraction result by the preset base temperature adjustment coefficient to obtain the dynamic base trust base. Subtract the span discrete penalty term from the dynamic basic trust base; if the result of the subtraction is greater than zero, it is set as the trust discount weight; if the result of the subtraction is less than or equal to zero, the trust discount weight is forcibly cleared to zero.
[0012] Preferably, the step of calculating the dynamic downward bias based on the local range of the data within the sliding window and the trust discount weight includes: Search for the maximum and minimum values of the data within the current sliding window, and subtract them to obtain the local range; Determine whether the local range is greater than the preset lower limit of the effective flutter amplitude; If the local range is not greater than the lower limit of the effective flutter amplitude, then the dynamic downward bias is forcibly set to zero.
[0013] Preferably, the calculation of the dynamic downward bias further includes: If the local range is greater than the lower limit of the effective flutter amplitude, then count the total number of flip points of the effective flip points marked in the current sliding window; The local range, the total number of flip points, and the confidence discount weight are multiplied sequentially, and the intermediate product results are stored using an extended bit-width variable. A fixed-point shift scaling operation is performed on the intermediate product result to generate the final dynamic downward bias.
[0014] Preferably, the step of reconstructing the real-time reference release threshold using the dynamic downward bias and generating the anti-jitter release threshold after combining it with clamping constraints includes: The initial anti-shake threshold is obtained by subtracting the current dynamic downward bias from the real-time reference release threshold. The initial anti-shake threshold is compared with the preset physical output lower limit. The larger of the two values is extracted to generate the anti-shake release threshold for the current judgment period, in order to prevent the threshold from being physically broken down.
[0015] Preferably, the step of attenuating and discharging the dynamically decreasing bias amount according to a preset clock cycle to achieve threshold reset includes: During each clock interrupt cycle, the decay step size is forcibly subtracted from the current dynamic probing bias amount. If the bias result after subtracting the attenuation step size is less than zero, the dynamic downward bias amount is forcibly reduced to zero, so that the anti-shake release threshold slowly rebounds to be equal to the real-time reference release threshold.
[0016] The present invention has the following beneficial effects: This invention can cope with temperature drift, mechanical vibration and disordered electromagnetic interference in extremely cold environments, and significantly improves the detection reliability and safety of the sensor under harsh working conditions.
[0017] Furthermore, to address temperature drift, after real-time acquisition of ambient temperature, a lookup table and linear interpolation algorithm based on multi-node calibration data are used to calculate the dynamic sensitivity compensation bias, correcting the initial release threshold and generating a real-time reference release threshold. This compensation bias adapts to the nonlinear physical attenuation characteristics of the sensor in cryogenic environments, enabling the real-time reference release threshold to accurately correspond to the actual physical release distance, thereby suppressing detection errors introduced by drastic temperature changes and reducing misjudgments during device startup.
[0018] Furthermore, regarding mechanical vibration and disordered electromagnetic interference, a basic confidence level is calculated based on the fundamental difference between the periodic regularity of mechanical vibration and the randomness of disordered electromagnetic interference. The confidence level of disordered electromagnetic surges is then deducted using a span-discrete penalty term to obtain a confidence discount weight. Based on this weight, this invention retains periodic mechanical vibration signals for decision-making while suppressing and eliminating random electromagnetic noise. This ensures that the final output target detection state is unaffected by electromagnetic surge disturbances, while also preventing frequent false triggering due to mechanical vibration. Attached Figure Description
[0019] Figure 1This is a flowchart of the steps of the low-temperature proximity switch magnetic target detection method based on the Hall effect provided in the embodiments of the present invention; Figure 2 This is a threshold comparison effect diagram provided by an embodiment of the present invention; Figure 3 This is a target detection effect diagram provided by an embodiment of the present invention. Detailed Implementation
[0020] Combination Figure 1 This paper elaborates on the specific implementation of a low-temperature proximity switch magnetic target detection method based on the Hall effect, including the following steps: S1, acquire real-time temperature value and discrete data of Hall magnetic field voltage, compensate the initial release threshold based on the real-time temperature value, and generate a real-time reference release threshold.
[0021] In extremely cold environments, the internal semiconductor characteristics of proximity switches exhibit significant sensitivity drift, and the external mechanical structure also undergoes contraction and deformation due to cold. If the initial release threshold at room temperature is used directly as the baseline for judgment, the system will face a huge basic detection error at the moment of power-on. Therefore, it is necessary to first compensate for the initial release threshold using real-time temperature values, thereby providing a relatively accurate benchmark reference for subsequent anti-shake and anti-jump processing.
[0022] The specific implementation method is as follows: Real-time temperature values and discrete data of Hall magnetic field voltage are acquired simultaneously. First, the absolute value of the temperature difference between the normal temperature reference temperature and the real-time temperature value is calculated, and a corresponding dynamic sensitivity compensation bias is generated based on the extreme cold compensation baseline. Then, the pre-calibrated low-temperature drift characteristics of the sensor are consulted to determine the compensation polarity. Based on this compensation polarity, the initial release threshold and the dynamic sensitivity compensation bias are added or subtracted to generate a real-time reference release threshold adapted to the current extreme cold environment.
[0023] The above processing allows for temperature-based correction of the voltage threshold, providing a foundation for subsequent anti-shake and anti-jitter measures. For example, in magnetic field detection scenarios, at room temperature, when a magnetic target approaches a specific distance, the magnetic field voltage output by the Hall element reaches the initial release threshold. However, in extremely cold environments, due to the decreased semiconductor carrier mobility, the output magnetic field voltage may attenuate at the same physical distance. Without correction, the system might mistakenly believe the magnetic target has not yet reached the release position. Through the above operations, the system can calculate the voltage attenuation based on the absolute value of the temperature difference and correct the initial release threshold according to the compensation polarity, ensuring that the generated real-time reference release threshold accurately corresponds to the actual physical release distance, thereby eliminating the fundamental detection error caused by temperature.
[0024] In an optional embodiment, the specific implementation of calculating the dynamic sensitivity compensation bias based on the absolute value of temperature difference is as follows: call the internally pre-calibrated and stored extreme cold compensation base, multiply the calculated absolute value of temperature difference by the extreme cold compensation base to obtain the dynamic sensitivity compensation bias, wherein the extreme cold compensation base represents the amount of voltage change corresponding to a unit temperature change, and its preferred value is 3 millivolts per degree Celsius.
[0025] In an optional embodiment, the specific implementation of determining the compensation polarity based on the sensor's low-temperature drift characteristics is as follows: During initialization, the characteristic flag bit is read. If the flag bit indicates that the Hall element exhibits magnetic induction attenuation at low temperatures, the compensation polarity is determined to be negative, and the initial release threshold is subtracted from the calculated dynamic sensitivity compensation bias. If the flag bit indicates that the element exhibits magnetic induction at low temperatures, the compensation polarity is determined to be positive, and the initial release threshold is added to the calculated dynamic sensitivity compensation bias. The preferred value for the initial release threshold is 2500.
[0026] This design, which uses characteristic flags to determine the compensation polarity, is compatible with Hall effect chips of different materials or models, avoiding the problem of equipment failure caused by the reversal of compensation polarity logic due to the replacement of sensor batches.
[0027] In another alternative embodiment, considering that the temperature drift of the Hall element is not an absolutely linear change, a piecewise calculation method is used in this embodiment instead of a single fixed extreme cold compensation base, specifically: During the calibration phase before the equipment leaves the factory, the proximity switch is placed in a high and low temperature chamber, and under fixed test conditions with a standard magnetic target at a standard release distance, the actual magnetic field voltage values output by the Hall element are measured at multiple discrete temperature nodes. Subsequently, the difference between the actual magnetic field voltage values measured at each temperature node and the initial release threshold measured at a normal temperature reference temperature is calculated, and the absolute value is taken to determine the dynamic sensitivity compensation bias corresponding to each temperature node. These discrete temperature nodes and their corresponding dynamic sensitivity compensation biases are compiled into a temperature-dynamic sensitivity compensation bias lookup table and stored in the controller. During equipment operation, the system looks up the temperature range in the lookup table based on the acquired real-time temperature value, and uses a linear interpolation algorithm to interpolate between two adjacent dynamic sensitivity compensation biases to calculate the accurate dynamic sensitivity compensation bias at the current temperature. In this embodiment, the preferred real-time reference temperature is 25 degrees Celsius.
[0028] This lookup-based calculation method, based on multiple calibration data, effectively eliminates the errors caused by a single, fixed extreme cold compensation base in extreme cryogenic regions. For example, in outdoor scenarios in extremely cold regions, the sensitivity of a sensor often decreases non-linearly as it experiences a rapid drop from freezing point to extreme cold. Lookup-based calculation can accurately track this non-linear physical decay process, making the generation of the real-time reference release threshold more closely match the sensor's true physical state and solving the detection blind zone problem caused by non-linear temperature drift in cryogenic environments.
[0029] S2, based on the set differential threshold, extract the step span sequence corresponding to the fluctuation and turning point of the discrete data of the Hall magnetic field voltage within the sliding window.
[0030] Magnetic targets experience irregular micro-vibrations when contracted in extreme cold, while the underlying layer contains noise from analog-to-digital conversion. Using conventional extremum search methods, these are easily interfered with by minute background noise or vibration spikes in the flattened areas, resulting in the extraction of numerous invalid false flip points. Therefore, a barrier with a set differential threshold must be established to accurately isolate the true physical fluctuations.
[0031] The specific implementation method is as follows: read discrete Hall magnetic field voltage data from the data buffer and construct a fixed-length sliding window. Then, sequentially calculate the adjacent differences of continuously input discrete data within the sliding window to generate a first-order difference sequence. The preferred length of the sliding window is 64.
[0032] Subsequently, a difference threshold is constructed using pre-set positive and negative noise thresholds. The first-order difference sequence is traversed, and only when the difference value in the first-order difference sequence completes a full fluctuation cycle spanning both the positive and negative noise thresholds is a real physical fluctuation abrupt change identified and marked as a valid reversal point. The span characteristics between adjacent valid reversal points are then extracted. The preferred values for the positive and negative noise thresholds are 2 and 20, respectively.
[0033] In magnetic field detection scenarios, the Hall voltage generally increases as a magnetic target approaches. However, extreme cold micro-tremors cause tiny spikes in the voltage during this increase. These spikes produce small first-order difference values, which are confined within the difference threshold. In contrast, real physical fluctuations and abrupt changes produce larger first-order difference values that exceed the difference threshold. Through this process, the interference from underlying stray fluctuations can be forcibly filtered out, ensuring that the constructed step-span sequence is pure and authentic, providing reliable temporal characteristics for subsequent evaluation of tremor patterns.
[0034] In an optional embodiment, the sliding window data update is implemented as follows: a circular buffer is allocated in memory as a sliding window, and the latest discrete Hall magnetic field voltage data is continuously read from the system data cache to overwrite the oldest data in the buffer.
[0035] In an optional embodiment, the specific implementation of determining the valid flip point based on the difference value crossing the threshold is as follows: The system internally uses a finite state machine containing an initial state, a positive transition state, and a negative transition state. When the difference value is greater than the positive noise threshold, the state machine switches to the positive transition state; when the difference value is less than the negative noise threshold, the state machine switches to the negative transition state. During the traversal of the first-order difference sequence, when the state machine flips from a positive transition state to a negative transition state or vice versa, this flip point is considered the completion of a full physical fluctuation cycle. The data index value of the current data in the circular buffer is then extracted and marked as a valid flip point, and the state machine is reset to the initial state.
[0036] Subsequently, the data index values of adjacent valid flip points are directly subtracted to obtain the number of discrete points between adjacent flip actions. This number is then used as the step span value and stored sequentially in a dedicated feature array to construct the step span sequence.
[0037] This rigorous decision-making mechanism based on state machines effectively solves the problem that single threshold judgment is prone to repeated marking due to signal overshoot or oscillation, ensuring the absolute accuracy of the step span sequence.
[0038] S3, based on the step span sequence, determine a span dispersion penalty term to characterize the dispersion degree of adjacent step spans, and calculate a trust discount weight based on the real-time temperature value and the span dispersion penalty term, wherein the trust discount weight is negatively correlated with the dispersion degree.
[0039] In complex industrial environments, it is crucial to accurately distinguish between the regular mechanical vibrations that require anti-shake measures and the disordered electromagnetic surges that must be eliminated. Mechanical vibrations caused by cold contraction in extremely cold environments exhibit periodic patterns, while electromagnetic interference often presents a disordered nature. Therefore, this distinction can be made by quantifying the regularity of the signals. Furthermore, vibration amplitude is significantly affected by temperature; using real-time temperature values as the basis for anti-shake authorization allows the system's anti-interference strategy to adapt to changes in the external physical environment.
[0040] First, the absolute value of the difference between adjacent data in the step span sequence is extracted to quantify the dispersion of the current signal and generate a span dispersion penalty term.
[0041] Subsequently, a dynamic baseline trust base corresponding to the current coldness is calculated using the ambient temperature reference temperature and the real-time temperature value, and a cutoff protection to prevent high temperature anomalies is implemented at this stage.
[0042] Finally, the trust discount weight is calculated based on the dynamic basic trust base and the span discrete penalty term.
[0043] In magnetic field detection scenarios in extremely cold environments, the micro-vibrations caused by mechanical contraction usually have a fixed frequency, and the corresponding step span sequence values are uniform with relatively small absolute values of adjacent differences. Conversely, if there are disordered electromagnetic surges generated by frequency converters on site, the voltage fluctuations they cause will cause the step span to fluctuate greatly, and the absolute values of adjacent differences will increase dramatically. Therefore, the trust discount weight can be set by adjusting the absolute values of adjacent differences to adjust the trust level of different signals.
[0044] In an optional embodiment, the method for calculating a dynamic basic trust base and performing high-temperature anomaly cutoff protection includes: The system reads a pre-stored ambient temperature reference and subtracts the real-time temperature value to obtain the temperature difference. A sign check is performed on this temperature difference. If the temperature difference is negative, it indicates that the environment is in a non-extremely cold, high-temperature anomaly state, and a zeroing operation is directly triggered, forcibly assigning the dynamic basic trust base to zero. If the temperature difference is positive, it is divided by a preset maximum extreme cold temperature difference threshold, and the quotient is used as the dynamic basic trust base. The maximum extreme cold temperature difference threshold ranges from 40 to 80 degrees Celsius, preferably 65 degrees Celsius.
[0045] This method, based on symbol verification and normalization, not only avoids invalid anti-shake calculations under high-temperature conditions, but also ensures the rationality of the dynamic basic trust base within its numerical range.
[0046] In an optional embodiment, the process of calculating the span discrete penalty term is as follows: Traverse the step-span sequence. If the total length of the step-span sequence is greater than zero, calculate the absolute value of the difference between adjacent step-span values. Sum all the absolute values of the differences, divide by the total length of the step-span sequence, and then divide by a preset maximum allowable dispersion to normalize and obtain the span dispersion penalty term. If the total length of the step-span sequence is equal to zero, then assign the span dispersion penalty term to zero. The preferred value for the maximum allowable dispersion is 30.
[0047] In another alternative embodiment, the method for calculating the trust discount weight is as follows: The dynamic baseline trust is subtracted from the span dispersion penalty term, and a sign check is performed again on the subtraction result. If the subtraction result is negative, it indicates that the disorder and dispersion of the signal have exceeded the baseline trust given by the ambient temperature, and the trust discount weight is directly reset to zero. If the subtraction result is positive, the subtraction result is used as the final trust discount weight.
[0048] This dual verification and direct zeroing mechanism makes the rejection of disordered spurious signals faster and more reliable, effectively preventing the risk of logic overflow caused by the transfer of negative weights to subsequent calculation modules.
[0049] S4. Calculate the dynamic downward bias based on the local range of the data within the sliding window and the trust discount weight.
[0050] After determining that the signal has the value of image stabilization, it is necessary to quantify the specific depth of image stabilization downshifting, so as to provide accurate bias parameters for subsequent reconstruction of the image stabilization release threshold.
[0051] The specific implementation is as follows: The local range of the Hall magnetic field voltage discrete data is extracted from the sliding window. First, it is compared with the lower limit of the effective jitter amplitude. If the local range is greater than the lower limit, the local range, the total number of flip points, and the confidence discount weight are multiplied together to obtain an intermediate product. Then, a fixed-point shift scaling operation is performed on the intermediate product to output the final dynamic downward bias. If the local range is not greater than the lower limit of the effective jitter amplitude, it indicates that the current signal fluctuation belongs to normal background noise or has no obvious physical jitter. In this case, the dynamic downward bias is directly set to zero, skipping the subsequent multiplication and scaling operations. The preferred value for the lower limit of the effective jitter amplitude is 40.
[0052] In magnetic field detection scenarios in extremely cold environments, when a magnetic target triggers severe mechanical contraction and vibration, the local range within the sliding window is large and there are many flip points. At the same time, the confidence discount weight is high. Through multiplication, a large dynamic downward bias is generated, thereby deepening the anti-shake downward probe depth to prevent accidental switch release. Conversely, if the vibration is weak or the signal confidence is low, the generated dynamic downward bias is smaller, avoiding excessive anti-shake that could lead to a sluggish system response.
[0053] In an optional embodiment, the multiplication operation and shift scaling are specifically implemented as follows: When the local range is determined to be greater than the lower limit of the effective jitter amplitude, to prevent subsequent multiplication of multiple variables from causing the basic data type to exceed the limit, an extended bit-width variable with a larger storage space is declared in memory. The local range, the total number of flip points, and the confidence discount weight are sequentially pushed into this extended bit-width variable for multiplication to accommodate the generated intermediate product results. Next, the internally stored scaling factor is called, and the logarithm of the scaling factor to base 2 is calculated to determine the corresponding right shift number, or the corresponding right shift number is determined by directly querying the pre-stored coefficient-shift number mapping table. The right shift operation is performed on the extended bit-width variable to complete the fixed-point shift scaling operation. The effective value truncated after shift scaling is the final generated dynamic downward bias.
[0054] By using this method based on extended bit width and shift operations, the risk of data overflow that may be caused by the accumulation of operations is effectively avoided, thus ensuring the stability of the operation.
[0055] In an optional embodiment, the boundary protection of the dynamic downward probe bias is specifically implemented as follows: an upper limit truncation protection is performed on the generated dynamic downward probe bias. If the dynamic downward probe bias is greater than the preset maximum downward probe limit value, it is forcibly assigned the maximum downward probe limit value, and the preferred value of the maximum downward probe limit value is 420.
[0056] This boundary truncation operation prevents the calculated downward bias from being too large under extreme conditions, which could cause the subsequent release threshold to fall below the physical resolution limit.
[0057] S5, the real-time reference release threshold is reconstructed using the dynamic downward bias, and an anti-shake release threshold is generated after combining it with clamping constraints.
[0058] Under conditions of excessive external interference or extreme operating conditions, the previously calculated dynamic downward bias may be too large, causing the reconstructed judgment threshold to fall below the sensor's minimum physical resolution limit or even become negative. If an unrestricted threshold is used directly for state determination, a sensor blind zone will be created. Therefore, a clamping constraint mechanism needs to be introduced in the reconstruction stage to ensure the safety and effectiveness of the threshold.
[0059] The specific operation is as follows: Obtain the real-time reference release threshold and the dynamic downward bias; subtract the dynamic downward bias from the real-time reference release threshold to obtain the initial anti-shake threshold. Then, perform a clamping constraint operation on the initial anti-shake threshold, that is, compare the initial anti-shake threshold with a preset physical output lower limit value, and extract the larger of the two as the final anti-shake release threshold. The preferred value for the physical output lower limit is 35.
[0060] In magnetic field detection scenarios with strong electromagnetic interference or severe mechanical vibration, the calculated dynamic downward bias may be extremely large. Directly subtracting this bias could cause the anti-shake release threshold to drop to zero or even a negative number, preventing the proximity switch from releasing properly at any distance. By using the aforementioned clamping constraint, the anti-shake release threshold can be limited above the lower limit of the physical output, ensuring that the sensor always possesses effective physical resolution and eliminating the judgment blind zone caused by extreme interference.
[0061] In an optional embodiment, the clamp constraint generates the anti-shake release threshold by calling an internally stored reference constant, the value of which is the physical output lower limit corresponding to the current sensor model. To prevent underflow and flipping of the value when the dynamic downward bias is greater than the real-time reference release threshold, an anti-underflow protection operation is introduced before performing the subtraction operation. Specifically, it is determined whether the real-time reference release threshold is greater than or equal to the dynamic downward bias; if so, the subtraction operation is performed to obtain the preliminary anti-shake threshold; otherwise, the preliminary anti-shake threshold is directly assigned to zero.
[0062] Subsequently, the initial stabilization threshold is compared with the physical output lower limit. If the initial stabilization threshold is less than the physical output lower limit, the physical output lower limit will be automatically extracted as the stabilization release threshold. If the initial stabilization threshold is greater than or equal to the physical output lower limit, the stabilization release threshold will remain unchanged.
[0063] This data type conversion-based underflow prevention and direct data clamping mechanism effectively intercepts the phenomenon of negative physical threshold drops when encountering extreme computational out-of-bounds interference.
[0064] In another optional embodiment, considering that the continuously calculated dynamic downward bias may fluctuate significantly in a strong interference environment, causing the generated anti-shake release threshold to change abruptly between adjacent cycles, thus triggering frequent reversals of subsequent control signals, the following approach is adopted: After generating the final anti-shake release threshold, it is subtracted from the historical anti-shake release threshold output in the previous sampling cycle to calculate the threshold change. This threshold change is then compared with a preset maximum allowable change step size. If the absolute value of the threshold change is greater than the maximum allowable change step size, the historical anti-shake release threshold is added to the maximum allowable change step size, and the sum is used as the final output anti-shake release threshold for the current cycle. If the absolute value of the threshold change is less than or equal to the maximum allowable change step size, the currently calculated anti-shake release threshold is directly output. The maximum allowable change step size is preferably set to 18.
[0065] This smooth transition mechanism based on the rate of change limit effectively suppresses drastic changes in the anti-shake release threshold, ensuring the stability of the proximity switch control signal output.
[0066] S6: Compare the currently acquired discrete data of Hall magnetic field voltage with the preset action threshold and anti-jitter release threshold to output a control signal, and perform attenuation discharge of the dynamic downward bias amount according to the preset clock cycle to achieve threshold reset.
[0067] If a magnetic target remains stationary or abnormally stuck after the proximity switch has activated its anti-jitter maintenance mode, the system's continued operation could potentially lead to a production accident. Furthermore, if the anti-jitter depth does not decrease after high-frequency interference subsides, the system's response will be sluggish. Therefore, a time-based attenuation and discharge mechanism is needed to achieve system self-healing and threshold reset while completing the control loop.
[0068] Specifically, it works as follows: acquiring the current discrete data of the Hall magnetic field voltage, comparing it with the preset action threshold and anti-jitter release threshold, and outputting a control signal to drive the proximity switch based on the comparison result. At the same time, it performs a deduction operation on the current dynamic downward bias amount with a preset clock cycle until the dynamic downward bias amount returns to zero, so that the anti-jitter release threshold gradually rebounds to the real-time reference release threshold as the bias amount decays.
[0069] In the magnetic field detection scenario, when a magnetic target approaches and causes the voltage to exceed the preset action threshold, an action signal is output; when the magnetic target moves away but is affected by extreme cold and vibration, causing the voltage to fluctuate around the anti-shake release threshold, the action state is maintained; if the magnetic target has actually moved away and the vibration interference has subsided, the anti-shake release threshold is gradually increased by periodically deducting the dynamic downward bias amount, and finally, when the voltage is lower than the anti-shake release threshold after rebound, a release signal is output.
[0070] The above operations ensure that the state is maintained during the anti-interference period and avoid the problem of being unable to release due to anti-shake lock.
[0071] In an optional embodiment, the specific implementation of state comparison and attenuation discharge is as follows: the currently acquired Hall magnetic field voltage discrete data is compared with the preset action threshold and the anti-jitter release threshold. If the Hall magnetic field voltage discrete data is greater than or equal to the preset action threshold, the flag bit of the internal state register is set to the valid state; if the Hall magnetic field voltage discrete data is less than the anti-jitter release threshold, the flag bit is cleared to the invalid state; if the Hall magnetic field voltage discrete data is between the two, the flag bit state remains unchanged.
[0072] Regarding the physical output of the signal, when the flag bit is in an active state, the general-purpose input / output pin is controlled to output a high-level signal. This high-level signal is amplified by the external transistor drive circuit and then turns on the output terminal of the proximity switch to output an action control signal. When the flag bit is in an inactive state, the general-purpose input / output pin is controlled to output a low-level signal, which cuts off the transistor drive circuit to output a release control signal.
[0073] For attenuation and discharge, an independent periodic clock task is configured. When the preset clock cycle is reached, the attenuation logic is triggered. Since the dynamic downward bias is stored in memory in a non-negative format, to prevent the value from overflowing and flipping due to the subtraction operation, underflow protection is introduced before performing the subtraction. Specifically, it is determined whether the current dynamic downward bias is greater than or equal to the preset second attenuation step size. If so, the dynamic downward bias is subtracted from the attenuation step size; otherwise, the dynamic downward bias is directly forced to be zero.
[0074] This state machine-based dual threshold comparison and anti-underflow attenuation mechanism ensures the accuracy of the control signal output and the safety of the bias attenuation process.
[0075] In another optional embodiment, the attenuation step size can be dynamically adjusted according to the interference intensity to optimize the reset efficiency. Specifically, this is achieved by obtaining the current dynamic downward bias and setting a first attenuation step size and a second attenuation step size, wherein the second attenuation step size is smaller than the first attenuation step size. The preferred values for the first and second attenuation step sizes are 35 and 6, respectively.
[0076] The dynamic offset is compared with a preset segmented threshold. If the dynamic offset is greater than the segmented threshold, it indicates that the system is in a deep stabilization state after strong interference. In this case, the dynamic offset minus a preset first attenuation step is used as the adjusted attenuation step to accelerate the threshold rebound speed. If the dynamic offset is less than or equal to the segmented threshold, it indicates that the system is close to the standard detection benchmark. In this case, the dynamic offset minus a preset first attenuation step is used as the adjusted attenuation step to achieve a smooth transition and prevent threshold rebound overshoot. The preferred value for the segmented threshold is 180.
[0077] This mechanism, which adjusts the attenuation rate in segments based on the amplitude of the bias, allows the anti-shake release threshold to balance rapid recovery and smooth transition without blocking normal detection, ensuring that the system can quickly and smoothly recover to the standard detection benchmark after severe interference subsides.
[0078] To demonstrate the effectiveness of the solution, relevant experiments were conducted. Below are the images obtained from the experiments: Figure 2 The diagram shows the threshold comparison results. The solid lines represent discrete data of Hall magnetic field voltage, the dotted lines with square markings represent preset action thresholds, the dashed lines with cross markings represent real-time reference release thresholds, the dotted lines with circular markings represent anti-shake release thresholds, and the filled areas with diagonal shading represent the dynamic downward bias protection band generated by the anti-shake mechanism.
[0079] As can be seen from the image, within the complex operating range of 200 to 800 for the Hall magnetic field voltage discrete data, the Hall magnetic field voltage discrete data frequently crosses the real-time reference release threshold, while the anti-jitter release threshold rapidly decreases within this range. The downward abrupt Hall magnetic field voltage spikes are effectively contained by the shaded area. This visually demonstrates that the present invention can filter out the risk of false triggering caused by extreme cold contraction and vibration, thus improving the detection reliability under harsh operating conditions.
[0080] Figure 3 The image shows the target detection results. The solid lines marked with triangles represent the dynamic downward bias.
[0081] The image shows that the dynamic dip offset exhibits localized decreases and rebounds around 500, demonstrating that the system can adjust the anti-shake dip depth in a timely manner based on the extracted signal characteristics, maintaining normal detection response while ensuring anti-interference capabilities.
[0082] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect, characterized in that, include: Acquire real-time temperature values and discrete data of Hall magnetic field voltage, compensate the initial release threshold based on the real-time temperature values, and generate a real-time reference release threshold; Based on a set differential threshold, the step span sequence corresponding to the fluctuation and turning point of the discrete Hall magnetic field voltage data within the sliding window is extracted. Based on the step span sequence, a span dispersion penalty term is determined to characterize the dispersion degree of adjacent step spans, and a trust discount weight is calculated based on the real-time temperature value and the span dispersion penalty term. The trust discount weight is negatively correlated with the dispersion degree. Based on the local range of the data within the sliding window and the trust discount weight, the dynamic downward bias is calculated. The real-time reference release threshold is reconstructed using the dynamic downward bias, and an anti-shake release threshold is generated after combining it with clamping constraints. The currently acquired discrete data of Hall magnetic field voltage is compared with the preset action threshold and the anti-shake release threshold. The output control signal controls the proximity switch to act, and the dynamic downward bias is attenuated and discharged according to the preset clock cycle to achieve threshold reset.
2. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 1, characterized in that, The step of compensating for the initial release threshold based on the real-time temperature value and generating a real-time baseline release threshold includes: The absolute value of the temperature difference is obtained by subtracting the real-time temperature value from the system's pre-stored ambient temperature reference temperature, and the absolute value of the temperature difference is multiplied by the preset extreme cold compensation base to generate a dynamic sensitivity compensation bias. The compensation polarity is determined based on the predetermined low-temperature drift characteristics of the sensor. The initial release threshold is then added to or subtracted from the dynamic sensitivity compensation bias based on the compensation polarity to generate the real-time reference release threshold under the current temperature environment.
3. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 1, characterized in that, The step span sequence corresponding to the fluctuation and turning points of the discrete Hall magnetic field voltage data within a sliding window, based on a set differential threshold, includes: The discrete data of the Hall magnetic field voltage are continuously acquired and updated in the sliding window, and a first-order difference sequence is generated by subtracting adjacent data one by one; For any difference value in a first-order difference sequence, if the previous difference value is greater than a preset positive noise threshold and the current difference value is less than a preset negative noise threshold, or if the previous difference value is less than the negative noise threshold and the current difference value is greater than the positive noise threshold, then the index position corresponding to the current difference value is marked as a valid flip point. Extract the step span value by subtracting the index sequence number of the previous adjacent valid flip point from the index sequence number of the current valid flip point, and then iterate through the steps to construct the step span sequence.
4. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 1, characterized in that, The step-span discrete penalty term, determined based on the step-span sequence to characterize the discreteness of adjacent step-span intervals, includes: Traverse the step span sequence. If the total length of the sequence is greater than zero, calculate the absolute value of the difference between all adjacent step span values and sum them. Divide the sum by the total length of the sequence and then divide it by the preset maximum allowable dispersion to normalize it, and obtain the span dispersion penalty term. If the total length of the sequence is equal to zero, then the span discrete penalty term is assigned a value of zero.
5. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 4, characterized in that, The calculation of the trust discount weight based on the real-time temperature value and the span discrete penalty term includes: Subtract the real-time temperature value from the system's pre-stored ambient temperature reference temperature. If the result of the subtraction is less than zero, force it to be zero to cut off the high-temperature logic exception. Divide the non-negative subtraction result by the preset maximum extreme cold temperature difference threshold to obtain the dynamic basic trust base. Subtract the span discrete penalty term from the dynamic basic trust base; if the result of the subtraction is greater than zero, it is set as the trust discount weight; if the result of the subtraction is less than or equal to zero, the trust discount weight is forcibly cleared to zero.
6. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 1, characterized in that, The calculation of the dynamic downward bias based on the local range of the data within the sliding window and the trust discount weight includes: Search for the maximum and minimum values of the data within the current sliding window, and subtract them to obtain the local range; Determine whether the local range is greater than the preset lower limit of the effective flutter amplitude; If the local range is not greater than the lower limit of the effective flutter amplitude, then the dynamic downward bias is forcibly set to zero.
7. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 6, characterized in that, The calculation of the dynamic downward bias also includes: If the local range is greater than the lower limit of the effective flutter amplitude, then count the total number of flip points of the effective flip points marked in the current sliding window; The local range, the total number of flip points, and the confidence discount weight are multiplied sequentially, and the intermediate product results are stored using an extended bit-width variable. A fixed-point shift scaling operation is performed on the intermediate product result to generate the final dynamic downward bias.
8. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 1, characterized in that, The step of reconstructing the real-time reference release threshold using the dynamic downward bias and generating an anti-jitter release threshold after combining it with clamping constraints includes: The initial anti-shake threshold is obtained by subtracting the current dynamic downward bias from the real-time reference release threshold. The initial anti-shake threshold is compared with the preset physical output lower limit. The larger of the two values is extracted to generate the anti-shake release threshold for the current judgment period, in order to prevent the threshold from being physically broken down.
9. The method for detecting magnetic targets using a low-temperature proximity switch based on the Hall effect according to claim 1, characterized in that, The step of attenuating and discharging the dynamically decreasing bias amount according to a preset clock cycle to achieve threshold reset includes: During each clock interrupt cycle, the decay step size is forcibly subtracted from the current dynamic probing bias amount. If the bias result after subtracting the attenuation step size is less than zero, the dynamic downward bias amount is forcibly reduced to zero, so that the anti-shake release threshold slowly rebounds to be equal to the real-time reference release threshold.
Citation Information
Patent Citations
Intelligent proximity switch and control method thereof
CN120415407A
Distribution box fault monitoring method
CN121231948A
