in an other thread David Barker told me that every sample should work. Now I'm a little bit confused (and not able to find the error).
The following program (owsearch.bas)
Code: Select all
Device = 18F452
Clock = 20
// import modules...
Include "ow.bas"
Include "convert.bas"
Include "usart.bas"
// on find event handler...
Event OnFind()
Dim Index As Byte
USART.Write("FAMILY $", HexToStr(SearchFamily,2))
USART.Write(" ($",HexToStr(SearchID(7),2),")")
USART.Write(" ($")
Index = 6
Repeat
USART.Write(HexToStr(SearchID(Index),2))
Dec(Index)
Until Index = 0
USART.Write(")",13,10)
End Event
// working variables...
Dim DeviceCount As Byte
// program start...
SetBaudrate(br115200)
SetPin(PORTC.0)
DeviceCount = Search(owSearchROM, OnFind)
USART.Write(DecToStr(DeviceCount), " device(s) found", 13, 10)
1. ($BE) ($000801018F83)
2. ($6C) ($000801018B9A)
The following program (DS18B20DisplayTempAll.bas) returns nothing !!!
Code: Select all
Device = 18F452
Clock = 20
// import modules...
Include "DS18B20.bas"
Include "convert.bas"
Include "usart.bas"
// on display temperature event...
Event OnDisplayTemp()
Dim TempA As ShortInt
Dim TempB As Word
Dim Index As Byte
RomID = SearchRomID
GetTemp(TempA, TempB)
USART.Write(DecToStr(TempA),".",DecToStr(TempB,4), $BA, "C")
// display ROM ID...
USART.Write(" ($")
Index = 6
Repeat
USART.Write(HexToStr(SearchRomID(Index),2))
Dec(Index)
Until Index = 0
USART.Write(")",13,10)
End Event
// program start...
SetBaudrate(br115200)
SetPin(PORTC.0)
// if we have some DS1820 devices connected to the bus,
// then display temperature for each one...
If Count > 0 Then
While true
ConvertAll
FindAll(OnDisplayTemp)
DelayMS(1000)
Wend
EndIf
Code: Select all
Device = 18F452
Clock = 20
// import modules...
Include "DS18B20.bas"
Include "convert.bas"
Include "usart.bas"
// working variables...
Dim
TempA As ShortInt,
TempB As Word
// program start...
SetBaudrate(br115200)
SetPin(PORTC.0)
// Find() will search the bus for a single DS1820 device
// and load its ROM ID into the DS1820 public variable RomID - you
// could do this manually. For example, RomID = MyRomID...
If Not Find Then
USART.Write("No device found", 13, 10)
Else
While true
Convert
GetTemp(TempA, TempB)
USART.Write(DecToStr(TempA),".",DecToStr(TempB,4), $BA, "C", 13, 10)
DelayMS(1000)
Wend
EndIf
Have anyone seen the DS1820 Samples run ok?
Thanks
CS