FPGA-based ECG signal peak detection and heart rate calculation, including testbench test file and ECG data conversion to coe file program

Table of contents

1. Preview of algorithm operation renderings

2.Algorithm running software version

3. Some core programs

4. Overview of algorithm theory

5. Algorithm complete program engineering


1. Preview of algorithm operation renderings

2.Algorithm running software version

vivado2019.2

matlab2022a

3. Some core programs

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2023/09/05 04:23:51
// Design Name: 
// Module Name: tops
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//

module tops(
input i_clk,
input i_rst,
output signed[11:0]o_data,
output signed[15:0]o_pv2_1, 
output signed[15:0]o_pv2_2, 
output signed[15:0]o_pv2_3, 
output signed[15:0]o_pv2_4, 
output             o_syn, 
output signed[31:0]o_heartrate,
output signed[15:0]o_heartcnt 
);
    
    
//调用心率数据
ECG_data ECG_data_u(
    .i_clk (i_clk), 
    .i_rst (i_rst), 
    .o_data(o_data)
    );

    
// ECG峰值检测模块find_heart_max的实例化,用于检测ECG信号的峰值信息  
//ECG峰值检测  
find_heart_max find_heart_max_u(
    .i_clk      (i_clk), 
    .i_rst      (i_rst), 
    .i_lvl      (16'd500), // 阈值设定为500,此处需要确认该数值的单位和范围是否正确
    .i_peak     ({o_data[11],o_data[11],o_data[11],o_data[11],o_data}),  // 将ECG数据打包成5个11位的信号作为输入峰值信号  
	 
    .o_pv2_1    (o_pv2_1), // 输出的第1峰值电压值  
    .o_pv2_2    (o_pv2_2), // 输出的第2峰值电压值  
    .o_pv2_3    (o_pv2_3), // 输出的第3峰值电压值  
    .o_pv2_4    (o_pv2_4), // 输出的第4峰值电压值  
    .o_idx_1    (), 
    .o_delay_cnt(), 
    .o_syn      (o_syn), // 同步信号,用于控制心率计算模块的工作时序  
    .curr_state (), 
    .cnten      (), 
	 
    .cnt0       (), 
    .cnt1       (), 
    .cnt2       (), 
    .cnt3       (), 
    .cnt4       (), 
	 
    .max_1      (), 
    .max_2      (), 
    .max_3      (), 
    .max_4      ()
    );


//根据峰值位置计算近似心率
//计算心率
heart_rate heart_rate_u(
    .i_clk(i_clk), 
    .i_rst(i_rst), 
    .i_heart    (o_syn), 
    .o_heartrate(o_heartrate), 
    .o_heartcnt (o_heartcnt)
    );

 
endmodule
0058

4. Overview of algorithm theory

        Electrocardiogram (ECG) is a technology widely used in medical diagnostics to monitor the electrical activity of the heart. With the development of medical technology, ECG signal processing systems based on FPGA (Field Programmable Gate Array) have attracted more and more attention. This system has the advantages of high real-time performance, high reliability, and low power consumption, and can meet the needs of modern medical equipment. This article will introduce in detail the method of ECG signal peak detection and heart rate calculation based on FPGA, including principles, formulas and implementation processes.

       The ECG signal is a bioelectrical signal that reflects the electrical activity of the heart. In the ECG signal, the peak point corresponds to the maximum voltage during ventricular depolarization, which is one of the important features for analyzing the ECG signal. By detecting the peak point of the ECG signal, the start and end moments of the heartbeat can be determined to calculate the heart rate.

       The FPGA-based ECG signal peak detection and heart rate calculation method mainly includes the following steps:

  1. ECG signal preprocessing: Due to the presence of noise and other interference in the ECG signal, the signal needs to be preprocessed for subsequent peak detection and heart rate calculation. Preprocessing methods include filtering, amplification, and baseline drift removal.
  2. Peak detection: In the preprocessed ECG signal, the peak point is detected through a certain algorithm. Commonly used peak detection algorithms include threshold method, slope method and maximum method.
  3. Heart rate calculation: Calculate the heart rate through the detected peak point. Commonly used heart rate calculation methods include period method, frequency method and instantaneous heart rate method.

In the process of peak detection and heart rate calculation, the formulas involved include:

        Threshold method: By setting a threshold, the point where the amplitude of the ECG signal exceeds the threshold is regarded as the peak point. The threshold can be determined experimentally or empirically.

       Slope method: By calculating the difference in voltage values ​​of adjacent sampling points, the point with a difference greater than a certain threshold is regarded as a peak point.

       Maximum method: In the ECG signal, the peak point is usually also the local maximum point. Therefore, the maximum value point can be regarded as the peak point by comparing the voltage values ​​of the current sampling point and adjacent sampling points.

     Heart rate calculation: Based on the relationship between the detected peak point time interval and the heartbeat cycle, the heart rate can be calculated.

The implementation process of ECG signal peak detection and heart rate calculation based on FPGA is as follows:

  1. ECG signal collection: Obtain the original ECG signal through ECG collection equipment.
  2. ECG signal preprocessing: Preprocess the original ECG signal, including filtering, amplifying, and removing baseline drift, to facilitate subsequent peak detection and heart rate calculation.
  3. Peak detection: Detect peak points in the preprocessed ECG signal according to the selected algorithm (such as threshold method, slope method or maximum method).
  4. Heart rate calculation: Calculate the heart rate based on the relationship between the detected peak point time interval and the heartbeat cycle.
  5. Data transmission and storage: Transmit the calculated heart rate data to the host computer or storage device for subsequent processing and analysis.
  6. System debugging and optimization: System debugging and optimization are carried out according to actual needs and system performance to improve the accuracy and real-time performance of the system.

       The FPGA-based ECG signal peak detection and heart rate calculation method has the advantages of high real-time performance, high reliability and low power consumption, and can meet the needs of modern medical equipment. Through the implementation of steps such as preprocessing, peak detection, and heart rate calculation of ECG signals, accurate analysis and processing of ECG signals can be achieved. This technology has broad application prospects in fields such as medical diagnosis, health monitoring and sports training.

5. Algorithm complete program engineering

OOOOO

OOO

O

Guess you like

Origin blog.csdn.net/aycd1234/article/details/132697674