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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by inse View Post
    Hi Eugeniu,

    as I have already explained in my first post:
    use the DIG modifier to separate the single digits of your calculated temperature.
    Then simply add 48 to each digit and you will get the ASCII code.

    If temperature is 2555 for 25.55°C
    n0 = (temperature dig 0) + 48

    n0 is 48+5 = 53 = ASCII "5"
    ...

    Regards,

    Ingo
    Dear Ingo ,

    I work by many days to do this and in my mind is a black hole. Please if you wish to help me , write a example ,

    i2cwrite I2CDAT, I2CCLK, $A0, adr,[TELL ME WHAT i MUST TO WRITE HERE ]

    I think that you now formula for temperature measurement with Onewire sensor ( one from others ) :
    " temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c) "

    If I will write :

    LCDOUT $FE, $C0, DEC TEMPERATURE
    I'll be reading 2555

    For LCDOUT and to see a comma , I use this formula :
    lcdout "temp= " , dec temperature/2 ,"," , dec2 100- (100/16)*(count_remain)," gr.C"

    , but ....If I write in EEPROM :

    i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]

    When I will read it with my FORMULA :

    i2cread I2CDAT , I2CCLK , $A0,J,[caracter]
    in " caracter "will can be read , time to time , a single sign / not a cipher
    Last edited by Eugeniu; - 16th October 2008 at 20:46.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Eugeniu,

    your program is a little bit hard to read without knowing Romanian (right?).

    If you want to store the temperature value in single ASCII characters, something like this might work:

    i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 0= + 48, (temperature dig 1) + 48, (temperature dig 2) + 48, (temperature dig 3) +48]

    Add the comma where you please or add it after reading back the value.

    Correct me if I am talking bull****...

    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,

    your program is a little bit hard to read without knowing Romanian (right?).

    If you want to store the temperature value in single ASCII characters, something like this might work:

    i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 0= + 48, (temperature dig 1) + 48, (temperature dig 2) + 48, (temperature dig 3) +48]

    Add the comma where you please or add it after reading back the value.

    Correct me if I am talking bull****...

    Regards,
    Ingo
    Uffff, not work . I see or 88888888 , or 44444444 or 77777777 .......
    I'll try to write every DIG , separate . I'll tell you tomorow if work .

    Thank you very much ! Good night !

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Eugeniu View Post
    LCDOUT $FE, $C0, DEC TEMPERATURE
    I'll be reading 2555
    If that's the only thing you are getting out of the temp sensor, then I'm thinking it probably meaning that your connection or your sensor probably isn't working because it's returning a value that's always max'd out for a byte variable...
    Put the sensor in some ice water and see if the reading changes...
    Get the core working first, then start adding things. You're not even sure if the sensor part is working in the first place!

    , but ....If I write in EEPROM :
    i2cwrite I2CDAT, I2CCLK, $A0, adr,[temperature]
    When I will read it with my FORMULA :
    i2cread I2CDAT , I2CCLK , $A0,J,[caracter]
    in " caracter "will can be read , time to time , a single sign / not a cipher
    Each one of these statements might only be WRITE'ing (or READ'ing) a BYTE, not a WORD. Not sure what the rest of your code says...

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


    Did you find this post helpful? Yes | No

    Default

    You wrote:

    "LCDOUT $FE, $C0, DEC TEMPERATURE
    I'll be reading 2555 "

    Now:

    ByteInteger = TEMPERATURE/100

    ByteDecimal = TEMPERATURE-(ByteInteger*100)

    LCDOUT $FE, $C0, DEC ByteInteger,",",ByteDecimal

    You will see on your display 25,55.

    You don't need to store the comma (separator) but you will store only ByteInteger and ByteDecimal in a location that can be recalled to read back the values. Than after the reading you will add the separator as above.

    Al.

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


    Did you find this post helpful? Yes | No

    Default

    Sorry I have forgotten a Dec. Please read......

    LCDOUT $FE, $C0, DEC ByteInteger,",",DEC ByteDecimal

  7. #7
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Dear MEN !

    I do not use a LCD display . I have make only a comparision .

    I use in front of my program this line to write text "

    I2Cwrite I2CDAT, I2CCLK, $A0, adr,[" Temperature is _________________ "]

    late in program , in free space I wish to write DATA of temperature

    adr = 15( where is free space )
    I2Cread I2CDAT, I2CCLK, $A0, adr,[ temperature DATA ]

    In finish, I wish to can read all - text and temperature DATA as ASCI CODE such as

    Temperatura is 25,55(for example) .

    from this formula :

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

    program read for every adrress (j) a sign (caracter ) in ASCI Code , and this CODE i'll translate in leds on .But where I write temperature DATA , program read other signs not ASCI CODE for 25,55 ( for example )

    Now understand me ?

    I 'll try to write only text with quote and temperature DATA except quote
    Last edited by Eugeniu; - 17th October 2008 at 08:40.

  8. #8
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Eugeniu View Post

    I 'll try to write only text with quote and temperature DATA except quote
    Not work . Data from DS1820 temperature sensor is in binary . Do you know how can convert it in decimal and use in formula ? Except use DEC .

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


    Did you find this post helpful? Yes | No

    Default

    YOU WROTE:
    -------------------------------------------------------------------------
    I do not use a LCD display . I have make only a comparision .
    I use in front of my program this line to write text "
    I2Cwrite I2CDAT, I2CCLK, $A0, adr,[" Temperature is _________________ "]
    late in program , in free space I wish to write DATA of temperature
    adr = 15( where is free space )
    I2Cread I2CDAT, I2CCLK, $A0, adr,[ temperature DATA ]
    ------------------------------------------------------------------------

    I assume you have grounded pin 1 , pin 2 and pin 3 of your 24LC01 chip and that you have pulled up pin 6 and pin 5 with a 4.7K resistors (see page 85 of the manual)

    Just use the following code:

    'set these variable

    WriteDev con %10100000
    ReadDev con %10100001
    Celsius VAR BYTE [32]

    Fix text in the array

    Celsius[0]=84
    Celsius[1]=101
    Celsius[2]=109
    Celsius[3]=112
    Celsius[4]=101
    Celsius[5]=114
    Celsius[6]=97
    Celsius[7]=116
    Celsius[8]=117
    Celsius[9]=114
    Celsius[10]=32
    Celsius[11]=105
    Celsius[12]=115
    Celsius[13]=32
    Celsius[14]=0
    Celsius[15]=44
    Celsius[16]=0


    Now in your program you read temperature from your device and you have the value in the variable TEMPERATURE!

    write:

    Celsius[14] = TEMPERATURE/100
    Celsius[16] = TEMPERATURE - (Celsius[14]*100)

    So you will have the integer part of your value in Celsius[14] and the decimal part in Celsius[16]. Celsius[15]=44 is your separator.

    Now write to your memory at address 0
    adr=0

    I2CWRITE I2CDAT, I2CCLK, WriteDev , adr,[ Str Celsius\32]
    PAUSE 10

    Now if your hardware works properly, you should have stored in your memory the string and the values.

    To recall them back:

    adr=0
    I2CREAD I2CDAT, I2CCLK, ReadDev , adr,[ Str Celsius\32]
    Pause 10

    At this point you send the array to your display

    For A0=0 to 16
    single byte (Celsius[A0]) can be sent to your display
    Next A0

    If you need to store more than on single value you have to increment your Address (adr) by a multiple of 32, and with two values you have filled one page (64 bytes)

    Al.

  10. #10
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    QUOTE=aratti;
    -------------------------------------------------------------------------
    I do not use a LCD display . I have make only a comparision .
    I use in front of my program this line to write text "
    I2Cwrite I2CDAT, I2CCLK, $A0, adr,[" Temperature is _________________ "]
    late in program , in free space I wish to write DATA of temperature
    adr = 15( where is free space )
    I2Cread I2CDAT, I2CCLK, $A0, adr,[ temperature DATA ]
    ------------------------------------------------------------------------

    I assume you have grounded pin 1 , pin 2 and pin 3 of your 24LC01 chip and that you have pulled up pin 6 and pin 5 with a 4.7K resistors (see page 85 of the manual)

    I use this display NOW , and scroll a simple text , but a long text , what is writing in a 24FC512 menory . It has pins 1,2,3,4 and 7 to ground .


    Just use the following code:

    'set these variable

    What doing this ?

    WriteDev con %10100000
    ReadDev con %10100001
    Celsius VAR BYTE [32]

    Fix text in the array

    I use a long text ......with caps.letters only ( you can see this in my programe ).


    Celsius[0]=84 = T
    Celsius[1]=101 = e
    Celsius[2]=109 = m
    Celsius[3]=112 = p
    Celsius[4]=101 = e
    Celsius[5]=114 = r
    Celsius[6]=97 = a
    Celsius[7]=116 = t
    Celsius[8]=117 =u
    Celsius[9]=114 =r
    Celsius[10]=32 = blank
    Celsius[11]=105 = i
    Celsius[12]=115 = s
    Celsius[13]=32 = blank
    Celsius[14]=0 this is not 0
    Celsius[15]=44 = ,
    Celsius[16]=0


    Now in your program you read temperature from your device and you have the value in the variable TEMPERATURE!

    write:

    Celsius[14] = TEMPERATURE/100
    Celsius[16] = TEMPERATURE - (Celsius[14]*100)

    So you will have the integer part of your value in Celsius[14] and the decimal part in Celsius[16]. Celsius[15]=44 is your separator.

    Now write to your memory at address 0
    adr=0

    I2CWRITE I2CDAT, I2CCLK, WriteDev , adr,[ Str Celsius\32]
    PAUSE 10

    Now if your hardware works properly, you should have stored in your memory the string and the values.

    To recall them back:

    Look back in message , I must to use only this formula , only one .
    I2Cread I2CDAT , I2CCLK , $A0 , J ,[caracter]


    adr=0
    I2CREAD I2CDAT, I2CCLK, ReadDev , adr,[ Str Celsius\32]
    Pause 10

    At this point you send the array to your display

    For A0=0 to 16
    single byte (Celsius[A0]) can be sent to your display
    Next A0

    If you need to store more than on single value you have to increment your Address (adr) by a multiple of 32, and with two values you have filled one page (64 bytes)


    Thank you !

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