【文章內(nèi)容簡介】
y sending the first bit (least significant) in their ROM number (also called registration number). (See Figure 1.) As with all 1Wire munication, the 1Wire master starts every bit whether it is data to be read or written to the slave devices. Due to the characteristics of the 1Wire, when all devices respond at the same time, the result will be a logical AND of the bits sent. After the devices send the first bit of their ROM number, the master initiates the next bit and the devices then send the plement of the first bit. From these two bits, information can be derived about the first bit in the ROM numbers of the participating devices. (See Table 1.) Table 2 Bit Search Information Bit (true) Bit (plement) Information Known 0 0 There are both 0s and 1s in the current bit position of the participating ROM numbers. This is a discrepancy. 0 1 There are only 0s in the bit of the participating ROM numbers. 1 0 There are only 1s in the bit of the participating ROM numbers. 1 1 No devices participating in search. According to the search algorithm, the 1Wire master must then send a bit back to the participating devices. If the participating device has that bit value, it continues participating. If it does not have the bit value, it goes into a wait state until the next 1Wire reset is detected. This 39。read two bits39。 and 39。write one bit39。 pattern is then repeated for the remaining 63 bits of the ROM number (see Table 2). In this way the search algorithm forces all but one device to go into this wait state. At the end of one pass, the ROM number of this last device is known. On subsequent passes of the search, a different path (or branch) is taken to find the other device ROM numbers. Note that this document refers to the bit position in the ROM number as bit 1 (least significant) to bit 64 (most significant). This convention was used instead of bit 0 to bit 63 for convenience to allow initialization of discrepancy counters to 0 for later parisons. On examination of Table 1, it is obvious that if all of the participating devices have the same value in a bit position then there is only one choice for the branch path to be taken. The condition where no devices are participating is an atypical situation that may arise if the device being discovered is removed from the 1 Wire during the search. If this situation arises then the search should be terminated and a new search could be done starting with a 1Wire reset. Table 3 Wire Master and Slave Search Sequence Master Slave 1Wire reset stimulus Produce presence pulse. Write search mand (normal or alarm) Each slave readies for search. Read 39。AND39。 of bit 1 Each slave sends bit 1 of its ROM number. Read 39。AND39。 of plement bit 1 Each slave sends plement bit 1 of its ROM number. Write bit 1 direction (according to algorithm) Each slave receives the bit written by Master, if bit read is not the same as bit 1 of its ROM number then go into a wait state. Read 39。AND39。 of bit 64 Each slave sends bit 64 of its ROM number. Read 39。AND39。 of plement bit 64 Each slave sends plement bit 64 of its ROM number. Write bit 64 direction (according to algorithm) Each slave receives the bit written by master, if bit read is not the same as bit 64 of its ROM number then go into a wait state. The condition where there are both 0s and 1s in the bit position is called a discrepancy and is the key to finding devices in the subsequent searches. The search algorithm specifies that on the first pass, when there is a discrepancy (bit/plement = 0/0), the 39。039。 path is taken. Note that this is arbitrary for this particular algorithm. Another algorithm could be devised to use the 39。139。 path first. The bit position for the last discrepancy is recorded for use in the next search. Table 3 describes the paths that are taken on subsequent searches when a discrepancy occurs. Table 4 Search Path Direction Search Bit Position vs Last Discrepancy Path Taken = take the 39。139。 path take the same path as last time (from last ROM number found) take the 39。039。 path The search algorithm also keeps track of the last discrepancy that occurs within the first eight bits of the algorithm. The first eight bits of the 64bit registration number is a family code. As a result, the devices discovered during the search are grouped into family types. The last discrepancy within that family code can be used to selectively skip