Previous in Forum: 4 Things You Probably Never Knew Your Mobile Phone Could Do   Next in Forum: Please Help!!!!!
Close
Close
Close
14 comments
Rate Comments: Nested
Participant

Join Date: Jan 2008
Posts: 1

i want embedded C code for heart rate calculation using PIC 16F877A

01/29/2008 12:10 PM

iam using heart rate sensor in my project to get digital pulses from patients. my problem is that how to process and calculate heart rate per minute from the pulses coming from sensor using PIC16F877A .so i want embedded C program code for the heart rate calculation

Register to Reply
Pathfinder Tags: heart rate calculation
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
New Zealand - Member - Kiwi Popular Science - Weaponology - New Member Engineering Fields - Power Engineering - New Member Engineering Fields - Electrical Engineering - New Member

Join Date: Sep 2006
Location: Auckland, New Zealand
Posts: 8777
Good Answers: 376
#1

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/29/2008 1:04 PM

(I am assuming that you know how to use and program up a microcontroller). This is actually very, very simple and you can easily figure it out for yourself and write your own code (especially given that this is what we would classify as homework). Think about it, you have a certain number of pulses per minute, so count them over a period of time to get your indication.

__________________
jack of all trades
Register to Reply
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#2

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/29/2008 1:22 PM

Very small tip in case if it really your project. You should run C timer function for predetermined period using any technique for loop you like more e.g. while, do while, if, for then organize calculating of build up counting of heart impulses. For organazing endless external loop within which you place your function you can use construction look like for(;;).

Hope it help you.

Register to Reply
Guru

Join Date: Dec 2005
Location: Etats Unis
Posts: 1871
Good Answers: 45
#3

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 4:21 AM

Yes I am happy to do this work for you.

Please send $1000 American dollars for me to start.

Perhaps you should consider changing your name to picbeginner?

__________________
The hardest thing to overcome, is not knowing that you don't know.
Register to Reply
Commentator

Join Date: Jun 2007
Posts: 82
Good Answers: 2
#10
In reply to #3

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 12:08 PM

I will do it for 950.00

__________________
The purpose of a system, is what it does.
Register to Reply
Associate

Join Date: Jan 2008
Posts: 43
#4

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 4:27 AM

Do you by anychance go to BMC in northern ireland or a related Tech? I just finnished Tech last year with an HND and my friend made a heart rate monitor. Wanting someone to do your work for you?

Search Google there has to be some code out there. My friend wasnt the first one to do it with a Pic16f877a.

Register to Reply
Associate

Join Date: Jan 2008
Posts: 43
#5

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 4:28 AM

you'l also need am a to d converter to change the pulses coming from the LED and photo diode.

Register to Reply
Power-User
Canada - Member - BC Born, Alberta Raised, Quebec (poutine) crazed... Engineering Fields - Aerospace Engineering - An airplane is just a bunch of beams... Hobbies - Model Rocketry - Had fun as a kid...fun stuff Hobbies - CNC - dreaming of cutting Engineering Fields - Control Engineering - PID ME!

Join Date: Aug 2006
Location: Montreal, CANADA
Posts: 368
Good Answers: 10
#6
In reply to #5

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 6:24 AM

"LED and photo diode."

Is that really all that clip on your finger is made up of? LED on one side of the finder and a photo diode on the other? Is it a fancy LED? Interesting...I'm playing around making a motion platform for flight simulators and would like to add a small feedback loop to see how the guinea pig in it (my father-in-law) would be affected. This feedback could possibly influence the PID motion controllers to make the ride smoother if someone gets too excited (i.e. scared).

__________________
kkjensen
Register to Reply
Associate

Join Date: Jan 2008
Posts: 43
#9
In reply to #6

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 7:21 AM

well good for u

Register to Reply
Power-User
Canada - Member - BC Born, Alberta Raised, Quebec (poutine) crazed... Engineering Fields - Aerospace Engineering - An airplane is just a bunch of beams... Hobbies - Model Rocketry - Had fun as a kid...fun stuff Hobbies - CNC - dreaming of cutting Engineering Fields - Control Engineering - PID ME!

Join Date: Aug 2006
Location: Montreal, CANADA
Posts: 368
Good Answers: 10
#7

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 6:37 AM

