Shop OBEX P1 Docs P2 Docs Learn Events
1620 high resolution and SX/B — Parallax Forums

1620 high resolution and SX/B

SteveDSteveD Posts: 64
edited 2007-05-31 03:53 in General Discussion
Has anyone used a DS1620 in high resolution mode, code·written with SX/B for use on a SX28?· If so would you mind sharing your program?

Thanks,
Steve

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-22 16:17
    Steve,

    ·· You may have to convert one of the existing PBASIC programs over to SX/B.· BASIC Stamp HR programs for the DS1620 have been posted before and are also in some Nuts & Volts articles.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • SteveDSteveD Posts: 64
    edited 2006-09-22 17:57
    Chris,
    Thank you for your reply. I have been working with the PBASIC program you are referring to for quite some time and have confirmed the fact that I am just not that smart. I have the .5 resolution transferring information from SX (slave) to BS2 (master) and have it displaying on the debug screen. I want to send the high-resolution information and was hoping someone had already got it working. I will keep trying.

    Thanks
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-22 22:52
    Who knows, maybe someone else wants to do the same thing and will do it as a challenge/project.· =)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Beau SchwabeBeau Schwabe Posts: 6,547
    edited 2006-09-22 23:34
    Here is a snippet of code written in Spin that I have been working on...



    [b]PUB[/b] hirestempc : tc |cr,cpc
    '' Returns temperature in 0.01° C units
    '' -- resolution is 0.0625° C
        [b]if[/b] started
           high(rst)                                        ' activate sensor
           shiftout(RdTmp, 8)                               ' send read temp command
           tc := shiftin(9)                                 ' read temp in 0.0625° C units
           low(rst)                                         ' deactivate sensor
           high(rst)                                        ' activate sensor
           shiftout(RdCntr, 8)                              ' send Read Counter command
           cr := shiftin(9)                                 ' read Remaining Counts
           low(rst)                                         ' deactivate sensor
           high(rst)                                        ' activate sensor
           shiftout(RdSlope, 8)                             ' send Read Slope command
           cpc := shiftin(9)                                ' read Counts Per deg C
           low(rst)                                         ' deactivate sensor
           tc := tc << 23 ~> 23                             ' extend sign bit
           tc &= !%1                                        ' Strip LSB
           tc *= 100                                        ' Scale values up by 100
           tc += ((cpc-cr)*100)/cpc                         ' Add hires LSB data
           tc -= 25                                         ' Bit offset adjust
           tc *= 5                                          ' convert to 10ths                                          ' 
           tc /= 10                                         ' Scale values down by 10
    
    [b]PUB[/b] hirestempf : tf
    '' Returns temperature in 0.01° F units
    '' -- resolution is 0.1125° F
        [b]if[/b] started
           tf := hirestempc * 9 / 5 + 3200                  ' convert to Fahrenheit
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2006-09-23 04:27
    Steve,
    Did you find any temperature offsets when testing the DS1620? Mine seems to be 5C warmer on the chip than the ambiant air.
    Frank
  • JDOhioJDOhio Posts: 72
    edited 2006-11-20 03:14
    Here is my snippet. I took this from an SX-28 example and ported it to SX-48. When I toggled the
    Rst line, I would receive all three values: temperature, counter, and slope.

    INIT_1620:
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, WrCfg           ' write to config register
        SHIFTOUT DQ, Clock, LSBFIRST, %00000010       ' with CPU; free-run
        Rst = 0                                       ' deselect device
        PAUSE 10                                      ' allow DS1620 EE to write
        Rst = 1                                       ' reselect
        SHIFTOUT DQ, Clock, LSBFIRST, StartC          ' start conversion
        Rst = 0                                       ' deselect
    RETURN
    
    RD_1620:
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, RdTmp           ' send read temp command
        SHIFTIN DQ, Clock, LSBPRE, tmpB1              ' get temp (C x 0.5)
        SHIFTIN DQ, Clock, LSBPRE, tSign1\1           ' get sign bit
        Rst = 0
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, RdCounter
        SHIFTIN DQ, Clock, LSBPRE, tmpB2              ' 
        SHIFTIN DQ, Clock, LSBPRE, tSign2\1           ' 
        Rst = 0
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, RdSlope
        SHIFTIN DQ, Clock, LSBPRE, tmpB3              ' 
        SHIFTIN DQ, Clock, LSBPRE, tSign3\1           ' 
        Rst = 0                                       ' deselect device
    RETURN
    
    



    I haven't evaluated chip temperature and ambient temperature.

    Joe
  • Beau SchwabeBeau Schwabe Posts: 6,547
    edited 2006-11-20 03:56
    All,

    You must be in One-Shot mode when reading the High Resolution temperatures. The reason is that there is more than one
    register that you need to read from in order to determine a temperature in high resolution mode. If you are free running, then
    there is a likely chance that the register can be overwritten before you have had a chance to read all of the necessary register
    values. In that case, the temperature reading will not be accurate.

    The code below is untested, but if you take JDOhio's code, and make the following changes for One-Shot mode it should work.

    INIT_1620:
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, WrCfg           ' write to config register
        SHIFTOUT DQ, Clock, LSBFIRST, %00000011       ' with CPU; one-shot
        Rst = 0                                       ' deselect device
        PAUSE 10                                      ' allow DS1620 EE to write
    RETURN
    
    StartConversion:
        Rst = 1                                       ' reselect
        SHIFTOUT DQ, Clock, LSBFIRST, StartC          ' start conversion
        Rst = 0                                       ' deselect 
    
    WaitForConversion:                                ' Wait for conversion to complete
        Rst = 1                                       ' reselect
        SHIFTOUT DQ,Clock, LSBFIRST, RdCfg            ' read configuration register
        SHIFTIN DQ,Clock,LSBPRE, CfgReg             
        Rst = 0                                       ' deselect 
        if CfgReg & 128 <> 128 then WaitForConversion
    RETURN
    
    RD_1620:
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, RdTmp           ' send read temp command
        SHIFTIN DQ, Clock, LSBPRE, tmpB1              ' get temp (C x 0.5)
        SHIFTIN DQ, Clock, LSBPRE, tSign1\1           ' get sign bit
        Rst = 0
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, RdCounter
        SHIFTIN DQ, Clock, LSBPRE, tmpB2              ' 
        SHIFTIN DQ, Clock, LSBPRE, tSign2\1           ' 
        Rst = 0
        Rst = 1                                       ' select device
        SHIFTOUT DQ, Clock, LSBFIRST, RdSlope
        SHIFTIN DQ, Clock, LSBPRE, tmpB3              ' 
        SHIFTIN DQ, Clock, LSBPRE, tSign3\1           ' 
        Rst = 0                                       ' deselect device
    RETURN
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 11/20/2006 6:40:11 AM GMT
  • JDOhioJDOhio Posts: 72
    edited 2006-11-23 02:04
    Beau,

    While I can follow the Spin syntax for most of your post, I'm not sure about the conversion from temperature reading/counts/slope to a number that has 0.0625 resolution (How did you calulcate that resolution?). Would you be able to post the equation/algorithm you are using in a language neutral manner? The DS1620 documentation has something close to your post but there isn't enough parenthesis, and I wasn't sure what to do with the LSB.

    Thanks,

    Joe
  • Beau SchwabeBeau Schwabe Posts: 6,547
    edited 2006-11-23 02:54
    JDOhio,
    The high resolution is in 1/16th Deg C units.... or 0.0625 that's the best resolution obtainable from the DS1620.

    Here is my revised "spin code" ... it basically follows the datasheet...


           tc := ReadRegister(RdTmp,9)                      ' read temp in 0.5° C units
           if tc > 255
              tc -= 512
           tc >>= 1                 'Strip LSB divide by 2  ' Scale 0.5° units to 1° units
           tc *= 100                                        ' Scale 1° units to 0.01° units
           tc -= 25                                         ' Offset adjustment for high resolution conversion
           cr := ReadRegister(RdCntr,9)                     ' read remaining counts
           cpd := ReadRegister(RdSlope,9)                   ' read counts per degree
           tc += ((cpd - cr)*100)/ cpd                      ' calculate high resolution temperature value
           Result := tc
     
    
      
    
    ''       Note: In the New RevE DS1620 chips released (06/05/2003), the Slope register($A9) will always 
    
    ''             read a value of 16 so it would be unnecessary to read the slope.  Simply hard code the  
    
    ''             'cpd' value in the above code with a value of 16 instead.
     
    
    


    Note for the above code.... 'tc' returns a value in x100 notation ... in other words 25 Deg C returns 2500


    Note: The DS1620 RevD implemented a proprietary temperature sensing architecture using dual slope convergence method to determine temperature.
          The DS1620 RevE implements a commonly used bandgap reference with sigma-delta ADC approach to determine temperature.
    
          Attached is a file I received directly from Dallas Semiconductor/Maxim noting the difference between RevD and RevE version of the DS1620
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 11/23/2006 4:44:19 AM GMT
  • SteveDSteveD Posts: 64
    edited 2006-11-23 16:27
    JDOhio,
    Here is my work in progress.· I already have a functioning program working however it does not return the high resolution hence work in progress.· Hopefully you can pull from it what works for you.· The temperature acquisition and conversion seems to work for me.· I am sending this information to a BS2 to be viewed in the debug screen.· I read your latest post and hurriedly uploaded this file, when I have more time I will double-check if this file is in fact the latest of my versions.· Please anyone feel free to point out my errors and guidance in a better direction.
    ·
    Also I did not include any way possible for the sign bit to be used.· I wondered if this is considered bad code writing, should it be included in the program even though it will never be used?

    Hope this helps and thanks,
    Steve

    Post Edited (SteveD) : 11/24/2006 1:25:28 AM GMT
  • SteveDSteveD Posts: 64
    edited 2006-11-24 01:16
    Also refer to Beau’s reason why it is not necessary to read the slope register.
    http://forums.parallax.com/showthread.php?p=608042
  • JDOhioJDOhio Posts: 72
    edited 2006-11-25 14:39
    Thanks Beau and thanks Steve!

    I have been able to read temperature, counter, and slope as Steve has done in his program. I did not attempt the conversion. My application is designed to write the information to an SD card using the Rogue Robotics MMC Module. In this manner, I can read a file from the SD card and do conversions in Excel. In an experiment, I also found that the slope does not change and am happy to learn that I won't have to read it (I suspect I have Rev E of the DS1620 - thanks Beau for the documentation).
    Another curious thing - I think it's curious. My experiment was to log temperature measurements (counter and slope, too) over a 24 hour period in my sunroom. I started in the morning before the sun hits the sunroom and continued until the next morning. When I graphed the results, I saw where the temperature went down from the ambient in my office to something cold in the sunroom. As the sun heated the sunroom the temperature rose, and as the sun set, the temperature went down. The curious thing is that when the DS1620 was exposed directly to the sun, there was a significant rise in temperature (the DS1620 is on the SX-48 protoboard and the protoboard is not enclosed). It is clear in the graph where the DS1620 was in shadow and where it was exposed to direct sun. My theory is that the dark color of the chip absorbs a little heat and the sensor reacts accordingly. I attached the graph.

    Joe
    415 x 250 - 18K
  • PJMontyPJMonty Posts: 983
    edited 2006-11-27 16:53
    Joe,

    If you're measuring ambient air temperature, then the device doing the measuring must be in shade the whole time. This is true of plain old thermometers, and it's true of their digital equivalents. If the measuring device is in the sun, then you are measuring how hot the sun heats up the measuring device, not the ambient air temperature.
      Thanks, PeterM
  • JDOhioJDOhio Posts: 72
    edited 2006-12-04 02:14
    PeterM,

    Thanks and sorry for the delay!

    I thought so - I just thought it was cool to show it. As a verification, I set up my camera to take pictures every 30 seconds a day or so after I made the temperature measurements (using an intervalometer I made with an SX-48). The resulting time lapse MPEG showed the same number of sun/shadow transitions as the data. This is just too fun.

    Joe
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-05-29 23:14
    Hello,
    I asked a similar question before, but nobody responded. I am getting a temperature somewhat offset with my DS1620. It gives me 25C, however other mercury and digital thermometers around say 22C. Do any of you have similar findings? Please send me a private message and carbon copy it on the board.
    Thanks.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-05-31 03:53
    Ok guys, I got some responses, so don't waste your time on typing another response to my post.
Sign In or Register to comment.