DS1820 versus DS18S20


Closed Thread
Results 1 to 15 of 15
  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

  7. #7
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Ds18b20p

    Thought the following code might interest someone?
    It's based on the code for the DS18B20 by Bruce on the Reynolds/Renton web site.

    The chip I used is the DS18B20-PAR ( the device is marked 'DS18B20P') and will only work with parasitic power. Achieved by using an 2N7000 MOSFET (gate on PORTC.1, source on the DQ line and the drain on +5 supply).

    The DQ line must be driven high within 10uS of the 'convert' command and maintained for the duration of the conversion (750mS for 12 bit conversion).

    The extra code to do this follows the conver command.

    Code:
    ' -----[ Title ]-----------------------------------------------------
    '
    ' File...... WVL Water Remote
    ' Purpose... Remote station for control of water heater
    ' Date...... June 2010
    '
    ' 7. DS18B20P measures tank temp. Parasitic power only with DQ pulled hard
    '    high after 'read temp' command by MOSFET 2N7000 with gate on PORTC.1
    
    ' 8. The DS18B20P range +125C to -55C
    
    ' 9. The DQ line must be high for the conversion period. Periods and resolution:
    '       9  bit   93.7mS     0.5C        1/2  degree
    '       10 bit  187.5mS     0.25C       1/4  degree
    '       11 bit  375.0mS     0.125C      1/8  degree
    '       12 bit  750.0mS     0.0625C     1/16 degree
    '    12 bit resolution used so conversion delay is 750mS and conversion factor is
    '    625 that gives temperature in 1/10000 degrees C
    
    ' 10. The code is based on the DS18B20 pages at web site REYNOLDS/RENTON
    '
    ' ----[ Includes / Defines ]-------------------------------------------
    '
    clear
    define OSC 20				' Use HSPLL during compilation
    DEFINE LCD_DREG	PORTB	    ' Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT	4		    ' Define first pin of connected to LCD
    DEFINE LCD_RSREG PORTB	    ' Define PIC port used for RS line of LCD
    DEFINE LCD_RSBIT 2		    ' Define pin used for RS connection
    DEFINE LCD_EREG	PORTB   	' Define PIC port used for E line of LCD
    DEFINE LCD_EBIT	1		    ' Define pin used for E connection
    define LCD_RWREG PORTB      ' Define PIC port used for RW
    DEFINE LCD_RWBIT 3          ' Define pin used for RW
    DEFINE LCD_BITS	4		    ' Define 4 bit communication mode to LCD
    DEFINE LCD_LINES 4		    ' Define using a X line LCD
    DEFINE LCD_COMMANDUS 1500	' Define delay time between sending LCD commands
    DEFINE LCD_DATAUS 44	    ' Define delay time between data sent
    FLAGS=0
    include "modedefs.bas"      ' Include serout defines
    '
    ' ----[ Variables ]----------------------------------------------------
    '
    TempR       VAR word        ' DS18B20P reading. raw data
    TempC       VAR WORD        ' Temp in deg C
    Float       VAR WORD        ' Holds remainder for + temp C display
    
    Heartbeat	var	PORTA.0		' Heartbeat each cycle
    
    DQ          var PORTC.0     ' DS18B20P. Comms
    Pullup      var PORTC.1     ' DS18B20P
    '
    ' -----[ Initialization - PIC ]--------------------------------------
    '
    ADCON1	= %00000110			' All ports digital
    CMCON	= %00000111			' Comparators off. Essential or PORTF won't work
    '
    ' -----[ Identify ]--------------------------------------------------
    '
    LCDOUT $fe,$80,"Water Heater"
    pause 1000
    LCDOUT $fe,1
    '
    ' *****************************************************************************
    ' *                                                                           *
    ' *                         M A I N   P R O G R A M                           *
    ' *                                                                           *
    ' *****************************************************************************
    									    
    Main:	
        GOSUB Get_temp
        LCDOUT $fe,$c0,"Temp  : ",DEC TempC,".",DEC Float
    		
    	toggle Heartbeat
        pause 1000	
    	goto Main	
    	
    ' *****************************************************************************
    ' *                                                                           *
    ' *                         S U B R O U T I N E S                             *
    ' *                                                                           *
    ' *****************************************************************************
    
    
    Get_temp: 
        OWOUT   DQ,1,[$CC, $44]         ' Skip ROM search & do temp conversion
        high Pullup                     ' Turns MOSFET on to make DQ line high
        pause 750                       ' Conversion time for 12 bit reading
        low Pullup                      ' Turn MOSFET off after read temp command     
    
        OWOUT   DQ,1,[$CC, $BE]         ' Skip ROM search & read scratchpad memory
        OWIN    DQ,2,[TempR.Lowbyte,TempR.Highbyte]' Read two bytes / end comms
    
    Convert_Temp:
        TempC = DIV32 10                        ' Use Div32 value to calculate precise deg C
        TempC = (TempR & $0FF0) >> 4            ' Mask middle 8-bits, shift into lower byte
        Float = ((TempR.Lowbyte & $0F) * 625)   ' Lower 4-bits of result * 625
      
        RETURN
    
    END
    The MCU is an PIC16F877A running at 20MHz.

    Regards Bill Legge

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Thanks to everyone,

    I i'll try the code and circuit that Bill Legge posted.

    Regards
    Gadelhas

  9. #9
    Join Date
    Aug 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default ds1820

    hi im elie,im doing my final project :temperature regulator system
    im newer in the picbasic pro
    i need to know a code t read the tempeature from the sensor ds1820
    thank you all for your replys

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Default

    Hi,Dave
    Sorry - no matches. Please try some different terms.
    Did you tried a search for the Homework section or the " yesterday eve last delay to finish " section ???

    BTW, this looks to be THE subject of the Year : This question appears @ all all the electronic forums I read ...



    Alain
    Last edited by Acetronics2; - 11th August 2010 at 09:35.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  12. #12
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I guess the searches only live for a short time.. Was supposed to be search results from this forum for the DS1820.

    But the point is search first..
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Aug 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default elie

    thank you for your reply but still no code ???????????????????

  14. #14
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Have you searched the forum?
    What about the code on this thread?

    What have you tried for yourself?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by barcosta View Post
    thank you for your reply but still no code ???????????????????
    There are stacks of examples of using a DS1820 sensor with a PIC on the internet, including lots of samples within the sections of this forum ( I should know, I've been given a lot of help with a project using these devices ).

    Use Google or the "search" function top right - enter DS18B20 as the search string...

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