key: cord-0981057-4clk0up5 authors: Almeida, David I. Rosas; Cárdenas, Armando Cantú; Fuentes, Iván Olaf Hernández; Cota, Rosa Citlalli Anguiano; León, Laura Ocotlán Orea; Martínez, David Rafael Cañez; Contreras, Angélica María Martínez title: Modeling and control of an invasive mechanical ventilation system using the active disturbances rejection control structure date: 2021-12-22 journal: ISA Trans DOI: 10.1016/j.isatra.2021.12.021 sha: ec3d92c26c000c1e3e18020b68e89bbc9c76192b doc_id: 981057 cord_uid: 4clk0up5 We propose a mandatory invasive mechanical ventilator prototype for severe COVID-19 patients with volume and pressure control operation modes. This system comprises basic pneumatic elements and sensors. Its performance is similar to commercial equipment, and it presents robustness to external disturbances and parametric uncertainties. To develop a control strategy, we propose a mathematical model with a variable structure that incorporates the dead zone phenomenon of the proportional valve, and considers external disturbances and parametric uncertainties. Based on this model, we propose a global control strategy that is based on pressure and flow regulation controllers, which use the active disturbances rejection control structure (ADRC). In this strategy, we propose robust state observers to estimate disturbances and the signals necessary for implementing the controllers. We illustrate the performance of the prototype and the control strategy through numerical simulations and experiments. We also compare its performance with PID controllers. These results corroborate its effectiveness and the possibility of its application in invasive mechanical ventilators with a simple structure, which can significantly help critical care of COVID-19 inpatients. Invasive mechanical ventilation (IMV) is essential in treating patients with acute respiratory distress syndrome (ARDS), which is a feature in severe COVID-19 [1] , [2] . The respiratory symptoms of can go from mild flu-like symptoms to respiratory failure in minutes to hours, depending on the state of health before infection. Complications caused by viral infection mainly occur in older adults and are the 5 most serious in those with comorbidities. Mechanical ventilation can decrease the work of breathing, increase oxygenation and remove carbon dioxide in patients with pneumonia, ARDS, or respiratory failure associated with COVID-19 [3], [4] . During the years 2020 and 2021,the world experienced an overwhelming scenario due to a rapid spreading disease with a globally poor medical surge capacity. No country was prepared to meet such a large number a complete analysis of the characteristics, advantages, and disadvantages of the different technologies used in mechanical ventilators and the challenges in developing control algorithms. Some adaptive control techniques have been applied to solve the pressure tracking control problem. An example can be found in [8] , where the authors propose an adaptive controller that is based on an inverse model of a patient's lung and the ventilator. This controller estimates the parameters of the system online 25 using the recursive least square with a forgetting factor. This proposal achieves robust performance over a wide range of patient conditions. This controller was applied on NPB 840 mechanical ventilator and obtained good results; however, the controller produces overshoots at the beginning of the expiration stage. Active Disturbance Compensation Control (ADRC) is a control structure that presents good robustness properties and has a certain simplicity in its implementation. This control structure has been successfully 30 applied in mechanical systems to solve regulation and tracking control objectives. A detailed description of this control structure and some applications can be found in [9] and [10] . This control structure was successfully applied in [11] to track trajectories in a mechanical system of one degree of freedom, with linear movement, using pneumatic actuators. This control strategy has also been applied to control a Bag Valve-Based mechanical ventilator prototype, which is a portable mechanical ventilator that is based on 35 bag-valve compression through a flexible belt and a DC motor [12] . This kind of ventilator is beneficial in providing short-term care for patients; however, there is a risk of accumulation of CO 2 inside the bag. Here, a double integrator with matched nonvanishing disturbances is used to model the volume and pressure control design. Because the proposed state observer is linear and there are nonvanishing disturbances in the plant, it does not guarantee that the observation error will converge to zero, and therefore it does not 40 guarantee adequate compensation. The experimental results show an acceptable performance compared to a commercial mechanical ventilator, presenting a considerable error between the pressure and the PEEP pressure level in the expiration period. This work presents a mandatory invasive mechanical ventilator prototype that is based on valves for severe COVID-19 patients with volume and pressure control operation modes. This system comprises a 45 service unit, a proportional valve for flow control, an on/off valve, an artificial lung, pressure and flow sensors, and a controller device. We propose a mathematical model with a variable structure to develop a control strategy that incorporates the dead zone phenomenon in the proportional valve, and which considers external disturbances and parametric uncertainties. Based on this model, we propose pressure and flow regulation controllers that use the ADRC structure. We then propose a global control strategy that, depending on the 50 operation mode selected, volume or pressure, commutes the pressure and flow controllers to generate the desired performance. To implement the controllers in this strategy, we propose robust state observers to estimate disturbances and the necessary signals. The result is a prototype with minimum error in pressure and flow, in both J o u r n a l P r e -p r o o f Journal Pre-proof operation modes, and in robustness. 55 We illustrate the prototype's performance and the control strategy through numerical simulations and experiments, both with and without external disturbances. We also compare its performance with PID controllers. These results corroborate its effectiveness and the possibility of its application in invasive mechanical ventilators with a simple structure, which can significantly help COVID-19 critical care inpatients. The rest of this article is organised as follows. The second section presents the basic definitions of an 60 invasive mechanical ventilator and it defines the problem. The dynamic ventilator model is proposed in the third section, which allows the design of the control strategy. Meanwhile, sections four and five present the design of the volume and flow controllers, respectively. Through the flow control, the volume control design is presented in section 4. In section 5, the pressure controller is presented. Section 7 presents the overall control strategy, which switches the flow and pressure controllers, depending on the mode of operation and the state of the breath cycle. Section 8 presents the performance of the proposed control strategy through numerical simulations. Section 9 presents the experimental results, which illustrate the adequate performance of the proposed control strategy. Section 10 presents the mechanical ventilator's experimental performance for volume and pressure operation modes, using PID controllers, and concludes that the ADRC control structure has a better performance. Finally, the conclusions and final comments are presented in section 11. The proposed invasive mechanical ventilation prototype can be classified as a mandatory or assisted continuous ventilation system, with two modes of operation: volume control mode and pressure control mode. The parameters and variables that establish its operation follow. • Ventilation period T . Period of time, in minutes, that a respiration cycle takes, which is divided into 75 two stages: the inspiration time T I and the expiration time T E , where T = T I + T E . • Inspiration-expiration ratio I : E. This is the relationship that exists between the inspiration time T I and the expiration time T E , it is calculated as I : E = T E /T I . • Ventilation frequency F . This is the inverse of the ventilation period T , whose units are cycles per minute. • Tidal volume V t . This the volume, in units of milliliters, of gas entering, or leaving, the lungs in a given amount of time. • Positive End-Expiration Pressure P EEP. This is the positive pressure that must remain at the end of expiration time to keep alveoli distended and avoid alveolar collapse, it is measured in centimeters of water (cmH2O). • Peak inspiratory pressure P IP. This is the maximum reference pressure in pressure control mode, its units are cmH2O. J o u r n a l P r e -p r o o f Journal Pre-proof • Limit pressure P lim . This is the safety pressure level in units of cmH2O. In volume operation mode, the ventilator cannot exceed this pressure level. In addition to these operating parameters, there are two variables that determine the operation of the 90 mechanical ventilator. • "On/Of f ", if this variable is equal to 1, then the system is in operation; if it is equal to 0, then the system is deactivated. • "M ode", this variable indicates the operating mode: when "M ode = 0", the system operates in volume control mode; while if "M ode = 1", then it operates in pressure control mode. A diagram of the pneumatic system within the invasive mechanical ventilator and its instrumentation is shown in Figure 1 . In this figure, the gas inlet path, in the inspiration process, is indicated by the red arrows; while the gas outlet path, in the expiration process, is indicated by the green arrows. The inlet route starts with a constant inlet pressure P 0 , which is obtained through a service unit. Next is a proportional valve for flow control, controlled by the voltage V i (t) . Pressure and flow sensors are placed at the outlet of 100 this valve, which provide measurements of the inspiration flow F i (t) and the pressure P (t); we assume that lung pressure P lung (t) is equal to pressure P (t). In the gas outlet path, there is a flow sensor to measure the outlet flow F e (t). In this way, the net flow F (t) in the lung is F (t) = F i (t) − F e (t), while the tidal volume V t (t), which is defined as the volume of gas entering the lungs in the respiration period T , is Next to the flow sensor is an on/off valve that is activated by the voltage V e (t), which allows the gas to 105 escape. Finally, P env is the ambient pressure, which is considered the reference of the system. Throughout The problem addressed is to propose a robust control strategy for the pneumatic system, shown in Figure 110 1, to operate as a mandatory invasive mechanical ventilator for critically ill COVID-19 patients, with volume control and pressure control modes of operation. The first step is to propose a mathematical model of the system that incorporates its main dynamic characteristics but at the same time must be as simple as J o u r n a l P r e -p r o o f Journal Pre-proof possible to allow its parameters and the design of the controllers to be estimated. Next, robust controllers must be proposed to solve volume regulation problems through flow control and pressure regulation, despite 115 the presence of external disturbances, parametric uncertainties, and unmodeled dynamics. Finally, the third step is to propose a global control strategy that allows the system to switch between the pressure and volume control modes of operation that is based on parameters set by the user. The dynamics of the system shown in Figure 1 are strongly non-linear due to the dead zone in the valves, 120 fluid dynamics, and delays caused by the lines connecting the valves to the patient. This section proposes a model, which is as simple as possible, that includes the most representative dynamics of the system and which allows the design of robust controllers that solve the flow and pressure control objectives. First, the inspiration process is analyzed. The flow F (t) has a behavior that is very similar to a first-order system. Consequently, the following model is proposed where a i and b i are positive constants, and γ i (·) is a disturbance term that incorporates non-modeled dynamics and external disturbances, which are considered bounded and with bounded derivatives for all t and F (t). The function z m (·), Figure 2 c), can be represented as the subtraction of a linear function, 2 a), with a saturation function sat (·), 2 b), so that the system (2) can be rewritten aṡ The dynamics of the lung can be represented by the following equation [13] P lung (t) = −αP lung (t) where C lung is the equivalent capacitance of the lung, F pat (t) is the inflow, α is a coefficient related to its 130 time constant, and γ pat (t) is a disturbance exerted by the patient's muscles, which is considered limited in amplitude and its derivative. Neglecting the dynamics of the air ducts, it can be considered that F pat (t) = F (t) and P lung (t) = P (t), so the dynamics of the lung are given bẏ For the expiration cycle, the outflow F (t) is modeled by the equatioṅ where a e and b e are positive constants that depend on the parameters of the system, γ e (·) is a term that contains external disturbances and unmodeled dynamics, with bounded amplitude and derivative, and P (t) 135 is given by equation (4). In summary, the mathematical model of the mechanical ventilator is a model with variable structure, where the switching of structures is governed by a function s w (t) defined as s w (t) = 1 for inspiration and s w (t) = 0 for expiration. For s w (t) = 1 the model of the system is given by the equations For s w (t) = 0 the model of the system is given by the equationṡ It is important to mention here that the initial conditions of each structure are the value of the state variables of the previous structure at the instant of switching. The experimental prototype of the mechanical ventilator is shown in Figure 3 . It is composed of the 145 maintenance unit, the flow regulating valve SMC VEF2121-1 and its controller VEA250, the on/off valve SMC VXZ230AZ2A, the artificial lung, and the sensor FS6122, from Siargo Ltd., performs flow and pressure measurements. Finally, the dSPACE Microlabbox platform is used to implement the models and control algorithms. Square signals were applied to identify the model parameters to the V i (t) and V e (t) inputs in such a Consider the first-order nonlinear systeṁ is the state, f (x) and g (x) are known functions, u (t) is a control input and γ (x, t) is a disturbance term that satisfies the condition |γ (x, t)| < δ where δ is a constant. The problem is to estimate the disturbance term γ (x, t). For this purpose, we propose the observer given by . where ω (t) is an auxiliary state acting as an estimate of the disturbance γ (x, t) in system (8) and the coefficients c i , i = 1, 2, 3 are positive. It is important to mention here that the solutions of system (9) are defined in Filipov's sense [14] . To demonstrate the estimation of the disturbance term in system (8), the error variable is defined, whose dynamics are given bẏ , , whose dynamics are given byż then there exists a positive definite matrix P , which is the solution of the Lyapunov equation where I is the identity matrix and A is given by Here, λ min (P ) and λ max (P ) denote the minimum and maximum eigenvalues of matrix P , respectively. We then have the following theorem. Theorem 1. For system (10) , suppose that |γ (x, t)| < δ. If where 0 < θ < 1, then the origin of the state space will be an asymptotically stable equilibrium point in the Lyapunov sense. Consequently, Proof. The proof of this Theorem can be found in [15] . In practice, the value of δ is not known but it exists, so a tuning process is carried out to define the values of the observer gains. For simplicity, a constant flow reference F ref is considered whose value is such that at the inspiration time T I , the tidal volume V t is achieved; that is, Because flow control is only applied in the inspiration process, the plant model is given by To design the control, first the disturbance term Γ (·) is estimated using the observer (9), which takes the form Once the disturbance is estimated, the controller for flow regulation is proposed. Let a constant flow based on the active disturbance rejection control structure we propose the control signal by substituting (14) in system (13) we geṫ where the term −ω F (t) + Γ (·) vanishes asymptotically, so making a suitable selection of the constant k 1 the convergence to the origin of the error e F (t) is guaranteed. In this control objective, there is a significant restriction in the dynamics of the system. The way to increase the pressure is through the injection of gas using the proportional flow valve, while the decrease in pressure can only be achieved by releasing gas through the on/off valve and suspending the injection of gas. In this sense, the dynamics of the pressure increase is through a controllable system, system (6), but the if e P (t) > 0, then the output V i (t) will be set to zero to stop the injection of air and will activate the V e (t) output to release air and decrease pressure. The combination of both structures must ensure the convergence of the pressure P (t) to the reference P ref . To increase the pressure, e P (t) < 0, the invasive mechanical ventilator model is given by (6) . First, based on (9), a state observer is implemented to estimate the disturbance γ pat (t), which takes the form 205 . where ω P (t) is the estimation of γ pat (t) . The design of V i (t) is as follows. The dynamics of the error e P (t) is given bẏ Due to the structure of this system, the control of e P (t) can only be done through the flow F (t). To guarantee the convergence of the error e p (t) to zero, the flow must be by substituting (17) in (16), we getė where its stability can easily be guaranteed with a gain k pi > −α. Now, to satisfy (17) a tracking controller is implemented for the flow, where the reference signal R faux (t) is given by Now we define the error variable ε (t) = F (t) − R faux (t), whose dynamics are given bẏ a control signal that stabilizes the origin ε (t) = 0 is However, the control signal (21) cannot be implemented because the termṘ faux (t) is not available. To solve this problem, the state observer (9) is used to estimate said term. The state observer is given by then the control signal that is implemented is by substituting the control signal (23) in the system (20), we havė because the term Γ (·) −Ṙ faux (t) − ω F (t) − ω ε (t) vanishes asymptotically, a value of the gain k f can be 215 chosen such that the origin ε (t) = 0, is an asymptotically stable equilibrium point. Now we must guarantee that despite the presence of commutations between pressure increase and decrease, it converges to the reference pressure. For this purpose, it is crucial to force that the flow F (t) remains limited when the pressure increases and that it tends to zero when the pressure decreases. Therefore, only the pressure dynamics are considered, which will be analyzed in terms of the pressure error e P (t). The model that represents the dynamics of the error e P (t) is a first-order system with variable structure given byė where there is a discontinuity surface at e P (t) = 0. The behavior of the trajectories in a neighborhood of this surface is analyzed. When the trajectories tend to the discontinuity surface by the right, we have lim eP →0 +ė in this situation gas is released. Therefore the flow F (t) has a negative value, and then lim eP →0 +ė which implies that the trajectories cross the discontinuity surface. When the trajectories tend to the discontinuity surface by the left, we have which implies that it arrives in asymptotic form. Based on the limits (27) and (28) it is shown that the error e P (t) converges to the origin as follows. If e P (t) < 0 then there is an asymptotic convergence to zero, there are no overshoots because it is a first order system. If we have an initial condition e P (t 0 ) > 0 or if due to some disturbance we have the condition e P (t) > 0, then the trajectories cross the discontinuity surface and subsequently the error converges to zero in asymptotic form. 230 Figure 5 gives a block diagram that shows the overall strategy of the mechanical ventilator operation control, which is described below. The state observers (12) , (15) and (22), which estimate the disturbances and signals necessary to imple-245 ment the controllers, correspond to blocks d), e) and f). The pressure controller, equation (23), corresponds to block g). This controller generates two outputs that control the valves in the system as follows. If the pressure P ref (t) ≥ P (t), which implies that the pressure needs to be increased, then V i P = V i (t) and V e P = Of f . Otherwise, V i P = 0 and V e P = On; that is, gas is released to lower the pressure. The flow controller, equation (14), corresponds to block h). Like the pressure controller, this controller generates the control signals for the two valves. If the breathing process is in the period of inspiration, that is to say F ref (t) > 0 and the pressure in the lungs is below the limit pressure; and V e F = Of f , otherwise V i F = 0 and V e F = On. This ensures that if the pressure in the lungs exceeds the limit pressure, then gas is released to decrease pressure and thus prevent patient harm. All of the blocks that have been previously described operate at the same time. However, the application of the signals from the controllers to the valves is governed by the logic established in block i), called the "Logic stage." The commutation of the controllers depends on the variables "On/Of f " and "M ode" and their operation logic is presented in Figure 6 . If the ventilator is deactivated, On/Of f = 0, then V i (t) = 0 and V e (t) = On, which implies that no gas is introduced to the patient and it can freely leave the lungs. In the volume control mode, the state of the variable s ω is checked. If it is in the inspiration period, s ω = 1, then V i (t) = V i F and V e (t) = V e F . It is important to mention that in the flow control block, 265 block h), it is previously ensured that the pressure in the lungs does not exceed the limit pressure P lim . If it is in the expiration period, s ω = 0, then the control outputs are V i (t) = V i P and V e (t) = V e P . In this way, the P EEP pressure is maintained in this time interval. Finally, the control signals V i (t) and V e (t) are applied to the respective valves through block j). It is important to note that the performance of the closed loop system does not depend on the initial conditions 270 in both control operation modes. while in the expiration period the pressure P (t) converges to the base pressure P EEP . The control signals V i (t) and V e (t) are shown in Figure 8 . Here it can be seen that the control signal V i (t) does not reach the value of 1.5V , which allows us to predict that the proportional valve will not saturate in the experiments. It is interesting to observe the switching of the signal V e (t) that allows the pressure to be released in the period 285 of expiration because it is important to see that it does not have many switches for pressure regulation. The behavior of the state observers that estimate the disturbances and the signals necessary to implement the control signals is shown in Figure 9 . Here, the state variables, black lines, and the estimated states, dotted red lines, are shown in the graphs in the left-hand column. Meanwhile, the estimated disturbances and auxiliary signals are shown in the graphs in the right-hand column. It is important to note that in all 290 cases, the error between the real and estimated states is minimal. Consequently, the estimate of disturbances is considered reliable. It is important to mention that, as in the simulation, to avoid abrupt changes in flow and pressure, the reference signals are smoothed to avoid damage to the patient. Figure 11 shows the performance of the mechanical ventilator in the volume control mode of operation. The upper graph shows the behavior of the flow, red line, and the flow reference signal, black line, while the lower graph shows the behavior of the 310 pressure P (t), black line, the base pressure P EEP , dotted line in green, and the limit pressure P lim , dotted line in blue. During the first two cycles, the level of the reference signal causes the pressure P (t) to reach a pressure close to P lim . However, because the flow does not show overshoots, the on / off valve is not activated to release pressure. The subsequent two cycles decrease the amplitude of the flow reference signal and, as can 315 be seen, the convergence of the flow to the reference signal has minimal errors. In the next two cycles, the value of P lim is decreased in such a way that the safety condition is met and the controller blocks the gas supply and releases the pressure so as not to exceed the P lim level. In the next cycle, it is returned to the previous P lim level and the mechanical ventilator returns to normal operation. In the final two cycles, a change is made in the base P EEP pressure. It can be seen that the pressure level in 320 the expiration period is adjusted correctly. The behavior of the control signals V i (t) and V e (t), as well as the state observers, are qualitatively similar to the obtained in numerical simulations. Finally, an additional experiment is carried out where external disturbances are applied to the system, which consists of applying, in a random and manual way, pressure disturbances to the lung. The results 325 are shown in Figure 12 , where it can be seen that the performance of the flow control does not present any perceptible change. Although there are considerable changes in the pressure level in the inspiration period, in the expiration period the pressure continues to converge to the P EEP pressure level. Finally, Figure 14 shows the behavior of the system when applying external disturbances on the lung, which are applied randomly and manually on the artificial lung. Here, it can be seen that the behavior of the 340 pressure is very similar to the case without disturbances thanks to the changes in the flow that compensate for the disturbances and which generate a robust control system. the same control switching strategy described in section 7, shown in Figure 5 , is used, while eliminating the flow and pressure controllers based on the ADRC structure, blocks h) and g), as well as state observers correspond to d), e) and f ) blocks. A block diagram of the global control strategy using PID controllers is given in Figure 15 . Here the PID controllers are placed; for pressure control, block 2) and for flow control, block 3), and a logical structure 350 that restarts the integrators at the moment of switching between flow control and pressure control, block 1). The gains of each of the controllers are, for pressure controller k p = 0.6, k i = 0 and k d = 0.05, and for flow controller k p = 0.015, k i = 0.14 and k d = 0. is an error between the pressure P (t) and the baseline pressure P EEP . These results show that the ADRC control structure, Figure 16 a), performs better than the PID control, Figure 16 b), for flow and pressure 360 control. This paper has demonstrated, in an analytical, numerical, and experimental way, that the control structure with active compensation of disturbances can be used successfully in the implementation of invasive mechanical ventilators, which are strongly non-linear systems, with delays, disturbances, and parametric 365 uncertainties. In addition, a simple pneumatic circuit that is only composed of a service unit, a proportional valve for flow control, an on/off valve, two flow sensors, a pressure sensor, and the controller is proposed as a viable and economical option to build an invasive mechanical ventilator for critically ill COVID-19 patients. For this option to be massively implemented, it is necessary to replace the dSPACE Microlabbox platform with a compact and economic control platform. However, making this replacement is not an easy task because 370 the operation of the state observers depend on a real-time execution and a sampling time of 1 ms maximum. Consequently, platforms such as Raspberry Pi have to be discarded. However, it has been shown in [16] that the ADRC control structure can be implemented in analog circuits. Therefore, the controllers and observers could be implemented in analog circuits. Meanwhile, the blocks to generate the reference signals, capture the flow and pressure signals, as well as the logic block that switches the pressure and flow controllers, can be 375 implemented in a compact platform such as the Raspberry Pi or myRIO from National Instruments. These platforms will also allow a user-friendly interface. They can also implement all of the security measures and alarms that the different international standards established for this type of equipment enable. Rapid progression to acute respiratory distress 380 syndrome: review of current understanding of critical illness from coronavirus disease 2019 (COVID-19) infection Clinical management of severe acute respiratory infection when novel coronavirus ( nCoV) infection is suspected: interim guidance WHO/nCoV/Clinical/2020.2). World Health Organization Challenges and solutions in meeting up the urgent requirement of ventilators for COVID-19 patients Characteristics of and important lessons from the coronavirus disease 2019 (COVID-19) outbreak in China: summary of a report of 72 314 cases from the Chinese 390 Center for Disease Control and Prevention Mechanical ventilation. Pediatric Respiratory Therapy, Edition, 3 A Practical Guide to Mechanical Ventilation Modeling and control of systems for critical care ventilation Adaptive inverse model control of pressure based ventilation Active disturbance rejection control: methodology and theoretical analysis Control structure with disturbance identification for Lagrangian systems Application of the active disturbance rejection control structure to improve the controller performance of uncertain pneumatic actuators Mechatronic design and active disturbance rejection control of a bag valve-based mechanical ventilator Adaptive control for mechanical ventilation for improved pressure support Differential equations with discontinuous righthand sides Robust observation and identification of nDOF Lagrangian systems Analog implementation of a robust control strategy for mechanical systems