Heart rate sensor MAX30102


Closed Thread
Results 1 to 40 of 85

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    413


    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

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,720


    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

  3. #3
    Join Date
    Oct 2010
    Posts
    413


    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

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,720


    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 15:06.
    Warning I'm not a teacher

  5. #5
    Join Date
    Oct 2010
    Posts
    413


    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)

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,720


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    this i2c sniffer will usually do the job


    Code:
      
    DEFINE I2C_SLOW 1    
          anselA=0        'dig i/o 
          ANSELC=0
          TRISC= %11111111
          TRISA= %11111110  
    
    
    SCL                 var Portc.1                     ' I2C Clock  PortA.3
    SDA                 var Portc.0                     ' I2C Data   PortA.2
    I                   VAR BYTE  
    addr                var byte
    rd                   var byte
    
        porta.0=1
        DEFINE DEBUG_REG PORTA
        DEFINE DEBUG_BIT 0      ;  if not used for pwr  
        DEFINE DEBUG_BAUD 38400
        DEFINE DEBUG_MODE 0     
        pause 2000
        Debug "Start",13 ,10
       addr=0
    
    
    for I = $02 to $fe step 2
    I2Cread SDA,SCL,i,addr,[rd] ; or I2Cread SDA,SCL,i,[rd] ;
    Debug "found addr ",#i , 13,10 
    nak:
    Next I
    end
    Last edited by richard; - 18th August 2020 at 01:32.
    Warning I'm not a teacher

  7. #7
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Heart rate sensor MAX30102

    thanks for the book.

    on the other hand, i would like to continue with this project as it is important for me and the kids in school.

    I have done the first attempt to communicate with the sensor but no luck.

    Based on the Datasheet MAX30102, device address, or slave id: %1010111, consists of 7 bit, B7-B1,and the MSB-7 is transmitted first followed by the remaining bits. B0 is LSB which can be 0 if we write or 1 if we read.

    Then again from the manual explains that for the first write operation, we send the slave id as the first byte!....followed by the register address byte and then one or more data.

    From the PBP manual, and from this link http://www.picbasic.co.uk/forum/cont...-EEPROM-Part-1

    It is clear that I2CWRITE and I2CREAD command takes care of the write or read bit, also for the ACK.

    Name:  from max30102.png
Views: 8450
Size:  101.9 KB

    Now i have tried to send the following:

    if PBP and command I2CWRITE takes care of the 8th bit then how could i manage to correspond it in the code.

    Code:
    i2cwrite sda,scl,%1010111,$04,error ' this is slave id cosnist of 7 bits.
    If i send the above command nothing will happen, and the data line will be offset from the clock.

    Name:  wrong code.png
Views: 8607
Size:  423.1 KB

    Now using the following code:

    Code:
    i2cwrite sda,scl,%10101110,$04,error
    i get this on the scope:

    Name:  no ack.png
Views: 8446
Size:  663.0 KB

    then i tried the following:
    Code:
    i2cwrite sda,scl,%10101110,$04,error
    pause 100
    i2cwrite sda,scl,%10101110,$04,error
    and the result on the scope: it looks strange again.

    Name:  strange.png
Views: 8388
Size:  604.4 KB

Similar Threads

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

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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