## 4 System Description
### Continuous Displacement Algorithm  
To recognize human activity, it is mandatory to collect and process data provided by the IMU unit. In this case, the acceleration magnitude (Amag) was used to calculate the difference between its two-consecutive samples (\(\Delta\alpha\)mag) with Amag, Amag-1, and compute the average between them, the previous and the current readings, for activity recognition.  
\[\Delta\text{Amag}=\sqrt{\text{x}^{2}+\text{y}^{2}+\text{z}^{2}} \tag{1}\]  
where x, y, z are the three axes of the accelerometer. Figures 3-5 show the behavior of Amag and \(\mid\Delta\text{Amag}\mid\) during three activity conditions:  
1. No activity (sitting).
2. Ordinary movements (walking).
3. Doing physical exercise (running).  
Figure 3: No activity.  
The Acc signal acquisition was carried out for 1 min in real-time. The signal can only react to the apparent motion of the body. Under stillness, no extremes were found, and the accelerometer maintained a constant value without any extremes, so the \(\mid\!\Delta\alpha\mathrm{mag}\!\mid\) maintained a constant value without unnecessary interruptions. Hence, the \(\mid\!\Delta\alpha\mathrm{mag}\!\mid\) was almost 1 at all times. Regular activities can cause sudden variations, but it is easy to realize that the signal behavior is random with tiny \(\mid\!\Delta\alpha\mathrm{mag}\!\mid\) at low frequencies. Likewise, if the user performs physical exercises, the \(\Delta\alpha\mathrm{mag}\) frequently varies with high repetitive extremes due to numerous motions that cause and \(\mid\!\Delta\alpha\mathrm{mag}\!\mid\) fluctuations repetitively with similar values. To distinguish between normal activities and training, the CDA counts the number of extremes per a specified period (20 s) to decide whether the person is exercising. Additionally, pertinent literature indicates that the body's temperature returns to standard levels approximately 20 min after exercise. Therefore, the timer is to count that period and adjust the temperature threshold accordingly at 37.5 \({}^{\circ}\)C, which is the maximum body temperature during exercising.  
The CDA flowchart, in Figure 6, presents a comprehensive overview of the implemented algorithm. We gathered accelerometer data using the Vector Equation and stored the data into an array of 100 elements each time, calculating the average between two vector elements each time. After the data were stored into another array, a threshold was generated, computing the total average of the 100 elements. Values above that threshold were counted as local extreme values. If the local extremes were above a set value acting  
Figure 4: Ordinary movements.  
Figure 5: Physical exercise.  
as a threshold, coronal activity was detected and adjusted the points accordingly. The following equation calculates the average vector:  
\[\text{AverageVector}[a]=\sum_{a=0}^{99}\frac{\frac{\text{vector}[a]+\text{vector}[ a-1]...a=99}{2}}{99} \tag{2}\]  
where: \(a\) is the capacity of an array ranging from 0 to 99 and Average Vector[\(a\)] is an array of 100 elements which calculates the avg of the vector[\(a\)] which is calculated by the \(\Delta\)Amag formula.  
This process was repeated for 20 s each time. Suppose the number of spikes we found on that time interval is above the spike threshold. In this instance, the exercise's Boolean variable is shifted from 0 to 1. Afterward, we adjust the temperature threshold from 36.8 to 37.5 \({}^{\circ}\)C which is the temperature threshold that comes into place if someone is exercising. This value is held for 20 min. The data acquisition is accomplished by using the device's serial port to transmit data and a computer (in combination with a serial monitor) to receive data. In summary, if they are enough extremes in a specified period and if the corresponding extreme values are above the threshold, the flag is shifted from 0 to 1. Consequently, the temperature cut-off value is adjusted from 36.8 \({}^{\circ}\)C to 37.5 \({}^{\circ}\)C.  
Figure 6: CDA flowchart.