LifeLink Algorithms Documentation
This document describes the signal processing algorithms used in the LifeLink project for Vital Signs monitoring and Fall Detection.
1. Heart Rate & SpO2 (FFT-Based)
We use the Fast Fourier Transform (FFT) to analyze the Photoplethysmogram (PPG) signal from the MAX30102 sensor. This method is more robust against motion artifacts compared to simple peak detection.
Implementation Details:
- Library:
espressif/esp-dsp(Hardware accelerated on ESP32-S3). - Sampling Rate: 100 Hz.
- Buffer Size: 512 samples (~5.12 seconds of data).
Steps:
- DC Removal: Subtract the mean value of the signal.
- Windowing: Apply a Hann Window to reduce spectral leakage.
- FFT: Compute the complex FFT.
- SpO2 Calculation:
- AC & DC Extraction:
- DC Component: Static absorption from tissue/bone (extracted from 0Hz FFT bin).
- AC Component: Pulsating absorption from arterial blood (magnitude at heart rate frequency).
- Ratio of Ratios:
$$R = \frac{AC_{red}/DC_{red}}{AC_{ir}/DC_{ir}}$$
- Final Formula: Saturation percentage using linear (empirical) approximation:
$$SpO_2 = 110 - 25 \times R$$
* Optimized for the clinical range (70-100%) providing high accuracy and low CPU overhead.
- AC & DC Extraction:
2. Advanced Fall Detection (3-Phase Model)
Fall detection uses data from the QMI8658 IMU and implements a state machine to distinguish real falls from daily activities.
Core Concept: SVM (Signal Vector Magnitude)
The total G-force is calculated as:
$$SVM = \sqrt{a_x^2 + a_y^2 + a_z^2}$$
The 3-Phase Logic:
- Phase 1: Free Fall:
Detects weightlessness (SVM < 0.6g). The system records the reference orientation of the arm just before the drop.
- Phase 2: Impact:
Sudden G-force spike (> 3.5g) within a 500ms window. This separates real falls from common arm impacts.
- Phase 3: Stillness & Orientation Check:
Monitors stability for 5 seconds. If the user remains still, the orientation change relative to Phase 1 is calculated.
Orientation Verification
Utilizing cosine similarity (dot-product) to calculate shift magnitude:
$$\theta = \arccos\left(\frac{v_{ref} \cdot v_{curr}}{|v_{ref}| \cdot |v_{curr}|}\right)$$
If $\theta > 60^\circ$ and stillness is verified $\rightarrow$ CONFIRMED FALL.
3. Sensor Fusion & Rate Limiting
- GPS (LC76G): Polled every 100ms.
- Rate Limiting: UI/Log updates at 10Hz to save CPU for DSP processing.