C programming aside...is your question about HOW to take your c code and get it to run on a pic? Microcontrollers don't run directly on C so this isn't what you want to try to "embed". You're going to need a compiler that will convert your C into assembly language (another language but specific to the controller) and then into a .HEX file that CAN be put on the PIC with a suitable programmer.

Personally, if any of this is new to you I would recommend the following software for the programming and compiling. You'll still need a burner to put the final hex file onto the pic itself.

http://www.mikroe.com/en/compilers/mikroc/pic/ You can download the software and use it for free for projects that have up to 2000 lines of compiled code...good enough for most little projects.

There's lots of places you can get a programmer (I use an OLIMEX MCP combined with the MPLAB IDE to burn the hex file from mikroc to the chip)

...or places you can borrow of access one (at school).

Good luck!


Disclaimer: I have no affiliation with the companies and products...I didn't have anyone to show me and wasted a lot of time trying to make my own programmer...I'm no electronic/computer engineer...I'm a mechie!

__________________
kkjensen
Register to Reply
Associate

Join Date: Jan 2008
Posts: 43
#8

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 7:19 AM

We used MPLABS to flash the PICs when we were compiling our projects. These are not cheap tho i think the bundle for the laptops were over £100.00 might get them cheaper? But they were easy to use.

Register to Reply
Commentator

Join Date: Jun 2007
Posts: 82
Good Answers: 2
#11

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 12:23 PM

Ok, here is my serious answer.

1. What regulatory requirements are there? This can vastly complicate the task and change your approach.

2. What accuracy or response rate do you want?

3. Do you want to display a graph or retain acquisition data?

4. Size, cost, time-to-market?

For patient connected, diagnostic or life support applications, the code should NOT be done by a beginner. You have to submit your work for review and many things that seem simple turn out to be more complicated. For example: How to you code for a button press? (Hint: it is more complicated than you think)

Anyway, I retract my $950.00 offer until I know much more about your application.

__________________
The purpose of a system, is what it does.
Register to Reply
Power-User
Canada - Member - BC Born, Alberta Raised, Quebec (poutine) crazed... Engineering Fields - Aerospace Engineering - An airplane is just a bunch of beams... Hobbies - Model Rocketry - Had fun as a kid...fun stuff Hobbies - CNC - dreaming of cutting Engineering Fields - Control Engineering - PID ME!

Join Date: Aug 2006
Location: Montreal, CANADA
Posts: 368
Good Answers: 10
#12
In reply to #11

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 1:26 PM

I think someone expected an out-of-the-box answer...and you had to go and ruin the naivety with all that detail from the real world.

