PDA

View Full Version : DS18s20 - negative teperature



Ceug2005
- 1st February 2005, 16:28
WHAT IS WRONG HERE ?!
i heave 2 sensors DS18S20 in one wire network , 4,7 k resitor pullup,
3 wires / Vcc = 5V , GND, data



1.with positive temerature works OK.
2.with negative teperature around 0°c is jumping from -655.11 to +88.xx , then i heave right data ,after some time is jumping again and again .....or is jumping from -655.11 to right data and back.


PIC16F877 AT 4 MHZ
-------------------------------

count_remain_0 Var Byte ' sensor 0
count_per_c_0 Var Byte ' sensor 0
count_remain_1 Var Byte ' sensor 1
count_per_c_1 Var Byte ' sensor 1
TempC0 VAR WORD ' RAW Temperature readings sensor 0
R_Temp0 VAR WORD ' RAW Temperature readings sensor 0
TempC1 VAR WORD ' RAW Temperature readings sensor 1
R_Temp1 VAR WORD ' RAW Temperature readings sensor 1
Deg CON 223 ' Data to display Deg ° symbol
Sign0 VAR BYTE ' +/- sign for temp display sensor 0
Sign1

'-------------------------------
.
.
.

'-------------------------------
'sensor 0
OWOUT PortB.0, 1, [$55,$10,$BB,$40,$2C,$00,$08,$00,$F9, $44] ' match ROM & do temp conversion
pause 50
OWOUT PortB.0, 1, [$55,$10,$BB,$40,$2C,$00,$08,$00,$F9, $BE] ' match ROM & read scratchpad memory

OWIN PortB.0, 2, [R_Temp0.Lowbyte, R_Temp0.Highbyte,skip 4,count_remain_0,count_per_c_0] '

if R_Temp0.bit9 = 0 then 'temp pozitive
sign0="+"
TempC0 = (((R_Temp0>> 1) * 100) - 25) + (((count_per_c_0 - count_remain_0) * 100) / count_per_c_0)

else
sign0="-" 'temp negative
R_Temp0 = R_Temp0.lowbyte ^%11111111
R_Temp0 = R_Temp0.lowbyte + 1
R_Temp0 = R_Temp0.lowbyte>> 1

TempC0 = (((R_Temp0>> 1) * 100) - 25) + (((count_per_c_0 - count_remain_0) * 100) / count_per_c_0)
endif

lcdout $FE , 1 ,sign0,DEC TEMPC0 DIG 3,DEC TEMPC0 DIG 2 ,".",DEC TEMPC0 DIG 1,DEC TEMPC0 DIG 0 ,Deg,"C","

....

mister_e
- 1st February 2005, 17:19
have a look on this link (http://www.rentron.com/PicBasic/one-wire3.htm)

Ceug2005
- 1st February 2005, 18:31
Ohhh Ty Steve.

If you want to buy a pizza , i dont send you to rent a car.

i ask what is wrong not to use DIV32 with DS18B20.
like you see i use DS18s20.

anj
- 1st February 2005, 21:07
One thing to watch out for when reading a DS18s20 is that they slow down with colder temps

The max timeout they specify to do a temp conversion is 750ms. Reading data before that can result in corruption
Yr code has
OWOUT PortB.0, 1, [$55,$10,$BB,$40,$2C,$00,$08,$00,$F9, $44] ' match ROM & do temp conversion
pause 50
OWOUT PortB.0, 1, [$55,$10,$BB,$40,$2C,$00,$08,$00,$F9, $BE] ' match ROM & read scratchpad memory

thus you are only allowing 50ms.
Setting this higher, or using a loop to check for the "done" bit being set will probably stabilise it at the lower temps.

Ceug2005
- 1st February 2005, 23:16
TY anj

all works fine with 750 - 800 ms.
And in AC Electrical caracteristics - data sheet is specified

" t_CONV max 750 ms ".


TY again

Ceug2005
- 2nd February 2005, 12:40
ds1820-report.pdf by Dalas semi