Multi-digit word variable to string


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Shouldnt we write first and then read? ok i understand that we have nothing to write. But why it doent work if i do not add the i2cwrite line?
    which is precisely what the i2cread command does for you automatically. it should not ever be necessary to add a extra write , no i2c chip i have ever encountered has needed such treatment


    i2cwrite SDA, SCL, addr
    is an incomplete transaction. if your chip needs it then it is not a true i2c device or something else is occurring.
    a logic analyzer would show what's really happening. its not normal and should be examined further to have any confidence
    that the code is really viable in the long term

    addr = %10110100
    trying to set bit0 [the r/w bit] of a i2c address with pbp's i2c commands is not possible and will not have any effect
    the code will set the r/w bit as needed
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    it could be the chip is not really i2c and behaves differently

    try this, at least its a nicer transaction
    i2cwrite SDA, SCL, addr,[7]
    i2cread SDA, SCL, addr,[TEMP.lowbyte, TEMP.highbyte]



    looking at the wiki link you posted, this would do exactly what the smbus timing diagram describes as a proceedure

    PEC var byte
    i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte,PEC] ' reg = $07 ;would be the normal pbp way

    worth trying
    Last edited by richard; - 19th December 2021 at 13:13. Reason: wiki
    Warning I'm not a teacher

  3. #3
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Hi Richard,

    sure i'll try that, and i will try to figure out what is going on with a logic analyzer.

    I have a saleae logic 8.

    Will try that later today. Many thanks for your time once again.

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


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    If there is only one MLX90614 sensor, the 7-bits address is 0x00 by default.
    according to wiki addr =0 where did you get B4 from ?

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    If the chip is the MAX30102, on page 16 seems that reading needs first a write.

    Ioannis

  6. #6
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Quote Originally Posted by Ioannis View Post
    If the chip is the MAX30102, on page 16 seems that reading needs first a write.

    Ioannis
    it is an IR MLX90614

  7. #7
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Applying the 0x00 is not working.

    When i add back the B4 or B5 for write or read mode correspondingly, everything is in a working order again.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    Its hard to work with crappy information


    Name:  LEO.jpg
Views: 1111
Size:  86.1 KB

    i2cread SDA, SCL,$b4,7,[temp.lowbyte,temp.highbyte,PEC] will do exactly that


    i just realized that what code you posted is in fact a snippet .
    addr and reg are never defined , osc is unknown ,i2c defines unknown, pin settings and i2c pull ups ...........

    could be another waste of time
    Warning I'm not a teacher

  9. #9
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Multi-digit word variable to string

    wait a sec,

    im reading the manual again from the SENSOR

    https://www.waveshare.com/w/upload/e/e4/MLX90614-EN.pdf

    Name:  ir sensor 2.png
Views: 1132
Size:  92.8 KB
    Last edited by astanapane; - 19th December 2021 at 13:54.

Members who have read this thread : 0

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