Heart rate monitor using 8051

admin June 2, 2016 82 Comments

This article is about a simple heart rate monitor using 8051 microcontroller. Like the previous 8051 projects, AT89S51 is the microcontroller used here. The device senses the heart rate from the finger tip using IR reflection method and displays it on a three digit seven segment display in beats per minute. The circuit has an accuracy of 4 beats per minute and it is very easy to use. In medical terms, the technique used here for sensing heart rate is called photoplethysmography.

Photoplethysmography.

Photoplethysmography is the process of optically estimating the volumetric measurement of an organ. Pulse oximetry, cardiovascular monitoring, respiration detection, heart rate monitoring etc are few common applications of photoplethysmography. Let us have a look at the application of photoplethysmography in heart rate monitoring from the figer tip. When the heart expands (diastole) the volume of blood inside the finger tip increases and when the heart contrcats (systole) the volume of blood inside the finger tip decreases. The resultant pulsing of blood volume inside the finger tip is directly proportional to the heart rate and if you could some how count the number of pulses in one minute, that’s the heart rate in beats per minute (bpm). For this an IR transmitter/receiver pair  placed in close contact with the finger tip. When the heart beats, the volume of blood cells under the sensor increases and this reflects more IR waves to sensor and when there is no beat the intensity of the reflected beam decreases. The pulsating reflection is converted to a suitable current or voltage pulse by the sensor. The sensor output is processed by suitable electronic circuits to obtain a visible indication (digital display or graph).

Heart rate monitor using 8051.

Circuit diagram.


heart-rate-monitor-using-8051

Working of the heart rate monitor

LTH1550-01 photo interrupter forms the photoplethysmographic sensor here. LTH1550-01 is simply a IR diode – photo transistor pair in single package. The front side of the IR diode and photo transistor are exposed and the remaining parts are well isolated. When the finger tip is placed over the sensor the volumetric pulsing of  the blood volume inside the finger tip due to heart beat varies the intensity of the reflected beam and this variation in intensity is according to the heart beat.

When more light falls on the photo transistor it conducts more, its collector current increases and so its collector voltage decreases. When less light falls on the photo transistor it conducts less, its collector current decreases and so its collector voltage decreases. This variation in the collector voltage will be proportional to the heart rate. Any way this voltage variation is so feeble and additional signal conditioning stages are necessary to convert it into a microcontroller  recognizable form.

The next part of the circuit consists of a two active low pass filters using opamp LM324.  The LM324 is a quad opamp that can be operated from a single rail supply. Resistor R23, R17 and capacitor C5 sets the gain and cut off frequency of the first filter. With the given component values, gain will be 11 and cut off frequency will be 2.5Hz. The gain and cut off frequency are determined using the following equations. Capacitor C15 is used to by-pass noise if any may cause false triggering of the comparator.

Voltage gain Av =1 + (R17 / R23)

Cut off frequency Fc= 1/(2π *R17*C5)

The second low pass filter also have same gain and cut off frequency. The two low pass filters form a very critical part of the circuit as any noise or false signals passing to the microcontroller stage will produce disastrous results. The output of the filter stage will be a voltage level fluctuating between 0 and 0.35 volts and this fluctuation is converted into a 0 to 5V swing using the comparator  based on the third opamp (IC1c). The reference voltage of the comparator is set to 0.3V. When ever the output voltage of the filter stage goes above 0.3V, the output of the comparator goes to zero and whenever the output voltage of the filter stage goes below 0.3V, the output of the comparator goes to positive saturation. The result will be a neat pulse fluctuating between 0 and 5V at a rate equal to the heart rate. This pulse is fed to the microcontroller for counting.

Program.

