CLASS DOCUMENTS


REPORTS & ASSIGNMENTS


CLASS CONTENT


USING THIS SITE








registered authors login here

You are: (logout)



For more on PMWiki, see pmwiki.org


Dallas Semiconductor DS 18 B 20 Digital Thermometer

Original Posting


Features

  • Unique 1-Wire (r) interface requires only one port pin for communication
  • Each device has a unique 64-bit serial code stored in an onboard ROM
  • Multidrop capability simplifies distributed temperature sensing applications
  • Requires no external components
  • Can be powered from the data line. Power supply range is 3.0V to 5.5V
  • Measures temperatures from -55 degrees celsius to +125 degrees celsius (-67 F to +257 F)
  • +/-0.5 degrees accuracy from -10 to +85 degrees celsius
  • Thermometer resolution is user-selectable from 9 to 12 bits
  • Converts temperature to 12-bit digital word in 750ms (max.)
  • User-definable non-volatile (NV) alarm settings
  • Alarm search command identifies and addresses devices whose temperature is outside of programmed limits (temperature alarm condition)
  • Available in 8-pin SO (150mil), 8-pin mu-SOP, and 3-pin TO-92 packages
  • Software compatible with the DS1822
  • Applications include thermostatic controls, industrial systems, consumer products, thermometers, or any thermally sensitive system

Datasheet

The datasheet and other information about this chip can be obtained here at maxim-ic.com.

The Part

The actual part looks like this:

The Part

And the pin configuration looks like this:

Pin Configuration

Schematic

The following image describes a basic setup in schamatic form. Please note: the capacitor in the schematic as well as the wire linking VCC to GND actually both occur inside the IC and do not need to be setup. You will see this in the next picture.

Schematic

Circuit

This image is of a very simple circuit using the DS18B20 in parasite power mode with an Arduino microcontroller. Notice that we're only using digital pin 10 to communicate with this chip. Also, note the 4k7ohm pull-up resistor on the dataline. This is what allows us to communicate in both directions on a single wire.

The Circuit

Library

There is an Arduino library for version 0008 of the Arduino software, however, it is also apparently compatible with versions above that. I have successfully used it with Arduino 0011. The library is downloadable from this page. Also on that page is some very helpful example code, which is programmed for another chip in the same family but can easily be modified for use with the DS18B20. Use this code as your starting point.

Code

There was one thing that I found to be helpful, but isn't going to be completely accurate. When you read the scratchpad on the DS18B20, the temperature reading will come out as 2 bytes (LSB first), and you'll have to turn them into an integer to make them useful.

This bit of code is helpful:

int b2i(byte b[])
{
  int i = 0;
  i |= b[0] & 0xFF;  //MSB
  i <<= 8;
  i |= b[1] & 0xFF;  //LSB
  return i;
}

As is this image:

Scratchpad

Use the next chart to turn your integer value into a proper temperature reading in your code.

Temp Chart

Output

When you run the example code, you ought to get some output on your serial port similar to this:

Output

Scalability

Here's where the power of the Dallas Semiconductor 1-Wire interface comes into play. Without changing a single line of code, you can (while the code is running, even) add three more DS18B20's like this:

Scalability

And you should start to see output like this:

More output

The search function in the library will perform a scan for all the parts on the bus and return each of their addresses (the 64-bit unique code) so that an arbitrary number of slave devices on the bus can be addressed programmatically.

  Edit | View | History | Print | Recent Changes | Search Page last modified on April 27, 2008, at 05:31 PM