Detection of 1 wire device


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Detection of 1 wire device

    Not sure if the logic is correct but this works

    [code]
    'Get and display the temperature
    GIE = 0
    owin DQ, 1, [],NoDevice
    OWOUT DQ, 1, [$CC, $44] ' Start temperature conversion
    OWOUT DQ, 1, [$CC, $BE] ' Read the temperature
    OWIN DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
    GIE = 1
    temperature = temperature */ 1600
    lcdout $FE,$D4+0,"TEMP ",dec(temperature / 100),$DF,"C"

    '************************************************* ****************************** '
    fan:'check to see if fan is needed
    fantrigger=fanset
    if (temperature / 100)> fantrigger then
    high portA.4
    endif

    **********************************************
    NoDevice:
    lcdout $FE,$D4+0,"TEMP N/C "
    GIE = 1
    goto fan
    **********************************************
    [code]

    The NoDevice section is outside of the main part of the program. The logic being that the PIC sends a reset pulse and if it's not received back then jumps out to the NoDevice section, and then goes to the next part of the code but skips the temperature reading section. Seems to work when I pull out the DS18B20 and then plug it back in

  2. #2
    Join Date
    May 2004
    Location
    Denmark
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Re: Detection of 1 wire device

    Hi

    I use this, and it work's

    check_sensorID:
    '************************************************* ****************************
    ' Check is the sensor connected
    '************************************************* ****************************

    OWOUT DQ, 1, [ $33 ] ' Read Chip Family code
    OWIN DQ, 2, [ FAM,ID[6],ID[5],ID[4],ID[3],ID[2],ID[1],CRC]
    if (ID[1] = 0)and (ID[2] = 0)and(ID[3] = 0)and (ID[4] = 0)and (ID[5] = 0)and (ID[6] = 0) then
    LcdOut $FE, 1, " NO " ' Show message
    Lcdout $FE, $C0, " Sensor "
    endif
    return

    Kent

  3. #3
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Detection of 1 wire device

    Go take a look at the last post in this thread...
    http://www.picbasic.co.uk/forum/showthread.php?t=18313
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. Replies: 1
    Last Post: - 5th October 2011, 08:59
  2. Target Device does not match selected device
    By queenidog in forum FAQ - Frequently Asked Questions
    Replies: 3
    Last Post: - 25th June 2011, 00:24
  3. Target device <> Selected Device????
    By deepgfishing in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th June 2007, 21:18
  4. mass storage device 1 MB Flash device
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2006, 03:11
  5. Emulate a 1-wire device
    By johnyman34 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd February 2005, 20:05

Members who have read this thread : 0

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