Blackened
Regular Member
Joined: 11/08/2012 Location: AustraliaPosts: 66 |
Posted: 02:26am 21 Jul 2013 |
Copy link to clipboard |
Print this post |
|
MMBasic 4.4 on Duinomite,
Ok, so I'm going through 10 ds18b20 sensors (wired in SS tip) I got in the mail this week. Checking them all and labelling the cables for later use. The following code is what I was using.
Method: Plug in one at a time, external power, 4.7k pullup resistor etc... I've used these before with success.
First one no problems, present with correct ID,
Second one... I get the same ID as before?
Test a second time with the second probe, new ID is output.
Third sensor, same problem. Had to run this twice to get a refreshed ID.
I know the searchflag probably should be "1" to start a new search, but "0" get next ID surely shouldn't report the previous sensor's ID?
Further testing........
I tried one at a time, using the "1" search flag and this worked fine. Each execution resulted in a refreshed ID that agreed with my printed label.
Next I tried 2 probes together on the bus, searchflag "0" and the first two executions produced the same ID, with the third producing the second sensor's ID.
Bug in the OWSearch function? Or bug in my grey matter?
Zeroing the Local array in the printing loop was just my attempt to ensure the array contents were not the result of a failed OWSearch that did not change the array values, and to ensure that there was no bug related to the array retaining it's value between subroutine calls.
Sub test2 'get serial number from ROM
Local a(1,8)
OWSearch 1,0,a(0,0),a(0,1),a(0,2),a(0,3),a(0,4),a(0,5),a(0,6),a(0,7)
Print "The serial number is : ";
For i = 0 To 7
Print a(0,i);
a(0,i)=0
Next i
End Sub |