Implementation of Gyro Accelerometer Sensor for Measuring Respiration Rate Based on Inhale and Exhale Using Kalman Filter

Respiratory rate is a fundamental vital sign that is sensitive to different pathological conditions including heart, lung, emotional stress, the influence of body temperature and activity fatigue. The respiratory rate in humans is measured by counting the number of breaths for one minute by monitoring and counting the number of times the chest rises and falls during the inhale and exhale process. Various methods for measuring respiratory rate that are commonly used including pneumograph, impedance and capnography are applied in patient monitoring. This study aims to examine and analyze the application of the kalman filter on the output of the gyro accelerometer sensor to increase the results of the detection of respiratory rates using the gyro accelerometer sensor. This study test was carried out using a patient simulator in Surabaya Ministry of Health Polytechnic nursing laboratory. This simulator patient can simulate respiration with a mechanical work system up and down the chest and abdomen, uses an Arduino Nano microcontroller to filter the output of the gyro accelerometer sensor and the results will be compared before and after the filter. The independent variable in this study is the respiration value, while the dependent variable is the sensor output before being filtered. In the relaxed condition of the respondent The most effective use of the kalman filter is found in the parameters R = 10, Q = 0.1 because in the use of these parameters, the value after being filtered has a value that tends to be stable. The highest error value in the application of the gyro accelerometer sensor occurs at sensor position 1 with R = 1 Q = 10 value of 2,6%. This study shows the effect of differences in respiration values before and after using a kalman filter. This study has limited differences in values that are far between the pre filter and after being filtered in several data collections.


I. INTRODUCTION
The respiratory rate in humans is measured by counting the number of breaths for one minute by monitoring and counting the number of times the chest rises and falls during the inhale and exhale process [1][2] [3], Respiration can be increased by the presence of something going on in the body such as a fever, illness, or other medical condition. Various methods of measuring respiratory rate are commonly used, including impedance pneumography, and capnography, which are commonly used in patient monitoring [4]. In addition, a new technique is being developed to automatically monitor the respiratory rate using an accelerometer sensor [5] [6]. Accelerometer is one of the sensors used to determine respiration through the movement of exhale and inhale made by the body when the breathing process occurs [7] [8]. Although research on the gyro accelerometer sensor has been carried out a lot, there are still some shortcomings including the calculation of the respiration value which has a large error because there are several changes in position detected by the sensor which are not actually movement of the respiration process. This is because the gyro accelerometer sensor detects every change in position due to its high sensitivity [8] [9]. One way to reduce the respiratory [10] [11] error value generated by the detection of inhale and exhale positions on the gyro accelerometer sensor can be done by filtering the gyro accelerometer output [6]. In previous studies, it was stated that the output of the gyro accelerometer sensor needs to be filtered using a kalman filter so that the sensor output is more precise and accurate. Kalman filter is a generic algorithm used to estimate the desired system parameters [12][13] [14] [15]. Input can be in the form of inaccurate measurements or have noise to estimate the state of certain variables or other variables that cannot be observed with greater accuracy [16]. The advantage of using a kalman filter is not to refine the results. However, to estimate the outcome of something uncertain [17]. Estimates to determine the output of a given sample that operates in real time, allowing greater system control [18] [19]. This study aims to examine and analyze the application of the kalman filter on the output of the gyro accelerometer sensor to improve the results of respiration detection using the gyro accelerometer sensor. The Kalman filter itself has never been applied to respiratory signal readings.

A. KALMAN FILTER
Kalman filter is a generic algorithm that is used to estimate the desired system parameters [12] [20]. Input can be in the form of inaccurate measurements or have noise to estimate the state of certain variables or other variables that cannot be observed with greater accuracy [16]. The use of kalman filters is usually on: • Object tracking: Uses the measured position of an object to more accurately estimate the object's position and velocity [21]. • Estimated weight on a digital scale: the pressure measured on a surface to estimate the weight of an object on that surface. • Navigation and control : Uses the Inertial Measurement Unit (IMU) [22][20] sensor to estimate an object's location, speed, and acceleration, and use these estimates to control the next object's movement [16][23].
The advantage of using a kalman filter is not to refine the results. However, to estimate the outcome of something uncertain [17]. Estimates to determine the output of a given sample that operates in real time, allowing greater system control. Rudolf Kalman developed a filter to improve the Wiener filter's problem in estimating a state [24]. In the Kalman filter, generally, the estimated state vector and the measured state vector at time k can be expressed as a state space model as written in the Eqs. (1) and (2). Vector and were modelled as a process and measurement noise which are assumed as zero mean, normally distributed, white Gaussian noise and independent each other with covariance matrix of Q and R respectively. Matrix A relates the estimated state vector and previous-estimated state vector. Matrix B relates the estimated state vector to input control . Matrix H conjunctions between the measurement state vector and estimated state vector . Generally, the step of Kalman filter is described in the FIGURE 1.
In this work, the elbow-joint angles were estimated based on EMG features which is in a scalar quantity thus all state vector and matrix in the Eqs. (1) and (2) were scalar quantities. In the constant movement, it was reasonable to assume that the matrix A is equal to 1. Due to the estimate state was directly measured from measurement state thus the H matrix is equal to 1 [12]. In this work, there was no control input parameter that affected the estimated angle, and the process noise is assumed as white Gaussian and zero mean. Therefore, the estimated state and measurement state in the Eqs. (3) and (4) can be written as follows: In the Kalman filter, the filtering process is consisting of predict stage and update estimation as shown in Fig.  4[25] [26]. In the predict stage, a priori estimated state ̑− is calculated based on previous estimated stated ̑− 1 as written in Eq. (5). A priori estimated error covariance − is determined using previous estimated error covariance −1 and process noise covariance Q, Eq. (6). In the update estimation stage, the current estimate state ̑is a linear combination of prior estimated state and the difference between measurement and priori estimated statȇ−. In this case, the EMG features is . Kalman gain is calculated using Eq. (7) which is contain priori error covariance and measurement noise covariance. The estimate state and error covariance are in accordance to Eqs. (8) and (9) respectively.
Kalman Filter is an algorithm used to predict (or estimate/estimate) the next result based on the previous data. It is not categorized as a general filter like LPF, HPF, and BPF. It is basically an estimator (estimator) to predict the state or any part in the signal that contains the signal. The result of this estimation process is the same as removing noise from the signal, therefore it is called Kalman Filter.
The system in Kalman Filter is assumed to be a linear system. The Kalman Filter minimizes the mean squared error estimate for a stochastic linear system using a linear noise sensor. It also minimizes the quadratic function of the estimation error for linear dynamic systems with white measurement and noise disturbance. Serves to estimate (estimate) the state (state) in dynamic systems and also to analyze system performance.  reset button which -function to reset the signal display on the graph, exit button which serves to close the Delphi application. There are 9 signal display charts, each of which has 2 signals, namely the white signal is a respiration signal from the gyro accelerometer sensor data before being filtered by Kalman and the colored signal is a respiration signal that has been filtered by Kalman. The respiration per minute values in bpm (breath per minute) are displayed next to the signal graph chart, respectively.

FIGURE 2. Module Circuit Inside Box
This Kalman filter test was conducted to determine the effect of the constants R and Q on the Kalman filter algorithm on the respiration value. The value of the Kalman filter constant is set to R=1 Q=10, R=10 Q=0,1, R=10 Q=1. For each test, data were collected 5 times and then the average of each set of respiration parameters was taken. The respiration value is compared between the readings on the module in Delphi with the readings on the standard patient simulator on the monitor.   20 20 It can be seen in FIGURE 4 that R=10 Q=0.1 has a small error value compared to the constant setting R=1 Q=10 and R=10 Q=1. This is because changes in the constant setting on the Kalman filter also affect the shape of the respiration signal so that the reading of the respiration value will also change [27]. In the setting of the Kalman filter constant R=1 Q=10 the signal is more responsive, the signal changes are faster so that there is noise in the signal even after filtering.

