I've a couple of parasitically powered DS18B20 on one Arduino pin. On MCU reset I scan the 1-wire bus for the devices. Is the order of detecting sensors always the same?
Thanks in advance?
I've a couple of parasitically powered DS18B20 on one Arduino pin. On MCU reset I scan the 1-wire bus for the devices. Is the order of detecting sensors always the same?
Thanks in advance?
Not the answer to your question but using the Dallas Temperature Library as it makes DS18's very simple.
http://milesburton.com/index.php/Dallas_Temperature_Control_Library
As fas as I know the detection is allways in the same order.
Thanks for the link, the library is really good, but for now I've re-written all my code in plain WinAVR just because I can't get anything bigger (in terms of Flash size) than ATmega8A in my location
Still the code in the lib can be very helpful. Maybe it states something about the detection process. The datasheet spends some text on the detection process.
SEARCH ROM [F0h]
When a system is initially powered up, the master must identify the ROM codes of all slave devices on the bus, which allows the master to determine the number of slaves and their device types. The master learns the ROM codes through a process of elimination that requires the master to perform a Search ROM cycle (i.e., Search ROM command followed by data exchange) as many times as necessary to identify all of the slave devices. If there is only one slave on the bus, the simpler Read ROM command (see below) can be used in place of the Search ROM process. For a detailed explanation of the Search ROM procedure, refer to the iButtonĀ® Book of Standards at Mixed-signal and digital signal processing ICs | Analog Devices. After every Search ROM cycle, the bus master must return to Step 1 (Initialization) in the transaction sequence.
According to my experiments with real devices the order of detecting devices is always the same for particular devices.
The handbook you have mentioned (that's from DS18B20 datasheet) has a detailed description of scanning 1-wire bus (Search ROM Command, p.58). The algorithm is very smart, as far as I can tell the order of devices depends on ROM codes of the devices.
Is the order of detecting sensors always the same?
Yes it is because the algorithm you run for detecting the addresses on the bus is always the same so they always appear in the same order each time you run it. If you add another device or scan the bus with a different algorithm then the order will change. The posh name for this is a "deterministic system".
Thanks!
For googlers: order is the same for a fixed set of 1-wire devices.