Picaxe Interface for the i2c controlled DS2482-100 1-wire master

rmeldo

Senior Member
Hi,

I am publishing the result of my own work on the subject.

The main objective of this project was to minimise the number of pins needed to use 1-wire devices like the DS18B20 temperature sensor. Least powerful Picaxes do not have the capability to o read the DS18B20 temperature sensor. They have however the capability to implement the i2c protocol, which is less reliant on message timing. The 18X chip is the smallest chip which has a partial 1-wire driver, but only one sensor per input pin is allowed.

This goes against the aims of the 1-wire (or any) bus.

The solution to this problem is already available from Rev-Ed, in the form of the 28X1 and 40X1 chips. These chips have the capability to implement 1-wire communication and to control at least one 1-wire bus.

Although the 28X1 and 40X1 have the 1-wire protocol, it can be very useful to use an external 1-wire master, for smaller picaxes or to have more than one 1-wire bus without having to use additional pins.

Maxim make a series of integrated circuits that implement the 1-wire transmission protocol, which is time critical. These ICs can then be controlled through a i2c or serial protocol.

The one with the serial interface is called DS2480, whereas the one with the i2c interface are called DS2482-100 and DS2482-800. The -800 comes in a 16 pins SOIC and it has 8 separate 1-wire buses.

This write-up deals with the interfacing of the Picaxe with the DS2482-100. It is not intended to be an exhaustive document, just the bare minimum to report what I did. Refer to the datasheets for the DS18B20 and the DS2482-100 as a complement, as well as to the Picaxe Basic manual.


Connections:

See the attached photograph of the circuit on a breadboard.

The chip, being a SOIC package was first soldered onto an adapting board to convert it into a DIP package.

Then it was connected to the Picaxe as for the schematics on page 1 of the DS2482-100 datasheet, except that the address pins AD0 and AD1 were pulled high instead than low, as shown in the figure. This made the i2c slave address of the device as follows: %0011011x (see page 16 of the datasheet).


The 1-wire bus controlled directly by the Picaxe was implemented by connecting 2 DS18B20 in parallel and by fitting a 4k7 pullup resistors to the AXE020 proto-board (see photograph). I forgot to fir the 4k7 resistor on the 1-wire bus, but when I did fit it it made no difference.

The Picaxe used, as it can be seen, was a 40X1 (that was what I had). A second 1-wire bus was created by wiring another DS18B20 directly to input pin 2 of the 40X1

The communication between the DS2482 and the picaxe was created by using the pins 18 and 23 of the 40X1, the ones that implement the i2c protocol.

The 40X1 also drove an AXE033 LCD display via serial communication, although an i2c connection is also possible.

Software driver:

The attached software implements the commands which the DS2482 responds to. See below the correspondence between the command names as for the datasheet and the subroutine names in Picaxe basic:

---------------------------------------------
DS2482 name Picaxe basic name
---------------------------------------------
Device reset = i2c_reset
Set Read Pointer = i2c_setReadPointer
Write configuration = i2c_writeConfiguration
1-Wire Reset = i2c_1wireReset
1-Wire single bit = i2c_1wireSingleBit
1-wire write byte = i2c_1wireWriteByte
1-Wire read byte = i2c_1wireReadByte
1-Wire triplet = i2c_1wireTriplet (not implemented)

An additional helper subroutine was written to check the status of the 1-wire bus, called: i2c_check_1WB


Software implementation

The driver was used to implement the commands sequence for the temperature sensors (see the DS2482-100 datasheet) to:

A) Read an display the serial number of each one of the DS18B20 sensors, when they are the only ones on the bus.
B) implement the sequence required by the DS18B20 to initiate and read the temperature


That's it. It all works. Enjoy.


It feels good to post my own work on the forum. A special thank goes to the forum members that have kindly provided me with help, advice and support since I joined the forum.

Riccardo
 

Attachments

Top