# How to calculate heart pulse?

Discussion in 'The Projects Forum' started by sakurarandom, Mar 26, 2011.

1. ### sakurarandom Thread Starter New Member

Mar 26, 2011
8
1
My group is given a project namely Heat Beat Monitoring System. We need to come out finger clip sensor that connect to PIC and then connect to PC using USB. Currently, my group has set up the finger clip sensor in breadboard, PIC is loaded with bootloader and Window Forms have been designed using Visual Studio 2008 in C++ language. Now I am facing problem how to calculate the heart rate in PIC using MPLAB in C language. May I know how do determine the output from sensor to PIC is in what form? And in MPLAB, how do i write the coding to calculate the heart beat?

Hereby attach my circuit. There is some error on the PIC connection so kindly ignore it. Thank you so much.

2. ### Audioguru New Member

Dec 20, 2007
9,411
896
Look in Google for the HEMON circuit. HEMON is short for Heart Monitor.
The code for the microcontroller is shown.

3. ### russpatterson Member

Feb 1, 2010
351
16
I've made a bunch or photoplethysmographic heart rate monitors. I've usually used a phototransistor but if your LDR works then that's great.

Can you see your heart rate on your PIC's pin 2 if you hook a scope to it? Do you have a blinking LED that goes off when your heart beats?

If your asking for the calculation for beats per minute it's something like:

Count the milliseconds between heart beat pulses on your pic. Then use a formula like: BPM = 60/(milliseconds/1000)

So if there's 1000 mS between beats your heart rate is 60 BPM, one beat per second. If there's 500 mS between beats your BPM is 120.

Last edited: Mar 26, 2011
4. ### sakurarandom Thread Starter New Member

Mar 26, 2011
8
1
For the sensor on my breadboard, I am not sure it blink with heart beat or not. I connect pin2 to oscilloscope..it end up a waveform about this shape http://www.picotech.com/experiments/calculating_heart_rate/results.html but peak to peak voltage is 53micro second. Kind of weird therefore my group member is going to transfer it to PCB board. One disadvantage of this circuit is that different ppl test the sensor, trigger always have to be made and therefore output voltage from pin2 is different. Thanks for your formula. In C lanaguage for my PIC, how my PIC about to count the period between my beats? This is what bothering me..

5. ### sakurarandom Thread Starter New Member

Mar 26, 2011
8
1
Oh ok. Thanks ya

6. ### sakurarandom Thread Starter New Member

Mar 26, 2011
8
1
Is anyone know or have software to convert assembly code to c code? I intend to convert pic 16f84 code to c language code. Thanks

7. ### russpatterson Member

Feb 1, 2010
351
16
Get the sample C files for your pic from the HITECH C install. It's free, just google HITECH C DOWNLOAD. To get the timing (there are many ways but here's one) setup an interrupt on a timer (like timer0) set it to go off 128 times per second or something. You can use a counter in that interrupt to know how much time has gone past. You can also just look at the timer values when you detect a beat and reset. That would be more accurate. Anyway getting the PIC working and getting timing values are something you should learn. Get the sample C code working then start reading the datasheet for your pic. Oscillator, timers, and interrupts are what you need to figure out for this.

That wave form you posted certainly looks like it could be heart rate ~60 BPM.

8. ### sakurarandom Thread Starter New Member

Mar 26, 2011
8
1
Thank you all. My project was successfully done.

russpatterson likes this.