Write Onewire data toa I2C memory / read ASCI


Closed Thread
Results 1 to 40 of 68

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Posts
    60

    Default Write Onewire data toa I2C memory / read ASCI

    Hi !

    I have a display with leds . If I write a text to a I2C memory (24FC512),I can read and scroll this text on leds display . But...I wish to write the result of measurement from ONEWIRE sensor DS1820 for example :

    " temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c) "


    and to read / display ASCI karacter , something like this :

    "i2cread I2CDAT , I2CCLK , $A0,adrr,[karacter]" karacter to be ASCI code

    I can not know to do this . Can somebody to help me ?

    Thank you very much !
    PS. Escuse me ! I do not know so well english .
    Last edited by Eugeniu; - 14th October 2008 at 22:36.

  2. #2
    Join Date
    Jul 2007
    Location
    Bavaria
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Hi Eugeniu,

    it's not clear to me what you want to do, maybe point 4.17.7. in the manual is what you should have a look at.

    4.17.7 DIG
    DIG returns the value of a decimal digit. Simply tell it the digit number
    (0 - 4 with 0 being the rightmost digit) you would like the value of, and
    voila.
    B0 = 123 ‘ Set B0 to 123
    B1 = B0 DIG 1 ‘ Sets B1 to 2 (digit 1 of
    123)

    This allows you to separate each digit from the computed result.

    But you can also divide the word into two bytes using the .lowbyte and .highbyte modifiers and write them to the display or memory.

    HTH

    Regards,
    Ingo

  3. #3
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by inse View Post
    Hi Eugeniu,

    it's not clear to me what you want to do, maybe point 4.17.7. in the manual is what you should have a look at......................
    I will try to explain :

    I use in this moment .....writing a text in a I2C memory ........

    for adr = 0 to 135
    lookup adr,["WELLCOM ! .......................... 5"],c
    I2cwrite I2CDAT , I2CCLK , $A0,ADR,[C]
    pause 5
    next adr


    Read text :

    i2cread I2CDAT , I2CCLK , $A0,J,[caracter]

    Use " case " for select :

    SELECT CASE CARACTER
    CASE 65: SIR_NO=4 ;A
    CASE 66: SIR_NO=9 ;B
    CASE 67: SIR_NO=14 ;C
    CASE 68: SIR_NO=19 ;D
    CASE 69: SIR_NO=24 ;E


    and .....go for select what leds are on .....

    TABLOU:
    LOOKUP OFSET,[_
    $3F,$48,$48,$48,$3F,_ ;A 0-4
    $36,$49,$49,$49,$7F,_ ;B 4-9
    $22,$41,$41,$41,$3E,_ ;C 9-14
    $3E,$41,$41,$41,$7F,_ ;D 14-19
    $41,$49,$49,$49,$7F,_ ;E 19-24


    I wish to write time to time in memory a temperature from a Onewire sensor tip DS1820 and when I read from memory to find there a ASCI CODE to can use same , in my program .
    Last edited by Eugeniu; - 15th October 2008 at 15:16.

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I have difficulty in understanding what you want to do! You should post the complete code to better understand what you have done and what you want to achieve.

    Remember that you cannot write and read with the same control!

    use:

    WriteDev con %10100000
    ReadDev con %10100001

    Perhaps it will solve your present problem.

    Al.

  5. #5
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    I have difficulty in understanding what you want to do!

    You should post the complete code to better understand what you have done and what you want to achieve.


    Al.
    Briefly : Tell me how can write in a I2C memory result from this :



    mainloop:
    OWOut DQ, 1, [$CC, $44] ' Start temperature conversion

    waitloop:
    OWIn DQ, 4, [count_remain] ' Check for still busy converting
    If count_remain = 0 Then waitloop
    OWOut DQ, 1, [$CC, $BE] ' Read the temperature
    OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
    temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    'Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)


    ******************

    adr = xx
    i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]
    pause 5

    ******************

    and how can read from memory something xx,xx (ASCI CODE )

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Eugeniu View Post
    Briefly : Tell me how can write in a I2C memory result from this :
    I too am having a bit of difficulty in understanding what you wish to achieve...

    adr = xx
    i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]
    pause 5

    ******************

    and how can read from memory something xx,xx (ASCI CODE )
    Is 'temperature' a byte or a word value?
    Are you wanting to get a fractional value out of the eeprom itself?
    Have you put a fractional value into that location of the eeprom?

    I2CREAD I2CDAT , I2CCLK , $A0 , adr , [ temp_read ] - would be a command line for starters...

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  3. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  4. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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