Photoelectric liquid leakage sensor and interference suppression method, device, equipment and medium thereof
By employing microcontroller-controlled pulse width modulation and differential calculation methods in the photoelectric leakage sensor, the problem of insufficient adaptability of traditional photoelectric leakage detection to ambient light and device aging is solved, achieving higher precision interference suppression and reduced false alarm rate.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DOGO TECH CO LTD
- Filing Date
- 2026-03-17
- Publication Date
- 2026-05-01
AI Technical Summary
Traditional photoelectric leakage detection solutions are not adaptable to changes in ambient light and temperature, as well as device aging, leading to frequent false alarms or delayed alarms and affecting working accuracy.
A microcontroller is used to control the light-emitting device to turn on and off within the same pulse width modulation period. A voltage sampling device is used to collect the on and off voltages respectively, and the ambient light background component and zero-point drift component are suppressed by differential calculation.
It significantly suppresses interference from photoelectric leakage sensors, improves working accuracy, reduces false alarm rate, adapts to environmental changes, and reduces power consumption.
Smart Images

Figure CN121954352A_ABST
Abstract
Description
Photoelectric leakage sensor and its interference suppression method, device, equipment and medium Technical Field
[0001] This application relates to the field of electronic technology, and in particular to an interference suppression method, apparatus, electronic device, computer-readable storage medium, and photoelectric leakage sensor for a photoelectric leakage sensor. Background Technology
[0002] Traditional photoelectric leakage detection systems often employ purely analog links, operating through amplification, rectification, and comparators combined with adjustable resistors to set thresholds. This approach is insufficiently adaptable to changes in ambient light and temperature, as well as slow drift caused by device aging. It frequently requires manual recalibration and is prone to false alarms or delayed reporting. Therefore, how to more accurately and effectively suppress interference in photoelectric leakage sensors and ensure their operational accuracy is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0003] The purpose of this application is to provide an interference suppression method for a photoelectric leakage sensor. This interference suppression method can more accurately and effectively suppress interference in the photoelectric leakage sensor, thereby ensuring its working accuracy. Another purpose of this application is to provide an interference suppression device, electronic device, computer-readable storage medium, and photoelectric leakage sensor, all of which have the above-mentioned beneficial effects.
[0004] In a first aspect, this application discloses an interference suppression method for a photoelectric leakage sensor, applied to a microcontroller deployed in the photoelectric leakage sensor, comprising:
[0005] The control signal generating device outputs a pulse width modulation signal so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation cycle;
[0006] A voltage sampling device is used to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window, and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window.
[0007] The differential voltage value is obtained by performing differential calculation on the lighting voltage and the extinguishing voltage to suppress the ambient light background component and zero-point drift component that are simultaneously superimposed on the lighting voltage and the extinguishing voltage, thereby achieving interference suppression of the photoelectric leakage sensor.
[0008] Optionally, the interference suppression method for the photoelectric leakage sensor further includes:
[0009] When the differential voltage value is lower than the dynamic threshold for a first preset number of pulse width modulation cycles, a leakage alarm is output.
[0010] When the differential voltage value is higher than the sum of the dynamic threshold and the preset hysteresis difference value within a second preset number of pulse width modulation cycles, the leakage alarm is deactivated.
[0011] Optionally, the dynamic threshold is determined by means of:
[0012] Under preset stable conditions, the differential voltage value samples within a third preset number of pulse width modulation cycles are statistically analyzed.
[0013] The baseline differential voltage value is obtained by averaging all the differential voltage value samples.
[0014] When the difference between the baseline differential voltage value and the preset voltage margin value is not lower than the preset minimum threshold, the difference between the baseline differential voltage value and the preset voltage margin value is used as the dynamic threshold.
[0015] When the difference between the baseline differential voltage value and the preset voltage margin value is lower than the preset minimum threshold, the preset minimum threshold is used as the dynamic threshold.
[0016] Optionally, the preset stability conditions include:
[0017] The photoelectric leakage sensor is in a working state where it does not output the leakage alarm message;
[0018] The differential voltage value samples are all within a preset threshold range;
[0019] The dispersion of the third preset number of differential voltage value samples is lower than the preset dispersion.
[0020] Optionally, the interference suppression method for the photoelectric leakage sensor further includes:
[0021] When the photoelectric leakage sensor operates under the preset stable conditions, it performs an update operation on the dynamic threshold at preset time intervals.
[0022] When the photoelectric leakage sensor is not operating under the preset stable conditions, the update operation regarding the dynamic threshold is stopped.
[0023] Optionally, the interference suppression method for the photoelectric leakage sensor further includes:
[0024] When a reset signal is received from the hardware watchdog, a reset operation is performed according to the reset signal; the reset signal is sent by the hardware watchdog to the microcontroller when it does not receive a timed "feed the watchdog" signal from the microcontroller.
[0025] And / or, when the self-test operation fails, the reset operation is performed.
[0026] Secondly, this application discloses a photoelectric leakage sensor, including a microcontroller, a signal generating device, a light-emitting device, and a voltage sampling device, all electrically connected to the microcontroller;
[0027] The microcontroller is used to control the signal generating device to output a pulse width modulation signal, so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation period; the voltage sampling device is used to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window, and to collect the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window; the lighting voltage and the extinguishing voltage are differentially calculated to obtain a differential voltage value, so as to suppress the ambient light background component and zero-point drift component superimposed on the lighting voltage and the extinguishing voltage, thereby realizing the interference suppression of the photoelectric leakage sensor.
[0028] Thirdly, this application discloses an interference suppression device for a photoelectric leakage sensor, applied to a microcontroller deployed in the photoelectric leakage sensor, comprising:
[0029] The control module is used to control the signal generating device to output a pulse width modulation signal so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation cycle;
[0030] The sampling module is used to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window using a voltage sampling device.
[0031] The calculation module is used to perform differential calculation on the lighting voltage and the extinguishing voltage to obtain a differential voltage value, so as to suppress the ambient light background component and zero-point drift component that are simultaneously superimposed on the lighting voltage and the extinguishing voltage, thereby realizing the interference suppression of the photoelectric leakage sensor.
[0032] Fourthly, this application discloses an electronic device, comprising:
[0033] Memory, used to store computer programs;
[0034] A processor, used to execute the computer program to implement the interference suppression method of any of the photoelectric leakage sensors described above.
[0035] Fifthly, this application discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the photoelectric leakage sensor interference suppression methods described above.
[0036] This application provides an interference suppression method for a photoelectric leakage sensor, applied to a microcontroller deployed in the photoelectric leakage sensor, comprising: controlling a signal generation device to output a pulse width modulation signal so that the light-emitting device is in a lighting window and an extinguishing window respectively within the same pulse width modulation period; using a voltage sampling device to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window, and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window; performing differential calculation on the lighting voltage and the extinguishing voltage to obtain a differential voltage value, so as to suppress the ambient light background component and zero-point drift component superimposed on the lighting voltage and the extinguishing voltage simultaneously, thereby realizing interference suppression of the photoelectric leakage sensor.
[0037] The present application provides a photoelectric leakage sensor with a microcontroller as its core. Based on this microcontroller, a signal generation device can output a PWM signal, simultaneously controlling the light-emitting device to sequentially light up and turn off within the same PWM cycle. This forms a lighting window and a extinguishing window within the same PWM cycle. The voltage sampling device can then collect the lighting voltage generated by the lighting light signal in the lighting window and the extinguishing voltage generated by the extinguishing light signal in the extinguishing window. By performing differential calculations on the lighting and extinguishing voltages, the differential voltage value obtained can significantly suppress the ambient light background component and zero-point drift component superimposed on both the lighting and extinguishing voltages. This achieves interference suppression for the photoelectric leakage sensor. In other words, by completing aligned dual-window (lighting and extinguishing window) sampling and differential calculation within the same PWM cycle, interference is suppressed at its source. Therefore, this technical solution can more accurately and effectively suppress interference in the photoelectric leakage sensor, thereby ensuring its working accuracy.
[0038] The interference suppression device, electronic device, computer-readable storage medium, and photoelectric leakage sensor provided in this application also have the above-mentioned technical effects, and will not be described in detail here. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the prior art and the embodiments of this application, the accompanying drawings used in the description of the prior art and the embodiments of this application will be briefly introduced below. Of course, the accompanying drawings described below with respect to the embodiments of this application are only a part of the embodiments in this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort, and such other drawings also fall within the protection scope of this application.
[0040] Figure 1 is a schematic diagram of the structure of a photoelectric leakage sensor provided in an embodiment of this application;
[0041] Figure 2 is a flowchart illustrating an interference suppression method for a photoelectric leakage sensor provided in an embodiment of this application.
[0042] Figure 3 is a schematic diagram of another photoelectric leakage sensor provided in an embodiment of this application;
[0043] Figure 4 is a schematic diagram of the interference suppression device for a photoelectric leakage sensor provided in an embodiment of this application;
[0044] Figure 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0045] The core of this application is to provide an interference suppression method for a photoelectric leakage sensor. This interference suppression method can more accurately and effectively suppress interference in the photoelectric leakage sensor, thereby ensuring its working accuracy. Another core aspect of this application is to provide an interference suppression device, electronic device, computer-readable storage medium, and photoelectric leakage sensor, all of which have the aforementioned beneficial effects.
[0046] To provide a clearer and more complete description of the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0047] This application provides an interference suppression method for a photoelectric leakage sensor.
[0048] First, please refer to Figure 1, which is a schematic diagram of a photoelectric leakage sensor provided in an embodiment of this application. This photoelectric leakage sensor mainly includes a microcontroller, a signal generating device, a light-emitting device, and a voltage sampling device, all electrically connected to the microcontroller (the signal generating device and voltage sampling device can be deployed inside the microcontroller). The signal generating device generates a pulse width modulation (PWM) signal. The light-emitting device performs a lighting and extinguishing action according to the PWM signal, so as to form a lighting window and an extinguishing window within the same PWM cycle. The lighting action corresponds to emitting a light signal to form a lighting window; the extinguishing action corresponds to stopping the emission of a light signal to form an extinguishing window. The voltage sampling device collects voltage signals in the lighting and extinguishing windows respectively. The voltage signal collected in the lighting window is the lighting voltage, generated by converting the lighting light signal of the lighting window; the voltage signal collected in the extinguishing window is the extinguishing voltage, generated by converting the extinguishing light signal of the extinguishing window.
[0049] Further, please refer to Figure 2, which is a flowchart illustrating an interference suppression method for a photoelectric leakage sensor provided in an embodiment of this application. This interference suppression method for a photoelectric leakage sensor is applied to the microcontroller shown in Figure 1 and may include, but is not limited to, the following S101~S103.
[0050] S101: The control signal generating device outputs a pulse width modulation signal so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation cycle.
[0051] This step aims to use a PWM signal to control a light-emitting device (such as an infrared LED) to sequentially light up and turn off within the same PWM cycle, thereby creating a lighting window and an off window within the same PWM cycle. As mentioned above, the microcontroller can have a built-in signal generator (PWM signal generator), which can output a stable PWM signal and set the lighting window and off window within the same PWM cycle, thereby controlling the light-emitting device to perform the lighting action during the lighting window and the off action during the off window.
[0052] In this design, the light-emitting device can be controlled by the microcontroller's PWM signal to periodically illuminate with a low duty cycle. This means that within a complete PWM cycle, the proportion of time the light-emitting device is illuminated is significantly less than the proportion of time it is off (the illumination window duration is much shorter than the off window duration). For example, within a 100ms PWM cycle, setting the light-emitting device's duty cycle to 1% means 1ms of illumination followed by 99ms of off. This design facilitates the division of the bright-state sampling window (illumination window) and the dark-state sampling window (off window) within the same PWM cycle. This allows for improved resistance to ambient light interference in conjunction with subsequent differential sampling. It also helps reduce the average power consumption and heat generation of the photoelectric leakage sensor, thereby minimizing drift caused by temperature rise. Of course, the specific values of the positions and duty cycles of the two sampling windows within the same PWM cycle can be set by technicians according to actual conditions, and the photoelectric leakage sensor provides a memory device for configurability.
[0053] S102: Use a voltage sampling device to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window, and collect the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window.
[0054] This step aims to acquire the lighting and extinguishing voltages using a voltage sampling device. The lighting voltage is the voltage generated based on the lighting light signal during the lighting window, and the extinguishing voltage is the voltage generated based on the extinguishing light signal during the extinguishing window. The lighting and extinguishing light signals can be acquired by a photosensitive device (such as a photodiode or photoresistor), which can also be electrically connected to a microcontroller. When the light-emitting device is lit, the photosensitive device can acquire the corresponding lighting light signal; when the light-emitting device is extinguished, the photosensitive device can acquire the corresponding extinguishing light signal.
[0055] As described above, the microcontroller can have a built-in voltage sampling device, which can control the voltage sampling device to collect the lighting voltage in the lighting window and the extinguishing voltage in the extinguishing window. Specifically, the voltage sampling device can be an analog-to-digital converter (ADC) and is connected to the light-emitting device through hardware circuitry. Based on this hardware circuitry and the ADC, the light signal collected by the photosensitive device can be converted into an electrical signal and then into a digital signal to obtain the lighting voltage corresponding to the lighting signal and the extinguishing voltage corresponding to the extinguishing signal.
[0056] In the implementation process, the PWM signal generating device can have a built-in counter and timer. The counter is used to locate the PWM signal to accurately determine which point in the current PWM cycle (light-up window / light-down window) it is currently in; the timer can detect the counter with microsecond-level granularity, and when its count falls into the light-up window or light-down window, it triggers the analog-to-digital converter (ADC) to sample the voltage, and then the main loop completes the reading of the sampled voltage.
[0057] S103: Differential voltage value is obtained by differential calculation of the lighting voltage and the extinguishing voltage, so as to suppress the ambient light background component and zero-point drift component that are superimposed on the lighting voltage and the extinguishing voltage, thereby realizing the interference suppression of the photoelectric leakage sensor.
[0058] This step aims to calculate the differential voltage value by differentially calculating the lighting voltage and the extinguishing voltage, effectively superimposing the ambient light background component and zero-point drift component in both the lighting and extinguishing voltages. The voltage difference between the lighting and extinguishing voltages is the differential voltage value. It can be understood that both the lighting and extinguishing voltages contain ambient light background components and circuit zero-point drift components. By performing differential calculations on the lighting and extinguishing voltages, the superimposed background and drift components can be significantly canceled, thereby improving anti-interference capability and decision stability.
[0059] As can be seen, the interference suppression method for the photoelectric leakage sensor provided in this application embodiment offers a photoelectric leakage sensor with a microcontroller as its core. Based on this microcontroller, a signal generation device can output a PWM signal, simultaneously controlling the light-emitting device to sequentially light up and turn off within the same PWM cycle. This allows the formation of a lighting window and a extinguishing window within the same PWM cycle. Furthermore, the voltage sampling device can be controlled to acquire the lighting voltage generated by the conversion of the lighting light signal in the lighting window and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window. Thus, by performing differential calculations on the lighting and extinguishing voltages, the differential voltage value obtained can significantly suppress the ambient light background component and zero-point drift component simultaneously superimposed on the lighting and extinguishing voltages, thereby achieving interference suppression for the photoelectric leakage sensor. In other words, it completes aligned dual-window (lighting and extinguishing window) sampling and differential calculation within the same PWM cycle, suppressing interference at its source. Therefore, this technical solution can more accurately and effectively suppress interference in the photoelectric leakage sensor, thereby ensuring its working accuracy.
[0060] Based on the above embodiments:
[0061] In one embodiment of this application, the interference suppression method of the photoelectric leakage sensor may further include: when the differential voltage value is lower than the dynamic threshold within a first preset number of pulse width modulation cycles, outputting a leakage alarm; and when the differential voltage value is higher than the sum of the dynamic threshold and the preset hysteresis difference value within a second preset number of pulse width modulation cycles, deactivating the leakage alarm.
[0062] In the actual operation of the photoelectric leak sensor, to effectively avoid boundary jitter and instantaneous interference, this application proposes a strategy of setting hysteresis and triggering or deactivating the alarm only after the judgment conditions are met for several consecutive cycles. In other words, the condition for the photoelectric leak sensor to change from a normal state (non-alarm state) to an alarm state (outputting a leak alarm prompt) is that the differential voltage value in multiple (first preset number) PWM cycles is lower than the dynamic threshold; the condition for the photoelectric leak sensor to change from an alarm state to a normal state (deactivating the leak alarm prompt) is that the differential voltage value in multiple (second preset number) PWM cycles is higher than the sum of the dynamic threshold and the preset hysteresis value. The specific values of the first preset number, the second preset number, and the preset hysteresis value can all be set by technicians according to actual conditions, and the photoelectric leak sensor is configurable.
[0063] The method for determining the dynamic threshold may include: under preset stable conditions, statistically analyzing differential voltage value samples within a third preset number of pulse width modulation cycles; calculating the mean of all differential voltage value samples to obtain the baseline differential voltage value; when the difference between the baseline differential voltage value and the preset voltage margin value is not lower than the preset minimum threshold, the difference between the baseline differential voltage value and the preset voltage margin value is used as the dynamic threshold; when the difference between the baseline differential voltage value and the preset voltage margin value is lower than the preset minimum threshold, the preset minimum threshold is used as the dynamic threshold.
[0064] Understandably, a dynamic threshold is a threshold that can be dynamically updated. By dynamically updating the threshold for judging differential voltage values, the self-learning threshold can adapt to slow background changes, avoiding the mislearning of anomalies as background. It should be noted that the calculation of the dynamic threshold needs to be performed under pre-set stable conditions to effectively ensure the accuracy of the dynamic threshold value, thereby guaranteeing the working accuracy of the photoelectric leakage sensor. Specifically, under preset stable conditions, differential voltage value samples within multiple (a third preset number) PWM cycles can be statistically analyzed and averaged to obtain a baseline differential voltage value. When the baseline differential voltage value - preset voltage margin value ≥ preset minimum threshold, the difference between the baseline differential voltage value and the preset voltage margin value can be used as the current dynamic threshold; otherwise, the preset minimum threshold can be directly used as the current dynamic threshold. Similarly, the specific values of the third preset number, preset voltage margin value, and preset minimum threshold can all be set by technicians according to actual conditions, and the photoelectric leakage sensor supports configuration.
[0065] The preset stability conditions can include: the photoelectric leakage sensor is in a working state where it does not output a leakage alarm; all differential voltage value samples are within a preset threshold range; and the dispersion of a third preset number of differential voltage value samples is lower than a preset dispersion. The dispersion characterizes the degree of fluctuation of the differential voltage value samples and can be any one of the standard deviation, range, or absolute deviation of the median, or an equivalent statistic. Clearly, these preset stability conditions can effectively ensure the accuracy of the dynamic threshold value, thereby guaranteeing the working accuracy of the photoelectric leakage sensor. Of course, the specific values of the preset threshold range and preset dispersion can also be set by technicians according to actual conditions, and the photoelectric leakage sensor supports configuration.
[0066] Furthermore, the interference suppression method for the photoelectric leakage sensor can also include: when the photoelectric leakage sensor is operating under preset stable conditions, performing an update operation on the dynamic threshold at preset time intervals; when the photoelectric leakage sensor is not operating under preset stable conditions, stopping the update operation on the dynamic threshold. In other words, the update of the dynamic threshold also needs to be performed under preset stable conditions to effectively ensure the accuracy of the dynamic threshold value, thereby ensuring the working accuracy of the photoelectric leakage sensor. In this case, the preset stable conditions can further include: the ambient light intensity is lower than a preset intensity to avoid performing dynamic threshold updates under strong light conditions; simultaneously, when the ambient light intensity is not lower than the preset intensity, the photoelectric leakage sensor can be forced not to alarm, effectively reducing the false alarm rate of the photoelectric leakage sensor under strong light conditions. In other words, when the ambient light intensity meets the preset strong light criterion, the sensor enters a strong light state and performs at least one of the following: forcibly not outputting a leakage alarm prompt, clearing the alarm count, or stopping the dynamic threshold update; when the ambient light intensity drops and stabilizes for a preset period, the sensor exits the strong light state and resumes judgment and threshold updates.
[0067] Furthermore, the interference suppression method of the photoelectric leakage sensor may also include: performing a reset operation according to the reset signal when a reset signal is received from the hardware watchdog; the reset signal is sent to the microcontroller by the hardware watchdog when it does not receive a timed dog-feeding signal from the microcontroller; and / or, performing a reset operation when the self-test operation fails.
[0068] This application embodiment can also realize the abnormal self-recovery function of the photoelectric leakage sensor. On the one hand, a hardware watchdog can be connected to the microcontroller, and the microcontroller can periodically send a feeding signal to the hardware watchdog to ensure the normal operation of the microcontroller. Then, when the hardware watchdog fails to receive the feeding signal sent by the microcontroller at the regular interval, it can be determined that the microcontroller has an operational abnormality, and a reset signal can be sent to the microcontroller to make it perform a reset operation. On the other hand, the microcontroller can have its own timed self-test function. When the self-test operation fails, it can also automatically perform a reset operation. Furthermore, after the microcontroller performs a reset operation, it can also set its own output to a default safe state, such as a no-alarm state, or an alarm indicator showing a standby / normal state, to avoid uncertain output states, that is, to avoid false alarms.
[0069] Finally, referring to Figure 3, which illustrates another photoelectric leakage sensor provided in this application, the photoelectric leakage sensor includes a microcontroller (MCU) and its corresponding power supply and protection circuit, an industrial interface output module, a transmitting device (light-emitting device) and a receiving device (photosensitive device) connected to the microcontroller, and a PWM signal generator and an analog-to-digital converter (ADC) built into the microcontroller. In its specific functional implementation, the photoelectric leakage sensor includes a transmitting and receiving optical module, an aligned sampling and differential acquisition module, a self-learning threshold module, a threshold and state determination module, a system configurable and traceable module, and an industrial interface module. The functions of each module are implemented as follows:
[0070] (1) Alignment sampling and differential acquisition module: The microcontroller reads the PWM counter, sets the lighting window and the extinguishing window in the same PWM cycle, controls the analog-to-digital converter (ADC) to read the receiving end voltage in the two inner windows respectively, and subtracts the sampling voltage of the lighting window from the sampling voltage of the extinguishing window to form a differential value, thereby canceling the DC component of ambient light and zero drift from the source.
[0071] (2) Self-learning threshold module: Under stable conditions where no alarm occurs, the differential value is within the protection zone range, and the dispersion is lower than the threshold, the baseline differential value is obtained by statistically analyzing the differential values over several periods. Then, the baseline differential value is subtracted by a preset margin, ensuring that the result is not lower than the preset minimum threshold, thereby determining the dynamic threshold. In the event of an alarm or an increase in dispersion, the update is stopped and the current threshold is maintained until the conditions stabilize. The threshold update operation is then resumed.
[0072] (3) Threshold and status determination module: compare the difference value with the dynamic threshold; in this process, in order to avoid boundary jitter, a hysteresis can be set, and an alarm or alarm status can be triggered only after the determination conditions are met for several consecutive cycles.
[0073] (4) System configurable and traceable modules: parameters such as minimum threshold, preset margin, continuous cycle counting threshold, guard band width, and the position and beat of the two sampling windows can all be written and stored; in addition, the debugging interface can output the lighting sampling voltage, the extinguishing sampling voltage, the differential value, the dynamic threshold and status information, which facilitates parameter setting, parameter verification, on-site maintenance and quality traceability.
[0074] (5) Industrial Interface Module: A transistor pull-down output or transistor pull-up output is provided on the same printed circuit board according to the assembly scheme. A transient overvoltage suppression device is connected in parallel between the output terminal and ground, and a series resistor is set. The above interface assembly and protection connection method can be used to be compatible with different external input types and improve the port's anti-static and transient interference capabilities. Specifically, a transistor pull-down output or transistor pull-up output is provided on the same printed circuit board according to the assembly scheme to be compatible with the digital input types of different controllers, PLCs, or acquisition modules. A transient overvoltage suppression device is connected in parallel at the output terminal, and a series resistor is set to improve the port's tolerance to electrostatic and transient interference and reduce the risk of malfunction.
[0075] (6) Abnormal self-recovery function: The reliable operation of the program is ensured by hardware watchdog and self-test strategy. When an abnormality occurs, a reset operation can be performed and the output can be placed in a pre-agreed safe default state.
[0076] (7) Strong light interference resistance: Based on the alignment of sampling and differential sampling within the same PWM cycle, a strong light state machine is set up. Once the strong light criterion is met, the system enters the strong light state, during which it forces no alarm, resets the counter to zero, and pauses self-learning threshold updates, etc., to avoid writing abnormal strong light into the baseline and triggering false alarms. When the sampled value falls back and remains stable for several cycles, the system automatically exits the strong light state and resumes normal judgment and self-learning updates. This solution can maintain stable operation in scenarios such as direct flashlight illumination, strong backlight, and direct illumination from on-site maintenance lights, and significantly reduces the risk of false alarms.
[0077] In summary, the interference suppression method for the photoelectric leakage sensor provided in this application has the following technical advantages:
[0078] (1) Robust disturbance suppression: The dual-window aligned sampling and differential calculation in the same PWM cycle significantly reduces the influence of ambient light and zero drift.
[0079] (2) Long-term stability: The self-learning threshold is updated slowly under stable conditions, and the update stops and the current threshold is maintained when an alarm occurs or the dispersion increases, so as to avoid abnormal learning as background.
[0080] (3) Low false alarms: Hysteresis and continuous periodic counting can effectively suppress boundary jitter and instantaneous interference.
[0081] (4) Configurable and traceable: Parameters can be written and stored, and debugging data can be sent out, which facilitates parameter management, maintenance diagnosis and quality traceability.
[0082] (5) Engineering adaptation: Industrial interface assembly is optional, and port-level electrostatic and transient interference suppression facilitates deployment in chemical and building scenarios.
[0083] (6) Low power consumption and small size: Utilizing low duty cycle emission and simple circuitry, it is suitable for sealed and space-constrained applications.
[0084] (7) Strong light resistance: By aligning sampling with the same PWM cycle and combining the strong light state machine with differential distribution, the interference of direct strong light and bright background can be suppressed in a coordinated manner; when strong light appears, no alarm is triggered and learning is temporarily suspended, and the system recovers smoothly after the strong light fades, which can significantly reduce the false alarm rate under strong light conditions.
[0085] This application provides a photoelectric leakage sensor.
[0086] As shown in Figure 1, the photoelectric leakage sensor provided in this application embodiment may include a microcontroller, a signal generating device, a light-emitting device, and a voltage sampling device, all of which are electrically connected to the microcontroller.
[0087] A microcontroller is used to control the output of a pulse width modulation signal from a signal generation device, so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation period. A voltage sampling device is used to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window. The lighting voltage and the extinguishing voltage are differentially calculated to obtain the differential voltage value, so as to suppress the ambient light background component and zero-point drift component that are superimposed on the lighting voltage and the extinguishing voltage, thereby realizing the interference suppression of the photoelectric leakage sensor.
[0088] As can be seen, the photoelectric leakage sensor provided in this application embodiment, with a microcontroller as its core, can use a signal generation device to output a PWM signal and simultaneously control the light-emitting device to sequentially light up and turn off within the same PWM cycle, so as to form a lighting window and a extinguishing window within the same PWM cycle. This allows the voltage sampling device to collect the lighting voltage generated by the lighting light signal in the lighting window and the extinguishing voltage generated by the extinguishing light signal in the extinguishing window. Therefore, by performing differential calculations on the lighting and extinguishing voltages, the differential voltage value obtained can significantly suppress the ambient light background component and zero-point drift component that are simultaneously superimposed on the lighting and extinguishing voltages, thereby achieving interference suppression for the photoelectric leakage sensor. In other words, by completing aligned dual-window (lighting and extinguishing window) sampling and differential calculation within the same PWM cycle, interference is suppressed at its source. Therefore, this technical solution can more accurately and effectively suppress interference in the photoelectric leakage sensor, thus ensuring its working accuracy.
[0089] For a description of the photoelectric leakage sensor provided in the embodiments of this application, please refer to the above method embodiments; further details will not be repeated here.
[0090] This application provides an interference suppression device for a photoelectric leakage sensor.
[0091] Please refer to Figure 4, which is a schematic diagram of the structure of an interference suppression device for a photoelectric leakage sensor provided in an embodiment of this application. This interference suppression device for the photoelectric leakage sensor is applied to a microcontroller deployed in the photoelectric leakage sensor and may include:
[0092] Control module 1 is used to control the signal generating device to output a pulse width modulation signal so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation cycle;
[0093] Sampling module 2 is used to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window using a voltage sampling device.
[0094] The calculation module 3 is used to perform differential calculation on the lighting voltage and the extinguishing voltage to obtain a differential voltage value, so as to suppress the ambient light background component and zero-point drift component that are simultaneously superimposed on the lighting voltage and the extinguishing voltage, thereby realizing the interference suppression of the photoelectric leakage sensor.
[0095] As can be seen, the interference suppression device for the photoelectric leakage sensor provided in this application embodiment offers a photoelectric leakage sensor with a microcontroller as its core. Based on this microcontroller, a signal generation device can output a PWM signal, simultaneously controlling the light-emitting device to sequentially light up and turn off within the same PWM cycle. This allows the formation of a lighting window and a extinguishing window within the same PWM cycle. Furthermore, the voltage sampling device can be controlled to acquire the lighting voltage generated by the conversion of the lighting light signal in the lighting window and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window. Thus, by performing differential calculations on the lighting and extinguishing voltages, the differential voltage value obtained can significantly suppress the ambient light background component and zero-point drift component simultaneously superimposed on the lighting and extinguishing voltages, thereby achieving interference suppression for the photoelectric leakage sensor. In other words, it completes aligned dual-window (lighting and extinguishing window) sampling and differential calculation within the same PWM cycle, suppressing interference at its source. Therefore, this technical solution can more accurately and effectively suppress interference in the photoelectric leakage sensor, thereby ensuring its working accuracy.
[0096] In one embodiment of this application, the interference suppression device of the photoelectric leakage sensor may further include an alarm processing module, which is used to output a leakage alarm when the differential voltage value is lower than the dynamic threshold within a first preset number of pulse width modulation cycles; and to deactivate the leakage alarm when the differential voltage value is higher than the sum of the dynamic threshold and the preset hysteresis difference value within a second preset number of pulse width modulation cycles.
[0097] In one embodiment of this application, the interference suppression device of the photoelectric leakage sensor may further include a threshold determination module, used to statistically analyze differential voltage value samples within a third preset number of pulse width modulation cycles under preset stable conditions; calculate the mean of all differential voltage value samples to obtain a baseline differential voltage value; when the difference between the baseline differential voltage value and a preset voltage margin value is not lower than a preset minimum threshold, the difference between the baseline differential voltage value and the preset voltage margin value is used as a dynamic threshold; when the difference between the baseline differential voltage value and the preset voltage margin value is lower than a preset minimum threshold, the preset minimum threshold is used as a dynamic threshold.
[0098] In one embodiment of this application, the aforementioned preset stability conditions may include: the photoelectric leakage sensor is in a working state where it does not output a leakage alarm; all differential voltage value samples are within a preset threshold range; and the dispersion of a third preset number of differential voltage value samples is lower than a preset dispersion.
[0099] In one embodiment of this application, the interference suppression device of the photoelectric leakage sensor may further include an update module, which is used to perform an update operation on the dynamic threshold at a preset time interval when the photoelectric leakage sensor is operating under preset stable conditions; and to stop performing the update operation on the dynamic threshold when the photoelectric leakage sensor is not operating under preset stable conditions.
[0100] In one embodiment of this application, the interference suppression device of the photoelectric leakage sensor may further include a reset module, which is used to perform a reset operation according to the reset signal when a reset signal is received from the hardware watchdog; the reset signal is sent by the hardware watchdog to the microcontroller when it does not receive a timed dog-feeding signal from the microcontroller; and / or, to perform a reset operation when the self-test operation fails.
[0101] For a description of the apparatus provided in the embodiments of this application, please refer to the above method embodiments; further details will not be repeated here.
[0102] This application provides an electronic device.
[0103] Please refer to Figure 5, which is a schematic diagram of the structure of an electronic device provided in this application. The electronic device may include:
[0104] Memory 11 is used to store computer programs;
[0105] The processor 10 is configured to execute a computer program to implement the steps of any of the above-described methods for suppressing interference in a photoelectric leakage sensor.
[0106] Figure 5 shows a schematic diagram of the electronic device's structure. The electronic device may include: a processor 10, a memory 11, a communication interface 12, and a communication bus 13. The processor 10, memory 11, and communication interface 12 all communicate with each other through the communication bus 13.
[0107] In this embodiment, the processor 10 may be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic devices.
[0108] The processor 10 can call the program stored in the memory 11. Specifically, the processor 10 can execute the operations in the embodiment of the interference suppression method for the photoelectric leakage sensor.
[0109] The memory 11 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment, the memory 11 stores at least a program for implementing the following functions:
[0110] The control signal generating device outputs a pulse width modulation signal so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation period; the voltage sampling device collects the lighting voltage generated by the conversion of the lighting light signal in the lighting window and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window; the differential voltage value is obtained by differential calculation of the lighting voltage and the extinguishing voltage to suppress the ambient light background component and the zero-point drift component that are superimposed on the lighting voltage and the extinguishing voltage, thereby realizing the interference suppression of the photoelectric leakage sensor.
[0111] In one possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.
[0112] In addition, memory 11 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.
[0113] Communication interface 12 can be an interface for the communication module, used to connect with other devices or systems.
[0114] Of course, it should be noted that the structure shown in Figure 5 does not constitute a limitation on the electronic device in the embodiments of this application. In practical applications, the electronic device may include more or fewer components than those shown in Figure 5, or combine certain components.
[0115] This application provides a computer-readable storage medium.
[0116] The computer-readable storage medium provided in this application embodiment stores a computer program, which, when executed by a processor, can implement the steps of any of the above-described methods for suppressing interference in a photoelectric leakage sensor.
[0117] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0118] For a description of the computer-readable storage medium provided in this application, please refer to the above method embodiments; further details will not be repeated here.
[0119] The various embodiments in this specification are described 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. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0120] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0121] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0122] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the methods and core ideas of this application. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of this application.
Claims
1. A method for suppressing interference in a photoelectric leakage sensor, characterized in that, A microcontroller deployed in the photoelectric leakage sensor includes: a control signal generating device outputting a pulse width modulation signal so that the light-emitting device is in a lighting window and an extinguishing window respectively within the same pulse width modulation period; a voltage sampling device acquiring a lighting voltage generated by converting the lighting light signal in the lighting window and an extinguishing voltage generated by converting the extinguishing light signal in the extinguishing window; and performing differential calculation on the lighting voltage and the extinguishing voltage to obtain a differential voltage value, so as to suppress the ambient light background component and zero-point drift component superimposed on the lighting voltage and the extinguishing voltage, thereby achieving interference suppression of the photoelectric leakage sensor.
2. The interference suppression method for the photoelectric leakage sensor according to claim 1, characterized in that, Also includes: When the differential voltage value is lower than the dynamic threshold for a first preset number of pulse width modulation cycles, a leakage alarm is output. When the differential voltage value is higher than the sum of the dynamic threshold and the preset hysteresis difference value within a second preset number of pulse width modulation cycles, the leakage alarm is deactivated.
3. The interference suppression method for the photoelectric leakage sensor according to claim 2, characterized in that, The dynamic threshold is determined by: under a preset stable condition, statistically analyzing differential voltage value samples within a third preset number of pulse width modulation cycles; calculating the mean of all differential voltage value samples to obtain a baseline differential voltage value; when the difference between the baseline differential voltage value and a preset voltage margin value is not lower than a preset minimum threshold, the difference between the baseline differential voltage value and the preset voltage margin value is used as the dynamic threshold; when the difference between the baseline differential voltage value and the preset voltage margin value is lower than the preset minimum threshold, the preset minimum threshold is used as the dynamic threshold.
4. The interference suppression method for the photoelectric leakage sensor according to claim 3, characterized in that, The preset stability conditions include: the photoelectric leakage sensor is in a working state where it does not output the leakage alarm prompt; all differential voltage value samples are within a preset threshold range; and the dispersion of the third preset number of differential voltage value samples is lower than the preset dispersion.
5. The interference suppression method for the photoelectric leakage sensor according to claim 3, characterized in that, Also includes: When the photoelectric leakage sensor operates under the preset stable conditions, it performs an update operation on the dynamic threshold at preset time intervals. When the photoelectric leakage sensor is not operating under the preset stable conditions, the update operation regarding the dynamic threshold is stopped.
6. The interference suppression method for the photoelectric leakage sensor according to claim 1, characterized in that, Also includes: When a reset signal is received from the hardware watchdog, a reset operation is performed according to the reset signal; the reset signal is sent by the hardware watchdog to the microcontroller when it does not receive a timed dog-feeding signal from the microcontroller; and / or, the reset operation is performed when the self-test operation fails.
7. A photoelectric leakage sensor, characterized in that, The system includes a microcontroller, a signal generating device, a light-emitting device, and a voltage sampling device, all electrically connected to the microcontroller. The microcontroller controls the signal generating device to output a pulse width modulation signal, so that the light-emitting device is in a lighting window and an off window respectively within the same pulse width modulation period. The voltage sampling device collects the lighting voltage generated by the lighting light signal in the lighting window and the off voltage generated by the off light signal in the off window. The differential voltage value is obtained by performing differential calculation on the lighting voltage and the extinguishing voltage to suppress the ambient light background component and zero-point drift component that are simultaneously superimposed on the lighting voltage and the extinguishing voltage, thereby achieving interference suppression of the photoelectric leakage sensor.
8. An interference suppression device for a photoelectric leakage sensor, characterized in that, A microcontroller deployed in the photoelectric leakage sensor includes: a control module for controlling a signal generating device to output a pulse width modulation signal, so that the light-emitting device is in the lighting window and the extinguishing window respectively within the same pulse width modulation period; a sampling module for using a voltage sampling device to collect the lighting voltage generated by the conversion of the lighting light signal in the lighting window, and the extinguishing voltage generated by the conversion of the extinguishing light signal in the extinguishing window; and a calculation module for performing differential calculation on the lighting voltage and the extinguishing voltage to obtain a differential voltage value, so as to suppress the ambient light background component and zero-point drift component superimposed on the lighting voltage and the extinguishing voltage, thereby realizing interference suppression of the photoelectric leakage sensor.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the interference suppression method for the photoelectric leakage sensor as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the interference suppression method for the photoelectric leakage sensor as described in any one of claims 1 to 6.