Heart beat monitor PIC16f84 Microcontroller display on LCD
A pair of LED and LDR is used as sensor for sensing the pulses of heart. The signal is generated when a finger is placed between LED and LDR. OP amp LM358 is used for the further processing of the signal generated from the LDR, if finger is placed and some obstacle for light is created, which it self is varying with the pressure of blood in the veins of finger.
The output of two operational amplifiers is TTL pulses. For a healthy person, these pulses should be nearly equal to 70 to 80 BPM and if we convert it into frequency then we will get 1.2 to 1.4 Hz.
The microcontroller PIC16f84 senses these TTL pulses generated from the analog circuit and count then using a very simple algorithm converts them into beats per minuets.
The results of the beats are shown on LCD with unit BPM.
For display of heart beat monitor , a general purpose LCD is used. Students can use any single line or two line LCD available in their local market. As, in the program, only first 16 characters and first line is used to display any message on LCD. If any student got 2 line and 20 characters LCD, it will also works good.
Here is circuit diagram of the heart beat monitor using PIC microcontroller 16f84.

below is c language code for the heart rate monitor using PIC microcontroller 16f84, the c code is written Hi-Tech C.
//# define
# include
#define rs RA2
#define e RA1
#define lcd_data PORTB
#define _XTAL_FREQ 4000000
void delayms(unsigned int itime);
void pulse(void);
void send_char(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
void init_lcd(void);
void dis_num(unsigned int data,unsigned char digit);
void prog1(void);
unsigned long no=0;
void main (void)
{
TRISA=0;
TRISB=0;
TRISA3=1;
init_lcd();
delayms(10);
lcd_clr();
delayms(10);
send_string(“Heart rate meter”);
delayms(1000);
lcd_clr();
delayms(10);
while(1)
{
prog1();
}
}
void prog1(void)
{
unsigned int temp1=0,temp2=0;
unsigned char i;
unsigned int hb=1;
while(RA3);
while(!RA3){
hb++;
delayms(1);
}
hb=30000/hb;
lcd_goto(2);
send_string(“H.B.R: bpm”);
lcd_goto(8);
dis_num(hb,3);
}
void delayms(unsigned int itime)
{
unsigned int i;
for(;itime>0;itime–)
{
__delay_ms(1);
}
}
void send_config(unsigned char data) //send lcd configuration
{
rs=0; //set lcd to configuration mode
lcd_data=data&0xf0; //lcd data port = data
pulse();
lcd_data=(data<<4)&0xf0;
pulse();
}
void pulse(void)
{
e=1; //pulse e to confirm the data
delayms(1);
e=0;
delayms(1);
}
void lcd_goto(unsigned char data) //set the location of the lcd cursor
{ //if the given value is (0-15) the
send_config(0×80+data); //cursor will be at the lower line
}
void lcd_clr(void) //clear the lcd
{
send_config(0×01);
delayms(2);
}
void send_string(const char *s) //send a string to display in the lcd
{
rs = 1;
while (*s)send_char (*s++);
}
void send_char(unsigned char data) //send lcd character
{
rs =1;
delayms(1); //set lcd to display mode
lcd_data=data&0xf0; //lcd data port = data
pulse();
lcd_data=(data<<4)&0xf0;
pulse();
}
void init_lcd(void)
{
rs=0;e=0; //command mode
delayms(10); //delay 10ms
lcd_data=0×30; //load initial nibble
pulse(); //Latch initial code
delayms(5); //delay 5ms
pulse(); //Latch initial code
delayms(1); //delay 1ms
pulse(); //Latch initial code
lcd_data=0×20;
pulse(); //Latch initial code
//configure lcd
send_config(0×28); //Set 4-bit mode, 2 lines
send_config(0xF); //Switch off display
send_config(0×06); //Enable cursor auto increase
}
void dis_num(unsigned int data,unsigned char digit)
{
if(digit>3)
send_char(’0′+(data/1000)%10);
if(digit>2)
send_char(’0′+(data/100)%10);
if(digit>1)
send_char(’0′+(data/10)%10);
if(digit>0)
send_char(’0′+(data/1)%10);
}
2 Responses
please send me the code for the same project in assembler language….
please send the code for same project in assembler language…….plzz..plzzz