Write Onewire data toa I2C memory / read ASCI


Closed Thread
Results 1 to 40 of 68

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Post

    Ok, look at the info below. Most of it came from http://www.rentron.com/PicBasic/one-wire3.htm and your posted program.

    This may not be the most elegant method, but it should give you a start. I still do not think there is any real value in adding all the "text" characters to the EEPROM, but that's a different story.

    Code:
    ' Additional Variables
    Cold_Bit		VAR temperature.Bit11	' Sign-Bit for +/- Temp. 1 = Below 0 deg C
    Sign			VAR BYTE	' +/- sign for temp display
    temperature_int		VAR BYTE	' integer part of temperature   
    temperature_dec		VAR BYTE	' fractional part of temperature
    
    ' Temperature Readout and manipulation
    OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
    
    IF Cold_Bit = 0 THEN	' If Cold_Bit = 0, positive temperature
        Sign  = "+"
        temperature = temperature & $00FF	' Mask lower byte of temperature
        (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    ELSE	' If Cold_Bit = 1, negative temperature
        Sign  = "-"
        temperature = temperature & $00FF	' Mask lower byte of temperature
        (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    ENDIF
    
    'separate interger part from decimal part
    temperature_int = ((temperature DIG 4) * 10) + (temperature DIG 3)	' integer part of temperature
    temperature_dec = ((temperature DIG 1) * 10) + (temperature DIG 0)	' fractional part of temperature
    
    'write digits to EEPROM
    i2cwrite I2CDAT, I2CCLK, $A0, 71,[(temperature DIG 4)+48]	'load EEPROM with integer part
    pause 5
    i2cwrite I2CDAT, I2CCLK, $A0, 72,[(temperature DIG 3)+48]	'load EEPROM with integer part
    pause 5
    i2cwrite I2CDAT, I2CCLK, $A0, 74,[(temperature DIG 2)+48]	'load EEPROM with decimal part
    pause 5  
    i2cwrite I2CDAT, I2CCLK, $A0, 75,[(temperature DIG 1)+48]	'load EEPROM with decimal part
    pause 5

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by languer View Post
    Ok, look at the info below. Most of it came from http://www.rentron.com/PicBasic/one-wire3.htm and your posted program.

    This may not be the most elegant method, but it should give you a start. I still do not think there is any real value in adding all the "text" characters to the EEPROM, but that's a different story.
    I think his problem is extracting the individual digits out of the byte values to display on the LED matrix's, by using DIG, and he hasn't figured that part out yet, which is why I suggested earlier since he's got an LCD, to play with that first and get used to everything (and to find out if his temp sensor is actually working in the first place). Then build it all back up to displaying the reading on the LED matrix.

  3. #3
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by languer View Post
    Ok, look at the info below. Most of it came from http://www.rentron.com/PicBasic/one-wire3.htm and your posted program.

    This may not be the most elegant method, but it should give you a start. I still do not think there is any real value in adding all the "text" characters to the EEPROM, but that's a different story.
    ...................................[/CODE]
    Thank you for link . I do not find your example on this link . Tell me a link for it , or post all example .
    I am looking for little time on this program ...and I see that they use LCD display with " DEC " command .
    Last edited by Eugeniu; - 19th October 2008 at 19:22.

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