Discussion in "8051 Discussion Forum" started by    karthikdm    Feb 6, 2011.
Sun Feb 06 2011, 10:15 am
#1
I'm planning to design a Heart rate meter.. Need an idea to start with
Is the following logic correct?

1.Start the timer and count for 20seconds
2.check for pulses from input port
3.for each pulse; increment a variable
4.when t=20seconds;stop timer
5.multiply the current value of assigned variable by 3(to get value for 60seconds\per min)
6.display the obtained result value


Need some idea about using the Timer in 8051..
Ajay, Majoka please guide...


[ Edited Sun Feb 06 2011, 10:16 am ]
Sun Feb 06 2011, 04:47 pm
#2
as we always say, generate a smaller tick e.g. 50ms with a 12Mhz crystal using timer, keep a counter that counts for how much time you want the delay.

say if its 1sec, then counter will go upto 20 (20x50 = 1000ms)
if 20sec counter will go upto 400 (400 x 50 = 20000ms)

got it? try it once.
 karthikdmromel_emperado like this.
Mon Feb 07 2011, 09:13 pm
#3
nice... where you want to use this buddy?
Mon Feb 07 2011, 09:19 pm
#4
Hehe really nice project. I was trying to make such metter too, but coudnt get nice clear discrete signal of heart beat.
Mon Feb 07 2011, 10:08 pm
#5


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 bt=0,sec=0,sec100=0,min=0,r,t1,t2;

// unsigned char val[] = {’0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′};

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++);
}
}
 karthikdm like this.
Mon Feb 07 2011, 10:12 pm
#6
Tue Feb 08 2011, 12:26 am
#7
coolmirza143 thanks for sharing this
Tue Feb 08 2011, 08:56 am
#8
Thanks for sharing Mirza
Here is some pictures of Heart Beat sensor PCB with the above circuit

Tue Feb 08 2011, 11:34 am
#9
My friends you all are welcome

Enjoy measuring your beats...

@Kartikdm nice pics but low resolution try sharing these in high quality with PCB layout file and your code after making your own design....
Tue Feb 08 2011, 01:30 pm
#10
sorry for the resolution..Those pics are taken from my mobile camera
will publish the code after trying...


[ Edited Tue Feb 08 2011, 01:30 pm ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Richardgar
Sat Apr 20 2024, 11:05 am
AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am