DS1820 versus DS18S20


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240

    Default DS1820 versus DS18S20

    Hi,

    I have a code that works great with the DS1820, however when i change to a DS18S20, the only thing that i get is 127.68ºC.

    I allready made a search on the forum, however all the resaults are exactly the same as my code.

    I have 2 DS18S20, and the show exactly the same value.

    Can somebody help me;

    Here is my code.
    Code:
    count_remain Var Byte			' Count remaining
    count_per_c  Var Byte			' Count per degree C
    temperature  Var Word
    
    
    
    '                              REGISTOS PINOUT 1 = IN; 0 = OUT
    ' ===========================================================
            '76543210
    TRISA = %11111111 
    TRISB = %00001111 
    TRISC = %00100000 
    TRISD = %00000000 
    TRISE = %00000000
    ADCON1 = %00001110
    ADCON0 = %00000000
    
    '                              NOMES PINOUT
    ' ===========================================================
    LED  VAR PORTC.3
    DQ   VAR PORTD.0
    
    '                              DEFENIÇÕES
    ' ===========================================================
     
       DEFINE LCD_DREG PORTB       ' LCD Data bits on PORTB
       DEFINE LCD_DBIT 4           ' PORTB starting address
       DEFINE LCD_RSREG PORTB      ' LCD RS bit on PORTB
       DEFINE LCD_RSBIT 3          ' LCD RS bit address
       DEFINE LCD_EREG PORTB       ' LCD E bit on PORTB
       DEFINE LCD_EBIT 2           ' LCD E bit address
       DEFINE LCD_BITS 4           ' LCD in 4-bit mode
       DEFINE LCD_LINES 2          ' LCD has 2 rows
       DEFINE LCD_COMMANDUS 2000   ' Set command delay time in us
       DEFINE LCD_DATAUS 50        ' Set data delay time in us
    
    '                             INICIO PROGRAMA
    ' ===========================================================
    
    Main:
       gosub Read_Sensor_Amp
       pause 100
    goto Main
    
    '                        LEITURA SENSOR AMPLIFICADOR
    ' ===========================================================
    
    Read_Sensor_Amp:
    OWOut DQ,1,[$CC,$44]
    Waitloop: OWIn DQ,4,[count_remain]
    If count_remain = 0 Then Waitloop
     OWOut DQ,1,[$CC,$BE]
     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)
    Lcdout $fe, 1, " Temp. Amplificador "
    Lcdout $fe, $C0,"      ",DEC (temperature/100),".",DEC2 temperature," C"
    return
    end

  2. #2
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    I think it's beacuse i'm using the DS18S20P. Can somebody confirm this?

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gadelhas View Post
    I think it's beacuse i'm using the DS18S20P. Can somebody confirm this?
    I think that means it uses "Parasitic Power" only.

    If so, you have to drive the DQ line HIGH for 750ms during the conversion.
    After that you can read it like normal.
    It doesn't get power from the VDD pin.
    DT

  4. #4
    biggej's Avatar
    biggej Guest


    Did you find this post helpful? Yes | No

    Default More time needed for conversion

    DT is on the right track but maybe for not exactly the right reason. The DS18S20 does not have to run with parisitic power but it can if needed. However this from Maxim..
    "Specification Differences: The primary specification difference between the two parts is the temperature conversion time: DS1820 = 500ms (max) and DS18S20 = 750ms (max)."

    I believe you may also be using "count remain" improperly to signal the end of conversion. End of conversiion may be determined by issing a "Read time slot" command until the result is non zero. (Yes, it is in the data sheet!) All that being said, you can probably get by with only adding the 750ms delay after the conversion command.
    Jim

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by biggej View Post
    DT is on the right track but maybe for not exactly the right reason. The DS18S20 does not have to run with parisitic power but it can if needed.
    The DS18S20 doesn't, but the DS18S20P also called DS18S20-PAR, only uses "Parasitic Power".

    The datasheet ...
    http://datasheets.maxim-ic.com/en/ds/DS18S20-PAR.pdf
    DT

  6. #6
    biggej's Avatar
    biggej Guest


    Did you find this post helpful? Yes | No

    Default Missed that 'P' suffix in the second post.

    I should have know Darrel had it right!
    It will take a wiring change to make Parasitic Power work too.
    Jim

Members who have read this thread : 1

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