DS18B20 VS DS18S20 & multiple


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default DS18B20 VS DS18S20 & multiple

    Hi,

    I'm trying to read 2 DS18S20 on a single 1wire bus

    I succeed in reading DS1820 in 12bit mode,
    But unable to read a DS18S20 in 9bit

    Anyone out who has an example code ?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Are you saying that this didn't work?

    http://www.picbasic.co.uk/forum/showthread.php?p=47692
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel

    well I only have DS18S20 or DS1820

    The DS1820 works with the following code but ofcourse in 12bit
    the DS18S20 does not return a valid temperature or some value chaning by it temperature
    any idea ?

    this is the working code with a DS1820

    DS18B20_9bit CON %00011111 ; 93.75ms, 0.5°C
    'DS18B20_10bit CON %00111111 ; 187.5ms, 0.25°C <-- My favorite
    'DS18B20_11bit CON %01011111 ; 375ms, 0.125°C
    'DS18B20_12bit CON %01111111 ; 750ms, 0.0625°C (default)

    OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_9bit]

    DS18S20:
    OWOut DQ, 1, [$CC, $44] ' Start temperature conversion

    waitloop: OWIn DQ, 4, [count_remain] ' Check for still busy converting
    IF count_remain = 0 Then waitloop

    OWOut DQ, 1, [$CC, $BE] ' Read the temperature
    OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]

    ' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
    temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)


    HSerOut [#Temperature.Lowbyte," ",#Temperature.Highbyte," ",DEC (temperature/100),".",DEC2 temperature," C",13]
    goto test

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


    Did you find this post helpful? Yes | No

    Default

    The DS1820/DS18S20 are 9-bit devices.
    By using the count_per_c and count_remain values, you can extend the range to 12-bit.
    But if you just want the 9-bit value, you don't need them.

    Only the DS18B20 has a settable resolution, that also reduces the conversion time as the resolution is reduced.

    The older DS1820/DS18S20 do not have that feature, and will always have a 750ms conversion time, so using a lower resolution doesn't really help anything.
    <br>
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Ok Darrel well it is all about conversion time I dont need more than a 1 degree resolution
    but conversiontime is important.

    Meanwhile I ordered some 18B20 versions

    Still dont get why my code does not work when I simple replace my DS1820 by a DS18S20

    Further , can you point me out how to read 2 sensors on 1 bus,again here
    conversiontime is imporant,resolution not

    Thanks

    Walter

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


    Did you find this post helpful? Yes | No

    Default

    ... can you point me out how to read 2 sensors on 1 bus ...
    Well, my first instinct is to say "Don't Do It".

    The overhead involved, is HUGE.
    You'll end up using 2-3K words of program space just doing the SearchRom, saving the serial number to RAM/EEPROM, then sending those serial numbers each and every time you access either one of the sensors.

    It's so much easier to just use another pin.
    And with separate pins, the program automatically knows which sensor it's talking too.
    With multiple devices on a single buss, there's no easy way to tell which sensor is in which location (without human intervention).

    But with that said, if you only have the one pin available?
    Here's where you need to start ...

    1 Wire Search Routine (Dave)
    http://www.picbasic.co.uk/forum/showthread.php?t=520

    Dallas 1-wire search Routine (jimbab)
    http://www.picbasic.co.uk/forum/showthread.php?t=3671
    Last edited by Darrel Taylor; - 5th February 2008 at 23:06. Reason: multi sensors need sensor setup function
    DT

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel

    Well I only have 1 pin free but will use only 1 sensor then

    As i'm polling with HSER several AD value's and I/O if was wondering to speed up the
    polling if it should not be possible to exit the loop when count_remain is not finished yet
    and send meanwhile the previous temperature value as reply to the serial poll for temperature

    once count_remain is 0 then update the temp value

    should this be done by an interupt routing when count remain = 0 ?

Similar Threads

  1. Please help with code for DS18B20
    By fratello in forum mel PIC BASIC Pro
    Replies: 109
    Last Post: - 28th April 2013, 21:12
  2. Help with DS18B20 program
    By presario1425 in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 22nd August 2012, 00:50
  3. Multiple PICS from Same Crystal?
    By WOZZY-2010 in forum General
    Replies: 2
    Last Post: - 6th February 2010, 15:18
  4. DS18B20 and 3310
    By d_a_l_3 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th February 2008, 08:57
  5. 16F877, DS18S20 and Serial Comm Problem
    By YellowTang in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2004, 10:36

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