jueves, 15 de noviembre de 2018

SPIROMETER


This equipment is used to measure the volume of air that the lungs can hold and the air flow velocity of inhalation and exhalation during respiration. It is composed of a flow sensor where one was located in the flexible tube and another in the lower part of the tube and an ultrasonic sensor located in the upper lid of the spirometer.

Programming code

The spirometer is composed by one intensive spirometer, an ultrasonic sensor and two flow sensors. The first step is measuring the distance of the ball into the spirometer, if we can measure the distance, we can calculate the inspired and expired volume.


Figure 1,spirometer
To measure the distance with ultrasonic sensor, we used the following code:
Figure 2,ultrasonic sensor programming code
The Arduino’s pin #7 is the trigger of the sensor and the 6th Arduino’s pin is the Echo, the ultrasonic sensor send a signal and when this signal detects an object, it comes back to the sensor in an specific time value, in the variable “duracion” is saved the time to detect the object and come back to the sensor and “distancia” is the distance in cm.
Each centimeter has 40 ml of air volume, for this reason, we made a linear regression with the distance VS volume:
Figure 3, linear regression distance vs volume
With the linear regression we can predict the volume with the distance’s value. To know the flow sensor sends an analog voltage, when the spiral is quiet, the voltage is 4.8 volts and when the spiral velocity is increasing, the voltage decreases until 2.4volts during a time value.
Figure 4,linear regression Voltage vs Flow

To count the time into the Arduino, was implemented the following code: 

Figure 5, programming code to get the time
RESULT

INSPIRE


EXHALE

No hay comentarios:

Publicar un comentario