Hi Darrel, thanks for the reply, ill have a good look at the link. Below is the code ive been working with. It seems to work fine, but thinking of it 30odd c does seem high
Trev
Code:OPTION_REG = %11010111 'Set PIC options (see datasheet). CMCON = 7 'turn analogue outputs to digital TRISA = %11111111 'all RA ports are inputs TRISB = %0 'all RB ports are inputs TRISD = %00000000 'all RB ports are inputs DEFINE LCD_DREG PORTD ' Set LCD Data port DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_RSREG PORTD ' Set LCD Register Select port DEFINE LCD_RSBIT 3 ' Set LCD Register Select bit DEFINE LCD_EREG PORTD ' Set LCD Enable port DEFINE LCD_EBIT 2 ' Set LCD Enable bit DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits) DEFINE LCD_LINES 2 ' Set number of lines on LCD DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us DEFINE LCD_DATAUS 50 ' Set data delay time in us TEMPSEN VAR PORTD.1 temperature Var Word ' Temperature storage negTemp var temperature.bit11 ' if 1 then its negative temp count_remain Var Byte ' Count remaining count_per_c Var Byte ' Count per degree C PAUSE 500 'GIVE TIME TO SETTLE LCDOUT $FE,1 LCDOUT "Hello" PAUSE 500 LOOP: OWOut TEMPSEN, 1, [$CC, $44] ' Start temperature conversion waitloop: OWIn TEMPSEN, 4, [count_remain] ' Check for still busy converting If count_remain = 0 Then waitloop OWOut TEMPSEN, 1, [$CC, $BE] ' Read the temperature OWIn TEMPSEN, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c] Lcdout $fe, 1,dec temperature, "_", dec1 temperature,"_",dec2 temperature Lcdout $fe, $c0,bin temperature Pause 5000 If negTemp = 0 Then lcdout $fe, 1, " Temp = ",DEC2 temperature/10,".", dec1 temperature," ",$DF,"C" Lcdout $fe, $c0,dec temperature,"_", dec temperature/10,"_",DEC2 temperature/10 Else Lcdout $fe, 1, "Not Done" Endif Pause 100 GOTO LOOP END





Bookmarks