# Structure Optimization and Control Design of Electronic Oxygen Regulator
## 3 Control Method Design  
### Mathematical Modeling  
The mathematical model of the oxygen regulator consists of two parts: the pulmonary valve and the stepper motor. Due to the complex structure of the entire oxygen regulator, model identification using system identification techniques is very difficult. Combining the advantages of identification techniques and mechanistic analysis, both the lung valve and stepper motor models are based on mechanistic analysis.  
Before building the mathematical model, it can be assumed that the gas is regarded as an ideal gas and satisfies the ideal gas equation [16]. The process of gas flow through the positive pressure chamber and the valve is very short, so the heat exchange can be neglected and the gas flow state is regarded as an isentropic process [15]. Considering the  
Figure 3: Direct oxygen regulator structure schematic.  
Figure 2: Electronic oxygen regulator working principle diagram.  
gas in the suction chamber as a control body, the dynamic equations of the gas pressure and flow in the suction chamber are as follows:  
\[\frac{dp}{dt}=\frac{\text{K}\cdot R_{g}\cdot T\cdot\delta_{m}}{V} \tag{1}\]  
\[\delta_{m}=G_{in}-G_{out} \tag{2}\]  
where \(p\) is the gas pressure in the suction chamber, \(T\) is the gas temperature, K is the gas adiabatic index, \(R_{g}\) is the gas constant, \(V\) is the volume of the suction chamber, \(\delta_{m}\) is the mass change, \(G_{in}\) is the gas mass flow rate into the suction chamber, and \(G_{out}\) is the gas mass flow rate out of the suction chamber.  
The gas flow area of the valve is calculated as follows:  
\[A=\pi\cdot(d-x\sin\theta\text{cos}\theta)x\cdot\sin\theta \tag{3}\]  
where \(d\) is the diameter of the valve hole, \(\theta\) is the valve half taper, and \(x\) is the valve opening.  
The gas flow in the suction chamber can be considered an isentropic flow [16]. When expressing the gas mass flow equation, there are two cases.  
In the first case, when \(p/p_{in}>\varepsilon\)  
\[G_{in}=\frac{C_{d}\cdot A\cdot p_{in}}{\sqrt{R_{g}\cdot T_{in}}}\sqrt{\frac{2 \kappa}{K-1}\left(\frac{p}{p_{in}}\right)^{\frac{2}{\kappa}}\left(1-\left( \frac{p}{p_{in}}\right)^{\frac{\kappa}{\kappa-1}}\right)} \tag{4}\]  
In the second case, when \(p/p_{in}\leq\varepsilon\)  
\[G_{in}=\frac{C_{d}\cdot A\cdot p_{in}\cdot B}{\sqrt{R_{g}\cdot T_{in}}}\sqrt{ \frac{2\kappa}{\kappa+1}\left(\frac{2}{\kappa+1}\right)^{\frac{2}{\kappa-1}}} \tag{5}\]  
where \(C_{d}\) is the flow coefficient of the flapper, \(A\) is the flow area of the flapper, \(\varepsilon=\left(\frac{2}{\kappa+1}\right)^{\frac{\kappa}{\kappa-1}}\) is the critical pressure ratio, \(p_{in}\) is the inlet gas pressure, and \(T_{in}\) is the inlet gas temperature.  
The following force balance equation is satisfied during the motion of the stepper motor:  
\[m\frac{d^{2}x}{dt}=F_{m}-c\frac{dx}{dt}-kx+F_{d} \tag{6}\]  
\[F_{m}=k_{m}\cdot i \tag{7}\]  
where \(m\) is the mass of the moving part, \(F_{m}\) is the electromagnetic force, \(c\) is the viscous damping factor, \(k\) is the spring stiffness, and \(F_{d}\) is the disturbance force, \(i\) is the coil current, and \(k_{m}\) is the electromagnetic force coefficient.  
The mathematical model can be synthesized as follows:  
\[\left\{\begin{aligned} \dot{p}=f_{1}(p,w_{1})+b_{1}x\\ \ddot{x}=f_{2}\left(x,\dot{x},w_{2}\right)+b_{2}u\\ y=p\end{aligned}\right. \tag{8}\]  
where \(w_{1}\) and \(w_{2}\) are unknown perturbations.  
\[b_{1}=\frac{\kappa\cdot R_{g}\cdot T}{V}k_{2} \tag{11}\]  
\[b_{2}=\frac{k_{m}}{mR} \tag{12}\]  
In the simulation calculation, \(G_{out}\) is calculated by the human lung capacity model. The variation of human lung capacity can be regarded as a sinusoidal law variation.