# Digital Heart-beat counter circuit

Status
Not open for further replies.

#### kenzhu

##### Newbie level 1
heart beat counter

Dear all,
I am currently on a project of designing a digital heart-beat counter using the piezoelectric sensor. I had a circuit which include the amplifying part and the display part. On the displaying part, it is displayed on the 7-segment LED. As for my project, i need to change the display part into a PIC. A few question that i need help on:

1) Can the display part of the circuit be changed into PIC?
2) Does the amplifying part on the circuit compatible to the PIC to count the beat?
3) Any recommended PIC model with built-in ADC?
4) any changes need to be made on the amplifying part so that it is compatible with PIC?
5) If yes, anyone can help me on designing a digital heart-beat counter with PIC as display part?

The PIC will connect to computer via serial port. Hope someone can help me on this as i'm urgent on the project. Thank you very much. Your help is much appreciated.

#### ezpcb

##### Banned
heart beat circuit

Of course a PIC will works for such project. PIC16F877 is a cheap and simple solution. Maybe the amplifying circuit need to be modified slighly to match the input range of the PIC.

#### yanzixuan

##### Member level 3
heart beat counter circuit

kenzhu said:
Dear all,
I am currently on a project of designing a digital heart-beat counter using the piezoelectric sensor. I had a circuit which include the amplifying part and the display part. On the displaying part, it is displayed on the 7-segment LED. As for my project, i need to change the display part into a PIC. A few question that i need help on:

1) Can the display part of the circuit be changed into PIC?
2) Does the amplifying part on the circuit compatible to the PIC to count the beat?
3) Any recommended PIC model with built-in ADC?
4) any changes need to be made on the amplifying part so that it is compatible with PIC?
5) If yes, anyone can help me on designing a digital heart-beat counter with PIC as display part?

The PIC will connect to computer via serial port. Hope someone can help me on this as i'm urgent on the project. Thank you very much. Your help is much appreciated.
it's very easy,this is a exercise example which i did long ago,but maybe helpful for you.
Code:
#include <pic.h>
/////////////////////////////////////////////////////////
//data define//
/////////////////////////////////////////////////////////
char LEDdata0=0xff,LEDdata1=0xff,LEDdata2=0xff,LEDdata3=0xff;
int buffer=0,ADdataFull;
int Counter=0;
char ADdataL,ADdataH;
char LED[16]={0b11000000,//0
0b11111001,//1
0b10100100,//2
0b10110000,//3
0b10011001,//4
0b10010010,//5
0b10000010,//6
0b11111000,//7
0b10000000,//8
0b10010000,//9
0b10001000,//a
0b10000011,//b
0b10100111,//c
0b10100001,//d
0b10000110,//e
0b10001110,//f
};
/////////////////////////////////////////////////////////
//interrupt handle//
/////////////////////////////////////////////////////////
void interrupt all(void)
{
int buf;
GIE=0;
if(ADIF==1)
{
ADIF=0;
buf=ADRESH;
buffer=ADRESL+(buf<<8);
}
if(TMR1IF==1)
{
TMR1IF=0;
TMR1H=0xfe;
TMR1L=0x00;
if(Counter==3)
{
Counter=0;
}
else
{
Counter++;
}
PORTD=0b00000000;
if(Counter==0)
{
PORTB=0b11110111;
PORTD=~LED[LEDdata0];
}
if(Counter==1)
{
PORTB=0b11111011;
PORTD=~LED[LEDdata1];
}
if(Counter==2)
{
PORTB=0b11111101;
PORTD=~LED[LEDdata2];
}
if(Counter==3)
{
PORTB=0b11111110;
PORTD=~LED[LEDdata3];
}
}
GIE=1;
}

////////////////////////////////////////////////////////
//init the pic cpu//
////////////////////////////////////////////////////////
void init(void)
{
INTCON=0b11000000;
ADCON0=0b01000001;
ADCON1=0b10000000;
ADIE=1;
ADON=1;

TMR1IE=1;
TMR1H=0xfe;
TMR1L=0x00;
T1CON=2b00001001;

TRISD=0x00;
TRISB=0x00;
}

/////////////////////////////////////////////////////////
//main program//
/////////////////////////////////////////////////////////
void main()
{
init();
while(1)
{
ADGO=1;

ADdataFull=buffer;
LEDdata0=ADdataFull%10;
ADdataFull=ADdataFull/10;
LEDdata1=ADdataFull%10;
ADdataFull=ADdataFull/10;
LEDdata2=ADdataFull%10;
ADdataFull=ADdataFull/10;
LEDdata3=ADdataFull%10;
//ADdataFull=ADdataFull/10;
/* ADdataTemp=ADdataFull/10;
LEDdata0=ADdataFull-ADdataTemp*10;
ADdataFull=ADdataTemp;
ADdataTemp=ADdataFull/10;
LEDdata1=ADdataFull-ADdataTemp*10;
ADdataFull=ADdataTemp;
ADdataTemp=ADdataFull/10;
LEDdata2=ADdataFull-ADdataTemp*10;
ADdataFull=ADdataTemp;
ADdataTemp=ADdataFull/10;
LEDdata3=ADdataFull-ADdataTemp*10;*/
}

}
PS:this program can be simulated on Proteus 7 Professional.

#### chiet86

##### Newbie level 1
Hi,
how your project izzit successful

carbeta5

### carbeta5

Points: 2
Helpful Answer Positive Rating
Status
Not open for further replies.