The D2Photo is a low cost light monitor based on Maxim Integrated's DS2406 1-Wire chip. This article discusses interacting with the D2Photo using an Embedded Data Systems' HA7E 1-Wire Bus Master. The following are annotated examples of pseudo-code including the specific commands to send and typical responses received from the HA7E. In the examples below, TX= data transmitted to the HA7, and RX= data received from the HA7.
To better understand the commands and responses please refer to the data sheet for the DS2406 which can be downloaded from here:
DS2406: Dual Addressable Switch
Discover the Device
In this example, the D2Photo is the only device on the 1-Wire bus so we simply use the 'S'earch Rom command to identify the first device:
Performing a standard device search: |
TX= S |
RX= 440000000F738912 |
Alternately, the 'F'amily search command could be used to discover all of the D2Photos and other DS2406 based devices:
Performing a family search for DS2406 devices: |
TX= F12 |
RX= 440000000F738912 |
TX= f |
RX= FF0000000F738912 |
...and so on, until all the DS2406 based devices have been enumerated at which point the 'f' command will simply return a carriage return.
Configuring the D2Photo to read the light state.
The PIO pins of the D2Photo must be set to "1" for the light input state to be determined.
Start by addressing the D2Photo having ROM Id 440000000F738912. |
TX= A440000000F738912 |
RX= 440000000F738912 |
Now use the Write Status Command (0x55) to write the status byte of memory location 7 to "7F".
Writing block of data: 5507007FFFFF |
TX= W065507007FFFFF |
RX= 5507007F1E3A |
Determining the light state and activity latches.
Start by addressing the DS2406 with ROM Id 440000000F738912. |
TX= A440000000F738912 |
RX= 440000000F738912 |
Now invoke the DS2406's Channel Access Command (0xF5), passing a channel control byte value of 0x4C, which will return the ChannelInfoByte without altering the state of the PIO lines.
Writing block of data: F54CFFFF. |
TX= W04F54CFFFF |
RX= F54CFF73 |
ChannelInfoByte Returned: 0x73 = 0111 0011
By examining the returned ChannelInfoByte, the following information can be determined about this D2Photo:
Based on bit 7 (0), this D2Photo is obtaining power parasitically. |
Based on bit 6 (1), this is a DS2406P, with 2 PIO Channels. |
Based on bit 5 (1), the activity latch on PIO-B is set. |
Based on bit 4 (1), the activity latch on PIO-A is set. |
Based on bit 3 (0), PIO-B Sensed Level is low. |
Based on bit 2 (0), PIO-A Sensed Level is low. |
Based on bit 1 (1), PIO-B is turned off (actively pulling the pin low). |
Based on bit 0 (1), PIO-A is turned off (actively pulling the pin low). |
The D2Photo should always report bit 0 & 1 as "11". If not, then the "Configuring the D2Photo to read the light state" steps should be repeated. Bit 2 & 3 should report "00" when the light is on and "11" when the light is off. Bit 4 & 5 should report "00" if the activity latches have not set and report "11" if they are set. See "Resetting the PIO Activity Latches" section for more details. Bit 6 & 7 should read "01" in EDS currently shipping models.
Resetting the PIO Activity Latches
The D2Photo provides an activity latch on the PIO lines which allow changes of the light state to be detected between reads. However, the activity latch must be reset to detect the next state change, which is demonstrated here:
Writing a ChannelControlByte of 0xCC to the DS2406 will reset the activity latches without altering any other settings on the PIO lines.
Start by addressing the DS2406 having ROM Id 440000000F738912. |
TX= A440000000F738912 |
RX= 440000000F738912 |
Now use the DS2406's Channel Access (0xF5) command to write the ChannelControlByte.
Writing block of data: F5CCFFFF |
TX= W04F5CCFFFF |
RX= F5CCFF43 |
ChannelInfoByte Returned: 0x43 = 0100 0011
Byte 5 & 6 are "00" which indicates the activity latch has been reset.
Comments
0 comments
Article is closed for comments.