Search Your Query

Custom Search

Saturday, 21 May 2011

8051 Based Heart Rate Meter

HEART BEAT CIRCUIT

C code for Heart Rate Meter:

//******************************************************//
8051 Based Heart Rate Meter Main Program
//*****************************************************//

#include <reg51.h>  // using ride 6.1.6 IDE ,Keil also use
#include <lcd.h>
sbit gg =P1^2;
unsigned char val[] = {’0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′};
unsigned char bt=0,sec=0,sec100=0,min=0,r,t1,t2;

void extrint (void) interrupt 0
{
bt++;

}
void timer0 (void) interrupt 1 using 1
{
TH0 = 0xdc;
sec100++;
if(sec100>=10)
{
sec++;
sec100=0;
if(sec>=6)
{
min++;
sec=0;
}
}
}

void disp(unsigned char n)
{
LCD_putc(val[n/100]);
LCD_putc(val[(n/10)%10]);
LCD_putc(val[n%10]);
}

void main()
{
EA = 1;
TMOD = 0×02;
IT0 = 1;
EX0 = 1;
ET0 = 1;
TR0 = 1;

LCD_delay(100);
LCD_init();
LCD_delay(100);
LCD_row1();
LCD_delay(100);
LCD_puts(”Welcome to H.R.M. “);
LCD_delay(100);
t1=0;t2=0;

while(1)
{

if(min>=1)
{
LCD_command(0xc0);
LCD_delay(100);
LCD_putc((bt/100)+48);
r=bt%100;
LCD_putc((r/10)+48);
LCD_putc((r%10)+48);
LCD_delay(100);
bt=0;
min=0;
}
}
}
/ /***********************************************//
LCD Header File Routines
//************************************************//

#include<string.h>
#include<stdio.h>
#define LCD_clear() LCD_command(0×1) /* Clear display LCD */
#define LCD_origin() LCD_command(0×2) /* Set to origin LCD */
#define LCD_row1() LCD_command(0×80) /* Begin at Line 1 */
#define LCD_row2() LCD_command(0xC0)

sbit rs = P2^5;
sbit en = P2^6;

void lcd_en ()
{
en = 1; en = 1; en = 1;
en = 0; en = 0;
}
void LCD_delay(unsigned char ms)
{
unsigned char n;
unsigned int i;
for (n=0; n
{
for (i=0; i<1535; i++); /* For 1 ms */
}

}

void LCD_command(unsigned char command)
{
rs=0; rs = 0;
P0 = command;
lcd_en ();
LCD_delay(1);

}

void LCD_init()
{
LCD_command(0×38);
LCD_command(0×06);
LCD_command(0×0c);
LCD_command(0×01);
LCD_delay(256);
}

void LCD_putc(unsigned char ascii)
{
rs=1;
P0 = ascii;
lcd_en ();
LCD_delay(2);
LCD_command(0×0C);
}

void LCD_puts(unsigned char *lcd_string)
{
while (*lcd_string)
{
LCD_putc(*lcd_string++);
}
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...