ds1621 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Kernel driver ds1621
  2. ====================
  3. Supported chips:
  4. * Dallas Semiconductor DS1621
  5. Prefix: 'ds1621'
  6. Addresses scanned: I2C 0x48 - 0x4f
  7. Datasheet: Publicly available at the Dallas Semiconductor website
  8. http://www.dalsemi.com/
  9. * Dallas Semiconductor DS1625
  10. Prefix: 'ds1621'
  11. Addresses scanned: I2C 0x48 - 0x4f
  12. Datasheet: Publicly available at the Dallas Semiconductor website
  13. http://www.dalsemi.com/
  14. Authors:
  15. Christian W. Zuckschwerdt <zany@triq.net>
  16. valuable contributions by Jan M. Sendler <sendler@sendler.de>
  17. ported to 2.6 by Aurelien Jarno <aurelien@aurel32.net>
  18. with the help of Jean Delvare <khali@linux-fr.org>
  19. Module Parameters
  20. ------------------
  21. * polarity int
  22. Output's polarity: 0 = active high, 1 = active low
  23. Description
  24. -----------
  25. The DS1621 is a (one instance) digital thermometer and thermostat. It has
  26. both high and low temperature limits which can be user defined (i.e.
  27. programmed into non-volatile on-chip registers). Temperature range is -55
  28. degree Celsius to +125 in 0.5 increments. You may convert this into a
  29. Fahrenheit range of -67 to +257 degrees with 0.9 steps. If polarity
  30. parameter is not provided, original value is used.
  31. As for the thermostat, behavior can also be programmed using the polarity
  32. toggle. On the one hand ("heater"), the thermostat output of the chip,
  33. Tout, will trigger when the low limit temperature is met or underrun and
  34. stays high until the high limit is met or exceeded. On the other hand
  35. ("cooler"), vice versa. That way "heater" equals "active low", whereas
  36. "conditioner" equals "active high". Please note that the DS1621 data sheet
  37. is somewhat misleading in this point since setting the polarity bit does
  38. not simply invert Tout.
  39. A second thing is that, during extensive testing, Tout showed a tolerance
  40. of up to +/- 0.5 degrees even when compared against precise temperature
  41. readings. Be sure to have a high vs. low temperature limit gap of al least
  42. 1.0 degree Celsius to avoid Tout "bouncing", though!
  43. As for alarms, you can read the alarm status of the DS1621 via the 'alarms'
  44. /sys file interface. The result consists mainly of bit 6 and 5 of the
  45. configuration register of the chip; bit 6 (0x40 or 64) is the high alarm
  46. bit and bit 5 (0x20 or 32) the low one. These bits are set when the high or
  47. low limits are met or exceeded and are reset by the module as soon as the
  48. respective temperature ranges are left.
  49. The alarm registers are in no way suitable to find out about the actual
  50. status of Tout. They will only tell you about its history, whether or not
  51. any of the limits have ever been met or exceeded since last power-up or
  52. reset. Be aware: When testing, it showed that the status of Tout can change
  53. with neither of the alarms set.
  54. Temperature conversion of the DS1621 takes up to 1000ms; internal access to
  55. non-volatile registers may last for 10ms or below.
  56. High Accuracy Temperature Reading
  57. ---------------------------------
  58. As said before, the temperature issued via the 9-bit i2c-bus data is
  59. somewhat arbitrary. Internally, the temperature conversion is of a
  60. different kind that is explained (not so...) well in the DS1621 data sheet.
  61. To cut the long story short: Inside the DS1621 there are two oscillators,
  62. both of them biassed by a temperature coefficient.
  63. Higher resolution of the temperature reading can be achieved using the
  64. internal projection, which means taking account of REG_COUNT and REG_SLOPE
  65. (the driver manages them):
  66. Taken from Dallas Semiconductors App Note 068: 'Increasing Temperature
  67. Resolution on the DS1620' and App Note 105: 'High Resolution Temperature
  68. Measurement with Dallas Direct-to-Digital Temperature Sensors'
  69. - Read the 9-bit temperature and strip the LSB (Truncate the .5 degs)
  70. - The resulting value is TEMP_READ.
  71. - Then, read REG_COUNT.
  72. - And then, REG_SLOPE.
  73. TEMP = TEMP_READ - 0.25 + ((REG_SLOPE - REG_COUNT) / REG_SLOPE)
  74. Note that this is what the DONE bit in the DS1621 configuration register is
  75. good for: Internally, one temperature conversion takes up to 1000ms. Before
  76. that conversion is complete you will not be able to read valid things out
  77. of REG_COUNT and REG_SLOPE. The DONE bit, as you may have guessed by now,
  78. tells you whether the conversion is complete ("done", in plain English) and
  79. thus, whether the values you read are good or not.
  80. The DS1621 has two modes of operation: "Continuous" conversion, which can
  81. be understood as the default stand-alone mode where the chip gets the
  82. temperature and controls external devices via its Tout pin or tells other
  83. i2c's about it if they care. The other mode is called "1SHOT", that means
  84. that it only figures out about the temperature when it is explicitly told
  85. to do so; this can be seen as power saving mode.
  86. Now if you want to read REG_COUNT and REG_SLOPE, you have to either stop
  87. the continuous conversions until the contents of these registers are valid,
  88. or, in 1SHOT mode, you have to have one conversion made.