ok have got it to work. i replaced the 4k7 resistor with a 2k4 resistor and rererererereread the data sheet for the ds1820 and put a pause 750 after the start temp conversion. IE.
OWOUT DQ,1, [$CC, $44]
PAUSE 750 ' Max conversion time
OWIN DQ, 4, [count_remain]
i found it on pg 20 under AC Electrical Characteristics temperature conversion time
i found its not as fast as i would have thought. is there any other way to make it faster or is this the speed of using the 1 wire devices
the code
OSCCON = %01101000 'INTRC = 4 MHz
TRISA = %11111111
ANSEL = 0 'DISABLE ALL ADC
CMCON = 7 'DISABLE ALL ANALOG COMPARATOR
WHILE OSCCON.2=0:WEND 'STABILISE THE CLOCK
ADCON1 = 1
DEFINE OSC 4
PAUSE 1000
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4 '4,5,6,7
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
pause 1000
lcdout $fe, 1
' One-wire temperature for DS18S20
' This program must be compiled with PBP version 2.40 or later
temperature VAR WORD ' Temperature storage
count_remain VAR BYTE ' Count remaining
count_per_c VAR BYTE ' Count per degree C
DQ VAR PORTA.1 ' One-wire data pin
mainloop:
OWOut DQ, 1, [$CC, $44] ' Start temperature conversion
pause 750 'NEEDED FOR TEMP STABILIZING
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]
' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
LCDOut $fe, 1, DEC (temperature / 100)," C"
GoTo mainloop ' Do it forever
end
thanks
crazy cooter
Bookmarks