First-aid breathing machine based on STM32, control system and method
By introducing a dual-loop PID ventilation control system and air pressure compensation strategy into the emergency ventilator, the problems of airflow rate control accuracy and stability in high-altitude areas have been solved, achieving precise airflow rate regulation and high system efficiency and stability, thus ensuring patient safety and treatment effectiveness.
Patent Information
- Application Number
- CN202510678841.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-12-12
AI Technical Summary
In high-altitude areas, the airflow control accuracy and stability of emergency ventilators decrease, and the asynchronous phenomenon between humans and machines leads to excessive ventilation. Existing single-loop PID control schemes are insufficient in performance under nonlinearity and external disturbances, making it difficult to meet the requirements of high-precision control.
Design an emergency ventilator based on STM32, which adopts a dual-loop PID ventilation control system. By installing sensors at the air inlet and outlet of the turbine fan, combined with atmospheric pressure sensors and differential pressure sensors, real-time monitoring and feedback of airflow velocity and air pressure are achieved. The turbine fan speed is precisely controlled by inner and outer loop PID controllers, and combined with air pressure compensation strategy, the control accuracy and stability are improved.
In high-altitude environments, precise control of airflow velocity was achieved, reducing overshoot and oscillation phenomena, improving the system's anti-interference ability and control accuracy, and ensuring patient safety and treatment effectiveness.
Smart Images

