Hi guys
This post is copied from the Hackerspace email list since it is most
relevant to the aiko code.
Thanks Andy for your code "trick" for unique node names for the device
addresses:
globalString = "(temperature_";
globalString += (address[7] & 0x0f) + '0';
I have used this successfully on my installed devices. However on my
test set-up with 3 other devices I did find that unique names did not
result from (address[7] & 0x0f) + '0';
The device addresses are shown below with the output:
OneWire device: 28 50 C6 EE 2 0 0 9D 10 18
(node sol_adv ? (temp_61 23.68 C))
OneWire device: 28 6 A3 69 2 0 0 9D 10 18
(node sol_adv ? (temp_61 23.68 C))
OneWire device: 28 15 9C 69 2 0 0 74 10 18
(node sol_adv ? (temp_52 23.68 C))
Note that 2 devices get node name temp_61.
I can only guess as to why this is happening since I don't fully
understand what "(address[7] & 0x0f) + '0';" actually does. It does
suggest though, that for the general case this may not provide unique
node names based upon device addresses.
For now this has helped me to get the aiko-segmeter code working for
my 3-off 18B20 devices but some more work may be required. Hopefully
the output info above is enough for you to amend the line for the
device address - if not I can try another few 18B20s and get some
more data. Let me know.
Thanks
Rob.
Luke
View profile
So, it starts off with the first part of the GlobalString string as
"(temperature_", and then it's taking address[7], which is the 8th
element of the address array (remembering that an address, in this
case, is an array of 8 bytes), and doing a bitwise AND of that byte
with the byte 0x0f, and taking the resulting byte (number) and
"adding" it (actually concatenating the string) onto the end of the
previous part of the string, and then adding a 0 on the end.
I hope that helps, it's a slightly dodgy explanation.
Rob
View profile
More options Jan 1, 10:31 pm
From: Rob <
rebrow...@gmail.com>
Date: Sat, 1 Jan 2011 03:31:18 -0800 (PST)
Local: Sat, Jan 1 2011 10:31 pm
Subject: Re: Multiple 18B20 devices on OneWire
Find messages by this author
Luke that elegantly states what I vaguely understood to be the case.
So with what I am seeing this implies that the 8th element of the
array is not unique to the device(!?). The datasheet says that after
the least significant 8 bits of the 64 bit ROM code the next 48 bits
contain a unique serial number. The most significant 8 bits contain
the CRC check so I take this to mean that address[7] is just the CRC
check info. In which case is it entirely unique or do we actually need
something like address[1-6] (not even sure if this is a valid form)
for the unique 48 bits? I don't yet understand the significance of the
bitwise ANDing of the 0x0f and the 0 on the end.
Thanks for your reply.
On Jan 1, 8:06 pm, Luke Weston <
reindeerfloti...@gmail.com> wrote:
Rob
View profile Translate to Translated (View Original)
More options Jan 8, 10:20 pm
From: Rob <
rebrow...@gmail.com>
Date: Sat, 8 Jan 2011 03:20:19 -0800 (PST)
Local: Sat, Jan 8 2011 10:20 pm
Subject: Re: Multiple 18B20 devices on OneWire
Find messages by this author
Ok, well I have found that "(address[6] & 0x0f) + '0';" is pretty much
useless as all returns from this were identical so maybe the last 8
bits of the 48 for the unique serial number are zeroes or similar.
Anyway "(address[1] & 0x0f) + '0';" has given some more useful stuff
with the responses (nodenames) being unique among the six devices
tried so far.
I guess to construct something from the full 48 bits of info would be
fairly involved but would provide a totally unique nodename for the
general case.