DS18S20 & Parasite Power


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

    Default DS18S20 & Parasite Power

    I've tried using the parasite power option and can not seem to get it to work at all. Is there something I'm missing from my code? It works fine using three wire but not two.

    Code:
    read_temp:
        owout portb.7,1,[$CC, $44]                  ' Send start temperature conversion
        owout portb.7,1,[$CC, $BE]                  ' Send read scratchpad command
        for x = 0 to 8                              ' Process all 9 bytes
        owin portb.7,0,[i]                          ' Read the scratch pad
        dq[x] = i                                   ' Place read byte into the array
        next x                                      ' Do again until all 9 bytes are processed
        temp.Byte0 = dq[0] : temp.byte1 = dq[1]     ' Store bytes 0 and 1 in the temp word variable
        if temp.8 = 1 then                          ' If bit8 of temperature is set then its negative		
         sign = "-"                                 ' Indicate temperature is NEGATIVE
         temp.lowbyte = temp.lowbyte ^ 255	        ' Reverse the bits of the lowbyte of TEMP
         sign = " "                                 ' Indicate temperature is POSITIVE
    	endif
    	half = temp.0 
        temp = ((temp.lowbyte) >> 1) * 10               ' Shift the lowbyte of the result right 1 place
        temp = temp + (half * 5)                        ' Strip off bit 0 (0.5 degree) and add it to DEC

  2. #2


    Did you find this post helpful? Yes | No

    Default

    I figured it out. I wasn't sure if would work with the ONIN/OWOUT commands or not but it appears it works just fine. I'm now running a sensor 25ft away on a Cat5 computer cable. All I was missing was the part where I had to drive the Dallas chip to the rail for a period of 600ms.

    Code:
    read_temp:
        owout portb.7,1,[$CC, $44]                  ' Send start temperature conversion
        low portb.6                                 ' Turn on transistor connected to rail
        pause 600                                   ' Allow enough time for Tconv
        high portb.6                                ' Turn off transistor
        owout portb.7,1,[$CC, $BE]                  ' Send read scratchpad command
        for x = 0 to 8                              ' Process all 9 bytes
        owin portb.7,0,[i]                          ' Read the scratch pad
        dq[x] = i                                   ' Place read byte into the array
        next x                                      ' Do again until all 9 bytes are processed
        temp.Byte0 = dq[0] : temp.byte1 = dq[1]     ' Store bytes 0 and 1 in the temp word variable
        if temp.8 = 1 then                          ' If bit8 of temperature is set then its negative		
         sign = "-"                                 ' Indicate temperature is NEGATIVE
         temp.lowbyte = temp.lowbyte ^ 255	        ' Reverse the bits of the lowbyte of TEMP
         sign = " "                                 ' Indicate temperature is POSITIVE
    	endif
    	half = temp.0 
        temp = ((temp.lowbyte) >> 1) * 10               ' Shift the lowbyte of the result right 1 place
        temp = temp + (half * 5)                        ' Strip off bit 0 (0.5 degree) and add it to DEC

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. Pic getting part power from Analog Port
    By ShaneMichael in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 22nd April 2009, 10:34
  4. PIC power backup with "super capacitor"
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 24th January 2007, 23:51
  5. 12 Servo's together does not seem to work, Power problem
    By macx75 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th December 2006, 19:30

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