ORG 000H                   // origin
MOV DPTR,#LUT              // moves starting address of LUT to DPTR
MOV P1,#00000000B          // sets P1 as output port
MOV P0,#00000000B          // sets P0 as output port
MAIN: MOV R6,#230D         // loads register R6 with 230D
      SETB P3.5            // sets P3.5 as input port
      MOV TMOD,#01100001B  // Sets Timer1 as Mode2 counter & Timer0 as Mode1 timer
      MOV TL1,#00000000B   // loads TL1 with initial value
      MOV TH1,#00000000B   // loads TH1 with initial value
      SETB TR1             // starts timer(counter) 1
BACK: MOV TH0,#00000000B   // loads initial value to TH0
      MOV TL0,#00000000B   // loads initial value to TL0
      SETB TR0             // starts timer 0
HERE: JNB TF0,HERE         // checks for Timer 0 roll over
      CLR TR0              // stops Timer0
      CLR TF0              // clears Timer Flag 0
      DJNZ R6,BACK
      CLR TR1              // stops Timer(counter)1
      CLR TF0              // clears Timer Flag 0
      CLR TF1              // clears Timer Flag 1
      ACALL DLOOP          // Calls subroutine DLOOP for displaying the count
      SJMP MAIN            // jumps back to the main loop
DLOOP: MOV R5,#252D
BACK1: MOV A,TL1           // loads the current count to the accumulator
       MOV B,#4D           // loads register B with 4D
       MUL AB              // Multiplies the TL1 count with 4
       MOV B,#100D         // loads register B with 100D
       DIV AB              // isolates first digit of the count
       SETB P1.0           // display driver transistor Q1 ON
       ACALL DISPLAY       // converts 1st digit to 7seg pattern
       MOV P0,A            // puts the pattern to port 0
       ACALL DELAY
       ACALL DELAY
       MOV A,B
       MOV B,#10D
       DIV AB              // isolates the second digit of the count
       CLR P1.0            // display driver transistor Q1 OFF
       SETB P1.1           // display driver transistor Q2 ON
       ACALL DISPLAY       // converts the 2nd digit to 7seg pattern
       MOV P0,A
       ACALL DELAY
       ACALL DELAY
       MOV A,B             // moves the last digit of the count to accumulator
       CLR P1.1            // display driver transistor Q2 OFF
       SETB P1.2           // display driver transistor Q3 ON
       ACALL DISPLAY       // converts 3rd digit to 7seg pattern
       MOV P0,A            // puts the pattern to port 0
       ACALL DELAY         // calls 1ms delay
       ACALL DELAY
       CLR P1.2
       DJNZ R5,BACK1       // repeats the subroutine DLOOP 100 times
       MOV P0,#11111111B
       RET

DELAY: MOV R7,#250D        // 1ms delay
 DEL1: DJNZ R7,DEL1
       RET

DISPLAY: MOVC A,@A+DPTR    // gets 7seg digit drive pattern for current value in A
         CPL A
         RET
LUT: DB 3FH                // LUT starts here
     DB 06H
     DB 5BH
     DB 4FH
     DB 66H
     DB 6DH
     DB 7DH
     DB 07H
     DB 7FH
     DB 6FH
END

About the program.

For the counting purpose both the timers of 8051 (Timer0 and Timer1) are used. Timer 1 is configured as an 8 bit auto reload counter for registering the number of incoming zero going pulses and Timer0 is configured as a 16 bit timer which generate the necessary 1 second time span for the Timer1 to count.For counting the number of beats Timer0 and Timer1 are used. Timer1 is set as an 8 bit auto reload counter for counting the the number of pulses (indicating the heart beat) and Timer0 is set as a 16 bit timer which generates a 65536uS delay. When looped 230 times it will produce a 15 second time span (230 x 65536uS =15S)  for the Timer 1 to count. The number of counts obtained in 15 seconds is multiplied by 4 to obtain the heart rate in beats per minute.

 The Timer 0 which generates the 1 second time span is configured in Mode 1 (16 bit timer). So the maximum it can count is 2^16 and it is 65536. In 8051 the crystal frequency is divided by 12 using an internal frequency divider network before applying it as a clock for the timer. That means the timer will increment by one for every 1/12th of the crystal frequency. For an 8051 based system clocked by a 12MHz crystal, the time taken for one timer increment will be 1µS (ie; 1/12MHz). So the maximum time delay that can be obtained using one session of the timer will be 65536µS. Go through this article Delay using 8051 timer for a better grasp.

