Thanks for the comments, I said i was rusty
Using a some what older version 2.47
Thanks for the comments, I said i was rusty
Using a some what older version 2.47
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
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.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
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
Cutting and pasting the following from Bruce's example gives a bad expression error at the line beginning DEC TempF DIG 3
EDIT:Code:lcdout $FE,1," TempF = ",Sign,DEC TempF DIG 4,_ DEC TempF DIG 3,DEC TempF DIG 2,".",DEC2 TempF,Deg,"F "
Resolved (sort of !)
Gives TempF = +031.99 on the LCD. Seems it was the "Deg" statement that was causing the issue. More work to do to get it reading the correct temperature (ie drop the 0) and if I recal 32F is 0 C and its not that cold in here !!!Code:lcdout $FE,1," TempF = ",Sign,DEC TempF DIG 4,DEC TempF DIG 3,DEC TempF DIG 2,".",DEC2 TempF,"F "
Last edited by malc-c; - 11th June 2008 at 10:51. Reason: more progress made
Hi, Malc
... Just try this one !!!
Hits the 10000 characters ... so, no code window !!!
It's been written for EP5 and DS18B20 ( I suppose you have a 18B20 as the 1820 is off production - if real 1820, ... nothing to change !!! )
you just have to add the °C to °F feature ...
I won't do everything for you ... be serious !!! ( LoL )
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
I have not used OW, but I can comment on the LCD Problem.
LCDOUT $FE,1 Clears the LCD Panel. So you are clearing the whole screen, every time it goes through the loop.
Depending on the speed of the loop, this can give issues like flashing display, flickering, or scanning that I have seen.
The way I do it, is a LCDOUT $fe,1 before the loop to clear the LCD... Then, to display the data...
Be sure to add some spaces onto the end of the displayed temp (" ") so that when it goes from 10 to 9 degrees... you don't end up with 90. It is messier to code this way, but will result in a 100% flicker-free LCD...Code:lcdout $FE,$80," Temp F = ",Sign,DEC TempF," " ELSE TempF = TempF + 3200 LCDOUT $FE,$80, " Temp F = ",Sign,DEC TempF," "
Only use $FE,1 to clear the entire screen when you have to.
Alain, thanks for the code, I'll have a play later and see what I get
Bookmarks