Write Onewire data toa I2C memory / read ASCI


Results 1 to 40 of 68

Threaded View

  1. #26
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Ok, so the parenthesis don't make a difference, no problem...Guess we're going to have to build this up from scratch...
    Do you have that LCD connected to your project? Is it working as you expect it to work (i.e. displays HELLO if you command it)

    EDIT: Never mind, obviously you do have the LCD connected...

    In reference to your I2CWRITE statements a few posts ago...
    adr = 24
    i2cwrite I2CDAT, I2CCLK, $A0, adr,[(temperature dig 2) + 48]
    pause 15.......and so on.....
    You do NOT need to store temperature in the manner you are storing it. What you are doing in effect is storing the ASCII equivalent of your temperature value in 3 bytes, then retrieving that same result and trying to display the ASCII result of each of those bytes...in effect, display the ASCII values of the ASCII values of the bytes originally stored....sort of like looking at a camera which is looking at you looking at a camera which is looking at you...infinite regression...

    It looks to me like you're doing twice as much work as you need to do!
    Try to store the temperature like this:
    Code:
    adr = 24
    i2cwrite i2cdat, i2cclk, $a0, adr,[temperature.highbyte]
    adr = 25
    i2cwrite i2cdat, i2cclk, $a0, adr,[temperature.lowbyte]
    This will store the WORD variable temperature in two bytes as required.
    Then for retrieving that same value:
    Code:
    adr = 24
    i2cread i2cdat, i2cclk, $a0, adr, temperature.highbyte
    adr = 25
    i2cread i2cdat, i2cclk, $a0, adr, tempearture.lowbyte
    .............
    lcdout DEC2 (temperature/100) , "," , DEC2 (temperature//100)
    This should display on the LCD is in fact the temperature sensor and it's code are working properly.

    To get the individual digits from this value for display on the LED matrix instead of the LCD:
    Code:
    adr = 24
    i2cread i2cdat, i2cclk, $a0, adr, temperature.highbyte
    adr = 25
    i2cread i2cdat, i2cclk, $a0, adr, tempearture.lowbyte
    .............
    digit var byte[5]
    digit[5] = temperature dig 4
    digit[4] = temperature dig 3
    digit[3] = temperature dig 2
    digit[2] = ","
    digit[1] = temperature dig 1
    digit[0] = temperature dig 0
    ............
    Last edited by skimask; - 20th October 2008 at 05:03.

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