DS2438 onewire code sample


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

    Default DS2438 onewire code sample

    heya, I'm having a heck of a time getting a ds2438 onewire device to work on a 16f84a. I can't seem to get it to work worth anything. there are samples for other types of code in the onewire family, but I can't seem to modify the code example to work. I've got a 4.7k pullup resistor hooked up as per the example, but I have no code to let me know how to time it. also theres only one device on the bus..

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default search

    Click the search button above, type in 1 wire device and it returns several example threads.

  3. #3


    Did you find this post helpful? Yes | No

    Default onewire ds2438 help

    I've tried various code samples allready. I've used a few temp gathering programs with and without modification. all the programs I've tried so far have produced insane readings. the documentation for the 2438 is minimal, and virtually non-existant for picbasic. I believe that the architecture of the ds2438 is a little different than the other onewire devices.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default code

    Ahoy Captain,
    Howz about lettin' us eyeball the code you are trying to adapt, lots of SMART people in here! Also tell us what PIC device you are using and what readings your getting. What readings you are expecting too. Oh and what clock speed you are using too. Please describe exactly what you are trying to get this device to measure, a schematic would be wonderful.
    JS
    http://www.maxim-ic.com/appnotes.cfm/appnote_number/27
    http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2919
    Last edited by Archangel; - 14th January 2007 at 23:59. Reason: add link

  5. #5
    Join Date
    Jul 2006
    Location
    Surrey, BC, Canada
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    Hello Captain Stern. This is a sample program for DS 2436 voltage and temp. monitor device. I hope it will help you
    Best Regards
    Vladimir

    File...... DS2436 TEST1 modified.PBP
    ' Purpose... Reads information from a Dallas DS2436

    ' -----[ I/O Definitions ]------------------------------------------------------
    '
    OWpin CON 0
    'DEFINE DEBUG_REG PORTB ' FOR DEBUG COMMAND
    'DEFINE DEBUG_BIT 1 ' FOR DEBUG COMMAND
    'DEFINE DEBUG_BAUD 2400 ' FOR DEBUG COMMAND
    'DEFINE DEBUG_MODE 0 ' FOR DEBUG COMMAND

    ' -----[ Constants ]------------------------------------------------------------
    '
    ' 1-Wire Support
    '
    ReadROM CON $33 ' read ID, serial num, CRC
    MatchROM CON $55 ' look for specific device
    SkipROM CON $CC ' skip rom (one device)
    SearchROM CON $F0 ' search

    OW_FERst CON %0001 ' Front-End Reset
    OW_BERst CON %0010 ' Back-End Reset
    OW_BitMode CON %0100
    OW_HighSpd CON %1000

    ' DS2346 control
    '
    ConvertV CON $B4 ' convert the voltage
    ConvertT CON $D2 ' convert the temperature
    ReadRegister CON $B2 ' read page 4 and page 5 of DS2436

    NoDevice CON %0 ' no device present
    'DegSym CON 176

    ' -----[ Variables ]------------------------------------------------------------
    '
    voltage VAR Word
    vLo VAR voltage.BYTE0
    vHi VAR voltage.BYTE1
    temp VAR Word
    tLo VAR temp.BYTE0
    tHi VAR temp.BYTE1
    romData VAR Word(8)

    devCheck VAR Word

    ' -----[ EEPROM Data ]----------------------------------------------------------
    '
    ' -----[ Initialization ]-------------------------------------------------------
    '
    Initialize:
    output 5
    lcdout $fe, 1
    portb.5 = 1
    pause 1300 ' allow LCD screen to clear
    portb.5 = 0


    GOSUB Device_Check ' look for device
    ' debug bin devCheck ' test no 1-wire device
    IF (devCheck <> NoDevice) THEN Main

    No_Device_Found:
    lcdout $fe, 1, "No 1-wire device"
    lcdout $fe, $c0, "Insert device"
    end

    ' -----[ Main Code ]------------------------------------------------------------
    '
    Main:

    GOSUB Get_Volt ' voltage conversion
    GOSUB Get_Temp ' temperature conversion

    testValue1: ' voltage = $01E3 ' uncomment to test without DS2436
    testValue2: ' temp = $1910 ' uncomment to test without DS2436

    lcdout $fe, 1, "Voltage:" ,Dec voltage/100,".", DEC1 voltage/10,"v"
    lcdout $fe, $c0, "Temperature:",DEC tHi, "C"

    PAUSE 600 ' delay for a bit....
    ' debug dec voltage
    GOTO Main

    END
    ' -----[ Subroutines ]----------------------------------------------------------
    '
    'DS2436 Page 4 Memory is read using the Read_Registers [$B2] command
    'addr purpose
    ' $60 Temp LSB (decimal degrees C)
    ' $61 Temp MSB (integer degrees C)
    ' $62 status (BIT0 shows T conversion status, Bit 3 shows V status)
    ' $63 status
    ' $77 Voltage LSB
    ' $78 Voltage MSB

    Get_Volt:
    OWOUT OWpin,OW_FERst,[SkipROM,ConvertV] ' send voltage conversion command
    PAUSE 15 ' give it some time (could wait until bit3 at $62 equals 0)
    OWOUT OWpin,OW_FERst,[SkipROM,ReadRegister, $77] ' lo byte voltage
    OWIN OWpin,OW_BERst,[vLo]
    OWOUT OWpin,OW_FERst,[SkipROM,ReadRegister, $78] ' hi byte voltage
    OWIN OWpin,OW_BERst,[vHi]
    RETURN

    Get_Temp:
    OWOUT OWpin,OW_FERst,[SkipROM,ConvertT] ' send voltage conversion command
    PAUSE 15 ' give it some time (could wait until bit1 at $62 equals 0)
    OWOUT OWpin,OW_FERst,[SkipROM,ReadRegister, $60] ' lo byte temp
    OWIN OWpin,OW_BERst,[tLo]
    OWOUT OWpin,OW_FERst,[SkipROM,ReadRegister, $61] ' hi byte temp
    OWIN OWpin,OW_BERst,[tHi]
    RETURN


    ' This subroutine checks to see if any 1-Wire devices are present on the
    ' bus. It does NOT search for ROM codes
    Device_Check:
    devCheck = 0
    OWOUT OWpin,OW_FERst,[SearchROM] ' reset and start search
    OWIN OWpin,OW_BitMode,[devCheck.BIT1,devCheck.BIT0]
    RETURN

Similar Threads

  1. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. MN1307 sample code problem
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th November 2008, 20:41
  5. 18F8722 sample code
    By George in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th June 2008, 13:42

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