Ok, with a bit of head scratching I've managed to get the LCD to display some text, and then added an edited section of Bruce's code to get the DEC value of TEMPf displayed on the screen
Code:
ANSEL = 0
ANSELH = 0
DEFINE OSC 20
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 1000
DEFINE LCD_DATAUS 100
Comm_Pin VAR PortA.5 ' One-wire Data-Pin "DQ" on PortA.5
Busy VAR BIT ' Busy Status-Bit
R_Temp VAR WORD ' RAW Temperature readings
TempC VAR WORD ' Temp in deg C
TempF VAR WORD ' Temp in deg F
Float VAR WORD ' Holds remainder for + temp C display
Cold_Bit VAR R_Temp.Bit11' Sign-Bit for +/- Temp. 1 = Below 0 deg C
Real_Cold CON 1 ' Define Real_Cold = 1
Sign VAR BYTE ' +/- sign for temp display
Dummy VAR BYTE ' Dummy for Div32
Start_Convert:
OWOUT Comm_Pin, 1, [$CC, $44] ' Skip ROM search & do temp conversion
Wait_Up:
OWIN Comm_Pin, 4, [Busy] ' Read busy-bit
IF Busy = 0 THEN Wait_Up ' Still busy..?, Wait_Up..!
OWOUT Comm_Pin, 1, [$CC, $BE] ' Skip ROM search & read scratchpad memory
OWIN Comm_Pin, 2, [R_Temp.Lowbyte, R_Temp.Highbyte] ' Read two bytes / end comms
GOSUB Convert_Temp
GOTO Start_Convert
Convert_Temp: ' +32.0 to +257 F
Sign = "+"
Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
TempC = DIV32 10 ' Use Div32 value to calculate precise deg C
Dummy = 1125 * R_Temp
TempF = DIV32 100
IF TempF >6795 THEN ' Over 99.5 deg F..?
TempF = TempF + 3200
lcdout $FE,1," Temp F = ",Sign,DEC TempF
ELSE
TempF = TempF + 3200
LCDOUT $FE,1, " Temp F = ",Sign,DEC TempF
ENDIF
TempC = (R_Temp & $0FF0) >> 4 ' Mask middle 8-bits, shift into lower byte
Float = ((R_Temp.Lowbyte & $0F) * 625) ' Lower 4-bits of result * 625
RETURN
The code compiles and loads OK, and I get the value (3199) shown on the screen, but seem to have a few niggles I can't workout what settings I need to change.
1) - if viewed at an angle, the display seems to be scanning (ie its similar to the effect when filming a TV and you get a black bar slowley moving over the picture)
2) - holding the DS1820 between fingers I would expect the value to change, but it doesn't
Any guidance would help
Bookmarks