Pages: [1]   Go Down
Author Topic: one wire search multiple sensors at same bus  (Read 846 times)
0 Members and 1 Guest are viewing this topic.
Portugal
Offline Offline
Edison Member
*
Karma: 27
Posts: 1414
Tomorrow I will know a BIT more than yesterday
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello all
I'm start working with one wire sensores dalas ds18b20 and I want connect 4 sensors in parasite mode (2 wires only).In onewire library there is a function ds.search(addr
  • ) which will discover the address of the sensor on the bus.My question is can I just have one sensor at the moment of the search or can I have all sensors connected on the bus and the ds.search(addr
  • ) will deal with it and fill the array with each address[] of the sensors?

From what I had read from the data sheet when the master perform the search doesn't all the sensor will reply on the same time causing data collision on the bus?
Logged

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8067
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/playground/Learning/OneWire

"Each 1-Wire device contains a unique 64-bit 'rom' code, consisting of an 8-bit family code, a 48-bit serial number, and an 8-bit CRC. The CRC is used to verify the integrity of the data."

Each call to ds.search(addr) fills addr with one device address and returns 'true' or returns 'false'/0 if there are no more devices.  You can reset the search and start over from the beginning by calling ds.reset_search().
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Portugal
Offline Offline
Edison Member
*
Karma: 27
Posts: 1414
Tomorrow I will know a BIT more than yesterday
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I understand that but what will be the first sensor id stored on the array? In my mind I'm thinking like this: Master perform the ds.search(addr) and there are 4 sensors on the bus.Since every sensor will received the master question I presume all then will answer at the same time( big mess on the bus), since I have no way to just speak to one separatly? Is this wrong?
How can the master store the ID then?
Logged

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


Offline Offline
Edison Member
*
Karma: 31
Posts: 1417
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try the DS18x20_Temperature.pde example in the OneWire library examples.

Pete
Logged

Where are the Nick Gammons of yesteryear?

Portugal
Offline Offline
Edison Member
*
Karma: 27
Posts: 1414
Tomorrow I will know a BIT more than yesterday
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well I already found the answer just now.Nothing like just read the datasheet could save hours of search. Aparantly there are to commands to do the search.Looking on the library code I found the search is done by writing 0xf0 wich will do like a brute force search for every one.Also there is another command if we just have just one sensor on the bus, here we just need to seend 0x33 and the sensor will reply the id
Quote
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 www.maxim-ic.com/ibuttonbook. After every Search ROM cycle, the bus master must return to Step 1 (Initialization) in the transaction sequence.
READ ROM [33h]
This command can only be used when there is one slave on the bus. It allows the bus master to read the slave’s 64-bit ROM code without using the Search ROM procedure. If this command is used when there is more than one slave present on the bus, a data collision will occur when all the slaves attempt to respond at the same time.

Thanks for all
« Last Edit: May 16, 2012, 01:00:39 pm by HugoPT » Logged

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


Pages: [1]   Go Up
Jump to: