DS1820 - Help I'm rusty !


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Cold_Bit VAR R_Temp.Bit11 gives "a bad data type"
    Not seeing where R_Temp is declared!

    OWIN Comm_Pin, 2, [R_Temp.Lowbyte, R_Temp.Highbyte] gives "expected [" and "expected ]" even though the exist
    and half a dozen "bad expressions"
    Are you using PBP 2.50A? There was a bug in the OWIN/OWOUT that was addressed here on the forums awhile back. Might apply to you if using PBP2.50A, not sure if the A patch covered the bug or not.
    http://www.picbasic.co.uk/forum/show...ighlight=2.50a
    Last edited by skimask; - 10th June 2008 at 21:17.

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the comments, I said i was rusty

    Using a some what older version 2.47

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Using a some what older version 2.47
    Then it's back to declaring R_Temp

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Now we're getting somewhere

    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

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Cutting and pasting the following from Bruce's example gives a bad expression error at the line beginning DEC TempF DIG 3

    Code:
    lcdout $FE,1," TempF = ",Sign,DEC TempF DIG 4,_
    DEC TempF DIG 3,DEC TempF DIG 2,".",DEC2 TempF,Deg,"F "
    EDIT:
    Resolved (sort of !)
    Code:
    lcdout $FE,1," TempF = ",Sign,DEC TempF DIG 4,DEC TempF DIG 3,DEC TempF DIG 2,".",DEC2 TempF,"F "
    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 !!!
    Last edited by malc-c; - 11th June 2008 at 10:51. Reason: more progress made

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking

    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
    Attached Files Attached Files
    ************************************************** ***********************
    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 " !!!
    *****************************************

  7. #7
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default LCDout

    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...

    Code:
    lcdout $FE,$80," Temp F = ",Sign,DEC TempF,"   "
        ELSE
           TempF = TempF + 3200
           LCDOUT $FE,$80, " Temp F = ",Sign,DEC TempF,"   "
    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...

    Only use $FE,1 to clear the entire screen when you have to.

  8. #8
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by davewanna View Post
    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...

    Only use $FE,1 to clear the entire screen when you have to.
    Hey, don't knock it, I'm not a perfectionist, if it gets the desired result then that is all that matters.

Similar Threads

  1. Please help with 1-wire DS1820
    By hatuan291 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th March 2010, 13:51
  2. DS1820 with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd May 2009, 05:07
  3. DS1820 display with 7-seg 4 digits
    By chai98a in forum Code Examples
    Replies: 12
    Last Post: - 10th April 2008, 13:12
  4. PIC lcd ds1820
    By wchpikus in forum mel PIC BASIC
    Replies: 2
    Last Post: - 24th May 2007, 14:46
  5. DS1820 again
    By paxmowa in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th January 2006, 14:49

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts