DS1620 temperature sensor in high resolution mode


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    4

    Default DS1620 temperature sensor in high resolution mode

    Hello has anyone got any code examples to use the DS1620 in hight res mode and displaying the result on a 16x2 LCD. I have been trying to modify the melabs ds1620 example using an example of basic stamp code for high res mode and I keep on getting very strange results.

    Here is the code example from melabs
    http://www.melabs.com/resources/samp...pbp/temp3x.bas

    Here is the code from the high res basic stamp (About half way down the page
    http://www.emesystems.com/OL2d1620.htm


    Any help you be much appreciated as I have been trying most of last weekend and I feel like riping my hair out.
    Last edited by crodan; - 13th March 2007 at 05:03.

  2. #2
    Join Date
    Mar 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default The code I am currently using

    Here is the code I have mashed together using the BS and Picbasic examples. I keep on getting very strange numbers in the 1000's. I have allready set the registers in the DS1620 eeprom.

    Here is the app note from dallas about the increased res functions of the ds1620
    http://pdfserv.maxim-ic.com/en/an/archive/AN68.pdf


    Define LOADER_USED 1

    Include "MODEDEFS.BAS"

    ' Define LCD pins
    Define LCD_DREG PORTB
    Define LCD_DBIT 0
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 4
    Define LCD_EREG PORTB
    Define LCD_EBIT 5

    ' Alias pins
    RST var PORTA.0 ' Reset pin
    DQ var PORTA.1 ' Data pin
    CLK var PORTA.2 ' Clock pin

    ' Allocate variables

    j var byte
    i var word
    x var word
    remain var word
    slope var word
    degC var word


    Low RST ' Reset the device


    PAUSE 500

    Low PORTA.4 ' LCD R/W line low (W)
    Pause 100 ' Wait for LCD to start

    Lcdout $fe, 1, "Temp in C" ' Display sign-on message




    mainloop:
    RST = 1 ' Enable device
    Shiftout DQ, CLK, LSBFIRST, [$ee] ' Start conversion
    RST = 0

    Pause 1000 ' Wait 1 second for conversion to complete

    RST = 1
    Shiftout DQ, CLK, LSBFIRST, [$AC] ' Send read command
    Shiftin DQ, CLK, LSBPRE, [x] ' Read 9 bit temperature
    RST = 0
    IF x.bit7=0 then pause 1000






    RST = 1
    Shiftout DQ, CLK, LSBFIRST, [$AA] ' Send read command
    Shiftin DQ, CLK, LSBPRE, [x\9] ' Read 9 bit temperature
    RST = 0

    x.byte1= -x.bit8 ' extend sign
    degc=x*5 ' compute to 10ths, +/- 0.5 degree C

    RST = 1 ' get the count remaining DS1620
    shiftout DQ, CLK,lsbfirst,[$A0]
    shiftin DQ, CLK,lsbpre,[remain\9]
    RST = 0



    RST =1 ' get the counts per degree
    shiftout DQ, CLK,lsbfirst,[$A9]
    shiftin DQ, CLK,lsbpre,[slope\9]
    RST =0

    x=slope-remain*10/slope ' compute 1/100ths degree
    degc=degc+550/10*100+x-552 ' adjust temperature to 1/100ths
    pause 1000


    ' Display the decimal temperature


    LCDout $fe, 1, rep "-"\degc.bit15,dec abs degc/10,".",dec1 abs degc
    goto mainloop ' Do it forever

    End

  3. #3
    Join Date
    Mar 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Double post sorry
    Last edited by crodan; - 15th March 2007 at 04:04. Reason: Double post sorry

  4. #4
    Join Date
    Mar 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    I'm not sure but I have been modifying the code and I think the problem is displaying the temp on the lcd and I am not displaying/changing it correctly

    From dallas app note 105

    DS1620, DS1623, and DS1625:
    1. Issue Start Convert protocol (EEh).
    2. When conversion is finished, read 9–bit temperature value (AAh).
    3. Truncate half–degree bit from reading.
    4. Convert truncated value from 2’s complement to signed integer (named temp_read).
    5. Read 9–bit counter value (A0h; named count_remain).
    6. Send undocumented Load Counter protocol (41h).
    7. Read 9–bit counter value (A0h; named count_per_degree).
    APPLICATION NOTE 105
    4 of 20
    8. Calculate high–resolution temperature using the high resolution temperature equation given in the
    previous section.

    The equation is tempreture=˝ LSB = 0.25.temp_read-1/2 LSB + (count_per_degree - count_remain)/count_per_degree


    When I use the code on the lcd
    Lcdout $fe, 1, dec (degc >> 1), ".", dec (degc.0 * 5), " degrees C"

    The lcd displays 2562

    When I use the code on the lcd
    Lcdout $fe, 1, rep "-"\degC.bit15,dec abs degC/10,".",dec2 abs degC

    The lcd displays 51.24

    My maths is quite bad and some parts look very alien to me so if anyone has got any sugestions on what I can try.

Similar Threads

  1. SERIN MIDI out of Synch?
    By jncortes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th June 2009, 20:08
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. sample code for M25P32
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th January 2007, 02:37
  5. Serin and TMR0
    By capitano in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th May 2006, 14:58

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