A signal detection method and system for a magnetic receiving device
By employing a multi-channel signal acquisition and dual-algorithm parallel detection framework, combined with a dynamic adaptive switching mechanism, the anti-interference and multi-axis adaptability issues in magnetic remote control signal detection are resolved, achieving optimal detection performance and high reliability under different signal-to-noise ratio scenarios.
Patent Information
- Application Number
- CN202610819044.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-25
AI Technical Summary
Existing magnetic remote control signal detection technology has shortcomings in terms of anti-interference capability, detection sensitivity, multi-axis adaptability, and algorithm adaptive switching, and cannot achieve optimal performance in different signal-to-noise ratio scenarios.
A multi-channel magnetic signal acquisition, signal preprocessing, dual-algorithm parallel detection framework and dynamic adaptive switching mechanism are adopted, combined with multi-axis dynamic selection and high-reliability confirmation mechanism, to realize the closed-loop processing of the entire signal detection process.
It achieves optimal detection performance across the entire signal-to-noise ratio range, improving the reliability and applicability of detection, adapting to different signal strengths and environments, and possessing high sensitivity and fast response capabilities.
Smart Images

Figure CN122632151A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of signal detection technology, and in particular to a signal detection method and system for a magnetic receiving device. Background Technology
[0002] Magnetic remote control technology is a method of achieving remote, non-contact control and communication using magnetic field signals of specific frequencies. It is widely used in underwater equipment control, geological exploration, resource detection, and other applications requiring high electromagnetic wave penetration. The core challenge in magnetic remote control receivers is accurately identifying weak, specific-frequency magnetic field signals from complex geomagnetic background noise and converting them into reliable control commands.
[0003] Existing magnetic remote control signal detection technology has the following main shortcomings: (1) Time-domain zero-crossing detection method: This method calculates the frequency by statistically analyzing the interval between zero-crossing points of the signal, which has the advantages of low computational load and high real-time performance. However, this method is prone to misjudgment when the noise is strong or the signal amplitude is close to the threshold; when the frequency of the interference signal is close to the target signal, the zero-crossing points will be counted repeatedly, resulting in complete distortion of the frequency calculation. In addition, this method is extremely sensitive to the DC offset and low-frequency drift of the signal. Even a small DC offset can cause the zero-crossing point to shift, resulting in system misjudgment and missed detection.
[0004] (2) Frequency Domain Goertzel Algorithm: The Goertzel algorithm is an efficient implementation method of Discrete Fourier Transform (DFT) for specific frequencies. It can calculate the energy of a single frequency point through second-order recursion, which is suitable for embedded platform scenarios with limited resources. However, the traditional Goertzel algorithm usually only compares the energy ratio of the target frequency point to a single reference frequency point. When there is a rich frequency domain interference structure, it is easy to miss the interference components near the target frequency point, leading to misjudgment. At the same time, the setting of a single threshold is difficult to take into account the detection sensitivity under different signal strengths. A fixed threshold is prone to false triggering under strong signals and slow response under weak signals.
[0005] (3) Fixed single-axis detection: Existing solutions usually only perform fixed detection on a single amplified channel. When the target magnetic field signal is close to a certain axis of the sensor, the signal of that channel is strong and the detection is sensitive; however, if a multi-axis sensor is used, the signals of different channels may have opposite phases and energy dispersion, resulting in the effective signal being completely dispersed into multiple channels. Fixed single-axis detection causes serious waste of signal energy and a significant decrease in detection sensitivity.
[0006] (4) Lack of adaptive switching mechanism: Existing solutions usually only use a single algorithm, which cannot achieve real-time adaptive dynamic switching. In high signal-to-noise ratio scenarios, the zero-crossing detection algorithm is fast but wastes valuable computing resources; in low signal-to-noise ratio scenarios, the simple time-domain algorithm cannot meet the accuracy requirements. The one-size-fits-all strategy of using a single algorithm makes it impossible for the system to achieve optimal performance under different operating conditions.
[0007] In summary, existing magnetic remote control signal detection technologies have significant shortcomings in terms of anti-interference capability, detection sensitivity, multi-axis adaptability, and algorithm adaptive switching. There is an urgent need for a highly reliable magnetic remote control signal detection method that can balance fast signal response and accurate frequency resolution, and possess multi-axis adaptive selection and dynamic algorithm switching capabilities.
[0008] Therefore, how to provide a signal detection method and system for magnetic receiving devices is an urgent problem to be solved. Summary of the Invention
[0009] This invention provides a signal detection method and system for a magnetic receiving device to solve the aforementioned technical problems in the prior art.
[0010] According to a first aspect of the present invention, a signal detection method for a magnetic receiving device is provided.
[0011] In one embodiment, the signal detection method for the magnetic receiving device includes: Acquire multi-channel magnetic signal acquisition data from the magnetic sensor, and perform signal preprocessing on the multi-channel magnetic signal acquisition data to obtain the effective AC component of the target magnetic signal frequency band; The effective AC component of each channel is evaluated in real time to assess the magnetic signal energy level, and multi-axis dynamic selection is performed based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel. Based on a dual-algorithm parallel detection framework and combined with a dynamic adaptive switching mechanism, the target magnetic signal of the current optimal detection channel is detected to obtain the target frequency detection result. According to the control command detection time window, the effective frequencies in the target frequency detection results are counted and statistically analyzed, and the statistical results are compared with the preset counting threshold. Based on the statistical comparison results, the effective control command is identified in the target frequency detection results to obtain the effective frequency identification results. By using a protocol decoding state machine, combined with timeout protection and state reset, the effective frequency identification result is mapped to a communication protocol symbol. The communication protocol symbol is then parsed into the corresponding control command, and the control command is sent through the communication interface, completing the entire closed-loop process from signal detection to command output.
[0012] According to a second aspect of the present invention, a signal detection system for a magnetic receiving device is provided.
[0013] In one embodiment, the signal detection system for the magnetic receiving device includes: The signal preprocessing module is used to acquire multi-channel magnetic signal acquisition data from the magnetic sensor and perform signal preprocessing on the multi-channel magnetic signal acquisition data to obtain the effective AC component of the target magnetic signal frequency band. The multi-axis dynamic selection module is used to evaluate the magnetic signal energy level of the effective AC component of each channel in real time, and to perform multi-axis dynamic selection based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel. The signal detection module is used to detect the target magnetic signal of the current optimal detection channel based on a dual-algorithm parallel detection framework and combined with a dynamic adaptive switching mechanism, so as to obtain the detection result of the target frequency. The effective frequency identification module is used to count and statistically analyze the effective frequencies in the detection results of the target frequency according to the control command detection time window, compare the statistical results with the preset counting threshold, and identify the effective control command in the detection results of the target frequency based on the statistical comparison results to obtain the effective frequency identification result. The control command output module is used to map the effective frequency identification result into communication protocol symbols by decoding the state machine through the protocol, and combining timeout protection and state reset. It then parses the communication protocol symbols into corresponding control commands and sends the control commands through the communication interface, thus completing the closed-loop processing from signal detection to command output.
[0014] According to a third aspect of the present invention, a computer device is provided.
[0015] In some embodiments, the computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the signal detection method for the magnetic receiving device described above.
[0016] According to a fourth aspect of the present invention, a computer-readable storage medium is provided.
[0017] In one embodiment, a computer program is stored on a computer-readable storage medium, which, when executed by a processor, implements the steps of the signal detection method for a magnetic receiving device described above.
[0018] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects: 1. This invention achieves dynamic adaptive switching between zero-crossing detection and Goertzel frequency domain detection through global adaptive dual-algorithm fusion, namely, through real-time signal energy assessment. This enables the system to have fast response capability under strong signals and accurate frequency resolution capability under weak signals, overcoming the inherent defects of a single algorithm and achieving optimal detection performance across the entire signal-to-noise ratio range.
[0019] 2. This invention utilizes an enhanced Goertzel frequency domain peak-neighbor comparison algorithm, which sets up multiple sentinel frequencies near the target frequency for parallel energy calculation. By comparing the significance of the peak and neighboring frequencies, it achieves robust target frequency identification. Combined with an adaptive energy threshold, it effectively suppresses false alarms caused by adjacent channel interference, broadband noise, and spectral leakage, significantly improving detection reliability.
[0020] 3. This invention achieves excellent directional adaptability through a multi-axis dynamic selection mechanism that automatically selects the channel with the strongest signal for detection and prevents channel jitter through hysteresis ratio; it automatically switches to a fixed-duration polling mode when the signal energy is low, ensuring effective detection in any orientation, and completely solving the directional blind zone problem of fixed single-axis detection in multi-axis sensors.
[0021] 4. This invention features low power consumption and resource friendliness through embedded systems. The detection algorithm is optimized for embedded platforms. The Goertzel algorithm only needs to maintain two state variables and one multiplication coefficient per frequency point, and the second-order IIR filter only needs four state variables. The overall algorithm module has low computational load and small memory footprint, and can run in real time on resource-constrained embedded microcontrollers, with good platform portability.
[0022] 5. This invention employs a highly reliable multi-level confirmation mechanism. The system utilizes multiple reliability measures, including signal validity threshold, hysteresis zero-crossing determination, anti-bouncing protection, periodic stability verification, time window counting confirmation, and state machine timeout protection, to construct a full-link reliability assurance system from signal input to command output. Any accidental abnormality in any link will not directly lead to erroneous output, and the overall system reliability meets the requirements of industrial control level.
[0023] 6. This invention features flexible parameter adjustability, meaning that key parameters of the algorithm in the system, such as the effective RMS threshold, algorithm switching energy threshold, period variation tolerance, hysteresis switching ratio, detection window duration, counting threshold, and timeout time, can all be dynamically modified online through the communication interface. This allows the system to adapt to different application environments and signal characteristics without recompiling the program, greatly improving the applicability and maintenance convenience of the system.
[0024] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0025] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0026] Figure 1 This is a schematic flowchart illustrating a signal detection method for a magnetic receiving device according to an exemplary embodiment; Figure 2 This is a schematic diagram illustrating the structure of a signal detection system for a magnetic receiving device according to an exemplary embodiment; Figure 3 This is a schematic diagram of the structure of a computer device according to an exemplary embodiment; Figure 4 This is a system architecture diagram illustrating an exemplary embodiment; Figure 5 This is a diagram illustrating a dual-algorithm parallel detection framework according to an exemplary embodiment; Figure 6 This is a flowchart illustrating the Goertzel enhancement algorithm according to an exemplary embodiment; Figure 7 This is a multi-axis dynamic selection state diagram illustrated according to an exemplary embodiment; Figure 8 This is a timing diagram illustrating a fixed-frequency window counting confirmation according to an exemplary embodiment; Figure 9 This is a state transition diagram of a protocol decoding state machine according to an exemplary embodiment.
[0027] Figure label: 201. Signal preprocessing module; 202. Multi-axis dynamic selection module; 203. Signal detection module; 204. Effective frequency identification module; 205. Control command output module. Detailed Implementation
[0028] The following description and accompanying drawings fully illustrate specific embodiments described herein to enable those skilled in the art to practice them. Some portions and features of certain embodiments may be included in or replace portions and features of other embodiments. The scope of the embodiments herein includes the entire scope of the claims and all available equivalents thereof. The various embodiments described herein are presented in a progressive manner, with each embodiment focusing on its differences from other embodiments; similar or identical parts between embodiments can be referred to interchangeably.
[0029] The modules in the apparatus or system of this application can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0030] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0031] Figure 1 An embodiment of a signal detection method for a magnetic receiving device according to the present invention is shown.
[0032] In this optional embodiment, the signal detection method for the magnetic receiving device includes: Step S101: Acquire multi-channel magnetic signal acquisition data from the magnetic sensor (i.e., the raw signal acquired by the magnetic sensor), and perform signal preprocessing on the multi-channel magnetic signal acquisition data to obtain the effective AC component of the target magnetic signal frequency band.
[0033] In this optional embodiment, multi-channel magnetic signal acquisition data from a magnetic sensor is obtained, and signal preprocessing is performed on the multi-channel magnetic signal acquisition data to obtain the effective AC component of the target magnetic signal frequency band, including: The sampling rate is set according to the target magnetic signal frequency band, and the magnetic sensor channels are synchronously sampled based on the sampling rate to obtain multi-channel signal acquisition data; Based on the preset static acquisition time, static magnetic field data is acquired in the initial stage after the magnetic sensor is powered on. The average value of each channel of the magnetic sensor is calculated based on the static magnetic field data and used as the initial DC background estimate. Based on the initial DC background estimate, DC removal is performed on the multi-channel signal acquisition data to obtain the DC-removed multi-channel magnetic signal. The cutoff frequency of the filter is set according to the lowest effective frequency of the target magnetic signal band, and a second-order infinite impulse response high-pass filter is used to filter out geomagnetic drift and temperature drift interference from the multi-channel magnetic signal after DC removal, so as to obtain the effective AC component of the target frequency band.
[0034] It should be noted that signal preprocessing includes DC removal and low-frequency filtering; the raw signal acquired by the magnetic sensor contains the DC component of the geomagnetic background field, low-frequency variations caused by temperature drift, and the AC component of the target remote control magnetic field signal. Directly performing frequency detection on the raw signal would introduce a significant DC offset error, therefore preprocessing is necessary.
[0035] The preprocessing process of this invention is divided into two stages: (1) DC background initialization estimation. After the system is powered on, static magnetic field data of sufficient duration is collected in the initial stage, and the average value of each channel is calculated as the initial DC background estimate. This process is only performed once in the initialization stage and will not be repeated in the real-time processing stage to avoid delays in response to sudden signal changes. In one specific embodiment, the static acquisition duration is set to 2 seconds.
[0036] (2) Real-time Second-Order IIR High-Pass Filter. A second-order infinite impulse response high-pass filter is used to process the sampled data in real time, removing DC bias and low-frequency drift. The filter design is based on the Butterworth prototype, and bilinear transform pre-distortion correction is used to ensure that the filtering characteristics meet the design requirements. The filter cutoff frequency is set according to the lowest effective frequency of the target magnetic signal, usually set to a suitable frequency below the lower limit of the target frequency band, effectively filtering out low-frequency geomagnetic drift and temperature drift interference while retaining the energy of the target signal. This second-order IIR structure only needs to maintain four state variables, has a small memory footprint, and is suitable for real-time operation on embedded platforms.
[0037] In one specific embodiment, the target magnetic signal frequency band is 6~10Hz, the filter cutoff frequency is set to 3Hz, the quality factor Q is about 0.707, and the difference equation is in the form of: y[n]=b0·x[n]+b1·x[n-1]+b2·x[n-2]–a1·y[n-1]–a2·y[n-2]. In one specific embodiment, the complete data processing flow of this step is as follows: The system selects the filter type according to the configuration, namely high-pass or low-pass, and calculates the corresponding second-order IIR filter coefficients b0, b1, b2, a1, a2; then, the original signal x[n] at the current sampling time, the input x[n-1] at the previous time, the input x[n-2] at the second time before, the output y[n-1] at the previous time, and the output y[n-2] at the second time before are substituted into the difference equation: y[n]=b0·x[n]+b1·x[n-1]+b2·x[n-2]-a1·y[n-1]-a2·y[n-2], to calculate the current output y[n]; update the state variables: x[n-2]←x[n-1], x[n-1]←x[n], y[n-2]←y[n-1], y[n-1]←y[n], to prepare for the calculation at the next sampling time. The above process is executed cyclically in each sampling period to achieve real-time DC removal or low-pass filtering of the original signal.
[0038] The meanings of the letters in the above difference equation are as follows: y[n] represents the output sample value of the filter at the current time, i.e., the nth sampling point; n represents the current sampling sequence number, which is a positive integer; b0, b1, and b2 represent the coefficients of the filter feedforward path, i.e., the coefficients of the numerator, used to weight the current and historical input signals; x[n] represents the input sample value of the filter at the current time, i.e., the digital quantity of the original signal after analog-to-digital conversion; a1 and a2 represent the coefficients of the filter feedback path, i.e., the coefficients of the denominator, used to weight the historical output signals. Among them, the coefficients b0, b1, b2, a1, and a2 are pre-calculated and stored by the bilinear transform method according to the target cutoff frequency, sampling rate, and quality factor Q during system initialization. For example, when the filter cutoff frequency is set to fc and the sampling frequency is set to fs, the intermediate variable can be calculated first: K=tan(π For a second-order Butterworth filter with a quality factor Q ≈ 0.707, the normalized coefficient can be expressed as: norm = 1 / (1 + K / Q + K) 2 The formula for calculating the coefficients of the corresponding low-pass filter is: b0 = K 2 norm, b1=2K 2 norm, b2=K 2 norm, a1=2(K 2 -1) norm, a2=(1−K / Q+K) 2 ) norm.
[0039] Step S102: The magnetic signal energy level of the effective AC component of each channel is evaluated in real time, and multi-axis dynamic selection is performed based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel.
[0040] In this optional embodiment, the magnetic signal energy level of the effective AC component of each channel is evaluated in real time, and multi-axis dynamic selection is performed based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel, including: The accumulation window length is determined based on the response speed and stability requirements of the strongest axis switching, and the energy accumulation window is set based on the accumulation window length. Within the energy accumulation window, the square values of the effective AC components of each channel are accumulated to obtain the energy accumulation value of each channel. After the window period of the energy accumulation window expires, the root mean square of the energy of each channel is calculated based on the energy accumulation value of each channel to obtain the magnetic signal energy level of each channel. If the magnetic signal energy levels of all channels are lower than the preset low energy threshold, the current detection mode will be switched to a fixed-duration channel polling mode, and the target magnetic signal of the current optimal detection channel will be obtained. If the maximum magnetic signal energy level in all channels is greater than or equal to the preset low energy threshold, the current detection mode is switched to the strongest axis selection mode. If the maximum magnetic signal energy level is greater than the product of the magnetic signal energy level of the current detection channel and the preset hysteresis ratio, the current detection channel is switched and the target magnetic signal of the current optimal detection channel is determined.
[0041] It should be added that, such as Figure 7 As shown, this illustrates the state transition relationships between the strongest axis selection, hysteresis switching judgment, and low-energy polling mode. Figure 7 In this model, `axis_energy_acc[i]` is the energy accumulator for the i-th axis; `ch_val[i]` is the sampled value of the i-th channel; `rms[i]` is the root mean square value of the i-th channel; `acc[i]` is the accumulated value of the i-th channel; `best` is the optimal channel energy value; `cur` is the current channel energy value; `r_rms_low` is the low energy threshold; `ch0`, `ch1`, and `chN-1` are channel 0, channel 1, and channel N-1, respectively; `axis_switch_ratio` is the axis switching hysteresis ratio; `axis_poll_duration_s` is the axis polling duration in seconds; and `AXIS_SEL_WIN_SIZE` is the axis selection window size. This step includes multi-axis dynamic selection and a low-energy polling mechanism. In practical applications, magnetic sensors typically contain multiple sensitive axes, such as dual-axis or tri-axis sensors. The target magnetic field signal will exhibit different coupling strengths on each axis under different orientations. Using a fixed channel for detection may lead to a significant drop in signal energy or even complete loss when the sensor's attitude changes. This invention proposes a multi-axis dynamic selection mechanism to achieve real-time evaluation of the signal energy of each channel and automatic selection of the optimal channel.
[0042] The system maintains an energy accumulation window, accumulating the squared values of the signals from each channel. After the window expires, the root mean square value of the energy for each channel is calculated, and the channel with the strongest energy is selected as the current detection channel. To avoid frequent jittering switching when channels have similar energies, a hysteresis switching mechanism is introduced: channel switching is only performed when the energy of the new optimal channel exceeds a certain proportion of the energy of the current channel; this certain proportion is the hysteresis ratio.
[0043] The energy accumulation window length AXIS_SEL_WIN_SIZE is determined based on the response speed and stability requirements of the strongest axis switching, and is set to 0.5 times the sampling rate, i.e., a window duration of 0.5 seconds, which corresponds to approximately 159 sampling points at a sampling rate of 317.5Hz. The setting rule is: if rapid tracking of magnetic field direction changes is required, the window duration can be shortened to 0.2~0.3 seconds; if reducing channel switching errors caused by instantaneous fluctuations is required, the window duration can be extended to 1.0~1.5 seconds. In a specific embodiment, an energy assessment window duration of 0.5 seconds achieves a good balance between fast response and stability. The selectable setting range is 0.2 seconds to 1.5 seconds, which can be adjusted by the user according to the rate of change of the target magnetic field.
[0044] In addition, when the signal energy of all channels is lower than the preset low energy threshold, the system determines that the current target signal may be extremely weak or the sensor orientation may be poor. At this time, it automatically exits the strongest axis selection mode and switches to the fixed-duration channel polling mode, that is, it uses each channel in turn for detection at fixed time intervals. This ensures that even if the target magnetic field direction is seriously mismatched with the current optimal channel, there is still a chance to capture an effective signal on other channels, which significantly improves the system's orientation adaptability and detection coverage.
[0045] The preset low-energy threshold g_rms_low_energy is defined as the upper limit of RMS energy for triggering the channel polling mode, and is set to 1.0 by default. The setting rule is: when the RMS energy of all channels is below this threshold, the system considers the target signal extremely weak or the sensor orientation severely mismatched. In this case, the detection efficiency of fixing on a single optimal channel is low, so the polling mode is switched to expand the detection coverage. This threshold is typically set to 2 to 5 times the noise baseline RMS_noise, or 10 to 20 times the effective RMS threshold g_rms_threshold. In a specific embodiment, g_rms_low_energy = 1.0, corresponding to a typical noise baseline of approximately 0.3 to 0.5. The selectable value range is 0.5 to 3.0, which can be adjusted by the user according to the actual environmental noise level and signal weakness.
[0046] The duration \(g\_axis\_poll\_duration\_s\) of each channel in the polling mode is determined according to the duration of the target signal, the system response requirement, and the number of channels, and the default setting is 5.0 seconds. The setting rule is as follows: if the duration of the target signal is short, such as a quickly passing magnetic field source, the duration of a single channel should be shortened to 2 - 3 seconds to avoid missing the signal; if the duration of the target signal is long or the environment changes slowly, the duration of a single channel can be extended to 8 - 10 seconds to reduce unnecessary channel switching overhead. In a specific embodiment, the duration of each channel in the polling mode is 5 seconds. In a dual-channel or triple-channel configuration, the detection coverage time for a complete round is 10 seconds or 15 seconds, which can maintain a reasonable detection update frequency while ensuring coverage. The optional value range is 2 - 10 seconds.
[0047] When the signal energy recovers above the low energy threshold, the system automatically exits the polling mode and re-enters the strongest axis selection mode. In a specific embodiment, the duration of the energy evaluation window is 0.5 seconds, the hysteresis ratio is set to 1.2, the low energy threshold is calibrated according to the actual ambient noise level, and the duration of each channel in the polling mode is 5 seconds.
[0048] In a specific embodiment, the complete process of this step of data processing is as follows: the system takes 0.5 seconds as the evaluation window and continuously accumulates the squared values of the signal sampling values of each channel; when the window expires, it calculates the root mean square value of the energy of each channel ; find the channel with the largest RMS value as the candidate optimal channel \(best\_axis\); if the candidate channel is different from the current channel, and the RMS value of the candidate channel exceeds the hysteresis ratio times (default 1.2 times) the RMS value of the current channel, then perform a channel switch: \(zc\_axis\_sel = best\_axis\); otherwise, keep the current channel unchanged. At the same time, the system compares the calculated current strongest axis RMS value \(s\_last\_rms\) with the low energy threshold \(g\_rms\_low\_energy\), default 1.0: if \(s\_last\_rms < g\_rms\_low\_energy\) and \(s\_last\_rms > 0\), then enter the low energy polling mode, and alternately switch each channel at intervals of \(g\_axis\_poll\_duration\_s = 5\) seconds in turn; if \(s\_last\_rms\) recovers above \(g\_rms\_low\_energy\), then exit the polling mode and re-enter the strongest axis selection mode. After each window switch or mode switch, the accumulator \(acc[i]\) and counter of each channel are cleared, and the energy evaluation of the next window starts again.
[0049] Step S103, based on the dual-algorithm parallel detection framework and combined with the dynamic adaptive switching mechanism, perform signal detection on the target magnetic signal of the current optimal detection channel to obtain the detection result of the target frequency.
[0050] In this optional embodiment, based on a dual-algorithm parallel detection framework and combined with a dynamic adaptive switching mechanism, the target magnetic signal of the current optimal detection channel is detected to obtain the target frequency detection result, including: The magnetic signal energy level corresponding to the target magnetic signal of the current optimal detection channel is obtained and compared with the preset effective signal threshold to obtain the effective target signal determination result. Based on the effective target signal determination result, the magnetic signal energy level corresponding to the target magnetic signal of the current optimal detection channel will be obtained and compared with the preset energy threshold to obtain the energy threshold comparison result; If the energy threshold comparison result is greater than or equal to the preset energy threshold, the algorithm will adaptively switch to the zero-crossing detection algorithm in the dual-algorithm parallel detection framework. The zero-crossing detection algorithm will be used to detect the target magnetic signal of the current optimal detection channel to obtain the target frequency detection result.
[0051] In this optional embodiment, the target magnetic signal of the current optimal detection channel is detected using a zero-crossing detection algorithm, and the detection result of the target frequency is obtained as follows: Based on the preset effective signal threshold, positive and negative thresholds are set, and hysteresis zero-crossing is determined based on the positive and negative thresholds to obtain effective zero-crossing events. The time interval between two consecutive valid zero-crossing events is compared with a preset ratio of the shortest valid period of the target signal to obtain the high-frequency noise bounce determination result. Based on the high-frequency noise bounce determination result, the period is calculated to obtain the valid period. The rate of change of continuously detected effective cycles is evaluated to obtain the rate of change of adjacent effective cycles, and the stability of effective cycles is screened by combining the preset tolerance threshold to obtain stable cycles. Once the number of consecutive stable cycles reaches the preset number of stable cycles, the consecutive stable cycles are frequency-converted to obtain the detection result of the target frequency.
[0052] If the energy threshold comparison result is less than the preset energy threshold, the algorithm will adaptively switch to the frequency domain detection algorithm in the dual-algorithm parallel detection framework. The frequency domain detection algorithm will be used to detect the target magnetic signal of the current optimal detection channel to obtain the target frequency detection result.
[0053] In this optional embodiment, the rule for setting the energy threshold is as follows: In a pure background noise environment without target magnetic signals, a segment of noise data was collected, and the root mean square value of the noise data was calculated as the noise baseline. Reference data is acquired when the target magnetic signal is known to exist, and the root mean square value of the reference data is calculated as the signal reference value. Set a transition value between the noise baseline and the signal reference value, and use the transition value as the energy threshold.
[0054] In this optional embodiment, the target magnetic signal of the current optimal detection channel is detected using a frequency domain detection algorithm, and the detection result of the target frequency is obtained as follows: Based on the target magnetic signal and target frequency band of the current optimal detection channel, select the target frequency point and adjacent sentinel frequency points, and calculate the recursive coefficients of the target frequency point and adjacent sentinel frequency points based on the sampling rate and the length of the frequency domain detection block; By using a window function, each sample value of the target magnetic signal in the current optimal detection channel is windowed to obtain the windowed value; According to the preset data window length, the two parallel recursive state machines of the frequency domain detection algorithm are started with a recursive delay. After the recursive delay starts, the window value and recursive coefficient are input into the two parallel recursive state machines for sample-by-sample windowing recursion to obtain the recursive result. The energy value of each frequency point is calculated based on the recursive result and the coherent gain compensation of the window function. Based on the energy value of each frequency point, the target magnetic signal of the current optimal detection channel is screened based on anomaly judgment to obtain the effective signal. The frequency of the frequency point corresponding to the effective signal is identified to obtain the detection result of the target frequency.
[0055] In this optional embodiment, the target magnetic signal of the current optimal detection channel is filtered based on anomaly determination according to the energy value of each frequency point to obtain effective signals, including: Based on the energy values at each frequency point, determine the peak value, the second largest value, and the peak frequency index; and calculate the peak ratio based on the peak value and the second largest value. The peak ratio is compared with a preset peak ratio threshold to obtain the peak ratio comparison result, and the peak frequency index is compared with a preset target frequency index to obtain the consistency comparison result. If the peak ratio comparison result is greater than or equal to the preset peak ratio threshold, and the consistency comparison result is that the frequency index is consistent, then the target magnetic signal of the current optimal detection channel is determined to be a valid signal.
[0056] It should be added that, such as Figure 5 As shown, starting from RMS energy detection, the algorithm automatically switches branches to demonstrate the internal processing flow of the zero-crossing detection system and the Goertzel detection system, as well as the unified callback entry point for the detection results. Figure 5`get_detect_input_sample()` is the function to obtain the detection input sample value; `raw` is the original sample value; `sqrt` is the square root; `sum` is the summation; `x` is the input signal sample value; `N` is the number of sampling points; `g_rms_auto_switch` is the RMS automatic switching threshold; `ZC` mode is the zero-crossing detection mode; `GZ` mode is the Goertzel frequency domain detection mode; `g_rms_threshold` is the RMS valid threshold; `hyst` is the hysteresis; `interval` is the time interval; `change` is the period change rate; `f=1000 / T` represents the conversion between frequency and period; `freq` is the specific frequency detected; `WAVE_A / B / C` is the waveform type A / B / C; `on_valid_period()` is the valid period callback function; `source` is the signal source identifier; `fixed_freq_on_detect()` is the fixed frequency detection trigger function; `rs485_send_cmd()` is the RS485 command sending function. The dual-algorithm parallel detection framework includes zero-crossing detection (ZC) and Goertzel frequency domain detection (GZ). This step includes the parallel operation and adaptive switching mechanism of the zero-crossing detection (ZC) subsystem and the Goertzel frequency domain detection (GZ) subsystem.
[0057] RMS Energy Detection and Automatic Algorithm Switching: The system maintains a sliding window to calculate the energy level of the input signal in real time. The strength of the current signal is evaluated through root mean square (RMS) calculation. The RMS value also serves as a criterion for judging the validity of the target signal. That is, when the RMS value exceeds the preset valid signal threshold, it is determined that there is a valid target signal, and the algorithm enters the detection state; otherwise, it is considered that the current signal is only background noise, and frequency detection is not performed to reduce the probability of false triggering and system power consumption.
[0058] The specific steps for evaluating the current signal strength using the root mean square (RMS) operation are as follows: The system maintains a sliding window of length N. At each sampling time, the squared sample value x[n] of the current DC-de-DC signal is accumulated, i.e., the accumulator acc = acc + x[n]², while the sampling counter cnt is incremented. When cnt reaches the window length N, the root mean square value of the signal within the window is calculated. After the calculation is completed, the accumulator acc and the counter cnt are cleared to zero, and the accumulation of the next window begins. In the formula, acc represents the sum of the squares of the signal sample values within the window, N represents the number of sampling points contained in the sliding window, i.e., the sampling rate, corresponding to a duration of 1 second, x[n] represents the signal amplitude of the nth sampling point, and RMS represents the root mean square value of the signal within the window, reflecting the energy level of the signal.
[0059] Based on RMS energy assessment, the system dynamically and automatically switches between two detection algorithms: when the signal energy is strong, the zero-crossing detection algorithm can quickly and accurately extract frequency information; when the signal energy is weak, it switches to the Goertzel frequency domain detection algorithm to obtain higher frequency resolution and noise immunity. The switching process is determined by an energy threshold, and an appropriate state-preserving mechanism is set to avoid frequent algorithm jitter near the signal energy boundary.
[0060] In one specific embodiment, the RMS calculation window duration is set to 1 second, the switching threshold is calibrated according to the actual signal strength and noise level, zero-crossing detection is used for high energy state, and Goertzel detection is used for low energy state.
[0061] The energy threshold `g_rms_auto_switch` is calibrated based on the comparison between signal strength and noise level in the actual environment. Specifically, data is collected in a pure background noise environment without a target signal, and its RMS value is calculated as the noise baseline `RMS_noise`. Then, data is collected under conditions where a target signal is known to be present, and its RMS value is calculated as the signal reference value `RMS_signal`. The switching threshold is set as the transition value between the noise baseline and the signal reference value, specifically 3 to 10 times the noise baseline, or an empirical value of (RMS_noise + RMS_signal) / 2. In a specific embodiment, `g_rms_auto_switch` is set to 5.0 by default. In a typical geomagnetic background noise environment, an RMS_noise of approximately 0.3 to 0.5 can reliably distinguish noise from a valid signal, and an RMS_signal is typically greater than 10.0. Users can also dynamically adjust this threshold online via serial port commands according to the actual application scenario.
[0062] In one specific embodiment, the complete data processing flow of this step is as follows: The system continuously acquires signals at a sampling rate of 317Hz and maintains an RMS sliding calculation window with a duration of 1 second, i.e., a window length of N=317 sampling points; in each sampling interruption, the current sampled value x[n] is squared and accumulated into acc, while the cnt counter is incremented; when cnt reaches 317, the calculation is performed. The signal energy level within the current 1-second window is obtained; acc and cnt are cleared to zero, and the accumulation of the next 1-second window begins; the calculated RMS value is compared with the preset energy threshold g_rms_auto_switch. If the RMS is greater than or equal to the threshold, it is determined to be a high-energy state; otherwise, it is a low-energy state, and then it is determined whether to use the zero-crossing detection algorithm or the Goertzel frequency domain detection algorithm for subsequent processing.
[0063] The zero-crossing detection subsystem operates in scenarios with strong signal energy and has advantages such as fast response speed, low computational overhead, and ease of implementation. Its detection process includes the following key steps: (1) Signal validity threshold: The real-time calculated RMS value is compared with the preset valid signal threshold. Zero-crossing detection is only performed when the signal energy exceeds the threshold, thus avoiding invalid frequency calculation for noise signals.
[0064] (2) Hysteresis zero-crossing determination: In order to avoid false zero-crossing counts caused by small noise jitter near the zero point, this invention introduces a hysteresis comparison mechanism. Two thresholds are set, positive and negative. The signal must cross from below the negative threshold to above the positive threshold to be determined as a valid zero-crossing, effectively filtering out small-amplitude noise interference.
[0065] The positive threshold V_th+ and negative threshold V_th- are dynamically determined based on the current signal energy level, specifically: V_th+ = g_rms_threshold × 0.5, V_th- = -g_rms_threshold × 0.5. Here, g_rms_threshold is the system-preset effective signal threshold, defaulting to 0.05. Therefore, the positive threshold defaults to approximately 0.025, and the negative threshold defaults to approximately -0.025, in units of signal amplitude. In practical applications, the value range of g_rms_threshold is typically 0.01~0.3, corresponding to a positive threshold range of 0.005~0.15 and a negative threshold range of -0.15~-0.005. A signal must cross from a state below the negative threshold to a state above the positive threshold to be recorded as a valid zero-crossing event, thus effectively filtering out spurious jitter caused by minute noise near the zero point.
[0066] (3) Anti-bouncing time protection: After a zero-crossing event is detected, if the time interval between two adjacent zero-crossing events is less than a certain proportion of the shortest effective period of the target signal, such as 80%, it is determined to be high-frequency noise bounce, which is ignored and the period is not calculated.
[0067] (4) Periodic stability verification: The rate of change of continuously detected effective periods is evaluated. The current period is considered stable and reliable only when the rate of change of adjacent periods is lower than the preset tolerance threshold. After reaching the preset number of stable periods, the period is converted into frequency and submitted to the upper layer for processing. This stability verification mechanism effectively eliminates erroneous frequency output caused by single accidental fluctuations and interference.
[0068] The specific calculation steps for the rate of change between adjacent periods are as follows: Let the currently detected effective period be T_new (in milliseconds), and the previously detected effective period be T_last (in milliseconds). Then, the rate of change between adjacent periods is defined as: change = |T_new - T_last| / T_last. In this formula, T_new represents the signal period obtained from the current zero-crossing detection, T_last represents the signal period obtained from the previous stable detection, and change represents the relative rate of change between two adjacent periods, which is a dimensionless quantity, usually expressed as a percentage. Each time the system detects a new effective period, it calculates this rate of change and compares it with a preset tolerance threshold. Only when change is less than the tolerance threshold is the current period considered stable and reliable.
[0069] The preset tolerance threshold `g_period_change_max` is defined as the maximum allowable relative rate of change between adjacent periods, with a default setting of 0.2 (20%). This threshold setting needs to comprehensively consider the stability of the target signal and the intensity of interference in the actual environment. Specifically, in scenarios where the target signal frequency is stable and interference is low, the tolerance threshold can be set to a smaller value, such as 0.1, to improve the stringency of detection; in scenarios where the target signal exhibits frequency drift or strong interference, it can be appropriately relaxed to 0.3 to reduce the probability of missed detection. The selectable value range is typically 0.1 to 0.3, and users can dynamically adjust it online via serial port commands according to the actual application scenario.
[0070] The preset stable period count, g_stable_count, is defined as the number of stable periods that the system needs to continuously detect before determining the frequency as valid; the default value is 1. This parameter setting requires a trade-off between detection response speed and anti-interference capability. When g_stable_count is a smaller value, such as 1-2, the system response speed is fast, but occasional interference may cause false triggering. When g_stable_count is a larger value, such as 3-5, the system has strong anti-interference capability, but it introduces a certain detection delay. In a specific embodiment, g_stable_count is set to 1, which, in typical application scenarios, can effectively eliminate accidental fluctuations while ensuring a fast response, combined with the periodic stability verification mechanism. The selectable value range is 1-5, and users can adjust it according to the actual signal quality.
[0071] (5) Frequency mapping: The detected stable frequencies are mapped to symbols in the communication protocol. For example, the frequency band near 6 Hz is mapped to the frame header symbol, the frequency band near 8 Hz is mapped to data bit 0, and the frequency band near 10 Hz is mapped to data bit 1. The boundary range of frequency mapping is set according to the frequency point design of the actual communication protocol.
[0072] The rules for setting the frequency mapping boundary range are as follows: Determine the target center frequency for each symbol according to the communication protocol. For example, a frame header symbol corresponds to 6Hz, data bit 0 corresponds to 8Hz, and data bit 1 corresponds to 10Hz. Then, using the target center frequency as a reference, extend the boundary by an allowable frequency offset range to both sides. The specific extension amount is determined based on the frequency offset characteristics of the target signal and the system detection accuracy, typically taken as the larger of ±5% of the center frequency or a fixed ±0.3Hz. For example, for a 6Hz frame header symbol, the lower boundary is set to 5.7Hz, and the upper boundary is set to 6.3Hz; for an 8Hz data bit 0, the lower boundary is set to 7.7Hz, and the upper boundary is set to 8.3Hz; for a 10Hz data bit 1, the lower boundary is set to 9.7Hz, and the upper boundary is set to 10.3Hz. This boundary range is configured as a constant parameter during system initialization, such as FREQ_A_MIN, FREQ_A_MAX, etc. Detected frequencies are only mapped to the corresponding communication symbols when they fall within the corresponding boundary range.
[0073] like Figure 6 As shown, the key steps include window function windowing, dual-path Hop parallel mechanism, multi-frequency point energy calculation, peak neighbor comparison, and adaptive threshold comparison. Figure 6 In this context, x[n] represents the input signal value at the nth sampling point; Hanning is the Hanning window; w[n] is the window function coefficient; N is the Goertzel block length; G is the coherence gain; Hop is the overlap step size; sample_cnt is the sampling counter; A-channel / B-channel are two-way parallel Goertzel state machines; q0, q1, and q2 are Goertzel recursive state variables; x_win is the sampled value after windowing; coef is the recursive coefficient; power is the energy value; e5, e6, e7, e8, and e9 are the energy values at frequencies of 5Hz, 6Hz, 7Hz, 8Hz, and 9Hz, respectively; peak_val is the peak energy value; second_val is the second largest energy value; peak_ratio is the peak ratio; eth_k1 is the adaptive energy threshold; peak_idx is the peak frequency index; gz_hit_freq is the Goertzel hit frequency; eth is the energy reference threshold; and on_valid_period() is a function that decodes the valid frequency into a protocol and outputs it. The Goertzel frequency domain detection subsystem operates in scenarios with weak signal energy, exhibiting advantages such as good frequency selectivity and strong anti-interference capability. This invention incorporates several enhancements to the traditional Goertzel algorithm, significantly improving detection reliability.
[0074] (1) Parallel detection of multiple frequency points: Unlike traditional schemes that only detect a single target frequency point, this invention simultaneously calculates the energy of the target frequency band and multiple adjacent frequency points. By setting sentinel frequency points on both sides of the target frequency point, when the interference signal is abnormally enhanced near the target frequency point, the system can identify this abnormal distribution and refuse to trigger, effectively avoiding misjudgment caused by adjacent channel interference.
[0075] The specific method of energy calculation for the target frequency band and its multiple neighboring frequency points in this invention is based on the Goertzel algorithm. The Goertzel algorithm is an efficient implementation method of Discrete Fourier Transform (DFT) for a specific frequency point. By recursively calculating the input sequence, it extracts only the energy information of the target frequency point without calculating the complete spectrum. Specifically, for each frequency point fk to be detected, the system pre-calculates its recursive coefficient coeff_k = 2·cos(2π·k / N), where k = round(N·fk / fs), N is the Goertzel block length, equal to the sampling rate, corresponding to 1 second of data, and fs is the sampling rate. For each sampled value x[n], the system performs a recursion: q0 = x_win[n] + coeff_k·q1 - q2, and updates the states q2←q1 and q1←q0. q0 represents the latest recursive result obtained after the current sampled value participates in the calculation; q1 represents the state variable obtained from the previous recursive calculation; q2 represents the state variable obtained from the previous two recursive calculations. When N sampling points are accumulated, the energy value of the frequency point is calculated: E_k = q1² + q2² - coeff_k·q1·q2. This invention simultaneously performs the above Goertzel calculation in parallel for five frequency points: 5Hz, 6Hz, 7Hz, 8Hz, and 9Hz, realizing real-time extraction of energy from multiple frequency points.
[0076] The specific steps for determining abnormal enhancement of interference signals near the target frequency are as follows: After completing parallel energy calculations at multiple frequencies, the system obtains the energy value E_target of the target frequency (e.g., 6Hz or 8Hz) and the energy values E_left and E_right of the sentinel frequencies on both sides (e.g., 5Hz, 7Hz, or 7Hz, 9Hz). First, the ratio or difference between the energy of the target frequency and the energy of the sentinel frequencies on both sides is calculated. If the energy of the target frequency is significantly higher than that of the sentinel frequencies on both sides, for example, if the energy of the target frequency is greater than a preset multiple of the energy of either sentinel frequency, then it is considered that there is a real concentration of signal energy at the target frequency, and it is judged as a normal signal. Conversely, if the energy of the target frequency is close to that of the sentinel frequencies, or if the energy of the sentinel frequencies is even higher than that of the target frequency, it indicates that the interference signal is broadbandly distributed near the target frequency rather than concentrated on a single frequency, and it is judged as abnormal enhancement, and the system refuses to trigger.
[0077] The specific steps for identifying abnormal distributions are as follows: In the multi-frequency energy calculation results, the system first finds the maximum energy value, i.e., the peak value peak_val and its corresponding frequency index peak_idx, and at the same time finds the second largest energy value second_val; calculate the peak ratio: peak_ratio = peak_val / second_val; if second_val is 0, then peak_ratio is set to the maximum value of 999; if peak_ratio exceeds the preset peak ratio threshold (default 1.5), and peak_idx corresponds to the target frequency, for example, 6Hz corresponds to index 1, 8Hz corresponds to index 3, then the energy distribution is considered to have a significant single-peak concentration characteristic centered on the target frequency, and is judged as a valid signal; if peak_ratio does not exceed the threshold, or the peak appears on a sentinel frequency that is not the target frequency, then the energy distribution is considered to be a broadband abnormal distribution, and the system refuses to trigger, effectively suppressing misjudgments caused by adjacent channel interference and broadband noise.
[0078] (2) Windowing Processing: To suppress spectral leakage, the sampled data is windowed before being input into the Goertzel recursion. Hanning, Hamming, Blackman, or Kaiser windows can be used, selected based on the specific application scenario's requirements for spectral leakage suppression and frequency resolution. After windowing, coherence gain compensation is applied to the calculation results to ensure the accuracy of energy estimation.
[0079] The sampled data here refers to the unified data stream after synchronous sampling by the multi-channel signal acquisition module, removal of the DC component, and selection of the detection channel, i.e., the strongest axis or total field. In the Goertzel frequency domain detection subsystem, this data stream is first simultaneously input to multiple parallel Goertzel recursion channels, corresponding to different target frequencies and sentinel frequencies. That is, before windowing processing, the sampled data has already completed the channel allocation for multi-frequency parallel detection. Therefore, windowing processing is a real-time preprocessing of the sampled data during the recursion process of multi-frequency parallel detection. Each frequency's Goertzel recursion unit receives the sampled value after weighting by the same window function, ensuring the consistency of energy estimation at each frequency.
[0080] The specific processing steps of windowing with a window function are as follows: The system uses the Hanning window as the default window function. The formula for calculating the window coefficients is: w[n]=0.5×(1-cos(2π·n / N)), where n is the serial number of the current sampling point within the Goertzel block, 0≤n<N, and N is the length of the Goertzel block; at each sampling moment, multiply the current input sampling value x[n] by the corresponding window coefficient w[n] to obtain the windowed sampling value x_win[n]=x[n]×w[n]; then input x_win[n] into the Goertzel recurrence formula: q0=x_win[n]+coeff·q1-q2 to complete the frequency point energy accumulation at this sampling point; when n increases from 0 to N-1 to complete a full block, calculate the energy values of each frequency point and output the detection result. At the same time, reset the Goertzel state variables, that is, clear q1 and q2, and zero sample_cnt, and start windowing and recurrence for the next data block.
[0081] The rules for selecting a window function according to the requirements of spectrum leakage suppression and frequency resolution in the actual application scenario are as follows: If the application scenario requires strict suppression of spectrum leakage, for example, there is strong adjacent frequency interference, a window function with large sidelobe attenuation should be selected, such as the Blackman window or the Kaiser window, β=6~8, where the sidelobe attenuation of the Blackman window is about -58dB, and the sidelobe attenuation of the Kaiser window can be flexibly adjusted according to the β value; if the application scenario requires high frequency resolution, for example, the target frequency point spacing is small, a window function with a narrow main lobe width should be selected, such as the Hanning window or the Hamming window. Among them, the main lobe of the rectangular window is the narrowest but the sidelobes are high. The main lobe width of the Hanning window is about twice that of the rectangular window, but the sidelobe attenuation is about -31dB, and the sidelobe attenuation of the Hamming window is about -41dB. The present invention defaults to using the Hanning window as a balanced choice, and its main lobe width and sidelobe attenuation can provide sufficient frequency resolution and spectrum leakage suppression ability in typical 6Hz / 8Hz / 10Hz magnetic remote control signal detection scenarios. Users can switch the window function type through serial port commands according to the on-site interference environment.
[0082] The specific steps for compensating the coherent gain of the calculation result are as follows: Since the window function attenuates the signal amplitude, different window functions have different coherent gains G. Among them, the coherent gain G of the Hanning window is 0.5, the Hamming window G≈0.54, and the Blackman window G≈0.42. In order to compensate for the energy attenuation caused by the window function and ensure the accuracy of energy estimation, after the system completes the Goertzel energy calculation, divide the original energy value by the square of the coherent gain G of the window function 2 , that is, the compensated energy = the original energy / G 2 . In the specific embodiment of the present invention using the Hanning window, G = 0.5, G2 =0.25, therefore the compensation coefficient is 1 / G 2 =4, meaning the compensated energy value E_comp = E_raw × 4. E_raw represents the original frequency domain energy estimate corresponding to the target frequency point. This energy value has been affected by the window function amplitude attenuation effect and has not yet undergone window function gain compensation. This compensation operation is automatically completed in the goertzel_run function before energy output, ensuring the comparability of energy estimation results under different window function configurations.
[0083] (3) Dual-path overlapping Hop parallel mechanism: Two independent Goertzel state machines are set up, with the second group starting with a delay of half a data window length relative to the first group. The two groups of state machines alternately complete the energy calculation, which doubles the effective time resolution, reduces the signal truncation loss caused by data window boundary alignment, and significantly improves the probability of capturing short burst signals.
[0084] (4) Peak Neighbor Comparison and Peak Ratio Decision: After obtaining the energy values of multiple frequency points, not only is the absolute energy of the target frequency point compared, but also peak neighbor comparison is performed to find the maximum energy value, i.e., the peak and the second largest value, and the ratio between the two is calculated. Only when the peak value is significantly higher than the second largest value, i.e., the peak ratio exceeds the preset peak ratio threshold, is the energy of the target frequency point considered to have significant frequency domain concentration and is determined to be a valid signal. This mechanism effectively suppresses false alarms caused by broadband noise and spectral leakage.
[0085] The peak-to-peak ratio threshold GOERTZEL_PEAK_RATIO_TH is defined as the minimum ratio that must be achieved between the peak energy value and the second-largest value, with a default setting of 1.5. The physical meaning of this threshold is that the energy of a target frequency point must be at least 1.5 times the energy of its neighboring points to be considered to have significant frequency domain concentration. The setting rule is as follows: in scenarios with less interference and a higher signal-to-noise ratio, the threshold can be appropriately increased, for example, to 1.8~2.0, to further reduce the false alarm probability; in scenarios with a low signal-to-noise ratio or dispersed signal energy, the threshold can be appropriately decreased, for example, to 1.2~1.5, to improve detection sensitivity. The selectable value range is typically 1.2~2.0, and users can adjust it online via serial port commands according to the actual communication environment and noise characteristics.
[0086] (5) Adaptive energy threshold: The energy decision threshold for Goertzel detection is not a fixed value, but is dynamically calculated based on the current RMS energy level of the signal. The threshold is proportional to the signal energy, which requires a higher frequency domain energy concentration for strong signals and appropriately relaxes the conditions for weak signals, thereby maintaining reasonable detection sensitivity and false alarm control under different signal-to-noise ratio conditions.
[0087] The specific steps for dynamically calculating the adaptive energy threshold based on the current signal RMS energy level are as follows: Calculate the baseline energy threshold based on the current signal energy level: eth = N 2 ×RMS 2 ×0.25, where N is the Goertzel block length, equal to the sampling rate, corresponding to the number of data points per second, RMS is the root mean square value of the signal calculated by the current sliding window, and the coefficient 0.25 corresponds to the coherence gain compensation coefficient 1 / G of the Hanning window. 2 G=0.5; Multiply the baseline threshold by the adaptive coefficient k1, which defaults to 0.5, to obtain the final decision threshold: eth_k1=eth×k1=N 2 ×RMS 2 ×0.25×0.5=N 2 ×RMS 2 ×0.125. In the formula, eth represents the theoretical energy baseline value estimated based on the current signal energy, eth_k1 represents the adaptive threshold actually used for Goertzel frequency point decision, N is the Goertzel block length, RMS is the root mean square value of the current signal, and k1 is the adaptive coefficient, with a default value of 0.5 and an optional range of 0.3 to 0.8. This adaptive mechanism requires a higher frequency domain energy concentration for strong signals and appropriately relaxes the conditions for weak signals.
[0088] In one specific embodiment, the target frequency bands are 6Hz and 8Hz, and five frequency points of 5Hz, 6Hz, 7Hz, 8Hz and 9Hz are detected simultaneously; a Hanning window is used for windowing processing, and the dual-path hop delay is half the window length; the peak ratio threshold is set to 1.5 and the adaptive threshold coefficient is 0.5.
[0089] In a specific embodiment, the complete data processing flow of the Goertzel detection step is as follows: Step 1, coefficient initialization, that is, after the system is powered on, according to the sampling rate fs=317.5Hz and the Goertzel block length N=317, corresponding to 1 second, the recursive coefficients coeff_k=2·cos(2π·k / N) for each frequency point, namely 5Hz, 6Hz, 7Hz, 8Hz, and 9Hz, are calculated, where k=round(N·fk / fs). Step 2, dual-path Hop delay start, that is, the system maintains the parallel Goertzel recursion state of two paths, A and B. Path B starts with a delay of N / 2 sampling points compared to path A. That is, after the s_gz_half_delay_cnt count reaches N / 2, path B starts to participate in the recursion, achieving 50% overlap processing. Step 3: Sampling-by-sampling windowing recursion. For each sampled value x[n], first calculate the Hanning window coefficient w[n] = 0.5 × (1 - cos(2πn / N)), obtaining the windowed value x_win = x[n] × w[n]. Then, x_win is sent to the recursion units of path A (s_gz5~s_gz9) and path B (s_gz5_b~s_gz9_b), respectively, and q0 = x_win + coeff·q1 - q2 is executed to update q2←q1 and q1←q0. Step 4: Block full energy calculation. When the sample_cnt of a certain path reaches N, the energy of that frequency point is calculated: E = (q1 2 +q2 2 -coeff·q1·q2)×4, where multiplying by 4 is the coherent gain compensation for the Hanning window, and then the state of this path is reset. Step 5, peak search and decision, that is, collect the energy values of the five currently valid frequency points, find the peak value peak_val, the second largest value second_val, and the peak index peak_idx, and calculate the peak ratio peak_ratio=peak_val / second_val; if peak_idx corresponds to the target frequency point, i.e., 6Hz or 8Hz; peak_val>eth_k1 and peak_ratio≥1.5, then it is determined to be a valid signal, and the corresponding frequency is output.
[0090] Step S104: According to the control command detection time window, count the effective frequencies in the target frequency detection results, compare the statistical results with the preset counting threshold, and identify the effective control command based on the statistical comparison results to obtain the effective frequency identification result.
[0091] It should be noted that the underlying detection algorithm, whether it's zero-crossing detection or Goertzel detection, may still contain randomness in the effective frequency detected in a single instance. To avoid false triggering caused by single noise pulses or random matches, this invention introduces a dual confirmation mechanism of a time window and a counting threshold between the underlying frequency detection and the final control command output, such as... Figure 8 As shown, the time relationship is displayed with time as the horizontal axis, including the detection trigger time of the target frequency signal, window opening / closing, count value accumulation, threshold reaching trigger, timeout reset, etc.
[0092] The system maintains independent detection window contexts for different control commands, such as power-on and power-off commands. When a target frequency is detected for the first time, a time window is opened and counting begins. During the window's duration, the counter increments each time the same target frequency is detected again. When the counter reaches a preset trigger threshold, the corresponding control command is output. If the window times out before reaching the trigger threshold, the window is automatically reset, waiting for the next detection.
[0093] The specific rules for setting the time window are as follows: The system sets independent detection time windows for different control commands. For the zero-crossing detection (ZC) subsystem, the detection window g_detect_window_ms for the 6Hz power-on command is set to 2000 milliseconds, i.e., 2 seconds, and the detection window g_detect8_window_ms for the 8Hz power-off command is set to 2000 milliseconds, i.e., 2 seconds. For the Goertzel detection (GZ) subsystem, the detection window g_gz_detect_window_ms for the 6Hz power-on command is set to 3000 milliseconds, i.e., 3 seconds, and the detection window g_gz_detect8_window_ms for the 8Hz power-off command is set to 3000 milliseconds, i.e., 3 seconds. The setting rule is that the window duration should cover at least several complete cycles of the target frequency. For example, for a 6Hz signal, it should cover at least 6 to 12 cycles, i.e., 1 to 2 seconds, while also considering the detection delay and false alarm probability of the algorithm. Due to the block processing delay of the Goertzel algorithm, its window is usually slightly longer than that of zero-crossing detection. The selectable value range is: 500~3000 milliseconds for ZC mode and 1000~5000 milliseconds for GZ mode.
[0094] The specific rules for setting the preset trigger thresholds are as follows: The trigger threshold is defined as the number of valid frequency hits that need to be detected within the time window; the corresponding control command is only output when this number is reached. For the zero-crossing detection (ZC) subsystem, the trigger threshold g_detect_trigger_cnt for the 6Hz power-on command is set to 4 times, and the trigger threshold g_detect8_trigger_cnt for the 8Hz power-off command is set to 5 times; for the Goertzel detection (GZ) subsystem, the trigger threshold g_gz_detect_trigger_cnt for the 6Hz power-on command is set to 3 times, and the trigger threshold g_gz_detect8_trigger_cnt for the 8Hz power-off command is set to 3 times. The rules are set as follows: the ratio of the trigger threshold to the detection window duration should be greater than the target frequency. For example, a 6Hz signal can theoretically experience 12 zero-crossings within a 2-second window. Taking 4 triggers corresponds to a duty cycle requirement of approximately 33%, balancing detection sensitivity and resistance to short-term interference. In scenarios with strong interference, the trigger threshold can be appropriately increased, for example, to 6-8 times for ZC 6Hz. In scenarios requiring rapid response, the trigger threshold can be appropriately decreased, for example, to 2 times for GZ 6Hz. The selectable value range is 2-10 times.
[0095] The advantages of this mechanism are: it limits the detection time range by using a time window, avoiding the long-term impact of historically accumulated false counts; it requires multiple independent confirmations by using a counting threshold, which significantly reduces the probability of a single accidental misjudgment; and the automatic reset mechanism for window timeout ensures that the system can return to the initial detection state after a long period of no effective signal.
[0096] In addition, the system maintains a device control state machine, such as an off state and an on state. It responds only to specific control frequencies in different states to avoid repeated triggering of the same command and to prevent malfunctions caused by state confusion. State switching is driven by feedback confirmation of control commands, ensuring that the next detection state is entered only after the command is successfully executed. In one specific embodiment, the detection frequency for the power-on command is 6Hz, the time window is 2 seconds, and the trigger threshold is 4 times; the detection frequency for the power-off command is 8Hz, the time window is 2 seconds, and the trigger threshold is 5 times. Different window and threshold parameters can be set for the Goertzel independent detection channel.
[0097] The system maintains the device control state machine g_dev_ctrl_state to ensure that it only responds to specific control frequencies in different states. The specific mechanism is as follows: The state machine defines two basic states: DEV_CTRL_CLOSED (off state) and DEV_CTRL_OPENED (on state). In the DEV_CTRL_CLOSED state, the system only responds to a 6Hz frequency detection hit, interpreting it as a power-on command, while ignoring an 8Hz frequency detection hit to avoid responding to a power-off command in a closed state; in the DEV_CTRL_CLOSED state... In the TRL_OPENED state, the system only responds to 8Hz frequency detection hits, interpreting them as a shutdown command, while ignoring 6Hz frequency detection hits to avoid repeatedly triggering the power-on command while the device is already powered on. State transitions are driven by feedback confirmation of control commands: after sending a power-on command, the system waits for a 0xFA confirmation code from an external device before switching to DEV_CTRL_OPENED; similarly, after sending a shutdown command, it waits for a 0xFB confirmation code before switching to DEV_CTRL_CLOSED. This state machine mechanism effectively prevents the same command from being triggered repeatedly and avoids erroneous operations caused by state confusion.
[0098] In one specific embodiment, the complete process of protocol decoding state machine data processing is as follows: The system maintains independent fixed frequency detection contexts (fixed_freq_ctx_t) for power-on commands (6Hz) and power-off commands (8Hz), including the window activation flag window_active, the window start time window_start_ms, and the hit counter hit_cnt. When the underlying algorithm ZC or GZ detects a valid frequency, the fixed_freq_on_detect function is called; this function first determines whether the frequency is allowed to be triggered based on the current state of the state machine g_dev_ctrl_state: power-on is only allowed at 6Hz in the CLOSED state, and power-off is only allowed at 8Hz in the OPENED state. If triggering is allowed, the `_ff_ctx_run` function is called to manage the detection window: if the window is not active, it is opened and `window_start_ms` is set to the current time, and `hit_cnt` is initialized to 1; if the window is active, the difference between the current time and the window's start time, `elapsed`, is calculated; if `elapsed` exceeds the preset window duration `win_ms`, the window times out and is reset, reopened with the current time as the starting point, and `hit_cnt` is set to 1; if it does not time out, `hit_cnt` is incremented; when `hit_cnt` reaches the preset trigger threshold `trig_cnt`, the corresponding control command `ENVENT_CMD_OPEN` or `ENVENT_CMD_CLOSE` is sent via `rs485_send_cmd`, and then the window state is cleared, i.e., `hit_cnt=0`, `window_active=0`, waiting for the next detection. In addition, the system checks whether the active window has timed out in each sampling cycle; if it has, it automatically calls `fixed_freq_detect_reset` or `fixed_freq8_detect_reset` to reset it.
[0099] Step S105: The effective frequency identification result is mapped to a communication protocol symbol by the protocol decoding state machine, combined with timeout protection and state reset. The communication protocol symbol is then parsed into the corresponding control command. The control command is sent through the communication interface to complete the closed-loop processing from signal detection to command output.
[0100] In this optional embodiment, mapping the effective frequency identification result to communication protocol symbols through a protocol decoding state machine, combined with timeout protection and state reset, includes: Using the protocol decoding state machine, the frame header frequency is continuously detected based on the valid frequency identification result. If the detection result is that a valid frame header is identified, the start timestamp is recorded and the data bit counter and data register are initialized. After receiving the frame header frequency, each valid data bit received is shifted into the data register and the data bit counter is incremented. During the data bit shifting and writing process, if the time interval between adjacent data bits exceeds the limit, or if the time interval accumulated from the frame header to the current data bit exceeds the limit, it is determined that the frame transmission is abnormal, and the protocol decoding state machine is reset to the initial waiting frame header state. When the data bit counter accumulates to the preset frame length, the data frame in the data register is output to obtain the communication protocol symbol.
[0101] It should be added that, such as Figure 9 As shown, this illustrates the transition conditions between the waiting frame header state and the data bit reception state, as well as the frame completion and reset paths. Figure 9 In this diagram, DEC_WAIT_A represents the decoding wait for the frame header; DEC_WAIT_B represents the decoding wait for the data bits; WAVE_A represents waveform A, corresponding to the frame header frequency; WAVE_B represents waveform B, corresponding to the data bit 0 frequency; WAVE_C represents waveform C, corresponding to the data bit 1 frequency; freq_to_wave() is a function that maps frequency values to the corresponding waveform type; reset indicates resetting and re-detecting; first_tick is the first detection timestamp; bit_cnt is the bit counter; frame_data is the frame data register; STEP_TIMEOUT_MS is the step timeout time in milliseconds; TOTAL_TIMEOUT_MS is the total timeout time in milliseconds; decode_reset() is the decoding reset function; rs485_send_cmd() is the RS485 send command function; ACK is the acknowledgment; 0xFA / 0xFB are hexadecimal acknowledgment codes. In addition to the fixed-frequency direct trigger mode, this invention also supports a frequency-encoded communication protocol mode. This mode maps different frequencies to communication symbols and uses frame format to encode and transmit multi-bit data.
[0102] The protocol uses a frame structure: the frame header is marked with a specific frequency, such as 6Hz, to mark the start of a frame; the data bits are encoded with two other frequencies, such as 8Hz for data 0 and 10Hz for data 1; the frame data length is set according to communication requirements, for example, 3 bits of data can encode 8 different instructions.
[0103] Protocol decoding is implemented by a state machine, comprising the following main states: Waiting for frame header state, where the system continuously monitors the frame header frequency. Once a valid frame header frequency is detected, the state transitions to the data bit receiving state, simultaneously recording the frame start timestamp and initializing the data bit counter and data register. Data bit receiving state, where after receiving the frame header, the system waits for the data bit frequency to arrive. Each received valid data bit is shifted and written to the data register, and the data bit counter is incremented. A step timeout protection is provided between adjacent data bits; if the next data bit is not received within the timeout period, it is determined that the frame transmission is abnormal, and the state machine resets to the waiting for frame header state. Frame completion output, where the data register contains the complete data frame content when the data bit count reaches the preset frame length. The system outputs the corresponding control command through the communication interface and resets the state machine to wait for the next frame. Simultaneously, a total timeout protection is provided from the moment the frame header is received; if the entire frame is not received within the total time, the state is also reset to prevent the state machine from suspending indefinitely. In one specific embodiment, the frame data length is 3 bits, the step timeout is 1000 milliseconds, the total timeout is 5000 milliseconds, and the communication interface adopts RS485 bus.
[0104] Figure 2 An embodiment of a signal detection system for a magnetic receiving device according to the present invention is shown.
[0105] In this optional embodiment, the signal detection system for the magnetic receiving device includes: The signal preprocessing module 201 is used to acquire multi-channel magnetic signal acquisition data from the magnetic sensor and perform signal preprocessing on the multi-channel magnetic signal acquisition data to obtain the effective AC component of the target magnetic signal frequency band. The multi-axis dynamic selection module 202 is used to evaluate the magnetic signal energy level of the effective AC component of each channel in real time, and to perform multi-axis dynamic selection based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel. The signal detection module 203 is used to detect the target magnetic signal of the current optimal detection channel based on a dual-algorithm parallel detection framework and combined with a dynamic adaptive switching mechanism, so as to obtain the detection result of the target frequency. The effective frequency identification module 204 is used to count and statistically analyze the effective frequencies in the detection results of the target frequency according to the control command detection time window, compare the statistical results with a preset counting threshold, and identify the effective control command in the detection results of the target frequency based on the statistical comparison results to obtain the effective frequency identification result. The control command output module 205 is used to map the effective frequency identification result into communication protocol symbols through the protocol decoding state machine, combined with timeout protection and state reset, to parse the communication protocol symbols into corresponding control commands, and send the control commands through the communication interface to complete the closed-loop processing of the entire process from signal detection to command output.
[0106] In summary, such as Figure 4 As shown, it should demonstrate multi-channel signal acquisition, signal preprocessing, dual-algorithm parallel detection framework, multi-axis dynamic selection, fixed-frequency window counting confirmation, protocol decoding state machine, and the data flow between each module. Figure 4 The meanings of the letters and abbreviations in the code are as follows: AD7177-2 is the model number of the analog-to-digital converter chip; Sigma-Delta ADC is a Σ-Δ analog-to-digital converter; SPI is a serial peripheral interface; 24bit is 24-bit resolution; DC is the DC component; Get_DC_Avg() is the function to obtain the DC average value; IIR is the infinite impulse response; fc is the cutoff frequency; ZC is zero-crossing detection; GZ is Goertzel frequency domain detection; RMS is the root mean square; AUTO is the automatic mode; DEC_WAIT_A is the decoding wait for the frame header state; DEC_WAIT_B is the decoding wait for the data bits state; RS485 is the RS-485 serial communication standard; AA55 is the frame header flag byte; LEN is the length; FUNC is the function code; DATA is the data field; CRC is the cyclic redundancy check; ch_data[] is the channel data array; flt_data[] is the filtered data array; zc-axis_sel is the zero-crossing detection axis selection; freq is the frequency. This invention aims to solve the problems of low detection sensitivity, poor anti-interference ability, and insufficient multi-axis adaptability in existing technologies under complex geomagnetic interference environments. The magnetic remote control signal detection of this invention includes the following functional modules: 1. Multi-channel signal acquisition module: A high-precision analog-to-digital converter is used to synchronously sample each channel of the magnetic sensor. The sampling rate is reasonably set according to the target magnetic signal frequency band, usually tens of times higher than the highest frequency of the target signal, in order to ensure effective sampling of the target signal and the accuracy of subsequent processing.
[0107] 2. Signal preprocessing module: Includes a DC background estimation unit and a second-order infinite impulse response (IIR) high-pass filter unit, used to remove geomagnetic DC bias and low-frequency drift interference, and retain the effective AC component of the target frequency band.
[0108] 3. Dual-algorithm parallel detection framework: It includes a zero-crossing detection (ZC) subsystem and a Goertzel frequency domain detection (GZ) subsystem, which run in parallel and achieve dynamic adaptive switching through a real-time signal energy assessment module.
[0109] 4. Multi-axis dynamic selection module: It evaluates the signal energy of each channel in real time, automatically selects the channel with the strongest signal to participate in the detection, and switches to polling mode under low signal energy conditions to ensure that the multi-axis sensor can effectively capture the target signal under different orientations.
[0110] 5. Fixed Frequency Window Counting Confirmation Module: Performs counting statistics on the detected effective frequencies within a time window. Through a dual confirmation mechanism of time window and counting threshold, it avoids malfunctions caused by single accidental triggers, significantly improving system reliability.
[0111] 6. Protocol Decoding State Machine Module: Maps frequency identification results to communication protocol symbols, and has timeout protection and state reset functions to ensure the integrity and robustness of the communication process.
[0112] The core ideas and technical solutions of this invention can be implemented in various specific ways. The following describes several typical implementation methods: 1. Filter type replacement: The second-order IIR high-pass filter in signal preprocessing can be replaced with a Chebyshev or Elliptic IIR filter of the same order to obtain a steeper transition band attenuation characteristic; it can also be replaced with a finite impulse response (FIR) high-pass filter to obtain a more stringent linear phase characteristic, which is suitable for scenarios that are sensitive to phase distortion.
[0113] 2. Replacement of Goertzel window function: The window function used in the Goertzel detection system can be replaced according to the actual requirements of spectrum leakage suppression and frequency resolution. For example, the Hamming window can be used to achieve a balance between the main lobe width and side lobe attenuation, the Blackman window can be used to obtain a lower side lobe level, or the Kaiser window can be used to flexibly balance the main lobe width and side lobe attenuation by adjusting the shape parameters.
[0114] 3. Expansion of switching metrics: The metrics used for dual-algorithm switching are not limited to RMS energy. Other features that can reflect signal strength, such as peak amplitude, signal variance, kurtosis, and signal-to-noise ratio estimation, can also be used as the basis for switching, providing better switching performance for different signal characteristics.
[0115] 4. Extension of multi-axis fusion strategy: Multi-axis dynamic selection is not limited to the strongest axis single selection strategy. Multi-axis joint detection and majority voting strategy can also be adopted. That is, each channel runs the detection algorithm independently. When multiple channels detect valid signals at the same time, a majority vote is performed to output, which further improves the reliability and fault tolerance of detection.
[0116] 5. Extension of window counting logic: The "time window + counting threshold" logic in fixed frequency window counting confirmation can be extended to a fixed integral window or an exponential weighted accumulation strategy. For example, different weights can be assigned to the detection events at different time points, such as high weight for recent events and low weight for distant events, so as to more sensitively reflect the continuity and timeliness of the signal.
[0117] 6. Extension of communication protocol: The frequency encoding method in protocol decoding is not limited to the 6Hz / 8Hz / 10Hz three-frequency scheme, but can be extended to more frequency points, such as adding 7Hz and 9Hz as auxiliary data bits, or using frequency shift keying (FSK) to achieve higher-speed data transmission, in order to adapt to different communication rates and data capacity requirements.
[0118] The key technical points included in this invention are as follows: 1. Dual-algorithm parallel response and fusion detection method: The time-domain zero-crossing detection algorithm and the Goertzel frequency-domain detection algorithm are deployed simultaneously in a single embedded system. The dynamic adaptive switching between the two algorithms is achieved through real-time signal energy assessment. The two algorithms share the same signal preprocessing link but run independently and complement each other.
[0119] 2. Enhanced Goertzel frequency domain peak neighbor comparison algorithm: Based on single target frequency detection, multiple neighboring frequency points are set as sentinels on both sides of the target frequency point. Through parallel energy calculation of multiple frequency points, comparison of the significance of peak and sub-peak values (i.e., peak ratio exceeding a preset threshold) and adaptive energy threshold decision, robust target frequency identification and false alarm suppression are achieved.
[0120] 3. Dual-path overlapping Hop parallel detection mechanism: Two sets of overlapping Goertzel state machines are set up. The second set starts with a delay of half a data window length relative to the first set. The two sets alternately complete energy calculation, which doubles the effective time resolution without increasing the computational burden.
[0121] 4. Multi-axis dynamic selection and low-energy polling combination strategy: Based on real-time energy assessment of multiple channels, the strongest signal channel is automatically selected for detection, and channel jitter is prevented by hysteresis ratio; when the energy of all channels is lower than the low energy threshold, it automatically switches to a fixed-duration channel polling mode to achieve a balance between directional adaptation and low signal acquisition capability.
[0122] 5. Cascaded preprocessing structure of DC background estimation and real-time second-order IIR high-pass filter: During the power-on initialization stage, the DC background estimate is calculated through static sampling. During the operation stage, the DC bias and low-frequency drift are removed in real time through a second-order IIR high-pass filter to ensure that the frequency detection is not affected by the slow changes in the geomagnetic field.
[0123] 6. Fixed-frequency window counting confirmation and state machine dual reliability architecture: A time window counting confirmation layer is set between the underlying frequency detection and the final command output. The probability of accidental false triggering is reduced by multiple independent confirmations within the window. At the same time, the device control state machine is maintained so that it only responds to the corresponding control frequency in different control states to prevent repeated triggering and state chaos.
[0124] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores static and dynamic information data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps described in the above embodiment of the signal detection method for a magnetic receiving device.
[0125] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present invention and does not constitute a limitation on the computer device to which the present invention is applied. A specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0126] Furthermore, the present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps described in the above-described embodiment of the signal detection method for a magnetic receiving device.
[0127] In addition, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described embodiment of the signal detection method for a magnetic receiving device.
[0128] Those skilled in the art will understand that implementing all or part of the processes in the signal detection method for a magnetic receiving device according to the above embodiments can be accomplished by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the signal detection methods for the magnetic receiving device as described in the above embodiments. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0129] This invention is not limited to the structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this invention is limited only by the appended claims.
Claims
1. A signal detection method for a magnetic receiving device, characterized in that, include: Acquire multi-channel magnetic signal acquisition data from the magnetic sensor, and perform signal preprocessing on the multi-channel magnetic signal acquisition data to obtain the effective AC component of the target magnetic signal frequency band; The effective AC component of each channel is evaluated in real time to assess the magnetic signal energy level, and multi-axis dynamic selection is performed based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel. Based on a dual-algorithm parallel detection framework and combined with a dynamic adaptive switching mechanism, the target magnetic signal of the current optimal detection channel is detected to obtain the target frequency detection result. According to the control command detection time window, the effective frequencies in the target frequency detection results are counted and statistically analyzed, and the statistical results are compared with the preset counting threshold. Based on the statistical comparison results, the effective control command is identified in the target frequency detection results to obtain the effective frequency identification results. By using a protocol decoding state machine, combined with timeout protection and state reset, the effective frequency identification result is mapped to a communication protocol symbol. The communication protocol symbol is then parsed into the corresponding control command, and the control command is sent through the communication interface, completing the entire closed-loop process from signal detection to command output.
2. The signal detection method for a magnetic receiving device according to claim 1, characterized in that, The process of acquiring multi-channel magnetic signal data from a magnetic sensor and performing signal preprocessing on the multi-channel magnetic signal data to obtain the effective AC component of the target magnetic signal frequency band includes: The sampling rate is set according to the target magnetic signal frequency band, and the magnetic sensor channels are synchronously sampled based on the sampling rate to obtain multi-channel signal acquisition data; Based on the preset static acquisition time, static magnetic field data is acquired in the initial stage after the magnetic sensor is powered on. The average value of each channel of the magnetic sensor is calculated based on the static magnetic field data and used as the initial DC background estimate. Based on the initial DC background estimate, DC removal is performed on the multi-channel signal acquisition data to obtain the DC-removed multi-channel magnetic signal. The cutoff frequency of the filter is set according to the lowest effective frequency of the target magnetic signal band, and a second-order infinite impulse response high-pass filter is used to filter out geomagnetic drift and temperature drift interference from the multi-channel magnetic signal after DC removal, so as to obtain the effective AC component of the target frequency band.
3. The signal detection method for a magnetic receiving device according to claim 1, characterized in that, The method of real-time evaluation of the magnetic signal energy level of the effective AC component of each channel, and multi-axis dynamic selection based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel includes: The accumulation window length is determined based on the response speed and stability requirements of the strongest axis switching, and the energy accumulation window is set based on the accumulation window length. Within the energy accumulation window, the square values of the effective AC components of each channel are accumulated to obtain the energy accumulation value of each channel. After the window period of the energy accumulation window expires, the root mean square of the energy of each channel is calculated based on the energy accumulation value of each channel to obtain the magnetic signal energy level of each channel. If the magnetic signal energy levels of all channels are lower than the preset low energy threshold, the current detection mode will be switched to a fixed-duration channel polling mode, and the target magnetic signal of the current optimal detection channel will be obtained. If the maximum magnetic signal energy level in all channels is greater than or equal to the preset low energy threshold, the current detection mode is switched to the strongest axis selection mode. If the maximum magnetic signal energy level is greater than the product of the magnetic signal energy level of the current detection channel and the preset hysteresis ratio, the current detection channel is switched and the target magnetic signal of the current optimal detection channel is determined.
4. The signal detection method for a magnetic receiving device according to claim 1, characterized in that, The dual-algorithm parallel detection framework, combined with a dynamic adaptive switching mechanism, performs signal detection on the target magnetic signal of the current optimal detection channel, and the detection results of the target frequency include: The magnetic signal energy level corresponding to the target magnetic signal of the current optimal detection channel is obtained and compared with the preset effective signal threshold to obtain the effective target signal determination result. Based on the effective target signal determination result, the magnetic signal energy level corresponding to the target magnetic signal of the current optimal detection channel will be obtained and compared with the preset energy threshold to obtain the energy threshold comparison result; If the energy threshold comparison result is greater than or equal to the preset energy threshold, the algorithm will be adaptively switched to the zero-crossing detection algorithm in the dual-algorithm parallel detection framework. The zero-crossing detection algorithm will be used to detect the target magnetic signal of the current optimal detection channel to obtain the target frequency detection result. If the energy threshold comparison result is less than the preset energy threshold, the algorithm will adaptively switch to the frequency domain detection algorithm in the dual-algorithm parallel detection framework. The frequency domain detection algorithm will be used to detect the target magnetic signal of the current optimal detection channel to obtain the target frequency detection result.
5. The signal detection method for a magnetic receiving device according to claim 4, characterized in that, The rules for setting the energy threshold are as follows: In a pure background noise environment without target magnetic signals, a segment of noise data was collected, and the root mean square value of the noise data was calculated as the noise baseline. Given the known existence of the target magnetic signal, reference data is acquired, and the root mean square value of the reference data is calculated as the signal reference value. Set a transition value between the noise baseline and the signal reference value, and use the transition value as the energy threshold.
6. The signal detection method for a magnetic receiving device according to claim 4, characterized in that, The method of using a zero-crossing detection algorithm to detect the target magnetic signal of the current optimal detection channel, and obtaining the target frequency detection result includes: Based on the preset effective signal threshold, positive and negative thresholds are set, and hysteresis zero-crossing is determined based on the positive and negative thresholds to obtain effective zero-crossing events. The time interval between two consecutive valid zero-crossing events is compared with a preset ratio of the shortest valid period of the target signal to obtain the high-frequency noise bounce determination result. Based on the high-frequency noise bounce determination result, the period is calculated to obtain the valid period. The rate of change of continuously detected effective cycles is evaluated to obtain the rate of change of adjacent effective cycles, and the stability of effective cycles is screened by combining the preset tolerance threshold to obtain stable cycles. Once the number of consecutive stable cycles reaches the preset number of stable cycles, the consecutive stable cycles are frequency-converted to obtain the detection result of the target frequency.
7. The signal detection method for a magnetic receiving device according to claim 4, characterized in that, The detection of the target magnetic signal in the current optimal detection channel using a frequency domain detection algorithm, and the resulting target frequency detection, include: Based on the target magnetic signal and target frequency band of the current optimal detection channel, select the target frequency point and adjacent sentinel frequency points, and calculate the recursive coefficients of the target frequency point and adjacent sentinel frequency points based on the sampling rate and the length of the frequency domain detection block; By using a window function, each sample value of the target magnetic signal in the current optimal detection channel is windowed to obtain the windowed value; According to the preset data window length, the two parallel recursive state machines of the frequency domain detection algorithm are started with a recursive delay. After the recursive delay starts, the window value and recursive coefficient are input into the two parallel recursive state machines for sample-by-sample windowing recursion to obtain the recursive result. The energy value of each frequency point is calculated based on the recursive result and the coherent gain compensation of the window function. Based on the energy value of each frequency point, the target magnetic signal of the current optimal detection channel is screened based on anomaly judgment to obtain the effective signal. The frequency of the frequency point corresponding to the effective signal is identified to obtain the detection result of the target frequency.
8. The signal detection method for a magnetic receiving device according to claim 7, characterized in that, The process of filtering the target magnetic signal of the current optimal detection channel based on anomaly detection according to the energy value of each frequency point to obtain effective signals includes: Based on the energy values at each frequency point, determine the peak value, the second largest value, and the peak frequency index; and calculate the peak ratio based on the peak value and the second largest value. The peak ratio is compared with a preset peak ratio threshold to obtain the peak ratio comparison result, and the peak frequency index is compared with a preset target frequency index to obtain the consistency comparison result. If the peak ratio comparison result is greater than or equal to the preset peak ratio threshold, and the consistency comparison result is that the frequency index is consistent, then the target magnetic signal of the current optimal detection channel is determined to be a valid signal.
9. The signal detection method for a magnetic receiving device according to claim 1, characterized in that, The process of mapping the effective frequency identification result to communication protocol symbols through the protocol decoding state machine, combined with timeout protection and state reset, includes: Using the protocol decoding state machine, the frame header frequency is continuously detected based on the valid frequency identification result. If the detection result is that a valid frame header is identified, the start timestamp is recorded and the data bit counter and data register are initialized. After receiving the frame header frequency, each valid data bit received is shifted into the data register and the data bit counter is incremented. During the data bit shifting and writing process, if the time interval between adjacent data bits exceeds the limit, or if the time interval accumulated from the frame header to the current data bit exceeds the limit, it is determined that the frame transmission is abnormal, and the protocol decoding state machine is reset to the initial waiting frame header state. When the data bit counter accumulates to the preset frame length, the data frame in the data register is output to obtain the communication protocol symbol.
10. A signal detection system for a magnetic receiving device, characterized in that, The signal detection system for the magnetic receiving device includes: The signal preprocessing module is used to acquire multi-channel magnetic signal acquisition data from the magnetic sensor and perform signal preprocessing on the multi-channel magnetic signal acquisition data to obtain the effective AC component of the target magnetic signal frequency band. The multi-axis dynamic selection module is used to evaluate the magnetic signal energy level of the effective AC component of each channel in real time, and to perform multi-axis dynamic selection based on the magnetic signal energy level of each channel to obtain the target magnetic signal of the current optimal detection channel. The signal detection module is used to detect the target magnetic signal of the current optimal detection channel based on a dual-algorithm parallel detection framework and combined with a dynamic adaptive switching mechanism, so as to obtain the detection result of the target frequency. The effective frequency identification module is used to count and statistically analyze the effective frequencies in the detection results of the target frequency according to the control command detection time window, compare the statistical results with the preset counting threshold, and identify the effective control command in the detection results of the target frequency based on the statistical comparison results to obtain the effective frequency identification result. The control command output module is used to map the effective frequency identification result into communication protocol symbols by decoding the state machine through the protocol, and combining timeout protection and state reset. It then parses the communication protocol symbols into corresponding control commands and sends the control commands through the communication interface, thus completing the closed-loop processing from signal detection to command output.