I have been trying for 2 weeks to get my project working properly and now I am at my wits end.
Part of my project is to read a DS18S20 and display the correct termperature on a 2x16 lcd display. I have searched the forum and all the examples for reading the device are the same so I just used it and it worked great.
Problem is I cannot understand what the count_remain variable actually does. I am also confused about the count_per_c variable. So I did what any older person would do and just remarked them out of the code to see what would happen. But nothing did. Everything worked the same.

the code is as follows:

Hope someone can help

Wilson

@ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT,LVP_OFF,WDT_OFF,MCLR_OFF,PROTEC T_OFF
@ DEVICE pic16F628a, CPD_OFF
trisa =%00100000
trisb =%00000000
cmcon =%00000111 'Comparators Off
Define LCD_BITS 4
Define LCD_DREG PORTB
Define LCD_DBIT 0
Define LCD_RWREG PORTA
Define LCD_RWBIT 4
Define LCD_RSREG PORTA
Define LCD_RSBIT 3
Define LCD_EREG PORTA
Define LCD_EBIT 2
Define LCD_COMMANDUS 5000
Define LCD_DATAUS 100
Define LCD_INITMS 2

pause 100

DQ VAR PORTB.5 ' One-wire data pin
temperature VAR WORD ' Temperature storage
'I removed the next two lines
'count_remain VAR BYTE ' Count remaining
'count_per_c VAR BYTE ' Count per degree C

loop:
LCDOUT $FE, 1
LCDOut $FE, $C0, "Temp ", dec(temperature / 100)," C "

OWOut DQ, 1, [$CC, $44] ' Start temperature conversion
pause 750 'NEEDED FOR TEMP STABILIZING

'and the following three lines
'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

'as well as the last bits of the next two lines
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]', Skip 4, count_remain, count_per_c]

temperature = (((temperature >> 1) * 100) - 25)' + (((count_per_c - count_remain) * 100) / count_per_c)

goto loop