计算机毕业设计外文翻译--1-wire搜索算法(编辑修改稿)内容摘要:

For illustration, this example assumes devices with a 2bit ROM number only. Search Example (for simplicity the family discrepancy register and tracking has been left out of this example) FIRST LastDiscrepancy = LastDeviceFlag = 0 Do 1Wire reset and wait for presence pulse ,if no presence pulse then done Send search mand ,0F0 hex Read first bit id_bit : 1 (Device A) AND 0 (Device B) AND 1 (Device C) = 0 Read plement of first bit cmp_id_bit : 0 (Device A) AND 1 (Device B) AND 0 (Device C) = 0 Since id_bit_number LastDiscrepancy, then search_direction = 0, last_zero = 1 Send search_direction bit of 0 , both Device A and C go into wait state Increment id_bit_number to 2 Read second bit id_bit : 0(Device B) = 0 Read plement of second bit cmp_id_bit : 1 (Device B) = 1 Since bit and plement are different then search_direction = id_bit Send search_direction bit of 0 ,Device B is discovered with ROM_NO of ‘00’ and is now selected LastDiscrepancy = last_zero NEXT Do 1Wire reset and wait for presence pulse ,if no presence pulse then done id_bit_number = 1, last_zero = 0 Send search mand ,0F0 hex Read first bit id_bit : 1 (Device A) AND 0 (Device B) AND 1 (Device C) = 0 Read plement of first bit cmp_id_bit : 0 (Device A) AND 1 (Device B) AND 0 (Device C) = 0 Since id_bit_number = LastDiscrepancy then search_direction = 1 Send search_direction bit of 1 , Device B goes into wait state Increment id_bit_number to 2 Read second bit id_bit : 0(Device A) AND 1(Device C) = 0 Read plement of second bit cmp_id_bit : 1(Device A) AND 0(Device C) = 0 Since id_bit_number LastDiscrepancy, then search_direction = 0, last_zero = 2 Send search_direction bit of 0 , Device C goes into wait state Device A is discovered with ROM_NO of ‘01’ and is now selected LastDiscrepancy = last_zero NEXT Do 1Wire reset and wait for presence pulse ,if no presence pulse then done id_bit_number = 1, last_zero = 0 Send search mand ,0F0 hex Read first bit id_bit : 1 (Device A) AND 0 (Device B) AND 1 (Device C) = 0 Read plement of first bit cmp_id_bit : 0 (Device A) AND 1 (Device B) AND 0 (Device C) = 0 Since id_bit_number LastDiscrepancy then search_direction = ROM_NO (first bit) = 1 Send search_direction bit of 1 , Device B goes into wait state Increment id_bit_number to 2 Read second bit id_bit : 0(Device A) AND 1(Device C) = 0 Read plement of second bit cmp_id_bit : 1(Device A) AND 0(Device C) = 0 Since id_bit_number = LastDiscrepancy, then search_direction = 1 Send search_direction bit of 1 , Device A goes into wait state Device C is discovered with ROM_NO of ‘11’ and is now selected LastDiscrepancy = last_zero which is 0 so LastDeviceFlag = TRUE NEXT LastDeviceFlag is true so return FALSE Advanced Search Variations There are three advanced search variations using the same state information, namely LastDiscrepancy, LastFamilyDiscrepancy, LastDeviceFlag, and ROM_NO. These variations allow specific family types to be targeted or skipped and device present verification (see Table 4). Verify The 39。 VERIFY39。 operation verifies if a device with a known ROM number is currently connected to the 1 Wire. It is acplished by supplying the ROM number and doing a targeted search on that number to verify it is present. First, set the ROM_NO register to the known ROM number. Then set the LastDiscrepancy to 64 (40 hex) and the LastDeviceFlag to 0. Perform the search operation and then read the ROM_NO result. If the search was successful and the ROM_NO remains the ROM number that was being searched for, then the device is currently on the 1Wire. Target Setup The 39。 TARGET SETUP39。 operation is a way to preset the search state to first find a particular family type. Each 1Wire device has a one byte family code embedded within the ROM number (see Figure 1). This family code allows the 1Wire master to know what operations this device is capable of. If there are multiple devices on the 1Wire it is mon practice to target a search to only the family of devices that are of interest. To target a particular family, set the desired family code byte into the first byte of the ROM_NO register and fill the rest of the ROM_NO register with zeros. Then set the LastDiscrepancy to 64 (40 hex) and both LastDeviceFlag and LastFamilyDiscrepancy to 0. When the search algorithm is next performed the first device of the desired family type will be discovered and placed in the ROM_NO register. Note that if no devices of。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。