新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)心率測(cè)量儀源代碼

單片機(jī)心率測(cè)量儀源代碼

作者: 時(shí)間:2016-11-30 來源:網(wǎng)絡(luò) 收藏

將你的食指輕輕地放在傳感器上,就能看到LEDadclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=5d97316317e90784&k=%D6%B8%CA%BE%B5%C6&k0=%D6%B8%CA%BE%B5%C6&kdi0=0&luki=1&n=10&p=baidu&q=98059059_cpr&rb=0&rs=1&seller_id=1&sid=8407e9176331975d&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1831118&u=http%3A%2F%2Fwww%2E51hei%2Ecom%2Fmcu%2F2078%2Ehtml&urlid=0" id="7_nwl" mpid="7" target="_blank">指示燈隨著你的心跳而閃動(dòng),人體指尖的動(dòng)脈比較發(fā)達(dá),當(dāng)動(dòng)脈血管隨心臟周期性收縮與舒張時(shí),血管中的血液容積也會(huì)發(fā)生變化。

上面這個(gè)是采集部分的原理圖全套的制作資料請(qǐng)到http://www.51hei.com/bbs/dpj-22525-1.html去下載,下面是心率測(cè)量儀的單片機(jī)部分源代碼

本文引用地址:http://butianyuan.cn/article/201611/323817.htm

/*
Project: Measuring heart rate through fingertip
Copyright @ Rajendra Bhatt
January 18, 2011
PIC16F628A at 4.0 MHz external clock, MCLR enabled
*/

sbit IR_Tx at RA3_bit;
sbit DD0_Set at RA2_bit;
sbit DD1_Set at RA1_bit;
sbit DD2_Set at RA0_bit;
sbit start at RB7_bit;
unsigned short j, DD0, DD1, DD2, DD3;
unsigned short pulserate, pulsecount;
unsigned int i;
//-------------- Function to Return mask for common anode 7-seg. display
unsigned shortmask(unsigned short num) {
switch (num) {
case 0 : return 0xC0;
case 1 : return 0xF9;
case 2 : return 0xA4;
case 3 : return 0xB0;
case 4 : return 0x99;
case 5 : return 0x92;
case 6 : return 0x82;
case 7 : return 0xF8;
case 8 : return 0x80;
case 9 : return 0x90;
} //case end
}

void delay_debounce(){
Delay_ms(300);
}

void delay_refresh(){
Delay_ms(5);
}

void countpulse(){
IR_Tx = 1;
delay_debounce();
delay_debounce();
TMR0=0;
Delay_ms(15000); // Delay 1 Sec
IR_Tx = 0;
pulsecount = TMR0;
pulserate = pulsecount*4;
}

void display(){
DD0 = pulserate%10;
DD0 = mask(DD0);
DD1 = (pulserate/10)%10;
DD1 = mask(DD1);
DD2 = pulserate/100;
DD2 =mask(DD2);
for (i = 0; i<=180*j; i++) {
DD0_Set = 0;
DD1_Set = 1;
DD2_Set = 1;
PORTB = DD0;
delay_refresh();
DD0_Set = 1;
DD1_Set = 0;
DD2_Set = 1;
PORTB = DD1;
delay_refresh();
DD0_Set = 1;
DD1_Set = 1;
DD2_Set = 0;
PORTB = DD2;
delay_refresh();
}
DD2_Set = 1;
}

void main() {
CMCON = 0x07; // Disable Comparators
TRISA = 0b00110000; // RA4/T0CKI input, RA5 is I/P only
TRISB = 0b10000000; // RB7 input, rest output
OPTION_REG = 0b00101000; // Prescaler (1:1), TOCS =1 for counter mode
pulserate = 0;
j = 1;
display();
do {
if(!start){
delay_debounce();
countpulse();
j= 3;
display();
}
} while(1); // Infinite loop
}



評(píng)論


技術(shù)專區(qū)

關(guān)閉