Skip to main content

The 1-Wire Communication Protocol

The 1-Wire is a registered trademark of Dallas Semiconductor Corp (now Maxim) for a serial communication protocol using a single data line and a ground reference. A 1-Wire Master (a microcontroller) initiates and controls the communication with one or more 1-Wire Slave devices (usually sensors). Each 1-Wire slave device has a unique, factory-programmed , 64-bit identifier, which serves as device address on the 1-Wire bus. This globally unique address is composed of eight bytes divided into three main sections. Starting with the LSB, the first byte stores the 8-bit family codes that identify the device type. The next six bytes store a customizable 48-bit individual address. The last byte, the most significant byte (MSB), contains a cyclic redundancy check (CRC) with a value based on the data contained in the first seven bytes. This allows the master to determine if an address was read without error. With a 248 serial number pool, conflicting or duplicate node addresses on the net are never a problem.

The 1-Wire protocol uses conventional CMOS/TTL logic levels (maximum 0.8V for logic “zero” and a minimum 2.2V for logic “one”) with operation specified over a supply voltage range of 2.8V to 6V.

A Typical 1-Wire Communication Flow


The first part of any communication involves the bus master issuing a reset, which synchronizes the entire bus. A slave device is then selected for subsequent communications. This can be done by selecting all slaves, selecting a specific slave (using the registration number of the device), or by discovering the next slave on the bus using a binary search algorithm. These commands are referred to collectively as network function or read-only-memory (ROM) commands. Once a specific device has been selected, all other devices drop out and ignore subsequent communications until the next reset is issued.
Once a device is isolated for bus communication, the master can issue device-specific commands to it, send data to it, or read data from it. Because each device type performs different functions and serves a different purpose, each type has a unique protocol once it has been selected. Even though each device type may have different protocols and features, they all have the same selection process and follow the command flow seen in the figure below.



Browse these links for more information on the 1-Wire Protocol.
  1. Overview of 1-Wire Technology and its use (Maxim)
  2. 1-Wire (Wikipedia)
  3. 1-Wire Communication with PIC Microcontroller

Example: DS1820 Digital Temperature Sensor

I am going to show you how to connect a DS1820, a 1-Wire digital temperature sensor, to a PIC microcontroller.



 

We are now going to implement this circuit in our PIC16F628A development board. We will place a 3-pin female header to hold DS1820 and an additional single pin header for a jumper to connect the data pin to a PIC port. Here is the modified board after soldering the female header connections and a 4.7K resistor on the board.


A more closer look:
 

We will discuss about the 1-Wire built in library of mikroC for PIC 2009 compiler in the next article. Our next experiment is going to be about reading the temperature values from a DS1820 sensor using the 1-Wire communication protocol. Till then, good bye.

Comments

  1. Hi,

    thank you very much for the clear info. I almost kill a day with DS1820. As an amateur its data sheet wasn't that helpfull. Lack of literatur.

    Thanks again.

    ReplyDelete
  2. Is positive and negative coming from that 1 wire? Mine can. Albeit mine is a different 1 wire solution. Each phase is adjustable without loss. Can Maxim do that?

    ReplyDelete

Post a Comment

Popular posts from this blog

Contact less tachometer using PIC16F628A

Introduction Tachometer is a device that gives you the information about the rotational speed of any shaft or disc. It usually measures the speed in revolutions per minute (RPM). Today we are going to make a simple tachometer that could measure the rotation speed of a disk without making any physical contact (that's why it is contact less) with the rotating object. The range of this tachometer is 0 - 9999 RPM and displays the RPM on a multiplexed 4-digit seven-segment display. Of course, we are going to do this project on our usual PIC16F628A development board. Infrared sensor Contact-less measurement of RPM will be achieved through an IR sensor. An IR diode will send a beam of infrared towards the rotating disc, and any reflected pulse will be received by a photo diode. The resistance of a photo diode drops drastically when exposed to infrared. An infrared is reflected by a white surface and absorbed by the dark ones. The test disc for this project is shown below. You can see ...

PIC16F628A Development Board

The development board we are going to make for our experimental microcontroller PIC16F628A will look like this. Here are the features it is going to have: Access to all I/O pins through female header pins 4 Push Buttons for Input 4 LEDs for Output An LCD Interface Port A 4-digit Seven-Segment Display Interface LCD Backlight Switch and Contrast Adjustment ICSP Programming (Very Important)

Experiment No. 2 : Push Button and Seven Segment Display Interface

In this experiment, we will program the PIC16F628A as an UP/DOWN Decade Counter. The count value will be displayed on a Seven-Segment Display and will be incremented/decremented by two push buttons on the board. Experimental Setup: The board has built in interface for a multiplexed 4-digit seven segment display (HS-5461AS2 from www.futurlec.com ).We will select only one digit by connecting a Digit Select pin to Vcc, as shown in figure below. A black jumper wire is used for this purpose. The seven segments will be driven through PORTB (already wired on the board). Connect Push Buttons (PB3 and PB4) to RA1 and RA0 female headers using jumper wires.