Heartrate monitor Bluetooth

Status
Not open for further replies.

johnjameson

Junior Member level 3
Joined
Jan 30, 2012
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,516
Hey Guys,
Attempting to write a small code for measuring your heartbeat through your fingertip.
Now its been years since I've done any programming but what I used to do was write the code in Keil and create the hex file from there,then use Flash magic to download the code to a 8051 chip.I think it was placed into a development board and connected via the serial.

So now I'm thinking of using the Amtel AT89S52 for this code,except I don't have a development board where I can slot the chip into to download the code.
Should I get something like this?
https://microcontrollershop.com/product_info.php?products_id=3741
Where I can slot the chip into and download the code? or is there some other method of downloading the code or should I be using a different 8051 chip?
 

So went back to square one,bought a heartbeat sensor,its one for an arduino but I hope its compatible with the 8051 too.

Using a different code taken from this datasheet
**broken link removed**

Code:
// Compiler: Keil, Target Chip AT89S52 or similar 
sbit SENSOR = P3^7; //sensor is connected to this pin, can be any other pin also 
unsigned int beatms; //Calculate time between two high going pulses in ms 
float bpm; // Beats per minute calculated from beatms variable above 
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
Delay x Milisecond 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ 
void delay_ms(unsigned int x) // delays x msec (at fosc=11.0592MHz) 
{ 
 unsigned char j=0; 
while(x-- > 0) 
 { 
 for (j=0; j<125; j++){;} 
 } 
} 
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
// -=-=-=-=- Main Program -=-=-=-=-=-=-= 
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
void main() 
{ 
// -=-=- Intialize variables -=-=-= 
beatms=0; // will store duration between two pulses 
 
// -=-=- Program Loop -=-=-= 
while(1) 
{ 
while(SENSOR==0);// wait for high pulse from sensor 
delay_ms(10); // 10ms delay so that it does not listen to any noise 
beatms = 10; // start counting beatms from 10ms since we have delay above 
 
while(SENSOR==1)// wait until signal is high 
{ 
delay_ms(1); //wait 1msec 
beatms++; //keep incrementing counter each 1ms 
} 
 
while(SENSOR==0) //keep looping till signal goes back high, wait for next 
{ 
delay_ms(1); //wait 1msec 
beatms++; //keep incrementing counter each 1ms 
} 
// beatms variable will now have time in ms between two high edge pulse 
bpm = (float)60000/beatms; // see document of #1181 for this calculation 
 
if(bpm > 200) 
{ 
// Invalid, Wait for next cycle 
} else { 
// Display reading in BPM, print variable BPM to LCD Display or Serial port. 
} 
} 
}


So all thats needed is to add a lcd code to view the results I think
 

Yes you can use that dev board and programmer for your work with AT89S52 chip. If you just want to measure pulses then you can use P pin and not S pin of the sensor module. The code you have used is for digital interface using P pin and not S pin. As mentioned in datasheet S pin gives 1 byte data which is particular time that is time between two rising or falling edges of pulses. You have to calculate BPM using the formula given in datasheet and byte obtained from S pin. If using P pin then connect it to External interrupt pin and use interrupt code or use any digital input pin and use the sunrom provided code. Don't use sunrom code if using serial (s) pin. It won't work.
 


Ok but I'm not using the sensor shown within the datasheet,I'm using the one in the pic I posted.
**broken link removed**

From what I can see it only has 3 pins,Power,Ground and signal out.
 

Out of three pins one will be DOUT (Digital out) and the other two VCC and GND. So DOUT will give pulses. You have to count pulses using External Interrupt pin.
 

Out of three pins one will be DOUT (Digital out) and the other two VCC and GND. So DOUT will give pulses. You have to count pulses using External Interrupt pin.

Right so the above code won't work as the pulses have to be counted on the External Interrupt pin.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…