Discussion in "8051 Discussion Forum" started by    karthikdm    Feb 6, 2011.
Mon May 30 2011, 12:00 am
#21
@coolmirza143,

Bro, this seems to be a nice project & i wish to implement it as early as possible. some questions are coming in my mind in the code portion.these Qs might be seem to naive but um really new in microcontroller.
1. i dont understand, what is the significance of the line "sbit gg =P1^2;"

2. what is the data port defined for lcd here?

pls, ans me & ii'm urging for ur help for maknig this project.

thnx
Mon May 30 2011, 08:59 am
#22
hello Joyshubhra.eee see the link below and make it, it is in working state....

http://www.8051projects.net/news-i166-heart-rate-monitor-system.html
Tue May 31 2011, 08:46 pm
#23
bro, what is the programming language & compiler u've used in the code?


[ Edited Tue May 31 2011, 10:08 pm ]
Wed Jun 01 2011, 07:43 am
#24
@ joyshubhra.eee
the controller is of AVR family
ATMEGA8
and winavr is a compiler with avr studio IDE
Sat Jun 04 2011, 10:23 pm
#25


@ joyshubhra.eee
the controller is of AVR family
ATMEGA8
and winavr is a compiler with avr studio IDE

majoka



so, you wanna say that, after changing the header file by "$regfile = "M8def.dat", if I compile the provided text file with BASCOM-AVR (as it seems to be coded with Basic programming) & then load the .HEX file to the MC, thats enough to count the pulse rate? nothing else is required !!

and I also want to know about the operating principle of this circuit.


[ Edited Sun Jun 05 2011, 01:11 am ]
Sun Jun 05 2011, 02:33 pm
#26
@ joyshubhra.eee
i think all data hex file etc is given if not then i think its AVR BASCOM compiler u has to compile the code in thst compiler after that hex file is generated and yes its enough id u compile it successfully
Sun Jun 05 2011, 11:35 pm
#27




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++);
}
}

coolmirza143




Hello @ coolmirza143,
i tryed ur code on heartbeat but its not reading any beat,just displays "Welcome to H.R.M 002",the 002 fluctuates btw 001 & 003,
pls check out the below lcd delay code for errors

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 */
}
ALSO i think your heartbeat sensor input is on P3.2,since ur using external int 0.

u defined this but never used it on the code

sbit gg =P1^2;

also why did you comment out these variables below in your code ?

// 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′};
Tue Jun 07 2011, 05:52 pm
#28
@ DaveChika
check the status of 7 pin of lm358 with oscilloscope when u place hand in front of LDR


[ Edited Tue Jun 07 2011, 05:52 pm ]
Sun Jul 10 2011, 08:44 am
#29
@majoka,
i was simulating with protues,i used a pulse generator instead.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am