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
Bookmarks