Discussion in "8051 Discussion Forum" started by    karthikdm    Feb 6, 2011.
Tue Feb 08 2011, 02:57 pm
#11
its ok dear dont be sorry we will w8 for your updates.... best of luck
Wed Feb 09 2011, 07:19 pm
#12
Here is the working code for Heart Beat Counter...
#include<reg52.h>

#include<intrins.h>

void _nop_(void);

#define delay_us _nop_(); //generates 1 microsecond
#define LCD P1

sbit RS=P2^5; //connect p0.0 to rs pin of lcd
sbit EN=P2^7; //connect p0.1 to en pin of lcd
sbit RW=P2^6;

sbit PULSE=P0^0; //pulse input from heart beat sensor
sbit LED=P3^0;   //led indicator for pulse indication

void integer_lcd(int);

void init_lcd(void);
void cmd_lcd(unsigned char);
void write_lcd(unsigned char);
void delay_ms(unsigned int);

unsigned int num=0;
unsigned int num1=0;
unsigned int dig_1,dig_2,dig_3,dig_4,test=0;
unsigned int dig_11,dig_21,dig_31,dig_41,test1=0,test2=0;
unsigned char k=0;


void main(void)
{

				init_lcd();		
				LED=0;
				write_lcd('H');
				write_lcd('E');
				write_lcd('A');
				write_lcd('R');
				write_lcd('T');
				write_lcd(' ');
				write_lcd('B');
				write_lcd('E');
				write_lcd('A');
				write_lcd('T');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				cmd_lcd(0xc0);
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd(' ');
				write_lcd('C');
				write_lcd('O');
				write_lcd('U');
				write_lcd('N');
				write_lcd('T');
				write_lcd('E');
				write_lcd('R');
				delay_ms(300);
				cmd_lcd(0x01);
				write_lcd('B');
				write_lcd('e');
				write_lcd('a');
				write_lcd('t');
				write_lcd('s');
				write_lcd(':');
				write_lcd(48);
				write_lcd(48);
				write_lcd(48);
				write_lcd(48);
														    
	while(1) 
	{   
	if(PULSE==1)  //check for input pulse from sensor
     {
	 	  cmd_lcd(0x01);	
	   	  test++;
	      num=test;
	        dig_4=num%10;
	      num=num/10;
	        dig_3=num%10;
	      num=num/10;
	        dig_2=num%10;
	      dig_1=num/10;
	      if(test==9999)
	     test=0;
				write_lcd('B');
				write_lcd('e');
				write_lcd('a');
				write_lcd('t');
				write_lcd('s');
				write_lcd(':');
				write_lcd(dig_1+48);
				write_lcd(dig_2+48);
				write_lcd(dig_3+48);
				write_lcd(dig_4+48);
				
				LED=1;
				delay_ms(50);
				LED=0;

    }
	}
	}

////////////////////////////////////////////////////////////////

void init_lcd(void)
{                            
delay_ms(10); //delay 10 milliseconds

cmd_lcd(0x38); //8 bit initialize, 5x7 character font, 16x2 display
cmd_lcd(0x0e); //lcd on, cursor on
cmd_lcd(0x06); //right shift cursor automatically after each character is displayed
cmd_lcd(0x01); //clear lcd
}

//transmit command or instruction to lcd
void cmd_lcd(unsigned char c)
{
EN=1;
RW=0;//set enable pin
RS=0; //clear register select pin
LCD=c; //load 8 bit data 
EN=0; //clear enable pin
delay_ms(2); //delay 2 milliseconds
}

//transmit a character to be displayed on lcd
void write_lcd(unsigned char c)
{

EN=1; //set enable pin
RW=0;
RS=1; //set register select pin
LCD=c;  //load 8 bit data
EN=0; //clear enable pin
delay_ms(2); //delay 2 milliseconds
}

//generates delay in milli seconds
void delay_ms(unsigned int i)
{
unsigned int j;
	while(i-->
0)
	{
		for(j=0;j<500;j++)
		{
			;
		}
	}
}

This code can only provide counting...for measuring Heart Rate; pulse counted should be compared with specific time interval...i need help of you great minds in solving timing part of the code
Thu Feb 10 2011, 01:43 pm
#13
@ karthikdm
why ur not using timer as a counter for measuring pulses
use timer as a counter and produce delay of 1sec after that registers of timer has value of no of pulses per sec
Thu Feb 10 2011, 08:14 pm
#14
@majoka
since heart pulses are very slow i'm planning to measure the counts for every 20seconds and convert it for per minute value..
I know only producing delays using 8051 timers..but i have no knowledge on using the interrupts and counters ..while using timers for delays,any other operations are not performed by the microcontroller during the delay period;so the pulses are counted only after the end of delay time..
Fri Feb 11 2011, 11:10 pm
#15
counter can also be used if pulses r slow or fast and it is better option when u use timer as a counter then there is no need of polling it it automatically increments contents of timer registers on each pulse so it is good option u not need to wait for pulses
 karthikdm like this.
Sat Feb 12 2011, 02:32 am
#16
Well from my experience(made it couple of time) this is not reliable you would see if you insert an abject between the ldr and led.

I would recomend you to put ad620 use adc adn do some real time pulse processing .I did it for making Blood Pressure monitor that logs data on computer
Sat Feb 12 2011, 08:31 am
#17
hi Afnan
share ur diagram and experience it may help others
Tue Feb 15 2011, 10:00 pm
#18
Hey guys I was just looking at the diagram for this circuit and was wondering what is the photocell being used, I am unfamiliar with a 220E.
Wed Feb 16 2011, 02:38 pm
#19
Hi all
Diagram is lost how ever i will give you an idea

use pic or avr for better adc res now logic is

adc->adc620->same LED and LED without lm 358

in software you have to define a thresh hold for valid pulse.
One thing when you insert an object you get pulse for first time but not for rest so you have to write code accordingly.
If there are any further question please feel free to ask
Wed Feb 16 2011, 03:31 pm
#20


Hey guys I was just looking at the diagram for this circuit and was wondering what is the photocell being used, I am unfamiliar with a 220E.

01000100



D1 is LED which is ultra bright and R1 is LDR value is 220....

this is a scanning mechanism these two are placed together as when you place thumb these two should have to be under your thumb....



LED will illuminate thumb and LDR will detect light and a signal will be generated by lm358..



now when heart pump blood the pressure and volume of blood in thumb will change this will create a change in illumination and LDR will detect a change so the value of lm358 out put at pin 7 will be changed!

so at every Heart beat there will be a change in out put pulse which is generated by lm358.....


[ Edited Wed Feb 16 2011, 03:35 pm ]
Tags working of heartbeat sensorLDR based heart beat sensor

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am