Figure CN121115898A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of ventilator technology, and particularly relates to an emergency ventilator, control system and method based on STM32. Background Technology
[0002] Emergency ventilators play a crucial life-support role in managing respiratory failure, post-anesthesia respiratory depression, and cardiac arrest, and precise tidal volume control is essential. However, at high altitudes, natural factors such as low air pressure and low air density can reduce the accuracy and stability of tidal volume control on emergency ventilators, leading to inaccurate tidal volume inhalation and increasing the risk of complications. Furthermore, the asynchronous phenomenon between the patient and the ventilator during assisted ventilation can induce overventilation, which not only weakens the therapeutic effect but also threatens the patient's life.
[0003] Currently, most emergency ventilators used in clinical practice employ the traditional single-loop PID ventilation control scheme (Proportional-Integral-Derivative) to control airflow. This scheme is widely used due to its simple structure, high stability, and fast response. However, its fixed structure makes it highly dependent on parameters, limiting its ability to handle nonlinear and time-varying systems. It is also sensitive to external disturbances and easily affected by changes in external interference or system parameters, leading to performance degradation and overshoot, thus reducing airflow control accuracy. To improve airflow control accuracy, researchers both domestically and internationally have proposed various improvement strategies, which can be broadly categorized into two directions: introducing advanced control strategies and optimizing traditional PID control strategies.
[0004] While the aforementioned improvement strategies enhance the control performance of traditional single-loop PID ventilation control to some extent, they essentially maintain the basic architecture of single-loop PID control. This architecture has limited adaptability when dealing with nonlinear problems and unexpected events. Particularly in high-altitude environments, the decrease in atmospheric pressure and air density reduces the resistance faced by the turbine, leading to a decline in turbine performance, increased nonlinearity in the airflow control system, and a higher risk of overshoot and oscillations. Furthermore, the physical characteristics of the ventilator's output tubing cause airflow loss, and single-loop PID control cannot accurately track the airflow signal, thus failing to meet high-precision control requirements.
[0005] Currently, ventilation control schemes for clinical ventilators typically employ traditional single-loop PID control. The control process can be summarized in three parts: First, the system sets a target airflow rate, and the main control board of the emergency ventilator drives the turbine fan at a specific speed to accelerate the output of gas from the air-oxygen mixing chamber. Second, a flow sensor (pressure sensor) collects the actual airflow rate (pressure) of the gas output from the turbine fan in real time and transmits the data back to the main control board for processing. Third, the main control board calculates the PID controller output based on the deviation between the system-set target airflow rate (pressure) and the actual collected airflow rate (pressure), and fine-tunes the turbine fan speed to achieve precise control of the airflow rate. This system has the advantages of simple structure and high real-time response, but it lacks capabilities in nonlinear adjustment and control signal tracking. In complex environments, its control performance is significantly degraded by natural factors such as atmospheric pressure and air density. Simultaneously, issues such as tubing leakage and reduced airway compliance can cause the airflow rate within the breathing tubing to decrease, resulting in a decline in system control accuracy. Summary of the Invention
[0006] To address the two key challenges of reduced airflow velocity control and asynchronous human-machine interaction in high-altitude environments currently faced by emergency ventilators, this invention designs an STM32-based emergency ventilator and its control system. Based on this, a dual-loop PID ventilation control system is proposed. This system monitors ambient atmospheric pressure by adding an atmospheric pressure sensor to the turbine fan inlet and an airflow sensor at the turbine fan outlet to collect and report the fan's output airflow velocity in real time. To accurately measure the ventilator's output airflow velocity and pressure, a differential pressure sensor and an air pressure sensor are installed at the end of the breathing tubing. The entire system is controlled by the emergency ventilator's main controller.
[0007] The technical solution adopted by the present invention to solve this problem is as follows:
[0008] An emergency ventilator based on STM32 has a mechanical airway structure including a turbine fan, a breathing tubing, and a mask. It also includes a data acquisition module, a fan control module, and an emergency ventilator main controller. The data acquisition module includes an atmospheric pressure sensor at the turbine fan inlet, an air flow sensor at the turbine fan outlet, and a differential pressure sensor and a pressure sensor at the end of the breathing tubing. The atmospheric pressure sensor, air flow sensor, differential pressure sensor, pressure sensor, and fan control module are all electrically connected to the emergency ventilator main controller.
[0009] The second objective of this invention is to provide an STM32-based emergency ventilator control system, including a dual-loop PID ventilation control system. The dual-loop PID ventilation control system includes the mechanical airway structure, data acquisition module, fan control module, and emergency ventilator main controller as described above in the STM32-based emergency ventilator, and also includes a human-machine interface module and a power management module electrically connected to the emergency ventilator main controller.
[0010] In the above technical solution, the main controller of the emergency ventilator is equipped with an STM32 microcontroller.
[0011] In the above technical solution, the power management module includes a power module, a switching circuit module, a multi-stage voltage conversion module, and a voltage regulator circuit module.
[0012] In the above technical solution, the human-computer interaction module includes an alarm circuit, a shuttle circuit, a screen, a serial port module, and a Bluetooth module.
[0013] In the above technical solution, the dual-loop PID ventilation control system includes two control loops: an outer loop and an inner loop. The outer loop control loop includes an outer loop PID controller, and the inner loop control loop includes an inner loop PID controller. The outer loop PID controller is responsible for controlling the output of the dual-loop PID ventilation control system, and the inner loop PID controller is used to receive instructions from the outer loop PID controller to precisely control the turbine fan speed.
[0014] In the above technical solution, in the inner loop control loop, the air flow sensor collects the airflow velocity in real time and calculates the deviation between the actual output airflow velocity of the turbine fan and the preset airflow velocity. The emergency ventilator main controller inputs the deviation into the inner loop PID controller to obtain the turbine fan speed and adjusts the turbine fan speed in time to achieve precise control of the airflow velocity output of the inner loop.
[0015] In the above technical solution, in the outer loop control loop, the differential pressure sensor collects the airflow velocity of the final output gas of the system in real time, and calculates the deviation between the actual output airflow velocity of the system and the preset airflow velocity. The emergency ventilator main controller inputs the deviation into the outer loop PID controller to obtain the change value of the inner loop target airflow velocity, and adjusts the target airflow velocity of the inner loop control loop to achieve stable output of the system airflow velocity.
[0016] The third objective of this invention is to provide a dual-loop PID ventilation control method for an emergency ventilator control system based on STM32, comprising the following steps:
[0017] S1. The main controller of the emergency ventilator presets the tidal volume setting value and drives the turbine fan to work at the preset airflow rate, blowing out the gas at the preset airflow rate.
[0018] S2. An air flow sensor is placed at the outlet of the turbine fan to collect the airflow velocity in real time and calculate the deviation between the actual output airflow velocity of the turbine fan and the preset airflow velocity.
[0019] S3. The main controller of the emergency ventilator inputs the deviation into the inner loop PID controller to obtain the turbine fan speed, and adjusts the turbine fan speed in a timely manner to achieve precise control of the airflow output of the inner loop.
[0020] S4. The differential pressure sensor is placed at the interface between the breathing tubing and the mask to collect the airflow rate of the final output gas of the system in real time and calculate the deviation between the actual output airflow rate of the system and the preset airflow rate.
[0021] S5. The main controller of the emergency ventilator inputs the deviation into the outer loop PID controller to obtain the change value of the inner loop target airflow velocity, and adjusts the inner loop target airflow velocity to achieve a stable output of the system airflow velocity.
[0022] S6. The air pressure sensor collects the airway pressure of the final output gas of the system in real time and judges it by threshold method. When the threshold is exceeded, it triggers an emergency stop to stop the turbine fan, so as to effectively protect the patient.
[0023] The fourth objective of this invention is to provide a control method for an emergency ventilator control system based on STM32, comprising the following steps:
[0024] First, the system initialization module controls system startup and initialization by detecting the power-on status;
[0025] After startup, the system executes a low-flow ventilation self-test mode to check whether each sensor is normal. If a fault is found, the fault module is triggered for judgment. Otherwise, the user can input commands through the serial port screen or Bluetooth module, and execute them in accordance with the human-machine interaction protocol.
[0026] Finally, the system starts running through the respiratory control algorithm. During ventilation, the system continuously monitors the ventilation status in real time. Once an abnormality is detected, the alarm module is triggered to interrupt ventilation to ensure patient safety.
[0027] The advantages and positive effects of this invention are:
[0028] 1. This invention designs a dual-loop PID airflow velocity control system, which integrates the air pressure compensation mechanism with dual-loop PID control technology, and solves the problem of decreased airflow control accuracy of emergency ventilators in high-altitude environments.
[0029] 2. This invention designs a dual-loop PID ventilation control system and an emergency ventilator control system based on an STM32 microcontroller, providing a reliable experimental platform for subsequent research on key algorithms. Attached Figure Description
[0030] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. However, it should be understood that these drawings are designed for illustrative purposes only and are not intended to limit the scope of the present invention. Furthermore, unless specifically indicated, these drawings are intended only to conceptually illustrate the structural construction described herein and are not necessarily drawn to scale.
[0031] Figure 1 This is an overall framework diagram of the STM32-based emergency ventilator in Example 1;
[0032] Figure 2 This is an overall framework diagram of the STM32-based emergency ventilator control system in Example 2;
[0033] Figure 3 This is a hardware system framework diagram of the STM32-based emergency ventilator control system in Example 2;
[0034] Figure 4 This is a flowchart of the control method of the emergency ventilator control system based on STM32 in Example 3;
[0035] Figure 5 This is the flowchart of the dual-loop PID control system in Example 4;
[0036] Figure 6 This is the schematic diagram of the inner loop PID control in Example 4;
[0037] Figure 7 This is a schematic diagram of the dual-loop PID airflow speed control principle in Example 4;
[0038] Figure 8 This is a diagram of the power management module framework;
[0039] Figure 9 This is the control flowchart for single ventilation mode;
[0040] Figure 10 This is a control flowchart for the ventilation mode;
[0041] Figure 11 This is the control flowchart for assisted ventilation mode;
[0042] Figure 12 The graph shows the experimental results at a flow rate of 40 L / min; where: 1 is the target curve, 2 is the single-loop PID flow rate control curve, and 3 is the double-loop PID flow rate control curve.
[0043] Figure 13 The graph shows the experimental results for a flow rate of 60 L / min; where: 1 is the target curve, 2 is the single-loop PID flow rate control curve, and 3 is the double-loop PID flow rate control curve. Detailed Implementation
[0044] First, it should be noted that the specific structure, features, and advantages of the present invention will be described in detail below by way of examples. However, all descriptions are for illustrative purposes only and should not be construed as limiting the present invention in any way. Furthermore, any single technical feature described or implied in the embodiments mentioned herein, or any single technical feature shown or implied in the accompanying drawings, can still be arbitrarily combined or deleted among these technical features (or their equivalents) to obtain more other embodiments of the present invention that may not be directly mentioned herein. Additionally, for the sake of simplifying the drawings, the same or similar technical features may be indicated only in one place in the same drawing.
[0045] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "setting," "connection," "fixing," and "screw-in" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Unless otherwise explicitly limited, those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances. The invention will now be described in detail with reference to the accompanying drawings.
[0046] Example 1:
[0047] An emergency ventilator based on STM32, such as Figure 1 As shown, its mechanical airway structure includes a turbine fan, a breathing tubing, and a mask. It also includes a data acquisition module, a fan control module, and an emergency ventilator main controller. The data acquisition module includes an atmospheric pressure sensor located at the turbine fan inlet, an air flow sensor located at the turbine fan outlet, and a differential pressure sensor and a pressure sensor located at the end of the breathing tubing. The atmospheric pressure sensor, air flow sensor, differential pressure sensor, pressure sensor, and fan control module are all electrically connected to the emergency ventilator main controller.
[0048] Example 2:
[0049] An STM32-based emergency ventilator control system is presented. The control system mainly comprises a hardware system, a software system, and a mechanical airway structure. The overall system design block diagram is shown below. Figure 2As shown in the diagram. The hardware system design encompasses a main control module, a fan control module, a signal acquisition module, a human-machine interface module, and a power management module. The hardware system is based on an STM32F407VGT6 microcontroller, supplemented by a 12V power supply, a turbine fan, a fan circuit board, a flow sensor, a pressure sensor, a medical display screen, and Bluetooth peripherals. The software system adopts a layered design structure, divided into a bottom-level driver layer, a middle-level control layer, and an upper-level interaction layer. The bottom-level driver layer is responsible for interacting with the hardware system to achieve precise control of the hardware devices. The middle-level control layer is responsible for the system operation and ventilation control of the ventilator, including the selection of breathing modes, the setting of breathing parameters, and the adjustment of airflow rate. The upper-level interaction layer is responsible for human-machine interaction, error alarms, and system settings, facilitating operation and maintenance by medical staff. The mechanical airway structure adopts a low-resistance fan-mixing structure design to reduce the design of the hollow oxygen mixing chamber in traditional ventilators, improving the portability and stability of the device.
[0050] The hardware system is divided into five core modules: a main control module (STM32F407 microcontroller core module), a power management module, a fan control module, a signal acquisition module, and a human-machine interface module. The hardware system uses the powerful STM32F407VGT6 as its main control chip, integrating a 12V power management system, a high-efficiency turbine fan, a dedicated driver board, various sensors, and a user-friendly human-machine interface unit. In the mechanical pneumatic circuit design, a post-mixing oxygen technology is adopted, significantly reducing air resistance and greatly improving the portability and operational stability of the equipment. An emergency ventilator control platform based on the STM32 microcontroller was designed and implemented. A modular design concept was adopted to construct the hardware system, software system, and mechanical pneumatic circuit structure. The hardware system, with the STM32F407 microcontroller as its core, integrates the main control, power management system, FOC fan drive control, multi-signal acquisition, and human-machine interface modules. The software system adopts a layered embedded architecture, constructing a complete human-machine communication protocol and control interface, as well as various low-level control task modules of the real-time operating system, ensuring the efficient and stable operation of the system. Meanwhile, by adopting a fan-driven post-oxygen mixing and low air resistance design, the portability of the equipment has been improved, while also ensuring its stability and efficiency during operation, thus realizing the construction of an emergency ventilator control platform.
[0051] In the above technical solution, in order to achieve high real-time performance and low power consumption, the main control module uses the STM32F407 microcontroller as the core processor.
[0052] In the above technical solution, the fan control module adopts the SVPWM fan control scheme to map the required speed / torque of the motor into a space voltage vector, and optimizes the inverter switching state to approximate the target vector, so as to achieve high-precision and fast response control of the fan air volume, thereby ensuring that the system provides appropriate breathing support stably and efficiently.
[0053] In the above technical solution, the signal acquisition module, in order to realize the dual-loop PID ventilation control system, mainly acquires three signals: air pressure, atmospheric pressure, and airflow velocity. The acquisition point locations are shown in [reference needed]. Figure 2 The signal acquisition module specifically includes:
[0054] 1. Inner ring airflow velocity signal acquisition module: To meet the design requirement of measuring airflow velocity in the range of 0 to 200 L / min, this paper selects the Gasboard-8500FS-L240H ultrasonic flow sensor from Sifang Optoelectronics Co., Ltd.
[0055] 2. External airflow velocity signal acquisition module: In order to acquire the output airflow velocity at the end of the breathing tubing, this paper adopts the bypass measurement method and uses the HAFBSF0400 differential pressure sensor manufactured by Honeywell for data acquisition.
[0056] 3. Pressure signal acquisition module: In view of the measurement requirements of the inhalation platform pressure of 0~70cmH2o (0~6.86kpa), the XGZP6859D pressure sensor is selected in this paper.
[0057] 4. Atmospheric pressure signal acquisition module: The BMP280 atmospheric sensor module is used to acquire ambient atmospheric pressure. The sensor has a measurement range of 300 to 1100 hPa and a measurement accuracy of 0.12 hPa, which meets the system's requirements for monitoring changes in ambient atmospheric pressure.
[0058] In the above technical solution, the human-machine interface module serves as a bridge between medical staff and the equipment. To improve the operational flexibility and system integration of the ventilator, this paper adopts a dual-mode mechanism of Bluetooth control and traditional rotary knob control, and uses a high-performance DMG80480K035_03W medical serial port screen from DWIN Medical as a visual operation interface. It also integrates a buzzer alarm system, thus constructing a human-machine interface module that is responsive, intuitive to operate, and fully functional.
[0059] In the above technical solution, the power management module design addresses the unique working environment of emergency ventilators, which may face instability or inability to connect to the main power grid. Therefore, this paper adopts a dual power supply scheme combining main power grid supply and 12V lithium battery supply to ensure a stable and reliable power supply for the emergency ventilator in outdoor environments. The power management module mainly includes a power supply module, a switching circuit module, a multi-stage voltage conversion module, and a voltage regulator circuit module.
[0060] Example 3:
[0061] A control method for an emergency ventilator control system based on STM32, the overall system control flow is as follows: Figure 4As shown. First, the system initialization module controls system startup and initialization by detecting the power-on status. After startup, the system executes a low-flow ventilation self-test mode to check if each sensor is functioning properly. If a fault is detected, the fault module is triggered for diagnosis. Otherwise, the user inputs commands via the serial port screen or Bluetooth module, which are parsed and executed according to the human-machine interface protocol. Finally, the system begins operation through the respiratory control algorithm. During ventilation, the system continuously monitors the ventilation status in real time. Once an abnormality is detected, the alarm module is triggered to interrupt ventilation to ensure patient safety.
[0062] Example 4:
[0063] 1. Principle of Dual-Loop PID Ventilation Control System
[0064] To achieve precise airflow velocity control, a dual-loop PID ventilation control system was designed. Compared to single-loop PID control, the dual-loop PID control structure includes two control loops: an outer loop and an inner loop. The outer loop controller is responsible for controlling the system's output, while the inner loop controller receives commands from the outer loop controller to precisely regulate the turbine fan speed, thereby improving system stability and response speed. Its control flow is as follows: Figure 5 As shown, the detailed control process of the system is as follows:
[0065] ① The main control board of the emergency ventilator presets the tidal volume setting value, drives the fan to work at the preset airflow rate, and blows out the gas at the preset airflow rate;
[0066] ② An air flow sensor is placed at the fan outlet to collect airflow velocity in real time and calculate the deviation between the actual output airflow velocity of the fan and the preset airflow velocity;
[0067] ③ The main control board of the emergency ventilator inputs the deviation into the inner loop PID regulator to obtain the fan speed, and adjusts the fan speed in a timely manner to achieve precise control of the airflow output of the inner loop;
[0068] ④ The differential pressure sensor is placed at the interface between the breathing tubing and the mask to collect the airflow rate of the final output gas of the system in real time and calculate the deviation between the actual output airflow rate and the preset airflow rate.
[0069] ⑤ The main control board of the emergency ventilator inputs the deviation into the outer loop PID controller to obtain the change value of the inner loop target airflow velocity, and adjusts the inner loop target airflow velocity to achieve a stable output of the system airflow velocity.
[0070] ⑥ The air pressure sensor collects the airway pressure of the final output gas of the system in real time, and judges it by threshold method. When the threshold is exceeded, the emergency stop of the fan is triggered to achieve effective protection of the patient.
[0071] 2. Design of Dual-Loop PID Control Method
[0072] In complex nonlinear systems, especially in high-altitude, low-pressure environments, air pressure changes reduce the performance of the turbine fan in emergency ventilators. Traditional single-loop PID controllers have limited control capabilities for nonlinear systems, leading to decreased airflow control accuracy and stability. To address this issue, this paper proposes a dual-loop PID airflow control scheme. The inner-loop PID controller rapidly adjusts the turbine fan speed based on the output airflow velocity, ensuring the airflow velocity quickly approaches the target velocity. The outer-loop PID controller responds to system demands, dynamically adjusting the target airflow velocity of the inner-loop PID controller based on the final output airflow velocity of the emergency ventilator. This reduces air loss caused by airway obstruction or leakage, ensuring the airflow velocity remains accurately and stably within the set range under any operating conditions, effectively improving the system's anti-interference capability and overall control performance. To minimize the impact of air pressure changes on the system, this paper integrates an air pressure compensation strategy into the single-loop PID control, innovatively designing an air pressure-compensated PID control scheme. This scheme corrects the airflow velocity sensor readings using an air pressure compensation coefficient to improve the stability of the inner-loop PID controller. The control logic is as follows: Figure 6 As shown.
[0073] The airflow velocity inside the ultrasonic flow sensor is collected, and the ratio of the standard atmospheric pressure to the value collected by the atmospheric pressure sensor is used as the air pressure compensation coefficient to reduce the impact of changes in ambient air pressure on the PID control system. The logical relationship is shown in Equation 1.
[0074]
[0075] In the formula, r1(t) is the target airflow velocity in the inner ring, c1(t) is the actual airflow velocity in the inner ring, and P S Let P(t) be the standard atmospheric pressure constant (101.3 kPa), P(t) be the actual value of the ambient atmospheric pressure, and e1(t) be the deviation value of the inner ring airflow velocity. The pressure-compensated PID control relationship can then be obtained as shown in Equation 2.
[0076]
[0077] In the formula, u1(t) is the inner ring airflow speed control value, i.e., the turbine fan speed, K p1 K i1 K d1 These are the proportional, integral, and derivative coefficients of the inner loop controller. Since the airflow loss in the breathing tubing is relatively small, the cumulative effect of the integral term in traditional PID control over a long period can lead to overcorrection and overshoot. To avoid this problem, this paper adopts an integral-separated outer loop PID controller. Based on the rate of change of airflow deviation, the integral term is shut down when the rate of change is below a preset threshold to avoid overshoot and improve system robustness. The outer loop airflow velocity is collected by a differential pressure flow sensor. The overall system control logic is as follows: Figure 7As shown.
[0078] 3. Design of Dual-Loop PID Airflow Velocity Control Algorithm
[0079] Given that the STM32 microcontroller is a digital chip, this paper adopts an incremental PID control strategy to implement a dual-loop PID airflow speed control algorithm. This strategy determines the increment of the control signal by calculating the current feedback deviation and its rate of change, rather than directly solving for the precise output value of the next control cycle. This reduces the computational load and enhances the real-time response capability and system stability of the control. ] The incremental inner-loop PID control relationship is shown in Equation 3.
[0080] Δu1(k)=K p1 ×Δe1(k)+K i1 ×e1(k)+K d1 ×(Δe1(k)+Δe1(k-(3)
[0081] In the formula, Δu1(k) is the inner ring airflow velocity increment, and Δe1(k) is the inner ring airflow velocity deviation value. The calculation formula is shown in Equation 4.
[0082] Δu1(k)=u1(k)-u1(k-1)(4)
[0083] After transformation, the incremental inner-loop PID calculation formula is shown in Equation 5:
[0084]
[0085] The formula for calculating the deviation of the inner annular airflow velocity is shown in Figure 6.
[0086]
[0087] In the formula, r1(k) is the target value of the inner ring airflow velocity at time k, c1(k) is the actual value of the airflow velocity collected by the ultrasonic flow sensor, and P(k) is the actual value of the atmospheric pressure. The inner ring parameter K in this paper was measured using an engineering experimental method for parameter tuning. p1 K i1 K d1 The values are 2, 0.05, and -6.5 respectively, and u1(0) and c1(0) are both 0. Compared with the inner-loop PID control algorithm, the incremental integral separation outer-loop PID uses the preset airflow velocity value of the emergency ventilator as the target value r2(k) and the airflow velocity value collected by the differential pressure sensor as the actual value c2(k) to directly calculate the outer-loop airflow velocity deviation value e2(k). Its incremental control relationship is shown in Equation 7.
[0088]
[0089] In the formula, K p2 K i2K d2 These are the proportional, integral, and derivative coefficients of the outer loop controller, respectively; K i2 α is the integral coefficient of the inner loop controller; α is the integral switching coefficient, which can be obtained by calculating the rate of change of the airflow velocity deviation. Its logic control relationship is shown in Equation 8.
[0090]
[0091] In the formula, T is the sampling interval (0.01), β is the switching threshold, and the outer loop parameter K in this paper is obtained through engineering experiments. p2 K i2 K d2 The values are 0.0006, 0.0001, and -0.0002, respectively, with β being 50. The output value of the outer loop PID controller is the value that needs to be adjusted to the inner loop target value. The precise output of the dual-loop PID airflow velocity control system is achieved by dynamically adjusting the inner loop PID target airflow velocity. The control relationship between the inner and outer loops is shown in Equation 9.
[0092]
[0093] In the formula, r2(0) is the target airflow velocity value of the outer loop PID control, that is, the airflow velocity value set by the ventilator.
[0094] 4. Design based on dual-loop PID forced ventilation control mode
[0095] In forced ventilation mode, the emergency ventilator relies on pre-set key parameters such as respiratory rate and tidal volume, and uses a respiratory control algorithm to precisely adjust the airflow rate to ensure that the patient receives a continuous and accurate tidal volume supply. Since a bypass acquisition method is used to collect the airflow rate signal at the end of the breathing tubing, and the differential pressure flow sensor is connected to the flow acquisition device via a flexible tube, it is necessary to calibrate the differential pressure sensor for airflow rate. Experiments show that the relationship between the acquired signal value and the actual airflow rate is as shown in Equation 10.
[0096]
[0097] In the formula, F is the calibrated airflow velocity (L / min), and f_ad is the value acquired by the microcontroller. The single-pass ventilation mode, as the basic ventilation mode, receives and parses operational commands such as tidal volume, respiratory rate, and inspiratory-expiratory ratio through the human-machine interface. It calculates the airflow velocity and inspiratory time, and accordingly programs the timer trigger point and the target airflow velocity of the dual-loop PID controller to drive the fan to achieve precise tidal volume supply. Its control principle is as follows: Figure 9 As shown.
[0098] The controlled ventilation mode is continuous periodic ventilation. By inputting respiratory control parameters, the trigger points for the start and end of each respiratory cycle of the timer are set. Simultaneously, a dual-loop PID controller adjusts the fan speed to ensure accurate output of the specified tidal volume during each ventilation cycle. To reduce abnormal increases in airway pressure caused by airway equipment malfunctions or airway obstruction, a respiratory monitoring function is added to the controlled ventilation mode. Its control logic is as follows: Figure 10 As shown.
[0099] 5. Design of PID-based assisted ventilation control mode
[0100] An auxiliary ventilation mode is designed using a single-loop PID pressure control algorithm. The operating speed of the turbine fan is adjusted by reading the pressure sensor's collected values as feedback signals to ensure precise control of the intake platform pressure. The proportional, integral, and derivative coefficients are 2, 0.002, and -6, respectively. Because the pressure signal acquisition path is a non-ideal path between the hose and the pressure sensor, measurement errors may occur. Therefore, this paper performs piecewise linear calibration on the raw signals collected by the pressure sensor. The conversion relationship between the collected signal values and the actual pressure is shown in Equation 11.
[0101]
[0102] In the formula, P is the calibrated air pressure signal value (cmH2O), and p_adc is the air pressure value collected by the microcontroller. To prevent harm to the patient due to respiratory aggression or sudden equipment failure during assisted ventilation, which could cause the expiratory sensitivity to fail to trigger properly, this paper sets a maximum inspiratory time threshold. When the inspiratory duration exceeds this preset threshold but the expiratory sensitivity is still not triggered, the system will immediately and automatically switch to the expiratory phase to ensure the patient's safety. The assisted ventilation control flowchart is as follows: Figure 11 As shown.
[0103] 6. Dual-loop PID ventilation control performance test
[0104] To verify the performance advantages of the dual-loop PID ventilation control method in high-altitude environments, this paper conducts a comparative experiment at an altitude of 4370 meters (atmospheric pressure of 59 kPa) to evaluate the improvement in response speed, stability, and accuracy of the dual-loop PID airflow speed control algorithm.
[0105] (1) Performance test and results analysis of dual-loop PID airflow velocity control method
[0106] The experiment used a dual-loop PID airflow control method as the experimental group and compared it with a single-loop PID airflow control method. The experiment used the emergency ventilator designed in this paper as the control platform. A differential pressure sensor integrated within the ventilator (sampling rate: 100Hz) was used to monitor the output airflow rate changes of the ventilator in real time, and the data was uploaded to the host computer for storage in real time via serial communication. In the experimental tests, the operating effects of the two control methods were tested under airflow rate setpoints of 40L / min and 60L / min, and the experimental results are as follows: Figure 12 , 13 As shown.
[0107] according to Figure 12 It can be seen that when the experimental airflow rate is set to 40 L / min, the dual-loop PID airflow rate control method stabilizes the airflow rate at 240 ms without overshoot, while the single-loop PID airflow rate control method stabilizes the airflow rate at 800 ms, but the airflow rate waveform exhibits overshoot and oscillation. According to... Figure 13 It can be seen that when the experimental airflow rate is set to 60 L / min, the dual-loop PID airflow rate control method stabilizes the airflow rate within 200 ms without overshoot, while the single-loop PID airflow rate control method exhibits severe overshoot, with a stabilization time exceeding 1000 ms. The experimental results demonstrate that, in terms of airflow rate control, the dual-loop PID airflow rate control method outperforms the single-loop PID airflow rate control method in both speed and stability.
[0108] The results analysis shows that the dual-loop PID airflow velocity control method, through the cooperation of the inner and outer loops combined with a dynamic air pressure compensation mechanism, successfully reduces the adverse effects of changes in external environmental air pressure on the overall control system response. This improvement effectively suppresses the overshoot of the system during the adjustment process and ensures that the turbine fan output airflow velocity is maintained more accurately and stably near the target airflow velocity value, thereby greatly improving the control accuracy and overall stability of the system under nonlinear and complex operating conditions.
[0109] (2) Accuracy test and result analysis of the dual-loop PID ventilation control system
[0110] This experiment selected a self-developed emergency ventilator as the experimental subject to compare and verify its accuracy performance in forced ventilation mode at different airflow rates (10, 40, 60, and 70 L / min). Two well-known domestic ventilators (Brand A and Brand B) were used as control groups for testing. The experiment used a Certifier flow analyzer manufactured by TSI Corporation (USA) as the measurement device, which has a wide measurement range of 0 to 300 L / min and a high accuracy of 2%. The experimental results are shown in Table 1.
[0111] Table 1. Results of the Accuracy Test
[0112]
[0113] Table 1 shows that the designed emergency ventilator exhibited an average error of 3.19% and a maximum steady-state error of 4.1% in the airflow control accuracy test. Meanwhile, the average error of ventilators from domestic brand A reached 16.51%, with a steady-state error range of 15.14% to 17.65%; the average error of ventilators from domestic brand B was 8.70%, with a steady-state error range of 6.98% to 10.89%. The results indicate that the airflow control accuracy of the emergency ventilator designed in this study is superior to that of currently available equipment in high-altitude environments. Analysis shows that the dual-loop PID ventilation control strategy significantly improves the ventilation control accuracy of the emergency ventilator in high-altitude, low-pressure environments, demonstrating the superior advantages of this scheme in adaptability to complex geographical environments and precise control performance.
[0114] This paper presents an in-depth study of the dual-loop PID ventilation control method, proposing a dual-loop PID-based airflow velocity control strategy and effectively applying it to single-blow ventilation and controlled ventilation modes of an emergency ventilator. This strategy rapidly adjusts the turbine fan speed using the inner-loop PID to approximate the target airflow velocity, while the outer-loop PID dynamically corrects the inner-loop target value based on the actual airflow velocity. Combined with a pressure compensation strategy, this significantly improves the system's anti-interference capability and control accuracy in high-altitude, low-pressure environments. Experiments verify the advantages of the dual-loop PID ventilation control method in terms of response speed, stability, and accuracy. Furthermore, this paper also successfully constructs an assisted ventilation mode based on a single-loop PID pressure control scheme and rigorously verifies the accuracy of its inspiratory plateau pressure control, ensuring comfort and safety during human-machine interaction.
[0115] The above embodiments have provided a detailed description of the present invention, but the content described is only a preferred embodiment of the present invention and should not be considered as limiting the scope of the present invention. All equivalent variations and improvements made within the scope of the present invention should still fall within the patent coverage of the present invention.
Claims
1. An emergency ventilator based on STM32, the mechanical airway structure of which includes a turbine fan, breathing tubing, and a mask, characterized in that: It also includes a data acquisition module, a fan control module, and an emergency ventilator main controller. The data acquisition module includes an atmospheric pressure sensor installed at the air inlet of the turbine fan, an air flow sensor installed at the air outlet of the turbine fan, and a differential pressure sensor and an air pressure sensor installed at the end of the breathing tubing. The atmospheric pressure sensor, air flow sensor, differential pressure sensor, air pressure sensor, and fan control module are all electrically connected to the emergency ventilator main controller.
2. A rescue ventilator control system based on STM32, characterized in that: The system includes a dual-loop PID ventilation control system, which comprises the mechanical airway structure, data acquisition module, fan control module, and emergency ventilator main controller of the STM32-based emergency ventilator as described in claim 1, and also includes a human-machine interface module and a power management module electrically connected to the emergency ventilator main controller.
3. The STM32-based emergency ventilator control system according to claim 2, characterized in that: The main controller of the emergency ventilator is equipped with an STM32 microcontroller.
4. The STM32-based emergency ventilator control system according to claim 2, characterized in that: The power management module includes a power module, a switching circuit module, a multi-stage voltage conversion module, and a voltage regulator circuit module.
5. The STM32-based emergency ventilator control system according to claim 2, characterized in that: The human-computer interaction module includes an alarm circuit, a shuttle circuit, a screen, a serial port module, and a Bluetooth module.
6. The STM32-based emergency ventilator control system according to claim 2, characterized in that: The dual-loop PID ventilation control system includes two control loops: an outer loop and an inner loop. The outer loop control loop contains an outer loop PID controller, and the inner loop control loop contains an inner loop PID controller. The outer loop PID controller is responsible for controlling the output of the dual-loop PID ventilation control system, while the inner loop PID controller is used to receive commands from the outer loop PID controller to precisely regulate the turbine fan speed.
7. The STM32-based emergency ventilator control system according to claim 5, characterized in that: In the inner loop control circuit, the air flow sensor collects the airflow velocity in real time and calculates the deviation between the actual output airflow velocity of the turbine fan and the preset airflow velocity. The emergency ventilator main controller inputs the deviation into the inner loop PID controller to obtain the turbine fan speed and adjusts the turbine fan speed in a timely manner to achieve precise control of the airflow velocity output of the inner loop.
8. The STM32-based emergency ventilator control system according to claim 9, characterized in that: In the outer loop control circuit, the differential pressure sensor collects the airflow velocity of the final output gas of the system in real time and calculates the deviation between the actual output airflow velocity and the preset airflow velocity. The emergency ventilator main controller inputs the deviation into the outer loop PID controller to obtain the change value of the inner loop target airflow velocity, and adjusts the target airflow velocity of the inner loop control circuit to achieve stable output of the system airflow velocity.
9. A dual-loop PID ventilation control method for an emergency ventilator control system based on STM32 as described in any one of claims 6-8, characterized in that: Includes the following steps: S1. The main controller of the emergency ventilator presets the tidal volume setting value and drives the turbine fan to work at the preset airflow rate, blowing out the gas at the preset airflow rate. S2. An air flow sensor is placed at the outlet of the turbine fan to collect the airflow velocity in real time and calculate the deviation between the actual output airflow velocity of the turbine fan and the preset airflow velocity. S3. The main controller of the emergency ventilator inputs the deviation into the inner loop PID controller to obtain the turbine fan speed, and adjusts the turbine fan speed in a timely manner to achieve precise control of the airflow output of the inner loop. S4. The differential pressure sensor is placed at the interface between the breathing tubing and the mask to collect the airflow rate of the final output gas of the system in real time and calculate the deviation between the actual output airflow rate of the system and the preset airflow rate. S5. The main controller of the emergency ventilator inputs the deviation into the outer loop PID controller to obtain the change value of the inner loop target airflow velocity, and adjusts the inner loop target airflow velocity to achieve a stable output of the system airflow velocity. S6. The air pressure sensor collects the airway pressure of the final output gas of the system in real time and judges it by threshold method. When the threshold is exceeded, it triggers an emergency stop to stop the turbine fan, so as to effectively protect the patient.
10. A control method for an emergency ventilator control system based on STM32 as described in any one of claims 2-8, characterized in that: Includes the following steps: First, the system initialization module controls system startup and initialization by detecting the power-on status; After startup, the system executes a low-flow ventilation self-test mode to check whether each sensor is normal. If a fault is found, the fault module is triggered for judgment. Otherwise, the user can input commands through the serial port screen or Bluetooth module, and execute them in accordance with the human-machine interaction protocol. Finally, the system starts running through the respiratory control algorithm. During ventilation, the system continuously monitors the ventilation status in real time. Once an abnormality is detected, the alarm module is triggered to interrupt ventilation to ensure patient safety.
