OW

Module NameOW
Import NameOW

The following functions and subroutines are available for the One Wire (OW) module.

Module Variables

Program Example

WriteBit

Sub WriteBit(value As Bit)
  • value - Bit value to write

Writes a single bit to the OW data pin.

ReadBit

 Function ReadBit() As Bit

Reads and return the state of the OW data pin

WriteByte

 Sub WriteByte(value As Byte)
  • value - Byte value to write.

Writes a byte (LSB first) to the OW data pin.

ReadByte

 Function ReadByte() As Byte 

Read and return a byte (LSB first) from the OW data pin.

WriteArray

 Sub WriteArray(ByRef array() As Byte, Optional max As Byte = &HFF)
  • array - Array of bytes.
  • max - Maximum number of byte to write. Default is the whole array, up to a maximum of 256 bytes.

Writes an array of bytes To the OW data pin.

ReadArray

 Function ReadArray(ByRef array() As Byte, Optional max As Byte = &HFF) As Boolean
  • array - Byte array to receive the data.
  • max - Maximum number of byte to read, up to a maximum of 256 bytes.

Read an array of bytes from OW data pin - will return true if last CRC Byte resolves to 0.

Reset

 Function Reset() As Boolean

Resets the OW data pin - returns true if a device is detected.

WaitForHigh

 Sub WaitForHigh()

Wait for the OW data pin to go high

Search

 Function Search(Optional cmd As Byte = owSearchROM) As Byte
  • cmd - Search command to execute.

Searches for devices connected to the OW bus, based on the command value (normally owSearchROM). The function returns the total number of devices found. An optional event handler will be triggered each time a device is found. Available commands are:

  • owReadROM - identify a Device
  • owSkipROM - omit addressing
  • owMatchROM - address a specific Device
  • owSearchROM - identify all devices

Count

Function Count() As Byte

Returns the total number of devices connected to the OW bus.

OnSearch

 Event OnSearch(command As Byte, family As Byte, ByRef romID() As Byte, ByRef abort As Boolean)
  • command - The command which is currently executing.
  • family - The device family identifier.
  • romID - The unique device identifier.
  • abort - Flag to abort the search. Default is false.

This event is fired when a call to search is made.

Module Variables

  • RomId(8) As Byte - device ID
  • Family As Byte - device family

Example

 ' one wire, used for search
Imports OW                          

' the event is triggered each time the OW module is asked to
' perform a search - here we will list all devices connected to
' the one wire bus...
Sub OnDeviceFound(command As Byte, family As Byte, ByRef romID() As Byte, ByRef abort As Boolean) Handles OW.OnSearch

   ' display family...
   Console.Write("0x", Hex(family,2)," : ") 

   ' display unique identifier...
   for index as byte = 0 to ubound(romID)
      Console.Write("0x", Hex(romID(index),2)," ")
   next 
   Console.Write(13,10)
End Sub

' display a list of all devices connected to the bus...
sub Main()  
   OW.Search()
end sub