Abstract
Spirometers are devices commonly used by clinicians to diagnose lung health by measuring pulmonary volumes and expiratory flow rates. Digital spirometers convert pressure differences across a mouthpiece into volumetric flow rates, which is integrated to calculate the volume. We designed a digital spirometer that uses a MPX2010 pressure sensor, two-stage op-amp circuit, and Arduino Nano Every to report user lung volumes.
The two-stage op-amp circuit contains a INA126 instrumental op-amp and a single-pole, non-inverting low-pass-filter with gain to increase the signal from the pressure sensor by 2252 and filter out noise above 10 Hz. Two separate calibration methods were tested to calculate the sensitivity of the device, a value necessary for converting from voltage to volume.
The chosen method yields measured values within 2.5% of the actual value. The device includes an algorithm to determine the functional vital capacity of the patient, which is a proven predictor of pulmonary health and function.
Introduction
Spirometry is a common method for clinicians to diagnose lung health. By measuring how much volume a patient can inhale and exhale compared to normal capacities, they can assess whether a patient is affected by various respiratory illnesses such as asthma, chronic obstructive pulmonary disease (COPD), or other conditions that limit breathing 1. There are several varieties of spirometers that differ in their functionality and features.
A basic spirometer consists of a mouthpiece connected by a tube to a piston system that will move up as the patient breathes in 2. On the high end, professional spirometers used in clinical settings have the mouthpiece connected to a machine that has many options to make and display electronic measurements such as peak expiratory flow rate, forced expiratory volume, and forced vital capacity.
A compromise between these types of spirometers is a digital spirometer that operates based on an internal turbine system which is cheaper but more susceptible to damage. Instead, a pressure sensor provides a similarly priced alternative with a longer life-span.
Therefore, the development of a quality digital spirometer application utilizing a pressure sensor with expanded functionality is critical for cheap care outside of clinical settings. The choice to implement this design with an arduino microcontroller provides a simple digital interfacing platform that offers sufficient capabilities to create an interactive spirometer.
A basic pneumotach consists of a membrane with fixed resistance against airflow. On each side of the membrane, pressure is different as air flows through. This pressure differential is linearly related to the airflow and is related by the resistance of the membrane.
A pressure transducer converts this pressure differential to a function of voltage where larger pressure differences correspond to higher voltage differences when the air flow is greater. By integrating the airflow over time, the volume of air passing through the pneumotach can be determined. Additionally, the proportionality constant must be determined through calibration with known volumes.
- is volume in liters
- is flow in liters/sec
- is the
- = resistance of the screen (Liters/sec/Pascal)
- is the sensitivity of the pressure transducer Pascal/Volt
- is the voltage
- is the sensitivity of the spirometer in Liters/sec/Volt
Figure 1. Equations used in the calculation of the proportionality constant for converting pressure difference to volume.
Besides basic inhalation and exhalation volumes, measurements with spirometers can also be used to calculate critical indicators of lung health. Forced vital capacity (FVC) shows the total volume of air that can be exhaled during a maximal forced expiration effort.
Previous studies have concluded that low FVC is a risk factor for premature death and this measure has often been referenced as the most important spirometry measurement 3. The details of calculating a patient’s FVC are outlined in the methods.
Methods
MPX2010 Pressure Sensor
A two-stage circuit was designed and constructed to effectively convert the respiratory output into an electrical signal that could be translated into a measurement. First, the air exhaled or inhaled by the patient produces a measurable pressure difference across a membrane detected by the MPX2010 Series pressure transducer (NXP semiconductors).
The pressure difference across a membrane is directly proportional to the volumetric flow rate across the membrane 4. The MPX2010 series device contains two pressure sensors, each of which translates the pressure at that point into a proportional voltage.
INA126
The MPX2010’s two output voltages are fed into the V+ and V- inputs of the INA126 instrumental operational amplifier (Texas Instruments) (Figure 2B). The voltage difference between the two MPX2010 output voltages is proportional to the pressure difference across the membrane.
The INA126 acts as a differential op-amp that amplifies the difference between the two voltage inputs. It provides an easy way to adjust the gain through the selection of the gain resistor 5.
Figure 2. Circuit diagram of designed digital spirometer. A. Overview of 2-stage circuit with total gain of 2252. Inputs are V+ and V- of the MPX2010 pressure sensor. The circuit is powered by ± 9 V from a Keithley 2230 Power Supply B. INA126 instrumentation op-amp with inputs from the MPX2010 pressure sensor, offset voltage if 0.0985 V, and of 1kΩ. The gain is measured to be 69.5. C. LF353 single-pole, non-inverting low-pass filter op-amp with gain of 32.4 and cutoff frequency of 10.61 Hz.
Given the choice of a 10 kΩ resistor, the theoretical gain would be 85 at the output of the op-amp. The actual gain was measured at 69.5.
This stage is also where an offset voltage is applied to center the voltage signal around 2.5 V to utilize the entire Arduino Nano Every input voltage range of between 0 and 5 V. All components are supplied with +9 V and -9 V from a Keithley 2230 Power Supply.
The reference pin of the INA126 requires a low impedance input voltage, so a voltage follower was implemented using one of the two op-amps on the LF353 op-amp (Texas Instruments). The voltage follower is supplied with 0.0985 V from the third output on the Keithley 2230 power supply, passed through a voltage divider to reduce it by half from 0.197 V. This voltage value was determined by trial and error until the voltage was centered around 2.5 V for no pressure difference.
LPF with Gain
Finally, the output of the differential op-amp is passed to a single-pole, non-inverting low-pass filter built from the second op-amp on the LF353 chip (Figure 2C). This LPF was designed with a cutoff frequency of 10.61 Hz to filter out noise, especially the 60 Hz noise present in most signals, and with a theoretical gain of 32.9 to maximize the range from 0 V to 5 V for the Arduino pin. Experimentally, this gain came out to be 32.4. The total gain of the circuit is 2252.
User Interface
Finally, this filtered voltage signal is provided to the Arduino to be converted into a digital signal. The Arduino is also connected to 3 buttons that are used in menu selection and an SSD136 128x64 I2C OLED screen used to display menus, instructions, and results.
Software
All software for signal processing and user interface was coded in Arduino Programming Language to be utilized by the Arduino Nano Every microcontroller.
Calculating Volume
Volumetric flow is calculated from pressure difference-dependent voltages by the equation:
where is the volume, is the sensitivity/proportionality constant of the spirometer (in units L/Volt), and is the voltage due to a pressure difference.
The main function of the digital spirometer is an integration function. The amplified and filtered voltage difference from the MPX2010 sensor is inputted into an analog pin in the Arduino.
The Arduino then utilizes an internal analog-to-digital converter to report the input voltage as an integer on a scale from 0 to 1023, which is then converted to a voltage by multiplying by 5.0 volts/1024 units. Code was written to sample the input voltage at a 100 Hz sampling frequency and store the values in an array. Other sampling rates were tested, but 100 Hz gave the most reliable results.
Higher sampling rates were affected more by the internal processes that take time and impair immediate sampling. Trapezoidal sums are then used to calculate the voltage sum of all values in the array, using a dt of 0.01 s. The integration function was tested with an array of known values and outputted the expected integrated sum, signifying proper function.
After calculating the voltage sum, the program must convert voltage to volume in liters. Calibration to determine the sensitivity of the spirometer is required before each series of uses to account for environmental factors. A 3-L syringe is used to supply reliable 3 L volumes across a membrane flanked by the MPX2010 pressure sensor.
Initially, a 3-L syringe with graduations was used to deliver volumes between 0 and 3 liters for more robust sensitivity measurements (Figure 3). However, unreliability in the measurements led to the utilization of simple 3 L volumes to determine k.
Figure 3. Linear fit used in initial calibration method. Least-squares linear fit found between voltage sum and volume for 15 points, 5 measures at each of the following volumes: 1 L, 2 L, and 3 L. The inverse of the slope is used as the proportionality constant to convert voltage sum to volume.
The calibration script estimates the value of k from five 3 L inputs. The voltage sums for the five inputs are averaged. Then, 3 L is divided by the voltage sum to yield k in terms of L/volt. This sensitivity value is used to convert the measured voltage sum into a volume, forming the basis of the spirometer’s function.
Exhalation and inhalation were treated differently since exhalation causes the proximal sensor to have a higher pressure while inhalation causes the distal sensor to have a high pressure. The circuit was designed such that exhalation causes increases in voltage while inhalation causes decreases in voltage.
Hysteresis
An important aspect of the volume measurement system is that the Arduino does not begin storing values until the user has exhaled or inhaled into the device. Thus, hysteresis was implemented to dictate when measurements were made.
Without any user input (using the device), the input voltage was between 2.53 and 2.58 V, depending on the environmental conditions. While sitting in the ambient environment, the voltage fluctuated by as much as 0.03 V.
Consequently, a conditional statement was written such that the Arduino did not record measurements until the input voltage changed by more than 0.05 V from the “ambient voltage.” Once the input voltage returns to within 0.05 V of the zero-point voltage, the Arduino stops recording measurements.
FVC Mode
A useful aspect of this spirometer is its ability to quickly determine the user’s FVC from four simple measurements: inspiratory capacity (IC), two tidal volumes (TV), and TV plus expiratory reserve volume (ERV). These measurements were chosen because their expected volumes are within the calibration range of the 3-L syringe 6. 7
IC is defined as the maximum volume able to be inhaled. TV is the volume of a normal inhalation/exhalation. One inhaled TV and one exhaled TV were averaged to use as the TV value. TV + ERV is the volume of a forceful exhale after a normal inhalation. Using the relationships outlined in Figure 4, the equation for FVC is:
where is the inspiratory reserve volume 8.
Figure 4. Spirometric volumes and relationships.
User Interface
As mentioned previously, the user controls the device through a set of three buttons (Left, Right, and Confirm) and an OLED. The user may select from three modes: Exhalation, Inhalation, and FVC.
Exhalation mode waits for an input voltage 0.05 V higher than the zero-point. Inhalation mode waits for an input voltage 0.05 V lower than the zero-point. After detecting no user input, the recorded volumes are displayed on the OLED.
The FVC mode combines these two concepts and prompts the user for four separate measures, two inhalations and two exhalations. The Arduino manipulates those specific measurements to calculate the FVC, which is displayed on the OLED, along with the user’s , , and .
Figure 5. State diagram of digital spirometer.
Results
Circuit Validation
The main aspect of the circuit that needed to be verified were the gains of the stages, which were measured by applying known voltages and voltage differences. A DC voltage difference of 0.11982 V, supplied by two outputs on the power supply, was applied to the INA126.
The DC-gain was measured at -69.467, significantly different from the theoretical gain of -85. The voltage follower had an input of 0.11798 V and an output of 0.11798 V, indicating unity gain as expected. Lastly, the LPF had a measured gain of 32.4, which was similar to the theoretical gain of 32.9.
Accuracy and Reliability
The two calibration methods were tested for accuracy and reliability (Figure 6). The original method for calculating the spirometer sensitivity (different volumes) yielded higher accuracy on average but also higher variability in the measurements. In addition to the low reliability, another disadvantage for this method included time taken to calculate the linear least-squares fit of the volume vs voltage.
The simplified algorithm (five samples of 3-liter inputs) showed similar accuracy and higher reliability for 3-liter measurements. This method is simpler and requires no manual inputs or calculations besides the 3-liter samples. Results were found to be improved if separate sensitivity values were used for exhalation and inhalation.
Figure 6. Percent errors of spirometer measurements for 3 liter inputs after different calibration methods. A. Percent errors of exhalation (Left, red; N = 20, M = -0.250, SEM = 0.242) and inhalation (Right, blue; N = 20, M = -0.317, SEM = 0.118) measurements using separate sensitivities for each mode, calculated from 5 samples of 3 liters. B. Percent errors of mixed exhalation and inhalation using a sensitivity calculated from 15 values of volumes between 0 and 3 L. N = 15, M = -0.011, SEM = 0.421.
Testing was limited by the available syringe for delivering known volumes. The original syringe had graduations but variability in reading and delivering resulted in less reliable measurements. The second syringe, which was used for the latter parts of device design, was limited to only 3 liters and no graduations.
In the end, both calibration methods provide simple algorithms to determine the sensitivity of the spirometer that can likely be applied to other volumes. However, the available equipment restricted testing of volumes other than 3 liters. The simplified method (Figure 5A) was chosen due to its ease of use and quickness.
FVC Mode
The FVC mode was not fully tested due to the previously mentioned constraints of the 3-liter syringe and the lack of human testing. However, the final reported FVC value agreed with the displayed measurements for each step.
Footnotes
-
Mandal, N. G. “Respirometers Including Spirometer, Pneumotachograph and Peak Flow Meter.” Anaesthesia & Intensive Care Medicine, vol. 7, no. 1, 2006, pp. 1-5, doi:https://doi.org/10.1383/anes.2006.7.1.1. ↩
-
Cross, Troy J et al. “The syringe potentiometer: a low-cost device for pneumotachograph calibration.” Journal of applied physiology (Bethesda, Md. : 1985) vol. 127,4 (2019): 1150-1162. doi:10.1152/japplphysiol.00150.2019 ↩
-
Barreiro, Timothy J, and Irene Perillo. “An approach to interpreting spirometry.” American family physician vol. 69,5 (2004): 1107-14. ↩
-
Schena, Emiliano et al. “Flow Measurement in Mechanical Ventilation: A Review.” Medical Engineering & Physics, vol. 37, no. 3, 2015, pp. 257-64, doi:https://doi.org/10.1016/j.medengphy.2015.01.010. ↩
-
Kuphaldt, Tony R. “The Instrumentation Amplifier.” Lessons in Electric Circuits. https://www.allaboutcircuits.com/textbook/semiconductors/chpt-8/the-instrumentation-amplifier/ ↩
-
Lofrese, John J., et al. “Physiology, Residual Volume.” StatPearls, StatPearls Publishing, 20 October 2021. ↩
-
Hallett S, et al. “Physiology, Tidal Volume.” StatPearls, StatPearls Publishing, 9 May 2021. ↩
-
Lung Volumes and Capacities. 15 Aug. 2020, https://bio.libretexts.org/@go/page/14026. ↩