FIGURE 4. Error graph on Kalman Filter constant
Likewise, in the setting of the Kalman filter constant R=10 Q=1 the resulting signal has a faster response, the noise generated by the gyro accelerometer sensor is not filtered as a whole which causes it to be detected as a respiration signal so that the respiration value has an error. While at the setting of the Kalman filter constant R=10 Q=0.1 the resulting signal has a slow response so that the noise in the respiration signal is not visible and causes a more accurate reading of the respiration value. In FIGURE 5 is a flow diagram where after the module has carried out the initialization process and then reads data from the gyro-accelerometer sensor after the data is obtained, the filtering process is carried out using a Kalman filter to produce a respiration signal. Then the respiration signal will go through a thresholding process with a threshold of 80% of the maximum value of the respiratory signal. Respiration value per minute is obtained from the formula 3 * 60000 divided by the period formed by 3 breaths. The processed respiration signal and respiration value are then sent to the Delphi application on a Personal Computer (PC) via Bluetooth using the Blue-tooth module. If Bluetooth on the PC has been activated, Delphi will get data on the value of the respiration signal and the value of respiration. Furthermore, the respiration signal is displayed on the graph and the respiration value will be displayed in real time.

IV. DISCUSSION
After testing the module, data collection and analysis of the results are carried out to determine the accuracy of the value of the output of the 3 gyro accelerometer sensors as sensors used to monitor the RR [7] [28]value in the research module. The standard deviation value obtained from the measurement with the module is said to be good, because the result of the standard deviation value does not exceed the average value of the module measurement. This shows that the average value of the module measurements can be used as a measurement representation of the overall data. Data collection was taken using a manequeen simulator with 3 kalman filter parameters. That is R=10, Q=10, then R=10, Q=0,1, and R=10, Q=1. For the use of the most effective kalman filter, there are parameters R = 10, Q = 0.1 Where the graph results obtained are the noise is filtered well but the kalman output response looks slow (less responsive).
And also due to the use of this parameter, the value after being filtered has a value that tends to be stable and there is no drastic increase and decrease compared to other kalman filter parameters [29]. The respiration values at the settings of 12, 15 and 20 Bpm have a stable value at the placement of 2 sensors in the manequeen simulator, with a maximum difference of 1 for each respiration setting Factors that affect the inaccuracy of the respiration value before the filter include the form of a signal that has a lot of noise, and is less stable so that it affects the results of the RR value every minute. The RR signal after the kalman filter has a stable signal shape. The performance of this work is also compared with the work of Ja-Woong Yoon, Yoen-Sik Noh, entitled "Improvement Of Dynamic Respiration Monitoring Through Sensor Fusion Of Accelerometer and Gyro-Sensor" which in this study also uses a kalman filter for processing the output signal of the gyro accelerometer sensor. The results of this study stated that the use of a kalman filter increased the sensor readings so that the respiration signal could be detected [30].

IV. CONCLUSION
The purpose of this study is to analyze the Kalman digital filter on the application of the gyro accelerometer sensor to detect breathing so that breathing can be detected properly by the sensor and produces a respiratory rate per minute for health diagnosis. This study shows that the Kalman filter can be applied to the use of a gyro accelerometer sensor so that the respiration signal produced is smoother and produces an accurate respiration value. After testing by comparing the parameter settings of the constant values on the Kalman filter, the most effective use of constant values is R = 10, Q = 0.1, because in the use of these parameters, the value after being filtered has a value that tends to be stable with the highest error value of 2,8%. This module uses a Delphi display on a PC by displaying 9 respiration signals on the three sensors so that it can analyze the shape of the respiration signal generated from the three sensors in real time. For further research, it can be developed again, namely replacing the gyro sensor which is more accurate and more precise in its output value. then replace the mechanical sensor so that respiration is easier to detect.