Reading 5 DS18B20 Problem


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

    Default Reading 5 DS18B20 Problem

    I'm running into some problems that aren't making much sense to me so I'm hoping someone here can point out why this is not working the way I think it should. For some reason the raw_temp variable is not loading properly into the array. I can read each sensor fine but when I go to store the value into the array it doesn't seem to store information in the right locations.



    Code:
        x               var     byte            ' Loop counter
        dq              var     byte[9]         ' 9 Byte Arrray for DS18B20
        raw_temp        var     word[5]         ' Raw Temperature
    
    read_temps:
        for x = 0 to 4
        owout x,1,[$CC,$44]                 ' Send start temperature conversion command
        low portb.5                         ' Turn on transistor between rail and data pin
        pause 750                           ' Allow enough time to process Tconv
        high portb.5                        ' Turn off transistor between rail and data pin
        owout x,1,[$CC,$BE]                 ' Send read scratch pad command
        owin x,0,[STR dq\9]                 ' Read all 9 bytes and store them in dq array
        raw_temp.Byte0[x] = dq[0]           ' Isolate raw temperature from the rest
        raw_temp.Byte1[x] = dq[1]
        next x
    goto read_temps

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Is there a way that I could issue a Start Temperature Conversion to all 5 sensors at the same time? The datasheet says it can be done when running on a bus however all my sensors have its there own IO's. I did it this way for field servicing simplicity. Just replace the sensor and your done if one should happen to fail.

Similar Threads

  1. Reading temperature using multi DS18B20
    By KVLV in forum Code Examples
    Replies: 16
    Last Post: - 3rd November 2017, 19:48
  2. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  3. DS18B20 error reading
    By Gaetano in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th August 2007, 16:21
  4. Reading keypad problem
    By PostAR in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th February 2007, 17:26
  5. Replies: 11
    Last Post: - 13th July 2005, 19:26

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