Shop OBEX P1 Docs P2 Docs Learn Events
I hate it when it works (DS1620) — Parallax Forums

I hate it when it works (DS1620)

sunblocksunblock Posts: 55
edited 2012-11-29 10:08 in Accessories
I've had to hook up a DS1620 to my project so that code running on the propeller knows the temperature--ball park. The DS2610 seemed lile a simple solution. And in fact, it is providing the correct answer, as far as I can measure. I've even taken a heat gun to rapidly raise the temp and let it go back down. The problem is with all the fooling around, I made it work, but according to all the examples I've seen, I am missing a lot of math for getting the right answer.

I initialize the DS1620 by sending the write config ($0C) command following by th Use CPU and 1shot CSR bits (%11).
Next, in a 1 second loop for testing, I issue the Start Conversion (SHIFTOUT $EE) command, followed by the read temperature command (SHIFTOUT $AA) and then read 9 bits of the temp (SHIFTIN 9). No hi resolution requirement. The value, a read with no math applied is the actual temperature in the basement! Take a heat gun and watch the value climb. Shut off heat gun, temp goes back down.


I guess I feel cheated out of having to write or use some code. Any ideas?

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-11-29 08:20
    What's to hate?!

    The DS1620 is supposed to be that easy to use. It returns its value in units of 0.5 °C, so you should really be seeing a number that is twice the actual temperature. E.g., a returned value of 47 when the temperature is 23.5°C. But it is easy to divide by two, even inadvertently.

    More math is required if you need it to cover negative temperatures. The ninth bit is the sign, and in the Prop you have to sign extend and otherwise handle the negative number.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2012-11-29 08:28
    sunblock wrote: »
    ...The problem is with all the fooling around, I made it work, but according to all the examples I've seen, I am missing a lot of math for getting the right answer. ... Any ideas?

    Maybe if you post your entire code, people can see what you've actually done. I'm sure you wouldn't want your project to be a victim of serendipity that later turns out to bite you in the end.
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2012-11-29 10:08
    This is a part around which much code has been developed. Tracy has probably spent at least 40 hrs using it on his own. Jon Williams, 100 hrs. It's one of the old favorites!
Sign In or Register to comment.