# Hardware-in-Loop Modules for Testing Automated Ventilator Controllers
## 2 Materials and Methods
### OxyVent Development  
When a patient is being mechanically ventilated, there are several settings that may be adjusted to maintain healthy SpO\({}_{2}\) levels. Two such settings are the fraction of inspired oxygen (FiO\({}_{2}\)), based on the alveolar gas equation [36; 37], and PEEP [38; 39]. Thus, the OxyVent module needed to provide an analogue for SpO\({}_{2}\) within a physiologically relevant range, as well as the ability to manipulate said SpO\({}_{2}\) reading via changes in the provided analogues for FiO\({}_{2}\) and PEEP. Figure 2: **Closed-loop ventilation controller logic for CO\({}_{2}\) removal. ****(A)** The functional controller logic flow chart is shown, followed by decision table steps of the controller logic for tidal volume (V\({}_{\text{T}}\)) and respiratory rate (RR). Arrows denote the direction for increases and decreases by controller logic and grey shaded values represent the starting point for controller logic. (**B)** Summary of test scenarios used for evaluating closed-loop ventilation controller logic. To simulate SpO\({}_{2}\), the OxyVent module incorporated the usage of a dissolved oxygen (DO) probe (Atlas Scientific, Long Island City, NY, USA) to measure the DO content in approximately 1200 mL of plain tap water contained in a closed, rigid cylindrical canister, as shown in Figure 3. The DO level within the water was controlled by bubbling a mixture of Breathing Grade Air and Ultra-High-Purity Grade Nitrogen (N\({}_{2}\)) into the water, and the ratio of this mixture could then be treated as an analogue for FiO\({}_{2}\). Compressed gas cylinders (Airgas, Radnor, PA, USA) were used to supply the gases to the system using \(\%\) in (\(\sim\)6.4 mm) plastic tubing and barbed fittings to connect each major component. Similarly to the MechVent module, two-stage regulators were used to step down the supply pressure from each cylinder to 15 psi (\(\sim\)776 mmHg), and 15 gal (\(\sim\)57-L) expansion tanks (McMaster-Carr, Elmhurst, IL, USA) were used to improve the stability of the supplied pressure. The outlets of each of the two expansion tanks were connected to solenoid valves (US Solid, Cleveland, OH, USA), which enabled independent control over the flow of each gas. Following the solenoid valves, the two supply lines were merged using a T-fitting into a single line that was then connected to the inlet of the rigid canister, as shown in Figure 3. Since the solenoid valves functioned in a binary fashion, i.e., being either fully open or fully closed, further control over the composition of the supplied gas mixture was enabled by utilizing open-closed pulsations at various duty cycles. We used three duty cycles that were defined as _Full_, open 100% of the time; _Partial_, open 50% of the time; and _Off_, closed. Because the OxyVent module performance relied on the absorption of O\({}_{2}\) into the water, multiple steps were taken in an attempt to improve consistency and reliability in the rapidity and homogeneity of said absorption. Firstly, a diffusion ring that was connected to the gas inlet and positioned at the bottom of the canister was designed. This diffusion ring distributed the gas from the supply line out around the perimeter of the canister through a series of holes, rather than a single centralized point. The canister was also placed on a magnetic stir plate (Thermo Scientific, Waltham, MA, USA) paired with a crosshead stir bar, which was set in the center of this diffusion ring and spun at 200 rpm. Finally, a secondary diffusion plate was integrated overtop the diffusion ring and stir bar. This plate spanned the entire cross section above the stir bar and included an array of 11 holes with spacings of approximately 23 mm. This prevented the formation of a vortex in the canister from the  
Figure 3: **Diagram of the OxyVent module. ** Compressed nitrogen (N\({}_{2}\)) and air flow from the supply tanks to expansion tanks and then to the pressure canister through solenoid valves controlled by a microcontroller.