Go Down

Topic: How to use 1-wire library with DS2406 (Read 6973 times) previous topic - next topic


Mar 05, 2009, 03:22 pm Last Edit: Mar 05, 2009, 04:52 pm by agentsmith Reason: 1
I'm spending some time on these 1-wire devices... so far I managed to get the DS18B20 working, which is pretty easy since there's code in the Playground.
But unfortunately there is (or i didn't find) any documentation of the 1-wire library.

I'm trying to use the DS2406 switch, it's detected but can't get it turn off/on.
This is the datasheet http://pdfserv.maxim-ic.com/en/ds/DS2406.pdf

Based on what I read here http://support.embeddeddatasystems.com/archives/6#more-6
to turn off or on the PIOA I have to write to bit 5 of location memory 07 through the Write Status (55h) command.

How can I do this using the 1-wire library?

EDIT: I saw select subroutine in OneWire.cpp performs a Write Status(55h) then select the address.
But I don't know in which format I have to pass the address 7.
I do these commands:


7 is the memory location in Status memory map, 20 is the hexadecimal value to turn bit 5 on (PIO-A channel flip-flop)



Apparently, the one wire library is a bit incomplete since the people that worked on it seem to have focused mainly on the initial hard part... the data signaling and on the temperature sensors.  The only option open to you (and me) with regards to other 1-wire chips is to read the Dallas/Maxim Data sheets.  The methods used to get useful responses from the 1-wire chips is unique to each device.  The hard part (signaling) is done... but you/I need to do the rest.

I've sort of been stuck at that point too.


Hmm I saw ds.select issues the 55h command and sends a one byte array called rom.
So I suppose the sequence of commands is:
1) select device
2) select memory location to write
3) send data to write
I would spend some time on this but the hardest part is that I'm a C++ noob and I get stuck on data formats and that stuff.
Hope someone who wrote the OneWire library help us...


I had to spend two nights CAREFULLY reading the datasheet.

By default the PIO A is turned on. To turn it off, use this command sequence:
Code: [Select]

 for ( i = 0; i < 6; i++) {
   data[i] = ds.read();

To turn it on again, just reset it, or replace 3F with 1F

Go Up