Multi-threshold sensor detection system and method based on cooperation of hardware comparator and software
This multi-threshold sensor detection system, which combines hardware comparators with software collaboration, solves the problems of response delay and reliability in sensor detection systems. It enables fast and reliable multi-threshold judgment and remote communication, while reducing system power consumption and cost.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-05
- Publication Date
- 2026-03-13
AI Technical Summary
Existing sensor detection systems present a trade-off between response speed and reliability. Software-based judgment is flexible but carries a high risk of latency, while hardware-based judgment is fast but lacks the ability to accurately measure and transmit data remotely.
A multi-threshold sensor detection system employing hardware comparators and software collaboration includes sensor signal acquisition, hardware threshold comparison, status indication, microprocessor module, and wireless communication module. It achieves fast and reliable multi-threshold judgment through hardware parallel comparison and precise software processing.
It achieves fast response and reliable multi-threshold alarms, while taking into account accurate measurement and remote communication, reducing system power consumption and cost.
Smart Images

Figure CN121655593A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a multi-threshold sensor detection system and method, belonging to the field of integrated circuit and sensor detection technology. Background Technology
[0002] In fields such as environmental monitoring, industrial safety, and smart homes, sensor detection systems are widely used to detect various physical and chemical quantities, such as gas concentration, temperature, and humidity. Because sensor output signals are typically weak and require differentiation of different state levels, signal amplification and multi-threshold judgment are necessary.
[0003] Existing multi-threshold detection schemes mainly fall into two categories: one is software judgment based entirely on sampling by the microprocessor via ADC. While this approach is flexible, its response speed is limited by the program's runtime, and it carries the risk of response delay or even failure when the system is busy, crashes, or is subject to interference, resulting in low reliability. The other approach uses multiple independent voltage comparators for hardware judgment. This approach has a fast response speed, but it cannot obtain precise sensor values and is also difficult to achieve remote data transmission and complex logic processing.
[0004] Therefore, there is an urgent need in this field for a sensor detection system that can achieve fast and reliable multi-threshold alarms, as well as accurate measurement and remote communication. Summary of the Invention
[0005] To address the issues of response delay, software-dependent reliability, and inability to simultaneously achieve rapid alarm and accurate measurement in traditional sensor detection systems, this invention proposes a multi-threshold sensor detection system and method based on hardware comparators and software collaboration.
[0006] The technical solution adopted by the present invention to solve the above problems is as follows: The multi-threshold sensor detection system based on hardware comparator and software collaboration of the present invention includes a sensor signal acquisition module, a hardware threshold comparison module, a status indication module, a microprocessor module and a wireless communication module; Sensor signal acquisition module, used to acquire sensor signals; The hardware threshold comparison module has its input connected to the output of the sensor signal acquisition unit. The hardware multi-threshold comparison unit is configured to perform parallel and independent threshold comparisons on the sensor signal and output comparison results of at least two levels. A status indication module is connected to the output of the hardware multi-threshold comparison unit and is used to provide a visual gear position indication based on the comparison result. The microprocessor module has its input terminal connected to the output terminal of the sensor signal acquisition unit, and is used to sample and digitize the sensor signal; The wireless communication module is connected to the microprocessor unit via data connection.
[0007] Furthermore, the hardware multi-threshold comparison module includes at least one voltage comparator. The inverting input of the voltage comparator receives the divided sensor signal, and the non-inverting input is connected to an adjustable reference voltage source. The adjustable reference voltage source is generated by adjusting a potentiometer. Furthermore, the status indication module includes multiple light-emitting diodes (LEDs), and the output of the hardware multi-threshold comparison module drives the LEDs through a switching circuit.
[0008] Furthermore, the switching circuit is a PNP transistor. The emitter of the PNP transistor is connected to the power supply, the collector of the PNP transistor is connected to the cathode of the light-emitting diode (LED), and the base of the PNP transistor is connected to the output terminal of the hardware multi-threshold comparison unit through a resistor.
[0009] Furthermore, it also includes a level conversion circuit. The digital output of the sensor signal acquisition unit is connected to the GPIO input of the microprocessor unit through the level conversion circuit. The level conversion circuit is implemented using a PNP transistor.
[0010] Furthermore, the wireless communication module is a Bluetooth communication module.
[0011] The microprocessor unit is configured to be woken from sleep mode and start the wireless communication unit when the hardware multi-threshold comparison unit outputs a specified comparison result.
[0012] The steps of the multi-threshold sensor detection method based on hardware comparator and software collaboration described in this invention include: Step 1: Perform real-time, parallel threshold comparison of sensor signals using a hardware multi-threshold comparison module, and directly drive the status indication module. Step 2: The same sensor signal is synchronously sampled and digitized using an ADC through a microprocessor module; Step 3: The digitized data is transmitted via the wireless communication module through the microprocessor module.
[0013] The beneficial effects of this invention are: 1. This invention features high reliability and fast response: It achieves multi-threshold judgment and alarm through an independent hardware comparator path, with fast response speed and no dependence on the software state of the microprocessor, fundamentally avoiding alarm failure caused by program abnormalities and greatly improving the reliability of the system. 2. Functional Synergy: Adopting a dual-path architecture of "parallel hardware judgment + precise software processing", it ensures rapid alarm while not affecting the microprocessor's accurate measurement and digitization of sensor signals, thus achieving optimal functional synergy. 3. Low power consumption: The output of the hardware comparator can be used as the interrupt wake-up source for the microprocessor, so that the system can be in a low-power sleep mode most of the time, which significantly reduces the overall power consumption of the system. 4. The invention has a simple structure and low cost: a high-performance system is built using conventional general-purpose components, and the complex software algorithm or dedicated chip is replaced by a clever circuit architecture design, which reduces the implementation cost. Attached Figure Description
[0014] Figure 1 This is a schematic diagram of the system power supply, microcontroller core, and basic status indicator circuit in a specific embodiment of the present invention. Figure 2 This is a schematic diagram of the Bluetooth wireless communication module interface circuit in a specific embodiment of the present invention. Figure 3 This is a schematic diagram of the two-channel gas sensor interface and signal processing circuit in a specific embodiment of the present invention. Figure 4 This is a schematic diagram of an adjustable multi-threshold detection and indication circuit based on a hardware comparator in a specific embodiment of the present invention. Figure 5 This is a schematic diagram of the program download and debugging interface circuit in a specific embodiment of the present invention. Detailed Implementation
[0015] Specific implementation method one: as follows Figure 1 As shown, a multi-threshold sensor detection system based on hardware comparator and software collaboration is described. The power management of the system is implemented by a voltage regulator chip IC1 (AMS1117-3.3), which converts the external +5V power supply to a stable +3.3V to power the system. Multiple filter capacitors (C1-C3, C19-C24) are distributed in the power network for decoupling and voltage stabilization. The microcontroller unit adopts chip U1 (STM32F103C8T6), whose minimum system includes a clock circuit composed of crystal oscillator Y1 (8MHz) and load capacitors C17 and C18, and a reset circuit composed of resistor R1 and capacitor C19, which is the basis for the operation of the microcontroller. The basic status indicator circuit is composed of light-emitting diodes LD1-LD4 and current-limiting resistors R3-R5, which are directly connected to the +3.3V power supply to serve as a visual indication of system power-on.
[0016] Specific implementation method two: such as Figure 2As shown, the VCC and GND pins of the Bluetooth communication module U2 (VG6328A) are connected to +3.3V and GND respectively; its serial communication pins TXD and RXD are cross-connected to the PA10 (RXD) and PA9 (TXD) pins of the microcontroller U1 respectively to achieve bidirectional data pass-through; the module's status indicator pin LED is connected to the microcontroller through a current-limiting resistor R8, which can be used by the program to query the status; at the same time, this pin drives an external indicator light LD5 (GREEN). When the module is successfully connected and the LED pin outputs a low level, LD5 lights up, providing the user with visual connection status feedback.
[0017] Specific implementation method three: such as Figure 3 As shown, a multi-threshold sensor detection system based on hardware comparator and software collaboration is designed with two identical and independent gas sensor interfaces (P3, P4). Taking the first channel as an example: the analog output (AO) of the sensor is level-adapted by a voltage divider circuit composed of resistors R12 and R13, and then sent to pin PA5 of microcontroller U1 for precise analog-to-digital conversion by its ADC module; the digital output (DO) of the sensor is connected to a level conversion and driving circuit composed of PNP transistor Q1 (SS8550); when When the sensor detects a specific gas (signal present), DO outputs a high level, Q1 is cut off, and the microcontroller's PA4 pin is pulled up to a high level by resistor R9. When the detection is normal (no signal), DO outputs a low level, Q1 is turned on, which pulls the PA4 pin low and provides a current path for the alarm indicator LD6 (YELLOW), causing it to light up. The second sensor interface works in exactly the same way as the first one, with its signals connected to the microcontroller's PA7 (AO1) and PA6 (DO1) pins, respectively, and driving the indicator LD7.
[0018] Specific implementation method four: such as Figure 4 As shown, the adjustable multi-threshold detection and indication circuit based on hardware comparators realizes the multi-level detection function in pure hardware; it consists of two dual operational amplifiers U3 and U4 (LM358), each of which is connected as an independent voltage comparator.
[0019] Taking U3A as an example, its working principle is explained as follows: Its inverting input terminal (pin 2) receives an input signal (V-) proportional to the measured physical quantity (such as resistance) through a voltage divider network composed of resistor R22, adjustable resistor RP2, and resistor R21; its non-inverting input terminal (pin 3) obtains an adjustable reference voltage (V+) through a voltage divider network composed of resistor R20, adjustable resistor RP1, and resistor R19; by precisely adjusting potentiometers RP1 and RP2, a precise trigger threshold (e.g., 100Ω and 300Ω) can be set; when the input signal voltage V- is higher than the reference voltage V+, the comparator outputs a low level, thereby driving the subsequent indicator circuit to light up, realizing multi-level, delay-free, and highly reliable indication. This circuit works independently of the microcontroller.
[0020] Specific implementation method five: such as Figure 5 As shown, interfaces P1 (HCZZ0021-2) and P2 (HCZZ0021-4) provide physical channels for program download and debugging. P1 is used to support the SWD (Serial Wire Debug) download protocol, and its two pins are connected to the SWDIO (PA13) and SWCLK (PA14) pins of the microcontroller U1, respectively. P2 brings out the microcontroller's serial port pins (PA9-TXD, PA10-RXD) as well as power and ground lines, which can support serial port program download and can also be used as the system's general asynchronous serial communication interface.
[0021] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent substitutions, and improvements made to the above embodiments without departing from the scope of the present invention, based on the technical essence of the present invention and within the spirit and principles of the present invention, shall still fall within the protection scope of the present invention.
Claims
1. A multi-threshold sensor detection system based on hardware comparator and software collaboration, characterized in that, It includes a sensor signal acquisition module, a hardware threshold comparison module, a status indication module, a microprocessor module, and a wireless communication module; Sensor signal acquisition module, used to acquire sensor signals; The hardware threshold comparison module has its input connected to the output of the sensor signal acquisition unit. The hardware multi-threshold comparison unit is configured to perform parallel and independent threshold comparisons on the sensor signal and output comparison results of at least two levels. A status indication module is connected to the output of the hardware multi-threshold comparison unit and is used to provide a visual gear position indication based on the comparison result. The microprocessor module has its input terminal connected to the output terminal of the sensor signal acquisition unit, and is used to sample and digitize the sensor signal; The wireless communication module is connected to the microprocessor unit via data connection.
2. The multi-threshold sensor detection system based on hardware comparator and software collaboration according to claim 1, characterized in that, The hardware multi-threshold comparison module includes at least one voltage comparator. The inverting input of the voltage comparator receives a divided sensor signal, and the non-inverting input is connected to an adjustable reference voltage source.
3. The multi-threshold sensor detection system based on hardware comparator and software collaboration according to claim 2, characterized in that, The status indication module includes multiple light-emitting diodes (LEDs), and the output of the hardware multi-threshold comparison module drives the LEDs through a switching circuit.
4. The multi-threshold sensor detection system based on hardware comparator and software collaboration according to claim 3, characterized in that, The switching circuit uses a PNP transistor. The emitter of the PNP transistor is connected to the power supply, the collector of the PNP transistor is connected to the cathode of the LED, and the base of the PNP transistor is connected to the output of the hardware multi-threshold comparison unit through a resistor.
5. The multi-threshold sensor detection system based on hardware comparator and software collaboration according to claim 1, characterized in that, It also includes a level conversion circuit, through which the digital output of the sensor signal acquisition unit is connected to the GPIO input of the microprocessor unit.
6. The multi-threshold sensor detection system based on hardware comparator and software collaboration according to claim 1, characterized in that, The wireless communication module is a Bluetooth communication module.
7. A method for implementing multi-threshold sensor detection using the multi-threshold sensor detection system described in claims 1 to 6, characterized in that, The steps of the multi-threshold sensor detection method based on hardware comparator and software collaboration include: Step 1: Perform real-time, parallel threshold comparison of sensor signals using a hardware multi-threshold comparison module, and directly drive the status indication module. Step 2: The same sensor signal is synchronously sampled and digitized using an ADC through a microprocessor module; Step 3: The digitized data is transmitted via the wireless communication module through the microprocessor module.