Also read this article Interfacing seven segment display to 8051 before trying this project.

Setting up the circuit.

When power is switched ON, the indicator LED D4 will glow an continues in that state. Now place your finger tip over the sensor and adjust preset R14 so that the LED D4 starts blinking. After you got the LED blinking, reset the power and wait for 15 seconds. The display will show your heart rate in beats per minute.

Testing Video.

 

 

LCD version of the heart rate monitor.

A simple LCD version of the heart rate monitor is shown below. This is just a modification of the above circuit.LCD displays are very popular now a most of the embedded system designers prefer them over multiplexed seven segment LED displays. Using LCD displays you can display text, custom characters, graphics and a lot of other stuff and it is a great advantage over the LED counterparts. JHD162 is the LCD display used here. It is a 16X2 LCD display based on the HD44780 driver IC. Go through the following link for knowing more about JHD162 and its interfacing to the 8051 microcontroller. Interfacing LCD display to 8051. The circuit diagram of the LCD version of the heart rate monitor is shown below.

LCD heart rate monitor using 8051

Data/command input pin DB0 to DB7 of the display is interfaced to Port0 of the microcontroller. Resistor network R17 is used for pulling up thePort0. Port0 needs external pull up for proper functioning. Preset resistor R1 is used for adjusting the contrast of the display. R2 limits the current through the back light LED. Other parts of the circuit are similar to the LED version.

Program.
RS EQU P2.7
RW EQU P2.6
EN EQU P2.5
ORG 000H
ACALL INIT
ACALL TEXT1
ACALL LINE2
ACALL TEXT3
MOV DPTR,#LUT
MOV P1,#00000000B
MOV P0,#00000000B
MAIN: MOV R6,#230D
SETB P3.5
MOV TMOD,#01100001B
MOV TL1,#00000000B
MOV TH1,#00000000B
SETB TR1
BACK: MOV TH0,#00000000B
MOV TL0,#00000000B
SETB TR0
HERE: JNB TF0,HERE
CLR TR0
CLR TF0
DJNZ R6,BACK
CLR TR1
CLR TF0
CLR TF1
MOV A,TL1
MOV B,#4D
MUL AB
ACALL SPLIT
ACALL INIT
ACALL TEXT1
ACALL LINE2
ACALL TEXT2
ACALL BPM

SJMP MAIN



INIT:

ACALL CMD
MOV A,#0FH
ACALL CMD
MOV A,#01H
ACALL CMD
MOV A,#06H
ACALL CMD
MOV A,#83H
ACALL CMD
MOV A,#3CH
ACALL CMD
RET

TEXT1:
MOV A,#48H
ACALL DISPLAY
MOV A,#65H
ACALL DISPLAY
MOV A,#61H
ACALL DISPLAY
MOV A,#72H
ACALL DISPLAY
MOV A,#74H
ACALL DISPLAY
MOV A,#20H
ACALL DISPLAY
MOV A,#52H
ACALL DISPLAY
MOV A,#61H
ACALL DISPLAY
MOV A,#74H
ACALL DISPLAY
MOV A,#65H
ACALL DISPLAY
RET

LINE2:

MOV A,#0C0H
ACALL CMD
RET
TEXT2:
MOV A,#62H
ACALL DISPLAY
MOV A,#70H
ACALL DISPLAY
MOV A,#6DH
ACALL DISPLAY
MOV A,#20H
ACALL DISPLAY
RET
TEXT3:
MOV A,#63H
ACALL DISPLAY
MOV A,#6FH
ACALL DISPLAY
MOV A,#75H
ACALL DISPLAY
MOV A,#6EH
ACALL DISPLAY
MOV A,#74H
ACALL DISPLAY
MOV A,#69H
ACALL DISPLAY
MOV A,#6EH
ACALL DISPLAY
MOV A,#67H
ACALL DISPLAY
MOV A,#2EH
ACALL DISPLAY
MOV A,#2EH
ACALL DISPLAY
MOV A,#2EH
ACALL DISPLAY
RET


