Heart Rate Monitor Using Microcontroller

Heart Rate Monitor Using AT89S51

     This article is about simple heart rate monitor using 8951 microcontroller. The device sense the heart rate from fingertip using IR reflection method and displays it on a three digit seven segment display in beats per minute. The circuit has an accuracy of four 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 a process of optically estimating the volumetric measurement of an organ. Pulse oximetry, cardiovascular monitoring, respiration detection, heart rate monitoring etc are few common application of photoplethysmography. Let us have look at the application of photoplethysmography in the  heart rate monitor in the fingertip. When the heart expands (diastole) the volume of blood inside the fingertip increases and when the heart contracts (systole) volume of blood inside the finger tip decreases. The resultant pulsing of blood volume inside the finger tip is directly proportional to the heart  contracts and if you could somehow count the number of pulse in one minute, that's the heart rate in beats per minute (bpm). For this an IR Rx/Tx pair is placed in close contact to the fingertip. 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 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


Working of heart rate monitor

       LTH1550-01 photo interruptor forms the photoplethysmographic sensor here. LTH1550-01 is simply a IR diode - photo transistor pair in single package. The front side of 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 fingertip 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 decreases so its collector voltage decreases. This variation in the collector voltage is will be proportional to the heart rate. Anyway this voltage variation is to feeble and additional signal conditioning stages are necessary to convert it into a microcontroller recognizable form.

       The next part of circuit consists of a two active low pass filter using op-amp LM324. The LM324 is quad op-amp that can be operated from a single rail supply. Resistor R23, R17 and capacitor C5 set the gain and cutoff frequency of the first filter. With the given component value, gain will be 101 and cutoff frequency will be 2.5Hz. The gain and cutoff frequency are determined using the following equations.

Voltage gain Av=1+(R17/R23)

Cutoff frequency Fc=1/(2π*R17*C15)

      The second low pass filter also have the same parameters. The two low pass filters from a very critical part of the circuit as any noise or false signal 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 op-amp (IC1c). The reference voltage of the comparator is set to 0.3V. Whenever 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.

For program leave your e-mail below.





20 comments:

  1. iqra.rizvi@gmail.com.. its very urgent.. can u please mail me the keil program of above HRM.

    ReplyDelete
  2. Hey, Im am building a similar circuit at the moment, If you have time will you please send me on the code, im thinking of using assembly and an 8051. Thanks email is grrdobrien@gmail.com

    ReplyDelete
  3. Hello, i was building a similar project. It would be a great help if you could send the program to
    mohit.adlakha09@gmail.com

    ReplyDelete
  4. Hi, I am doing similar project for my dissertation, a bit stuck on the programming part. Can you please send me the the code on moha_moha_9@hotmail.com
    thanks

    ReplyDelete
  5. send me the code of the program on rrajput815@gmail.com thank you

    ReplyDelete
  6. this is my email can u sent it to me nickhuncute@gmail.com

    ReplyDelete
  7. please could you sent the programming code to ayanramakrishna9@gmail.com.it would be very helpful

    ReplyDelete
  8. Please mail me the code of this project
    charu.mathur8@gmail.com

    ReplyDelete
  9. Hello sir.
    This is a great project to work on.
    can you please send me the source code (programming file)?
    my email address is wahab_majeed@yahoo.com

    ReplyDelete
  10. Could you please send me the code of this project, i am using embedded c and the same micro controller as above.

    ReplyDelete
  11. Hello sir.
    can i get the code of this project in C language.
    my mailing ID is
    ali.bsee1808@iiu.edu.pk

    ReplyDelete
  12. I am building a similar circuit now. Can u please send me the code at kamath.raja@gmail.com please? Thank you

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. code for 7segment display

      Delete
    2. 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

      Delete
  14. code for lcd display
    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

    ReplyDelete
  15. 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

    ReplyDelete
  16. It lights up all 3 led 7 segments, it doesn't work, please help me

    ReplyDelete