Heart rate sensor MAX30102


+ Reply to Thread
Results 1 to 40 of 85

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    401

    Default Heart rate sensor MAX30102

    Dear all,

    the covid-19 period, i have spent lots of time designing a 3D printed Adaptable medical Mask for covid-19. It was succesful using bio-compatible materials

    (here's the liink: https://www.linkedin.com/feed/update...6630277947393/)

    I have printed free of charge, for the kids in school about 50 of face shields in order to be safe inside the lectures.

    The same i did for the professional 3D printed Adaptable Medical Mask, for Hospitals. Just printed couple of those for testing.

    Now i would like to prepare a free of charge again low cost electronic heart rate circuit, for my sons classroom. Kids are in total 15 in class.


    As it is my first time using I2C protocol, i would like your help in order to establish a connection with the heart sensor MAX30102.

    If anyone have tried this sensor i would be much appreciated if you could share a part of your code.

    I have in front of me the manual of the MAX30102 and all the control and register modes. Actually i'm reading this 2 days now, and really as a newbie, cant understand where to start from.

    I will use the PIC18F26K22 at 16Mhz as from the PICBASIC manual I2C protocol needs to run up to 20MHZ using the I2CWRITE or I2CREAD software commands. (i hope i'm right)

    Next the following ports will be used.

    Code:
    LATC.1 for Data 
    LATC.2 for Clock 
    
    also reserved two more ports for external serial display
    
    LATC.6 for TX
    LATC.7 for RX
    Some MAX30102 registers

    Code:
    ;-------------------------------------------------------------|
    ;------------------------ max30102 registers------------------|
    ;-------------------------------------------------------------|
    define  I2C_WRITE_ADDR  $AE     ; b10101110
    define  I2C_READ_ADDR   $AF     ; b10101111
    define  I2C_ID_ADDR     $57     ; 7-bit version of the above
    ;define I2C_ID_ADDR  57h ; 7-bit version of the above
    
    ;//register addresses
    ;---------------------- STATUS REGISTER -----------------------
    define REG_INTR_STATUS_1   $00
    define REG_INTR_STATUS_2   $01
    
    define REG_INTR_ENABLE_1   $02
    define REG_INTR_ENABLE_2   $03
    
    ;----------------------- FIFO REGISTERS -----------------------
    define REG_FIFO_WR_PTR     $04   ; FIFO WRITE POINTER REG ADDR IS 0X04
    define REG_OVF_COUNTER     $05
    define REG_FIFO_RD_PTR     $06
    define REG_FIFO_DATA       $07
    
    ;---------------------- CONFIG REGISTER -----------------------
    define REG_FIFO_CONFIG     $08
    define REG_MODE_CONFIG     $09
    define REG_SPO2_CONFIG     $0A
    define REG_LED1_PA         $0C
    define REG_LED2_PA         $0D
    
    
    define REG_PILOT_PA        $10
    define REG_MULTI_LED_CTRL1 $11
    define REG_MULTI_LED_CTRL2 $12
    
    ;----------------------- TEMP REGISTER -------------------------
    define REG_TEMP_INTR       $1F
    define REG_TEMP_FRAC       $20
    define REG_TEMP_CONFIG     $21
    define REG_PROX_INT_THRESH $30
    
    ;----------------------- PART ID REGISTER ----------------------
    define REG_REV_ID          $FE
    define REG_PART_ID         $FF
    Now i'm trying to understand based on the manual how could i communicate with sensor and at least see it alive (any led light on the sensor)

    Really looking for your help.

  2. #2
    Join Date
    Oct 2010
    Posts
    401


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    on the first post i think i made a mistake with Defines.

    Is this the correct way to assign a constant value to the name?

    Code:
    ;-------------------------------------------------------------|
    ;------------------------ max30102 registers------------------|
    ;-------------------------------------------------------------|
    I2C_WRITE_ADDR con  $AE     ; b10101110
    I2C_READ_ADDR con   $AF     ; b10101111
    I2C_ID_ADDR  con    $57     ; 7-bit version of the above
    ;I2C_ID_ADDR con  57h ; 7-bit version of the above
    
    ;//register addresses
    ;---------------------- STATUS REGISTER -----------------------
    REG_INTR_STATUS_1 con   $00
    REG_INTR_STATUS_2 con   $01
    
    REG_INTR_ENABLE_1 con   $02
    REG_INTR_ENABLE_2 con   $03
    
    ;----------------------- FIFO REGISTERS -----------------------
    REG_FIFO_WR_PTR con     $04   ; FIFO WRITE POINTER REG ADDR IS 0X04
    REG_OVF_COUNTER con     $05
    REG_FIFO_RD_PTR con     $06
    REG_FIFO_DATA con       $07
    
    ;---------------------- CONFIG REGISTER -----------------------
    REG_FIFO_CONFIG con     $08
    REG_MODE_CONFIG con     $09
    REG_SPO2_CONFIG con     $0A
    REG_LED1_PA con         $0C
    REG_LED2_PA con         $0D
    
    
    REG_PILOT_PA con        $10
    REG_MULTI_LED_CTRL1 con $11
    REG_MULTI_LED_CTRL2 con $12
    
    ;----------------------- TEMP REGISTER -------------------------
    REG_TEMP_INTR con       $1F
    REG_TEMP_FRAC con       $20
    REG_TEMP_CONFIG con     $21
    REG_PROX_INT_THRESH con $30
    
    ;----------------------- PART ID REGISTER ----------------------
    REG_REV_ID  con         $FE
    REG_PART_ID  con        $FF

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    LATC.1 for Data
    LATC.2 for Clock
    a recipe for failure in the making ?
    use of LATx ports in "highlevel" commands is incorrect and will not work as expected



    Is this the correct way to assign a constant value to the name?
    a quick little exercise trying to compile this will reveal the differences between defines and constants
    Code:
    reg var byte'#define bite_me 5     ;try one or the other of these two or niether 
    'bite_me con 5         ;                      "
    
    
    REG_INTR_STATUS_1 con   $00
    REG_INTR_STATUS_2 con   $01
    REG_INTR_STATUS_2 con   $07
    REG_INTR_STATUS_3 con   bite_me
    
    
    define REG_INTR_ENABLE_1   $02
    define REG_INTR_ENABLE_2  bite_me
    define REG_INTR_ENABLE_2  1
    
    
    #define REG_INTR_ENABLE_3   $02
    #define REG_INTR_ENABLE_4  bite_me
    #define REG_INTR_ENABLE_4  1
    
    
    loopy:
    
    
    reg =  bite_me
    reg = REG_INTR_ENABLE_3 
    reg = REG_INTR_ENABLE_1
    reg = REG_INTR_STATUS_1
    
    
    goto loopy
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  4. #4
    Join Date
    Oct 2010
    Posts
    401


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    Thanks for the reply.

    do you mean that i cannot use the following format?

    Code:
    DataPin var LATC.1
    ClockPin var LATC.2

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    if that will become

    I2CREAD DataPin, ClockPin, Control,{Address,}[Var{,Var...}]{,Label}

    then yes that is not allowable and will cause difficult to determine bugs.
    you have to remember pbp is ancient technology, latx registers did not exist when it was created
    it never gets any significant updates
    Last edited by richard; - 17th August 2020 at 14:06.
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  6. #6
    Join Date
    Oct 2010
    Posts
    401


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    It is a bit consfusing for me.

    But i will try to figure it out.

    My goal is to communicate with this heart sensor. First step is to send this command to light up the LED and then try to read the information needed.

    I have tried this I2C ping program http://www.picbasic.co.uk/forum/showthread.php?t=20185, in order to see if the sensor responds with the ACK. (i though that the sensor was dead)

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    did you try my i2c sniffer ?

    i2cwrite sda,scl,%10101110,$04,error
    how can that work ? you are attempting to write to the FIFO_WR_PTR yet providing no data to be written .

    i2cwrite sda,scl,$ae,$04,[1],error

    in general code snippets are a waste of time
    what pins , how are they set
    a schematic
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  8. #8
    Join Date
    Oct 2010
    Posts
    401


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    Richard i havent used your sniffer code. Will do today it today.

    The breadboarding....i think is clear as schematic, if you like schematic i could also make one.

    Name:  breadboard.png
Views: 387
Size:  548.6 KB

    SCL is set as input in TRISC

    Code:
    TRISC = %10000100 ' portc.7 and portc.2 set as input. 
    
    all other unused ports are configured as output and set to low. 
    
    SDA var portc.1
    SCL var portc.2
    Now regarding the FIFO_WR_PTR it is not clear to me in the manual what data to write to it.

    Name:  Register maps.png
Views: 399
Size:  146.8 KB

    for example for the REG_MODE_CONFIG which is $09

    Name:  mode config.png
Views: 330
Size:  9.0 KB

    there is a detailed info of the bits need to be set.

    Name:  mode.png
Views: 319
Size:  81.4 KB

    For someone that is the first time working with a peripheral or a new method, it should be so many years a detailed info for configuration. At least a step by step guide.

    I'm not talking about you, but for all the others were in this forum for so many years. There were few guys were really helping. We lost a chief who was really made detailed explanations like talking to a baby.

    If we need to keep PBP alive, we need to start from 0. Here is not a plave to learn from skratch, and i agree. But if anyone loves PBP, we need to do that. Attract newbies like me, that would like to learn.

    Anyway, i will get in focus on this project, because it matters to me. If anyone would like to get involved and have in house a MAX30102, i would be really happy if could help me out as well.

    Richard i understand that you have no time and you have really other things to focus. Really appreciate your help, and i think you are one of the persons help in here.

    Many thanks.

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    The breadboarding....i think is clear as schematic, if you like schematic i could also make one
    not really , i looked at 3 modules the mikroe one is 3.3v only .the one mouser/e14 sell is 3.3 or 5v and has a logic level converter on board
    another provides no schematic and only vague spec no schema, i cannot identify your module

    by the look of your cro traces you are belting 5v in on the scl,sda pins , better hope its 5v tolerant

    TRISC = %10000100 ' portc.7 and portc.2 set as input.
    is wrong both must be input , the routine will switch tris as req
    if the module have 3.3 v pull ups might be better to use the open collector/drain method for i2c command
    [edit] forget that ,its open collecter by default.


    all other unused ports are configured as output and set to low.
    unnecessary


    SDA var portc.1
    SCL var portc.2
    conflicts with your tris statement anyway


    Now regarding the FIFO_WR_PTR it is not clear to me in the manual what data to write to it.
    me either but it will do something if everything else is correct
    Last edited by richard; - 21st August 2020 at 10:20.
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  10. #10
    Join Date
    Oct 2010
    Posts
    401


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    Changed to input both portc.1 and portc.2

    This is the module.

    https://reedpaper.wordpress.com/2018...x-wrong-board/

    I have also following the "fix". Well module is 3.3V but i have never seen in all of the Arduino connections any note.

    I have changed the connections and used the 3.3V output from the Display to power the rest of the circuit.

    I dont beleive that i have burned the module as this is the result before i change the voltage supply from 5V to 3.3V.

    Code:
    i2cwrite sda,scl,$AE,$04
    pause 100
    This is the proof of ACK in 9th bit. As from the data sheet if the Id is the right one, the module pulls down the SDA during 9th bit to acknowledge receipt of data.

    Name:  ACK correct.png
Views: 321
Size:  648.2 KB
    Last edited by astanapane; - 21st August 2020 at 12:16.

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    i2cwrite sda,scl,$AE,$04
    i see you're still torturing the device sending incomplete write resister i2c control messages at it
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    For someone that is the first time working with a peripheral or a new method, it should be so many years a detailed info for configuration. At least a step by step guide.


    I'm not talking about you, but for all the others were in this forum for so many years. There were few guys were really helping. We lost a chief who was really made detailed explanations like talking to a baby.


    If we need to keep PBP alive, we need to start from 0. Here is not a plave to learn from skratch, and i agree. But if anyone loves PBP, we need to do that. Attract newbies like me, that would like to learn
    if you are familiar with i2c protocol and the vagaries of the device you have studied and intend to use then the pbp manual
    tells you everything you need to know to communicate with your device with pbp's i2c commands.
    the pbp manual is not there to teach i2c protocol to a novice , its raison d'etre is to explain usage of pbp implementation.

    having said that you can always ask questions on forums but really the onus is on you to do the ground work. its your project.
    its a pretty tall order to expect a complete novice tutorial for every device you can pluck out of the air from unpaid volunteers
    there are still few here willing to have a go at helping but don't forget dt was paid support , that resource has never been replaced.
    leo will usually help but he has not ventured onto this forum for years and years afaik.
    Last edited by richard; - 21st August 2020 at 11:01.
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

Similar Threads

  1. New PIC failure rate
    By timmers in forum General
    Replies: 5
    Last Post: - 26th March 2009, 12:11
  2. Rf module baud rate
    By tazntex in forum Serial
    Replies: 4
    Last Post: - 5th August 2008, 18:47
  3. Replies: 6
    Last Post: - 18th January 2008, 08:17
  4. SHIFTOUT Clock rate
    By Brock in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th July 2006, 23:42
  5. Detect baud rate
    By Dick M in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd July 2005, 21:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts