I need your advice for 16f84+lcd+ds18s20 temp sensor

Status
Not open for further replies.

evilsent

New Member
Hi all:
My first proyect was to send text from 16f84 to my LCD 16x2. It´s Done thanks to people who helped me here!.

Now i want to use the ds18s20 temp sensor...i wrote a code in basic. I want show the temp in the lcd.
IT showed 54.71..and then 16.23, and so ..with big differences between them.I´ve connected the sensor using the 3 pins..not in parasite mode. I connected the DQ to PORTAB.7..with a 4.7k resistor and to vdd

TRISB.7 = 1


Temp1 Var PORTB.7 ' Temperature storage
Countr Var Byte ' Count remaining
Countc Var Byte ' Count per degree C
DS18S20 VAR WORD
c0 VAR WORD
c1 VAR WORD
c2 VAR WORD
c3 VAR WORD
Pause 500
Lcdout $FE, 1
Lcdout "La temperatura:"
start:
'START TEMP READING
OWOUT TEMP1, 1, [$CC, $44] ' $CC-SKIP SEARCHING FOR MULTIPLE DS18S20, $44-START

WAITF:
OWIN TEMP1, 4, [COUNTR] 'CHECK FOR STILL BUSY CONVERTING SIGNAL
IF COUNTR=0 THEN WAITF

OWOUT TEMP1, 1, [$CC, $BE] 'READ THE TEMPERATURE
OWIN TEMP1, 0, [DS18S20.LOWBYTE, DS18S20.HIGHBYTE, SKIP 4, COUNTR, COUNTC]

DS18S20=((DS18S20>>1*100)-25)+(((COUNTC-COUNTR)*100)/COUNTC)
c0 = DS18S20 dig 3
c1 = DS18S20 dig 2
c2 = DS18S20 dig 1
c3 = DS18S20 dig 0

Lcdout $FE, $C0, #c0,#c1,".",#c2,#c3," C"
pause 1000

goto start
end

Thanks in advance!!
 
Last edited:
Hello,
Simplify program to most basic component then add back features one at a time. Forgive me for not having the exact answers but some food for thought:

1) Follow datasheet flow diagram i.e. Reset, SkipRom, ConvertT, Reset, SkipRom, ReadScratch.
2) Use delays of 1/2 second or 1 second for now instead of checking bus.
3) Assuming that RB.7 is the open drain output of the 16f84?
4) Comment out high resolution temp readings for now, and read whole degree temp by multiply by 10 and one right shift of DS18S20 variable or 5*DS18S20.

Keep refering to data sheet, and experiment, you will get it.
 
Thx for your advice...i reprogramed my code and used delays of 1000Ms instead of cheking the bus...and nothing new...the same problem...so i checked the wiring and i changed a few wires and resistors...and it worked just fine...then i use the code i´ve posted above and it worked too......

Now im happy Thxs again!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…