Hey picmaster! (If you're monitoring this compilation of all our wisdom and knowledge) If this is HOMEWORK then knuckle down and learn! If you're not in school then...knuckle down and learn! Taking the time and putting in the effort to figure things out is never going to come back to bite you...it'll just help you be better prepared for the future.

__________________
kkjensen
Register to Reply
Guru
New Zealand - Member - Kiwi Popular Science - Weaponology - New Member Engineering Fields - Power Engineering - New Member Engineering Fields - Electrical Engineering - New Member

Join Date: Sep 2006
Location: Auckland, New Zealand
Posts: 8777
Good Answers: 376
#13
In reply to #12

Re: i want embedded C code for heart rate calculation using PIC 16F877A

01/30/2008 7:08 PM

Given the available information and the project description, I believe it is just a school project. The solution after all is so simple as to be blatantly obvious and easy to implement (unless you are new to programming).

Calling yourself "PICMASTER" and asking this question also points to a newcomer to the world of microcontroller programming (or at the very least raises some serious questions regarding the quality of graduates).

Oh, another point that I have noted is some people seem to post answers that indicate that they have not read the original post. It's all well and good to give advanced information on real world application specifics, but it does tend to muddy the waters when all the poster wants to know is something simple (I guess some people will get something out of it).

__________________
jack of all trades
Register to Reply
Participant

Join Date: May 2008
Posts: 1
#14

Re: i want embedded C code for heart rate calculation using PIC 16F877A

05/09/2008 11:40 AM

Hi,

I have the same problem. I have to calculate the heart rate. The digital signal is 3V during 6ms for the 1 logic and 0V for the 0logic.

I'm using a PIC18LF....and MPLAB ide v 8.10

Here is my code for now :

#include "Toothpick.h"
#include "p18f6720.h"
#include "testRes.h"
#include "hopcodes.h"


// Semaphores
unsigned char MySemaphores = 0x00;
#define MSF_RunTestNow 0x01 // set once per second if a test is running
#define MSF_TestsRunning 0x02 // set if a test is running
#define MSF_Connected 0x04


// programme main
void main (void){

overlay long i, deb , fin, bpul, compteur;
overlay float f;
// if no LinkMatik, flash red led rapidly
while ((ToothpickSemaphores&TPSF_LMTEXISTS)==0)
{
LedRed = ~LedRed;
msDelay( 50 );
}

FxPCommand( FxPC_Start, 0, 0 ); // Start FlexiPanel service
AwaitLMTComplete(); // Service operating, no client
LedGreen = LedGreenOn;
DirAN2 = DirInput; // defini an2 comme une entrer

// boucle principal
while(1){
// initialisation des variables

i=0;
deb=2;
fin=4;
bpul=0;
compteur=1;
f=0;
//boucle pour enregistrer 5 sec de pulsation
while(i<5000){
//boucle pour une pulsation
i++;
while(bpul!=0){
msDelay(6);
i++;
//lecture et aquisition de l'entrer
// An is a digital input
if( AN2Pin > 0){ // verification de l'entrer
if ( deb == 0){
deb=i/1000;
}
else{
bpul=1; // sortir de la boucle pulsation
fin=i/1000;
compteur++; // pour optenir le nombre de pulsations
}
}
f=f+(60/(fin-deb)); // pour la durée exacte des pulsations
bpul=0; // permet de relancer la boucle pulsation
deb=fin;
}
f=f/compteur;
//envoyer la fréquence
SetUp_valeur_1( 0, &f);

if (LedGreen == LedGreenOn)
{LedGreen = LedGreenOff;}
else {
LedGreen = LedGreenOn;
}

}
}

}


// HighInterrupt handler - nothing needs to be done
void HighInterrupt (void)
{
}

// LowInterrupt handler - only thind to do is clear the once-per-second clock tick interrupt
void LowInterrupt (void)
{
}



// Error event handler
void ErrorStatus( unsigned char ErrNum )
{
#ifndef RELEASE_VERSION
// During development - Flash error number for diagnositic purposes
Breakpoint( ErrNum );
#else
// Product release - best policy for unanticipated errors is to reset
Reset();
#endif
}


// LinkMatik Event handler
void LMTEvent( unsigned char EventID, void *pData1, void *pData2 )
{
if ( EventID==LMTE_Connected )
{
MySemaphores |= MSF_Connected;
}
if ( EventID==LMTE_Disconnect )
{
MySemaphores &= ~MSF_Connected;
}
if ( EventID==LMTE_Found )
{
msDelay( 250 );
LedGreen = 1 - LedGreen;
PushbuttonIntFlag = 0;
}
if ( EventID==LMTE_OK )
{
msDelay( 250 );
LedGreen = 1 - LedGreen;
}



if ( EventID==LMTE_Syntax )
{
#ifndef RELEASE_VERSION
// During development - Flash error number for diagnositic purposes
Breakpoint( ((unsigned char*)pData1)[0] );
#else
// Product release - best policy for unanticipated errors is to reset
Reset();
#endif
}

}

// FxPEvent handler
void FxPEvent( unsigned char EventID, void *pData )
{
if ( EventID==FxPE_Connect )
{
// turn off red led during connection
LedRed = LedRedOn;
}

if ( EventID==FxPE_Disco )
{
// turn off red led after disconnection
LedRed = LedRedOff;
}
}

Thx for your help.

Register to Reply
Register to Reply 14 comments
Copy to Clipboard

Users who posted comments:

caramba (1); darkover (1); gowdy87 (4); hioptemp (2); jack of all trades (2); kkjensen (3); rcapper (1)

Previous in Forum: 4 Things You Probably Never Knew Your Mobile Phone Could Do   Next in Forum: Please Help!!!!!

Advertisement