← Back to projects
This project implements a real-time ECG signal processing and heart rate detection system on an STM32L432 microcontroller using FreeRTOS. Raw ECG samples are filtered at 500 Hz, R-peaks are detected using triangle-template matching, and heart rate is computed in BPM. The system outputs a buzzer “heartbeat” on each detected beat and displays BPM on a 7-segment display over UART.
The design follows the EE152 signal-processing pipeline and is structured as a small real-time system with separate tasks for sampling/processing, status, audio output, and display updates.
Hardware Setup
- ECG analog input on PA0 (A0)
- Debug/canned ECG output on DAC PA4 (A3) and debug output on DAC PA5 (A4)
- 7-segment LCD driven via UART TX on PA9 (D1)
- Piezo buzzer output on PA12 (D2)
- R-peak digital pulse output on D6 for timing/verification
Software Architecture
- FreeRTOS multi-task scheduling
- Main processing loop handles sampling + filtering + peak detection
- Separate tasks for status LED, buzzer output, and BPM/LCD updates
Signal Processing Pipeline
- ADC → 60 Hz notch (biquad IIR) → 5 Hz high-pass → triangle template → 35 Hz low-pass → moving stats → adaptive threshold → R-peak detection
- Adaptive threshold computed using ~2-second moving statistics
- Lockout (refractory period) to prevent double-counting closely spaced peaks
Timing & Verification
- Real-time operation at 500 Hz sampling rate
- Debug DAC output enables visualizing intermediate stages of the pipeline
- R-peak digital pulse provides a clean verification signal for detection timing
Real-Time ECG Signal Processing
Real-time ECG filtering at 500 Hz, with BPM computation, buzzer heart beat output, and live 7-seg display over UART.
STM32FreeRTOSUARTDACADC
Highlights
- 60 Hz notch + 5 Hz high-pass + 35 Hz low-pass filter pipeline
- Triangle-template matching + adaptive thresholding + lockout
- Task-based scheduling and debug outputs for visualization
This project implements a real-time ECG signal processing and heart rate detection system on an STM32L432 microcontroller using FreeRTOS. Raw ECG samples are filtered at 500 Hz, R-peaks are detected using triangle-template matching, and heart rate is computed in BPM. The system outputs a buzzer “heartbeat” on each detected beat and displays BPM on a 7-segment display over UART.
The design follows the EE152 signal-processing pipeline and is structured as a small real-time system with separate tasks for sampling/processing, status, audio output, and display updates.
Hardware Setup
- ECG analog input on PA0 (A0)
- Debug/canned ECG output on DAC PA4 (A3) and debug output on DAC PA5 (A4)
- 7-segment LCD driven via UART TX on PA9 (D1)
- Piezo buzzer output on PA12 (D2)
- R-peak digital pulse output on D6 for timing/verification
Software Architecture
- FreeRTOS multi-task scheduling
- Main processing loop handles sampling + filtering + peak detection
- Separate tasks for status LED, buzzer output, and BPM/LCD updates
Signal Processing Pipeline
- ADC → 60 Hz notch (biquad IIR) → 5 Hz high-pass → triangle template → 35 Hz low-pass → moving stats → adaptive threshold → R-peak detection
- Adaptive threshold computed using ~2-second moving statistics
- Lockout (refractory period) to prevent double-counting closely spaced peaks
Timing & Verification
- Real-time operation at 500 Hz sampling rate
- Debug DAC output enables visualizing intermediate stages of the pipeline
- R-peak digital pulse provides a clean verification signal for detection timing