资源简介
ECG检测系统的设计方案,包括了硬件说明,软件说明和基于keil for arm的C源代码
PCB已经调通,程序代码也DEBUG好
可供借鉴
代码片段和文件信息
//Hardware : ADuC7020
//Reference : ADCtimer.c(C:\ADuC_Beta702x\code\Keil Code Examples
// \ADuC7020\ADC\ADCtimer\ADCtimer.c)
#include // Include ADuC7020 Header File
#define sample 177
// ADuC7020设置为采样率200Hz 但PC端接收到的数据为177/8 Hz.
//可能是串口速度太慢,而且是在加心率算法后的结果
#define baseline 2000
int adchr=0;
int ecgadc0=0ecgadc1=0ecgadc2=0ecgadc3=0ecgadc4=0;
//这部分变量是采样和心率滑动平均时用,但是实际并没有用到
int sequ=0Rtime=100Stime=0Rwaveold=0Rwavenew=0;
//这部分变量处理R波位置和心率计算 计算一次心率需要2个R波
int Rwave[2]r=0;
int RRinterval[4]={0000}*rrRRaverage=0j=0;
// 计算R-R间的平均值
int Max=0Min=5000Maxold=0Maxnew=0;
//这部分变量是关于阀值设置的.
int MaxthresholdMinthreshold;
int pMaxpMin;
int Max_Minarray[6]={200020002000200020002000}temp=0;
char ignoflag=1threflag=1calflag=0reversalflag=0;
char HRcountflag=0aflag=0iflag=0maxflag=0;
/*int count=0countp=0countpold=0countpnew=0;
//these variables are used to count QRS complex and to follow baseline.
long base=0;
//But baseline following has not finished yet.
int basec=0baseave=2000;
char normalflag=1;
int QRSwave=0;*/
void initialization_chip(); //Initialize ADuC7020.
void ADCpoweron(int); //ADC need power on time.
void Leadchoose(int);
void Modechoose(int);
void failure(void); //If communicate with PC failed
void ADC_interrupt();
void UART_interrupt();
void Parameter_reset();
int findMax();
int findMin();
int main (void)
{
short int leadmodeleadflag=1modeflag=1;
char trx;
initialization_chip();
//from initialization_chip_060323.c to suit for hardware version 3.0
while(leadflag)
{
leadflag=0;
while(!(0x01==(COMSTA0 & 0x01))){}
//wait PC‘s data
trx=COMRX;
lead=(short int)trx;
switch(lead)
{
// Lead input ADG658+ ADG658-
case ‘1‘: Leadchoose(0x3ff90000); break;
//LeadI LA and RA S8 S5
case ‘2‘:Leadchoose(0x3fe10000); break;
//LeadII LL and RA S2 S5
case ‘3‘: Leadchoose(0x3fe30000); break;
//leadIII LL and LA S2 S7
case ‘4‘: Leadchoose(0x3ff50000); break;
//1mv cal LL and AGND S4 S6
case ‘5‘: Leadchoose(0x3fec0000);break;
//aVR RA and L+F S6 S2
case ‘6‘: Leadchoose(0x3ffa0000);break;
//aVL La and R+F S8 S3
case ‘7‘: Leadchoose(0x3fe60000);break;
//aVF LL and R+L S2 S4
case ‘8‘:Leadchoose(0x3fc000ff);break;
//V1 C and R+L+F S1 S1 the difference with case
case ‘9‘:Leadchoose(0x3fc00000);break;
//V2~V6 C and R+L+F S1 S1 8 and 9because Vi need
default : failure();leadflag=1; // reversal
}
}
while(modeflag)
{
modeflag=0;
while(!(0x01==(COMSTA0 & 0x01))){}
trx=COMRX;
mode=(short int)trx;
switch(mode)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 14893 2008-12-24 11:35 ecg.c
文件 561152 2008-12-23 15:18 心电测量板XAD ECG软件.doc
文件 1016320 2009-01-03 14:04 心电测量板XAD ECG硬件.doc
----------- --------- ---------- ----- ----
1592365 3
评论
共有 条评论