1-Wire


Closed Thread
Results 1 to 10 of 10

Thread: 1-Wire

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Texas
    Posts
    16

    Question 1-Wire

    Can anyone help me with the syntax for writing to a one-wire devices scratch pad?
    I want to set the Th, Tl, and config bytes (byte 3,4,5).

    I was thinking

    Owout PortX.X, 1, [$CC, $4E] 'skip ROM search and write to scratch pad
    Owout PortX.X, 1, [$XX, $XX,$XX] bytes 3, 4, and 5

    Do I need place holders for the first to two bytes on the scratch pad? If so, what is that syntax?

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


    Did you find this post helpful? Yes | No

    Default

    It looks like you are using a DS18B20.
    It's best to include that kind of information with the questions.
    If not then this won't apply.

    DS1820 resolution
    http://www.picbasic.co.uk/forum/showthread.php?p=47692
    DT

  3. #3
    Join Date
    May 2008
    Location
    Texas
    Posts
    16


    Did you find this post helpful? Yes | No

    Default 1-wire

    Thanks old chap

    i have been beating my head into the wall

    I understand the alarm registers are 8 bit with the MSB being the sign bit. Is that a straight decimal conversion? i.e. 25 degrees Celsius would be %00011001

    Again

    Thanks a lot

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


    Did you find this post helpful? Yes | No

    Default

    Sure, that'll work. Added: (not the beating your head part)
    Or you could just use 25.

    Code:
    OWOUT DQ, 1, [$CC, $4E, 25, 0]
    High limit = 25°C
    Low limit = 0°C

    If you want to use negative alarms, it's easier to use a variable

    Code:
    LowLimit   VAR BYTE
    HighLimit  VAR BYTE
    
    HighLimit = 20
    LowLimit = -10
    
    OWOUT DQ, 1, [$CC, $4E, HighLimit, LowLimit]
    Do you know how to read the alarm status yet?
    <br
    Last edited by Darrel Taylor; - 9th May 2008 at 07:13. Reason: Add:
    DT

  5. #5
    Join Date
    May 2008
    Location
    Texas
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    Think so

    How's this?

    Alarm_H VAR Bit
    Alarm_L Var Bit

    Owout DQ, 1, [$CC, $EC]
    Owin DQ, 1, [Alarm_H, Alarm_L]

    Is it going to send back a 1 or 0 alarm bit?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by WarPony View Post
    Think so

    How's this?
    Well, not so good.

    There is only 1 Alarm status bit, No SkipROM, and mode 4 (bit data) is used to retrieve it after the AlarmSearch command.

    Code:
    Alarm   VAR BIT
    
    OWOUT   DQ, 1, [$EC]
    OWIN    DQ, 4, [Alarm]
    If there is an alarm, you have to read the temperature to figure out whether it's too high or too low.

    It will return a 0 if there is an alarm, 1 if not. But you can reverse that easily with...
    Code:
    Alarm = Alarm ^ 1
    hth,
    DT

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. 32 bit square root
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 6th May 2009, 03:37
  4. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  5. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23

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