BPM:
MOV A,R1
ACALL ASCII
ACALL DISPLAY
MOV A,R2
ACALL ASCII
ACALL DISPLAY
MOV A,R3
ACALL ASCII
ACALL DISPLAY
RET



CMD: MOV P0,A
CLR RS
CLR RW
SETB EN
CLR EN
ACALL DELAY
RET

DISPLAY:MOV P0,A
SETB RS
CLR RW
SETB EN
CLR EN
ACALL DELAY
RET

DELAY: CLR EN
CLR RS
SETB RW
MOV P0,#0FFh
SETB EN
MOV A,P0
JB ACC.7,DELAY

CLR EN
CLR RW
RET

DELAY1:MOV R5,#255D
HERE2:DJNZ R5,HERE2
RET

SPLIT: MOV B,#10D
DIV AB
MOV R3,B
MOV B,#10D
DIV AB
MOV R2,B
MOV R1,A
RET

ASCII: MOVC A,@A+DPTR
RET
LUT: DB 48D
DB 49D
DB 50D
DB 51D
DB 52D
DB 53D
DB 54D
DB 55D
DB 56D
DB 57D

END

 

Comments
  • sabri
    May 5, 2016

    hi sir. ı want to make this project so much but ı have no more documents for thıs can you sent me all of stuff for this ? ı am waıtıng your attetıon have a nıce day

  • sruthy
    March 17, 2016

    sir,
    it is very helpful.thank you so much

  • deepak
    March 8, 2016

    Sir… The project is successful….. But only the problem is with lth1550-01…… Plzz suggest a alternate sensor…. Or the location of sensor availability in the region of andhra pradesh…..
    Plzz sir it’s so urgent

  • Ramavtar Jangid
    October 5, 2015

    sir
    i needed full components list of this project (heart rate moniter using 8051)
    pls email me..

  • Raihan Ahmed
    October 4, 2015

    Can I replace the LTH 1550-01 sensor with a TCRT 5000 sensor ? What adjustments I have to make ?? Need urgent reply. Thanks in advance

  • yesubabu
    September 1, 2015

    pleas share it for me

  • prem
    May 10, 2015

    is this project working?????
    i want to do this project pls anybody sugest me that it is working or not pls help me guys

  • hamid
    April 21, 2015

    send the hex file please right now it’s urgent

  • Hemant Nagvanshi
    April 10, 2015

    Sir can you tell me what software you used to create hex file.
    I’m getting warning in Keil Uvision…. and microcontroller is not working

    • jojo
      April 10, 2015

      @Hemant – If you get a warning in Keil, there should some problem with your code or Keil setting. We use MIDE-51 for creating HEX files. But that doesn’t matter…

      • Raymond Tan
        April 19, 2015

        Dear, Hemant

        i using MIDE-51 for creating HEX file, i just copy above coding and save to “.asm”, after compile it, i get 43 error. Do you configure or set any setting?

        Thanks.

        • Raymond Tan
          April 19, 2015

          Dear, Jojo

          i using MIDE-51 for creating HEX file, i just copy above coding and save to “.asm”, after compile it, i get 43 error. Do you configure or set any setting?

          Thanks.

  • charuta
    April 4, 2015

    Will you please send me c code for this project…..i need it .

  • bhasa
    March 16, 2015

    send me hex file at bhasanewar@gmail.com

  • Reshma Raj
    March 14, 2015

    sir can u please send me the components list for both circuits?

  • bhasa
    March 9, 2015

    can someone plz send me hex file of these both program? plz plz plz its urgent.

  • Raymond Tan
    March 1, 2015

    Hi Sir, can u send me the component required list?

  • jeck
    February 26, 2015

    hi caan you send me hex file ?? plse i want to do this

  • Utkarsh Pantawane
    January 30, 2015

    I can’t find LTH 1550-01 IR diode photo transistor pair. Which other component can be use as substitute.

  • dhanshree
    January 26, 2015

    please can you mail me required component list ??

  • October 17, 2014

    Hellow Sir,
    I am feeling that there is any prob in the programing that have given . For that some error is appearing. But the circuit is correct. Please mae it correct, for us

  • Prashant katkar
    October 12, 2014

    pls can you mail me hex file format of this program?

  • ROHAN
    October 7, 2014

    THe cicuit is bulid by me but no giving correct output..Plz help

  • david niko
    September 19, 2014

    Hi, can i use OPB606A instead of LTH1550-01, they have pretty much same values ? pls answer me i will be appreciated.

  • Sanjeevan
    August 7, 2014

    I can’t find LTH 1550-01 IR diode photo transistor pair. Which other component can be use as substitute.
    plzzzz tell me fast its really urgent

  • zacks
    August 4, 2014

    I can’t find LTH 1550-01 IR diode photo transistor pair. Which other component can be use as substitute.

  • RAMA KRISHNA
    July 24, 2014

    hai..i want to do this project by using above program….
    can i get output…? if any corrections necessary…plzz give inf of modifications

  • July 15, 2014

    please send me hex file of the program.i have submission it is urgent.

  • aditya
    July 12, 2014

    sir can you please guide if i want to replace 7 segments with lcd??

  • TATTU
    July 1, 2014

    IS EVERYONE GOT THE OUTPUT

  • zacks
    June 9, 2014

    Thank you for posting the project. Please could you mind sending me the list of components used in the project? I will really be grateful if you send me list of the components. looking forward to hearing from you. More grease to your elbow

  • Hi, I want to subscribe for this web site to take moset up-to-date updates, therefore where can i do it please assist.

  • magiceco
    May 14, 2014

    sir i have assembled this circuit with proper components as shown in the circuit diagram but did not convert this program to hex,will you please sent me the hex code at samsungb2030@gmail.com

  • kiran
    May 5, 2014

    Please please send me a good code for the above project. i have project submission tomorrow at 9am

  • roshni
    May 5, 2014

    with the code mentioned above we are facing a problem so please correct the errors and post it as soon as possible

  • satya
    April 22, 2014

    pls can you mail me hex file format of this program?

    how to burn this program to microcontroller

  • pratik
    April 5, 2014

    sevensegment replace lcd?? give me programm plz

  • killer
    March 28, 2014

    pls can you mail me hex file format of this program?

  • amit
    March 23, 2014

    Sir, please send me pcb layout and exact cost of this project.
    . and please convert programming in assembly language.
    it is urgent.

  • R Thangaraj
    March 21, 2014

    I think the LED in the sensor should be forward biased and not as shown in the diagram.

  • March 16, 2014

    thanks. good well explained article. could please send me the same code in assembly language. URGENT

  • muhammad usman iliyasu jen
    March 6, 2014

    pls send me the list of components used and power circuit.
    thanks

  • sahithi
    March 3, 2014

    Can u please tell me whether this heart rate monitor can be combined with a bp monitor???

  • vijaykumar
    February 18, 2014

    sir i have assembled this circuit with proper components as shown in the circuit diagram but it will not working properly ,
    the led D4 will glowing continuously it will not blinking and display will showing 000 every after 15 seconds ,so please help me what can i do…
    help me urgent thank you .

    • S Lyons
      February 19, 2014

      You will need to follow the set-up instructions – hold your finger on the tip of the sensor and adjust the R14 variable resistor (with your *other* hand!) until D4 is pulsing – until that happens there is no signal that the following circuitry (that counts the pulse to work out the heart-rate) will not give a reading (i.e. will show 000). Of course, if you are DEAD then there won’t be a reading either… 😎

  • kiran
    February 18, 2014

    can anyone, plz tell me y gain is 101 at each stage of amplification.. thanku

  • bhagyesh modi
    February 3, 2014

    can u plz forward me with the pcb layout of the above project.. i’ll b highly obliged.. waiting for ur reply.. u can mail me the pcb layout on my email ID mentioned above…..

  • aishu
    January 3, 2014

    sir,can you please post the corresponding block diagram with explanation?
    pls..

  • rohit
    December 2, 2013

    give other alternative for the lth1550-01 ldr sensor?

    • kiran
      February 4, 2014

      tcrt5000,tcrt1000

  • Mubashir
    November 18, 2013

    sir can u please post RC car circuit using IC’s?

  • Soju
    November 8, 2013

    Hello, i did not understand why register R5 is loaded with 252 and used as a counter in the displaying part. Please help. Thanks in advance

  • November 4, 2013

    è possibile avere il pcb?

  • sandesh k a
    October 28, 2013

    can you please give the same procedure of circuit connection and code to measure heart rate using atmega 32a ??? please sir want it fast

  • October 26, 2013

    give other alternative for the lth1550-01 ldr sensor?

  • Dillip
    October 26, 2013

    Sir can I use lm358 or lm 293 instead of lm 324 and moreover why amplification is required in the third stage? Can’t I get the pulse in the 2nd stage only

    • kiran
      January 15, 2014

      3rd stage is jus buffer ckt, which decr output impedence.. nd it helps whn u connect to MCU

      • rahul
        April 15, 2014

        hey can anyone send me the layout of this project its very urgent…. plz.
        ..

  • October 26, 2013

    any ldr type matches with lth1550-01 sensor?

  • guptha
    October 26, 2013

    is any alternative to use of instead of lth 1550-01 sensor and any ldr type suport tell that sensor

  • Dillip
    October 23, 2013

    Sir, can I use LDR instead of the photo transistor?

    • admin
      October 24, 2013

      its difficult to use the LDR. it is not sensitive enough for this application

      • rian
        March 31, 2015

        Sir,can you mail me hex file format of this program?

  • Ajit
    October 5, 2013

    Can we use any other sensor than LTH1550-01??
    If Yes please mention the name
    Thanks

  • jackson
    October 5, 2013

    can i just replace another infrared transmitter and receiver with
    lth 1550-01

  • Ajit
    October 4, 2013

    Can I use any other Sensor for this project instead of LTH1550-01???
    Please Reply Urgent

  • ROHIT
    October 3, 2013

    HOW CAN PROGRAM OF 8051 MICRICONTROLLER

  • jackson
    September 30, 2013

    about the preset.
    what does the n/c means?

    • karthi
      January 25, 2014

      no connection

  • jackson
    September 28, 2013

    what is x1 with frequency 11Mhz?

  • dpka
    September 23, 2013

    can you please tell me what method or programmer was used to program the micro-controller?

  • ROHIT KUMAR
    September 17, 2013

    how can we convert it in C language programming or execute it on keil in assembly language?

  • admin
    May 13, 2013

    Xi is a 11.0592 MHz crystal.
    abcdefgh are shorted with each other.

    • bilal
      May 23, 2013

      thanks

    • suvarna
      February 28, 2016

      sir it urgent can u plz….. sent me layout of it . within 1 week have submit project

    • March 9, 2016

      hello sir this circuit not working on bread board i tired more than 50 time is there something wrong with sensor pin plz check out

  • bilal
    May 5, 2013

    what is X1? and what about 7 segment display… ? abcdefgh of these 3 segments are shorted with each other??… please send me details on my mail address bilalzai@yahoo.com

  • shegzzyy
    May 3, 2013

    Thanks.very useful.can you post the pic micro version in asm.once again thanks in advance

  • nemo
    May 2, 2013

    how can we convert it in C language programming or execute it on keil in assembly language?

Leave a Reply

Your email address will not be published. Required fields are marked *