+ Post New Thread
Results 1 to 19 of 19
  1. #1
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    heart beat monitor based on pic16f877a

    hi all ,
    i face a problem while working with this project, i need a c code that can program pic to do these things;
    1) count number of beats in the heart signal
    2)display the result on lcd
    3)how to connect lcd(16*2) with pic16f877a
    plz help me ,because its very urgent
    thank all

    •   Alt22nd October 2010, 12:02

      advertising

        
       

  2. #2
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    Where in the do you got stuck up with? The questions you have us to do are readily available in the net.Googling is enough for it. The first question which you have posted have an algorithm i.e the time period between the 2 beats is converted to BPM by a formula which i don't exactly remember. You can locate that too in the net.
    Regards,
    Jerin.


    1 members found this post helpful.

  3. #3
    Full Member level 1
    Points: 5,141, Level: 16
    pcup's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    103
    Helped
    17 / 17
    Points
    5,141
    Level
    16



  4. #4
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    Re: heart beat monitor based on pic16f877a

    first of all thank u,
    but my question about c code needed to program pic to do these things,because i don't have any idea how to deal with it.
    Regards,
    bouz.

    ---------- Post added at 21:50 ---------- Previous post was at 21:47 ----------

    thank u pcup



  5. #5
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    Refer this link. It might help you.
    Optical heartbeat monitor.
    Regards,
    Jerin.



  6. #6
    Full Member level 1
    Points: 5,141, Level: 16
    pcup's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    103
    Helped
    17 / 17
    Points
    5,141
    Level
    16

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by bouz00100 View Post
    first of all thank u,
    but my question about c code needed to program pic to do these things,because i don't have any idea how to deal with it.
    Regards,
    bouz.

    Refer : C Programming for Embedded Systems By Kirk Zurell
    Microcontroller Programming The Microchip PIC By Julio Sanchez & Maria P. Canton
    PIC Microcontroller Project Book By John Iovine
    Above books are reference's for PIC beginner. Your application specific code and examples are available in Embedded Health Informatics Journals and eBooks do google

    Best of Gluck



  7. #7
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    but my question about c code needed to program pic to do these things,because i don't have any idea how to deal with it.
    Are you talking about the coding of the project or you don't know coding in C?
    Regards,
    Jerin.



  8. #8
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by incomplete_jerin View Post
    Are you talking about the coding of the project or you don't know coding in C?
    Regards,
    Jerin.
    hi,
    i'm talking about code needed to programming pic , and this code written by c lang.
    Regards,
    booz



    •   Alt28th October 2010, 18:00

      advertising

        
       

  9. #9
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    Do you have the flow chart of the project with you or have you prepared it?
    Regards,
    Jerin.


    1 members found this post helpful.

    •   Alt29th October 2010, 05:54

      advertising

        
       

  10. #10
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by incomplete_jerin View Post
    Do you have the flow chart of the project with you or have you prepared it?
    Regards,
    Jerin.
    yes, i have flow chart for this project

    Untitled 2.pdf
    Regards,
    booz.
    Last edited by bouz00100; 30th October 2010 at 16:15.



  11. #11
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    Fine..... Did you started writing the code with this flowchart?
    Regards,
    Jerin.



  12. #12
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by incomplete_jerin View Post
    Fine..... Did you started writing the code with this flowchart?
    Regards,
    Jerin.
    yes.... ;)
    u want c it.



  13. #13
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by incomplete_jerin View Post
    Did in which compiler?
    Regrads,
    Jerin.
    microc pro for pic ,
    if u have any suggestions ,plz let me know
    regards,
    booz



  14. #14
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    MikroC..... Thats nice.... Watz the status till now?
    Just post the code & let me see the code. Just provide comments too as much you can along the code.
    Regards,
    Jerin.



  15. #15
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by incomplete_jerin View Post
    MikroC..... Thats nice.... Watz the status till now?
    Just post the code & let me see the code. Just provide comments too as much you can along the code.
    Regards,
    Jerin.
    hi, this is my code
    if you have any comments , tell me plz

    /*Header******************************************* ***********/
    unsigned int inputsignal;
    unsigned int firstRun = 1;
    unsigned int cnt; // Define variable cnt == 1KHz clk
    unsigned int HR;

    void interrupt() {
    cnt++; // Interrupt causes cnt to be incremented by 1
    TMR0 = 194; // Timer TMR0 is returned its initial value
    INTCON = 0x20; // Bit T0IE is set, bit T0IF is cleared
    }

    void main() {
    OPTION_REG = 0x84; // Prescaler is assigned to timer TMR0
    ANSEL = 0x0C; // Pins AN2 and AN3 are configured as analog
    TRISA = 0xFF; // All port A pins are configured as inputs
    ANSELH = 0;
    TRISC = 0; // All port C pins are configured as outputs
    TRISD = 0; // All port D pins are configured as outputs
    TRISB = 0;
    PORTC = 0x0; // Reset port C
    PORTD = 0x0; // Reset port D
    PORTB = 0x0;
    ADCON1.F4 = 1 ; // Voltage reference is brought to the RA3 pin.
    while (1){
    inputsignal = ADC_Read(2); // Result of A/D conversion is copied to inputsignal
    portd = inputsignal;
    if (inputsignal>=64) { //64 is peak value of heart signal//
    delay_ms(1000) ;//this dealy to make sure that signal goes down//
    if (firstRun=1){//detect first pulse
    firstRun = 0;
    cnt = 0; // Variable cnt is assigned a 0
    TMR0 = 194; // Timer T0 counts from 194 to 255
    INTCON = 0xA0; // Enable interrupt TMR0
    } else {//enter else if second pulse detected
    //number of interrupt is time between two pulses in ms which is stored in cnt
    HR=60000/cnt;

    //send this value to lcd
    // lcd code...................
    //...................//
    // i don't have lcd ,so to c the output i do this//
    Portc = cnt;
    Portb = HR;
    //then start test again -reset timer and wait pulse from ad
    cnt = 0 ;
    TMR0 = 194; // Timer T0 counts from 194 to 255
    INTCON = 0xA0; // Enable interrupt TMR0
    }
    }
    }
    }
    i didn't c any output on port (b&c)
    but ad is running
    so i don't know the problem ?

    regards;
    booz ;)



  16. #16
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    Do one thing buddy. I see that you have written a step:
    OPTION_REG = 0x84; // Prescalar is assigned to timer TMR0
    Actually you should enable the internal pull up resisters on PORT B to get output @ PORT B which would be done by clearing the MSB of the OPTION_REG. So the value for OPTION_REG will be 0x04.
    Then,
    ANSEL = 0x0C; // Pins AN2 and AN3 are configured as analog
    to set the PORT A pins as analog8/digital pins, there is a register called ADCON1 & ADCON0 is used for which channel to select for ADC to work. Also change ANSELH to ADRESH.
    Refer the data sheet for 16F87XA for more details & simulate once again the code & see whether it is working or not.
    Regards,
    Jerin.



  17. #17
    Newbie level 5
    Points: 461, Level: 4

    Join Date
    Oct 2010
    Posts
    8
    Helped
    1 / 1
    Points
    461
    Level
    4

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by incomplete_jerin View Post
    Do one thing buddy. I see that you have written a step:

    Actually you should enable the internal pull up resisters on PORT B to get output @ PORT B which would be done by clearing the MSB of the OPTION_REG. So the value for OPTION_REG will be 0x04.
    Then,

    to set the PORT A pins as analog8/digital pins, there is a register called ADCON1 & ADCON0 is used for which channel to select for ADC to work. Also change ANSELH to ADRESH.
    Refer the data sheet for 16F87XA for more details & simulate once again the code & see whether it is working or not.
    Regards,
    Jerin.
    hi, there is no problem with A/D
    i have connect lcd with circuit , but i think there is problem in calculation of heart rate , c the code plz and till me if u found any thing important



    /*Header******************************************* ***********/

    // LCD module connections
    sbit LCD_RS at RB4_bit;
    sbit LCD_EN at RB5_bit;
    sbit LCD_D4 at RB0_bit;
    sbit LCD_D5 at RB1_bit;
    sbit LCD_D6 at RB2_bit;
    sbit LCD_D7 at RB3_bit;
    sbit LCD_RS_Direction at TRISB4_bit;
    sbit LCD_EN_Direction at TRISB5_bit;
    sbit LCD_D4_Direction at TRISB0_bit;
    sbit LCD_D5_Direction at TRISB1_bit;
    sbit LCD_D6_Direction at TRISB2_bit;
    sbit LCD_D7_Direction at TRISB3_bit;
    // End LCD module connections

    unsigned inputsignal=0;
    unsigned int firstRun = 1;
    unsigned int cnt=0; // Define variable cnt == 1KHz clk
    long HR=0;
    char *text;
    unsigned char outlcd;

    void interrupt() {
    cnt++; // Interrupt causes cnt to be incremented by 1
    TMR0 = 194; // Timer TMR0 is returned its initial value
    INTCON = 0x20; // Bit T0IE is set, bit T0IF is cleared
    }

    void main() {
    Lcd_Init(); // LCD display initialization
    Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)
    Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)

    OPTION_REG = 0x84; // Prescaler is assigned to timer TMR0
    ANSEL = 0x02; // Pins AN1 is configured as analog
    TRISA = 0xFF; // All port A pins are configured as inputs
    ANSELH = 0;
    TRISC = 0; // All port C pins are configured as outputs
    TRISD = 0; // All port D pins are configured as outputs
    PORTC = 0x0; // Reset port C
    PORTD = 0x0; // Reset port D
    ADCON1.F4 = 0 ; // VSS voltage reference
    ADCON1.F7 = 1 ; //A/D Conversion Result Format Select bit adfm=1
    ADCON0 = 0x07; // A/D is enabled and AN1 is analog input

    text = "instantaneous"; // Define the first message
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1,2,text); // Write the first message in the first line
    text ="heart rate test";
    Lcd_Out(2,1,text);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    Lcd_Cmd(_LCD_CLEAR);
    text ="1)connect";
    Lcd_Out(1,1,text);
    text="electrodes";
    Lcd_Out(2,1,text);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    Lcd_Cmd(_LCD_CLEAR);
    text ="2)relax please";
    Lcd_Out(1,1,text);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);


    while (1){
    inputsignal = ADC_Read(1); // Result of A/D conversion is copied to inputsignal
    portd = ADRESL;
    portc = ADRESH;
    if (inputsignal>=600) {
    delay_ms(500);
    if (firstRun==1)
    {
    firstRun = 0;
    cnt = 0; // Variable cnt is assigned a 0
    TMR0 = 194; // Timer T0 counts from 194 to 255
    INTCON = 0xA0; // Enable interrupt TMR0
    }
    else {
    //find heart rate
    Lcd_Cmd(_LCD_CLEAR);
    text="Heart rate=";
    Lcd_Out(1,1,text);
    //number of interrupt is time between two pulses in ms
    HR=60000/cnt;
    outlcd=HR/100 ; //hundreds digit in HR
    Lcd_Chr(1,12,48+outlcd); // Write result in ASCII format
    outlcd=(HR/100)%10;//tens digit in HR
    Lcd_Chr_CP(48+outlcd);
    outlcd=(HR)%10 ;//ones digit in HR
    Lcd_Chr_CP(48+outlcd);
    Lcd_out(2,5,"puls/min.");

    //rest vlaue of counter
    //and start next test
    cnt = 0 ;
    TMR0 = 194; // Timer T0 counts from 194 to 255
    INTCON = 0xA0; // Enable interrupt TMR0
    }
    }
    }
    }


    1 members found this post helpful.

  18. #18
    Full Member level 1
    Points: 848, Level: 6

    Join Date
    Oct 2010
    Posts
    115
    Helped
    4 / 4
    Points
    848
    Level
    6

    Re: heart beat monitor based on pic16f877a




  19. #19
    Advanced Member level 2
    Points: 3,276, Level: 13
    incomplete_jerin's Avatar
    Join Date
    Jun 2010
    Location
    INDIA
    Posts
    551
    Helped
    102 / 102
    Points
    3,276
    Level
    13

    Re: heart beat monitor based on pic16f877a

    Quote Originally Posted by bouz00100 View Post
    hi, there is no problem with A/D
    i have connect lcd with circuit , but i think there is problem in calculation of heart rate , c the code plz and till me if u found any thing important



    /*Header******************************************* ***********/

    // LCD module connections
    sbit LCD_RS at RB4_bit;
    sbit LCD_EN at RB5_bit;
    sbit LCD_D4 at RB0_bit;
    sbit LCD_D5 at RB1_bit;
    sbit LCD_D6 at RB2_bit;
    sbit LCD_D7 at RB3_bit;
    sbit LCD_RS_Direction at TRISB4_bit;
    sbit LCD_EN_Direction at TRISB5_bit;
    sbit LCD_D4_Direction at TRISB0_bit;
    sbit LCD_D5_Direction at TRISB1_bit;
    sbit LCD_D6_Direction at TRISB2_bit;
    sbit LCD_D7_Direction at TRISB3_bit;
    // End LCD module connections

    unsigned inputsignal=0;
    unsigned int firstRun = 1;
    unsigned int cnt=0; // Define variable cnt == 1KHz clk
    long HR=0;
    char *text;
    unsigned char outlcd;

    void interrupt() {
    cnt++; // Interrupt causes cnt to be incremented by 1
    TMR0 = 194; // Timer TMR0 is returned its initial value
    INTCON = 0x20; // Bit T0IE is set, bit T0IF is cleared
    }

    void main() {
    Lcd_Init(); // LCD display initialization
    Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)
    Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)

    OPTION_REG = 0x84; // Prescaler is assigned to timer TMR0
    ANSEL = 0x02; // Pins AN1 is configured as analog
    TRISA = 0xFF; // All port A pins are configured as inputs
    ANSELH = 0;
    TRISC = 0; // All port C pins are configured as outputs
    TRISD = 0; // All port D pins are configured as outputs
    PORTC = 0x0; // Reset port C
    PORTD = 0x0; // Reset port D
    ADCON1.F4 = 0 ; // VSS voltage reference
    ADCON1.F7 = 1 ; //A/D Conversion Result Format Select bit adfm=1
    ADCON0 = 0x07; // A/D is enabled and AN1 is analog input

    text = "instantaneous"; // Define the first message
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1,2,text); // Write the first message in the first line
    text ="heart rate test";
    Lcd_Out(2,1,text);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    Lcd_Cmd(_LCD_CLEAR);
    text ="1)connect";
    Lcd_Out(1,1,text);
    text="electrodes";
    Lcd_Out(2,1,text);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);
    Lcd_Cmd(_LCD_CLEAR);
    text ="2)relax please";
    Lcd_Out(1,1,text);
    delay_ms(1000);
    delay_ms(1000);
    delay_ms(1000);


    while (1){
    inputsignal = ADC_Read(1); // Result of A/D conversion is copied to inputsignal
    portd = ADRESL;
    portc = ADRESH;
    if (inputsignal>=600) {
    delay_ms(500);
    if (firstRun==1)
    {
    firstRun = 0;
    cnt = 0; // Variable cnt is assigned a 0
    TMR0 = 194; // Timer T0 counts from 194 to 255
    INTCON = 0xA0; // Enable interrupt TMR0
    }
    else {
    //find heart rate
    Lcd_Cmd(_LCD_CLEAR);
    text="Heart rate=";
    Lcd_Out(1,1,text);
    //number of interrupt is time between two pulses in ms
    HR=60000/cnt;
    outlcd=HR/100 ; //hundreds digit in HR
    Lcd_Chr(1,12,48+outlcd); // Write result in ASCII format
    outlcd=(HR/100)%10;//tens digit in HR
    Lcd_Chr_CP(48+outlcd);
    outlcd=(HR)%10 ;//ones digit in HR
    Lcd_Chr_CP(48+outlcd);
    Lcd_out(2,5,"puls/min.");

    //rest vlaue of counter
    //and start next test
    cnt = 0 ;
    TMR0 = 194; // Timer T0 counts from 194 to 255
    INTCON = 0xA0; // Enable interrupt TMR0
    }
    }
    }
    }
    Some corrections in the code:
    PORTC = 0x0; // Reset port C
    PORTD = 0x0; // Reset port D
    Always do write:
    PORTC = 0 or 0x00; // Reset port C
    PORTD = 0 or 0x00; // Reset port D

    ADCON1.F4 = 0 ; // VSS voltage reference
    ADCON1.F7 = 1 ; //A/D Conversion Result Format Select bit adfm=1
    Don't assign the bits of a register like ADCON1. It is always desirable to give away a value to the register like, ADCON1 = 0x10;
    Can you please post me the logic of writing the code posted here?
    Regards,
    Jerin.


    1 members found this post helpful.

+ Post New Thread
Please login